diff --git a/src/detection/brightness/brightness.h b/src/detection/brightness/brightness.h index f0adf329d..3db260a66 100644 --- a/src/detection/brightness/brightness.h +++ b/src/detection/brightness/brightness.h @@ -7,6 +7,7 @@ typedef struct FFBrightnessResult { FFstrbuf name; double min, max, current; + bool builtin; } FFBrightnessResult; const char* ffDetectBrightness(FFBrightnessOptions* options, FFlist* result); // list of FFBrightnessResult diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index e10d912be..de3750a94 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -42,6 +42,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa brightness->max = 1; brightness->min = 0; ffStrbufInitCopy(&brightness->name, &display->name); + brightness->builtin = true; } } } @@ -111,6 +112,7 @@ static const char* detectWithDdcci(FF_MAYBE_UNUSED const FFDisplayServerResult* brightness->min = 0; brightness->current = current; ffStrbufInit(&brightness->name); + brightness->builtin = false; uint8_t edid[128] = {}; if (IOAVServiceReadI2C(service, 0x50, 0x00, edid, ARRAY_SIZE(edid)) == KERN_SUCCESS) @@ -179,6 +181,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F brightness->min = 0; brightness->current = current; ffStrbufInitCopy(&brightness->name, &display->name); + brightness->builtin = false; } } diff --git a/src/detection/brightness/brightness_bsd.c b/src/detection/brightness/brightness_bsd.c index c77c378fe..6b7a0a8b3 100644 --- a/src/detection/brightness/brightness_bsd.c +++ b/src/detection/brightness/brightness_bsd.c @@ -32,6 +32,7 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFl brightness->max = BACKLIGHTMAXLEVELS; brightness->min = 0; brightness->current = status.brightness; + brightness->builtin = true; struct backlight_info info; if(ioctl(blfd, BACKLIGHTGETINFO, &info) == 0) diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 645fb58c6..602649c3c 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -74,6 +74,7 @@ static const char* detectWithBacklight(FFlist* result) brightness->max = ffStrbufToDouble(&buffer); brightness->min = 0; brightness->current = actualBrightness; + brightness->builtin = true; } } ffStrbufSubstrBefore(&backlightDir, backlightDirLength); diff --git a/src/detection/brightness/brightness_nbsd.c b/src/detection/brightness/brightness_nbsd.c index 1fd7773b0..67464772e 100644 --- a/src/detection/brightness/brightness_nbsd.c +++ b/src/detection/brightness/brightness_nbsd.c @@ -7,7 +7,7 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFl // https://man.netbsd.org/NetBSD-10.1/acpiout.4#DESCRIPTION char key[] = "hw.acpi.acpiout0.brightness"; char* pn = key + strlen("hw.acpi.acpiout"); - + for (uint32_t i = 0; i <= 9; ++i) { *pn = (char) ('0' + i); @@ -20,6 +20,7 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFl brightness->max = 100; brightness->min = 0; brightness->current = value; + brightness->builtin = true; } return NULL; } diff --git a/src/detection/brightness/brightness_obsd.c b/src/detection/brightness/brightness_obsd.c index ea5d7334c..bb0bd861b 100644 --- a/src/detection/brightness/brightness_obsd.c +++ b/src/detection/brightness/brightness_obsd.c @@ -25,6 +25,7 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFl brightness->max = param.max; brightness->min = param.min; brightness->current = param.curval; + brightness->builtin = true; return NULL; } diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp index fbbcf6e35..27d53cca8 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -24,6 +24,7 @@ static const char* detectWithWmi(FFlist* result) brightness->max = 100; brightness->min = 0; brightness->current = vtValue.get(); + brightness->builtin = true; ffStrbufInit(&brightness->name); if (FFWmiVariant vtName = record.get(L"InstanceName")) @@ -61,6 +62,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F brightness->max = max; brightness->min = min; brightness->current = curr; + brightness->builtin = false; } } } diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index e4862f526..78caf587f 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -82,6 +82,8 @@ void ffPrintBrightness(FFBrightnessOptions* options) ffPercentAppendNum(&str, percent, options->percent, str.length > 0, &options->moduleArgs); } + ffStrbufAppendS(&str, item->builtin ? " [Built-in]" : " [External]"); + ffStrbufPutTo(&str, stdout); } else @@ -100,6 +102,7 @@ void ffPrintBrightness(FFBrightnessOptions* options) FF_FORMAT_ARG(item->min, "min"), FF_FORMAT_ARG(item->current, "current"), FF_FORMAT_ARG(valueBar, "percentage-bar"), + FF_FORMAT_ARG(item->builtin, "is-builtin"), })); } @@ -204,6 +207,7 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options yyjson_mut_obj_add_real(doc, obj, "max", item->max); yyjson_mut_obj_add_real(doc, obj, "min", item->min); yyjson_mut_obj_add_real(doc, obj, "current", item->current); + yyjson_mut_obj_add_bool(doc, obj, "builtin", item->builtin); } FF_LIST_FOR_EACH(FFBrightnessResult, item, result) @@ -227,6 +231,7 @@ static FFModuleBaseInfo ffModuleInfo = { {"Minimum brightness value", "min"}, {"Current brightness value", "current"}, {"Screen brightness (percentage bar)", "percentage-bar"}, + {"Is built-in screen", "is-builtin"}, })) };