From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/detection/brightness/brightness_haiku.cpp | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/detection/brightness/brightness_haiku.cpp (limited to 'src/detection/brightness/brightness_haiku.cpp') diff --git a/src/detection/brightness/brightness_haiku.cpp b/src/detection/brightness/brightness_haiku.cpp new file mode 100644 index 0000000..86fbe6d --- /dev/null +++ b/src/detection/brightness/brightness_haiku.cpp @@ -0,0 +1,46 @@ +extern "C" { +#include "brightness.h" +#include "common/strutil.h" +} + +#include +#include + +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 (%d)", monitor.vendor, monitor.name, screen.ID().id); + ffStrbufTrimRightSpace(&brightness->name); + } else { + ffStrbufInitF(&brightness->name, "Screen %d", screen.ID().id); + } + + brightness->max = 1.0f; + brightness->min = 0.0f; + brightness->current = value; + brightness->builtin = true; + + } while (screen.SetToNext() == B_OK); + + return NULL; +} -- cgit v1.2.3