mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:52:08 +02:00
Brightness: detect & print screen type
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ static const char* detectWithWmi(FFlist* result)
|
||||
brightness->max = 100;
|
||||
brightness->min = 0;
|
||||
brightness->current = vtValue.get<uint8_t>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"},
|
||||
}))
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user