Display: remove --detect-name

This commit is contained in:
李通洲
2023-06-20 15:54:57 +08:00
parent a53d74e483
commit 54f6b6a9c9
5 changed files with 26 additions and 23 deletions
-6
View File
@@ -747,12 +747,6 @@
"description": "Set if all displays should be printed in one line",
"default": "none"
},
"detectName": {
"title": "modules.display.detectName",
"description": "Set if display name should be detected and printed (if supported)",
"type": "boolean",
"default": false
},
"preciseRefreshRate": {
"title": "modules.display.preciseRefreshRate",
"description": "Set if decimal refresh rates should not be rounded into integers when printing",
+24 -2
View File
@@ -1,6 +1,8 @@
#include "common/bar.h"
#include "common/printing.h"
#include "common/jsonconfig.h"
#include "detection/brightness/brightness.h"
#include "detection/displayserver/displayserver.h"
#include "modules/brightness/brightness.h"
#include "util/stringUtils.h"
@@ -10,6 +12,8 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options)
{
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult));
const FFDisplayServerResult* ds = ffConnectDisplayServer(instance);
const char* error = ffDetectBrightness(&result);
if(error)
@@ -30,7 +34,9 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options)
{
if(options->moduleArgs.key.length == 0)
{
ffStrbufAppendF(&key, "%s (%s)", FF_BRIGHTNESS_MODULE_NAME, item->name.chars);
ffStrbufAppendS(&key, FF_BRIGHTNESS_MODULE_NAME);
if (ds->displays.length > 1)
ffStrbufAppendF(&key, " (%s)", item->name.chars);
}
else
{
@@ -39,10 +45,26 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options)
});
}
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor);
printf("%.0f%%\n", item->value);
if (instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
ffAppendPercentBar(instance, &str, (uint8_t) (item->value + 0.5), 0, 10, 10);
}
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
{
if(str.length > 0)
ffStrbufAppendC(&str, ' ');
ffAppendPercentNum(instance, &str, (uint8_t) (item->value + 0.5), 10, 10, str.length > 0);
}
ffStrbufPutTo(&str, stdout);
}
else
{
+1 -14
View File
@@ -53,7 +53,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options)
if(options->moduleArgs.outputFormat.length == 0)
{
if((options->detectName && result->name.length) || (moduleIndex > 0 && displayType))
if(moduleIndex > 0)
{
ffStrbufClear(&key);
if(options->moduleArgs.key.length == 0)
@@ -117,7 +117,6 @@ void ffInitDisplayOptions(FFDisplayOptions* options)
options->moduleName = FF_DISPLAY_MODULE_NAME;
ffOptionInitModuleArg(&options->moduleArgs);
options->compactType = FF_DISPLAY_COMPACT_TYPE_NONE;
options->detectName = false;
options->preciseRefreshRate = false;
}
@@ -139,12 +138,6 @@ bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, co
return true;
}
if (ffStrEqualsIgnCase(subKey, "detect-name"))
{
options->detectName = ffOptionParseBoolean(value);
return true;
}
if (ffStrEqualsIgnCase(subKey, "precise-refresh-rate"))
{
options->preciseRefreshRate = ffOptionParseBoolean(value);
@@ -193,12 +186,6 @@ void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module)
continue;
}
if (ffStrEqualsIgnCase(key, "detectName"))
{
options.detectName = yyjson_get_bool(val);
continue;
}
if (ffStrEqualsIgnCase(key, "preciseRefreshRate"))
{
options.preciseRefreshRate = yyjson_get_bool(val);
-1
View File
@@ -17,6 +17,5 @@ typedef struct FFDisplayOptions
FFModuleArgs moduleArgs;
FFDisplayCompactType compactType;
bool detectName;
bool preciseRefreshRate;
} FFDisplayOptions;