mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Brightness: adds ddcciSleep: null to skip DDC/CI detection
This commit is contained in:
+12
-4
@@ -1750,10 +1750,18 @@
|
||||
"$ref": "#/$defs/percent"
|
||||
},
|
||||
"ddcciSleep": {
|
||||
"type": "integer",
|
||||
"description": "Sleep time in milliseconds between DDC/CI requests\nSee <https://www.ddcutil.com/performance_options/#option-sleep-multiplier> for details",
|
||||
"minimum": 0,
|
||||
"maximum": 400,
|
||||
"description": "Sleep time in milliseconds between DDC/CI requests\nSet to null to skip DDC/CI detection\nSee <https://www.ddcutil.com/performance_options/#option-sleep-multiplier> for details",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "null",
|
||||
"description": "Skip DDC/CI detection"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 400
|
||||
}
|
||||
],
|
||||
"default": 10
|
||||
},
|
||||
"compact": {
|
||||
|
||||
@@ -20,6 +20,7 @@ enum {
|
||||
FF_DDC_CI_COMMAND_PACKET = 0x80u,
|
||||
FF_DDC_CI_LUMINANCE_OPCODE = 0x10u,
|
||||
};
|
||||
#define FF_BRIGHTNESS_DDCCI_SLEEP_SKIP ((uint32_t) -1)
|
||||
#define FF_DDC_CI_MAKE_HEADER(len) (FF_DDC_CI_COMMAND_PACKET | ((len) & 0x7F))
|
||||
|
||||
const char* ffDetectBrightness(FFBrightnessOptions* options, FFlist* result); // list of FFBrightnessResult
|
||||
|
||||
@@ -236,7 +236,7 @@ const char* ffDetectBrightness(FFBrightnessOptions* options, FFlist* result) {
|
||||
|
||||
detectWithDisplayServices(displayServer, result);
|
||||
|
||||
if (displayServer->displays.length > result->length) {
|
||||
if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && displayServer->displays.length > result->length) {
|
||||
detectWithDdcci(displayServer, options, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,8 @@ const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FF_A_U
|
||||
|
||||
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
detectWithBacklight(options, result);
|
||||
if (result->length == 0) {
|
||||
|
||||
if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && result->length == 0) {
|
||||
detectWithDdcci(options, result);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -164,9 +164,11 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist*
|
||||
detectWithBacklight(result);
|
||||
|
||||
#ifdef FF_HAVE_DDCUTIL
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
if (result->length < displayServer->displays.length) {
|
||||
detectWithDdcci(options, result);
|
||||
if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP) {
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
if (result->length < displayServer->displays.length) {
|
||||
detectWithDdcci(options, result);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist*
|
||||
detectWithWmi(result);
|
||||
}
|
||||
|
||||
if (result->length < displayServer->displays.length) {
|
||||
if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && result->length < displayServer->displays.length) {
|
||||
FF_DEBUG("resultCount=%u < displayCount=%u, trying DDC/CI", result->length, displayServer->displays.length);
|
||||
detectWithDdcci(displayServer, result);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,11 @@ void ffParseBrightnessJsonObject(FFBrightnessOptions* options, yyjson_val* modul
|
||||
}
|
||||
|
||||
if (unsafe_yyjson_equals_str(key, "ddcciSleep")) {
|
||||
options->ddcciSleep = (uint32_t) yyjson_get_uint(val);
|
||||
if (yyjson_is_null(val)) {
|
||||
options->ddcciSleep = FF_BRIGHTNESS_DDCCI_SLEEP_SKIP;
|
||||
} else {
|
||||
options->ddcciSleep = (uint32_t) yyjson_get_uint(val);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -133,7 +137,11 @@ void ffParseBrightnessJsonObject(FFBrightnessOptions* options, yyjson_val* modul
|
||||
void ffGenerateBrightnessJsonConfig(FFBrightnessOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
|
||||
yyjson_mut_obj_add_uint(doc, module, "ddcciSleep", options->ddcciSleep);
|
||||
if (options->ddcciSleep == FF_BRIGHTNESS_DDCCI_SLEEP_SKIP) {
|
||||
yyjson_mut_obj_add_null(doc, module, "ddcciSleep");
|
||||
} else {
|
||||
yyjson_mut_obj_add_uint(doc, module, "ddcciSleep", options->ddcciSleep);
|
||||
}
|
||||
|
||||
ffPercentGenerateJsonConfig(doc, module, options->percent);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user