mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Brightness (Haiku): Implement
This commit is contained in:
committed by
Carter Li
parent
ccf4f22f8b
commit
3043971259
+1
-1
@@ -1205,7 +1205,7 @@ elseif(Haiku)
|
||||
src/detection/bios/bios_windows.c
|
||||
src/detection/board/board_windows.c
|
||||
src/detection/bootmgr/bootmgr_haiku.cpp
|
||||
src/detection/brightness/brightness_nosupport.c
|
||||
src/detection/brightness/brightness_haiku.cpp
|
||||
src/detection/btrfs/btrfs_nosupport.c
|
||||
src/detection/chassis/chassis_windows.c
|
||||
src/detection/cpu/cpu_haiku.c
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
extern "C" {
|
||||
#include "brightness.h"
|
||||
#include "common/strutil.h"
|
||||
}
|
||||
|
||||
#include <Application.h>
|
||||
#include <Screen.h>
|
||||
|
||||
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
// We need a valid be_app to query the app_server here.
|
||||
BApplication app("application/x-vnd.fastfetch-cli-fastfetch");
|
||||
BScreen screen{}; // default screen is the main one
|
||||
|
||||
do {
|
||||
if (!screen.IsValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float value = 1.0f;
|
||||
status_t status = screen.GetBrightness(&value);
|
||||
if (status != B_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
monitor_info monitor;
|
||||
// WARNING: This is experimental new Haiku API
|
||||
status_t err = screen.GetMonitorInfo(&monitor);
|
||||
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
|
||||
if (err == B_OK) {
|
||||
ffStrbufInitF(&brightness->name, "%s %s (%ld)", monitor.vendor, monitor.name, screen.ID().id);
|
||||
ffStrbufTrimRightSpace(&brightness->name);
|
||||
} else {
|
||||
ffStrbufInitF(&brightness->name, "Screen %ld", screen.ID().id);
|
||||
}
|
||||
|
||||
brightness->max = 1.0f;
|
||||
brightness->min = 0.0f;
|
||||
brightness->current = value;
|
||||
brightness->builtin = true;
|
||||
|
||||
} while (screen.SetToNext() == B_OK);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user