From 819c78e74c4046d5917777d093556cb45edecb33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 4 Aug 2023 16:05:25 +0800 Subject: [PATCH] Fastfetch: add option `--bright-color` --- CHANGELOG.md | 1 + doc/json_schema.json | 5 +++++ src/common/init.c | 1 + src/common/jsonconfig.c | 2 ++ src/common/printing.c | 5 ++++- src/data/help.txt | 1 + src/fastfetch.c | 2 ++ src/fastfetch.h | 2 ++ src/logo/builtin.c | 14 +++++++------- src/logo/logo.c | 9 +++++++-- src/modules/title/title.c | 3 ++- 11 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42fca53da..403c33fef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Features: * Add new option `--temperature-unit` * Better CPU and Host detection for Android (Android) * Support yakuake terminal version & font detection (Terminal, Linux) +* Add new option `--bright-color` which can be used to disable the default bright color of keys, title and ASCII logo. Bugfixes: * Fix possible hanging (TerminalFont, #493) diff --git a/doc/json_schema.json b/doc/json_schema.json index 7d5e1465b..92f2779ee 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -304,6 +304,11 @@ } ] }, + "brightColor": { + "title": "Set if the keys, title and ASCII logo should be printed in bright color", + "type": "boolean", + "default": true + }, "binaryPrefix": { "type": "string", "title": "Set the binary prefix to used when printing bytes", diff --git a/src/common/init.c b/src/common/init.c index 8ffadbc98..a74be3e33 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -35,6 +35,7 @@ static void defaultConfig(void) ffStrbufInit(&instance.config.colorKeys); ffStrbufInit(&instance.config.colorTitle); + instance.config.brightColor = true; ffStrbufInitStatic(&instance.config.keyValueSeparator, ": "); instance.config.processingTimeout = 1000; diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 1b91c0035..9e7f1e481 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -379,6 +379,8 @@ const char* ffParseDisplayJsonConfig(void) else return "display.color must be either a string or an object"; } + else if (ffStrEqualsIgnCase(key, "brightColor")) + config->brightColor = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "binaryPrefix")) { int value; diff --git a/src/common/printing.c b/src/common/printing.c index 538698550..1ef1a0ea6 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -12,7 +12,10 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb if(!instance.config.pipe) { - fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); + if (instance.config.brightColor) + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + if(customKeyColor != NULL && customKeyColor->length > 0) ffPrintColor(customKeyColor); else diff --git a/src/data/help.txt b/src/data/help.txt index 2eb23e67f..f56ea5d5c 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -58,6 +58,7 @@ Display options: -s,--structure : Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available. --color-keys : Set the color of the keys --color-title : Set the color of the title + --bright-color : Set if the keys, title and ASCII logo should be printed in bright color. Default is true -c,--color : Set the color of both the keys and title --separator : Set the separator between key and value. Default is a colon with a space --set : Hard set the value of a key diff --git a/src/fastfetch.c b/src/fastfetch.c index 2b0ac906f..f12ffe0ca 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -906,6 +906,8 @@ static void parseOption(FFdata* data, const char* key, const char* value) optionCheckString(key, value, &instance.config.colorTitle); ffOptionParseColor(value, &instance.config.colorTitle); } + else if(ffStrEqualsIgnCase(key, "--bright-color")) + instance.config.brightColor = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "-c") || ffStrEqualsIgnCase(key, "--color")) { optionCheckString(key, value, &instance.config.colorKeys); diff --git a/src/fastfetch.h b/src/fastfetch.h index fde4923f1..b261654ee 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -39,6 +39,8 @@ typedef struct FFconfig FFstrbuf colorKeys; FFstrbuf colorTitle; + bool brightColor; + FFstrbuf keyValueSeparator; bool showErrors; diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 08f5a6768..5b097f3c6 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -30,12 +30,12 @@ const FFlogo ffLogoBuiltins[] = { .lines = FASTFETCH_DATATEXT_LOGO_ALMALINUX, .colors = { FF_COLOR_FG_RED, - FF_COLOR_MODE_BOLD FF_COLOR_FG_YELLOW, + FF_COLOR_FG_LIGHT_YELLOW, FF_COLOR_FG_BLUE, - FF_COLOR_MODE_BOLD FF_COLOR_FG_GREEN, + FF_COLOR_FG_LIGHT_GREEN, FF_COLOR_FG_CYAN, }, - .colorKeys = FF_COLOR_MODE_BOLD FF_COLOR_FG_YELLOW, + .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_RED, }, // Alpine @@ -416,7 +416,7 @@ const FFlogo ffLogoBuiltins[] = { .names = {"Astra", "Astra Linux", "astralinux"}, .lines = FASTFETCH_DATATEXT_LOGO_ASTRA_LINUX, .colors = { - FF_COLOR_MODE_BOLD FF_COLOR_FG_RED, + FF_COLOR_FG_LIGHT_RED, FF_COLOR_FG_WHITE, }, .colorKeys = FF_COLOR_FG_RED, @@ -1565,9 +1565,9 @@ const FFlogo ffLogoBuiltins[] = { .lines = FASTFETCH_DATATEXT_LOGO_HYBRID, .colors = { FF_COLOR_FG_BLUE, - FF_COLOR_MODE_BOLD FF_COLOR_FG_BLUE, + FF_COLOR_FG_LIGHT_BLUE, }, - .colorKeys = FF_COLOR_MODE_BOLD FF_COLOR_FG_BLUE, + .colorKeys = FF_COLOR_FG_LIGHT_BLUE, .colorTitle = FF_COLOR_FG_BLUE, }, // HydroOS @@ -2735,7 +2735,7 @@ const FFlogo ffLogoBuiltins[] = { .lines = FASTFETCH_DATATEXT_LOGO_PENGWIN, .colors = { FF_COLOR_FG_MAGENTA, - FF_COLOR_MODE_BOLD FF_COLOR_FG_MAGENTA, + FF_COLOR_FG_LIGHT_MAGENTA, FF_COLOR_FG_MAGENTA, }, }, diff --git a/src/logo/logo.c b/src/logo/logo.c index 025f78420..343eba264 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -19,7 +19,10 @@ typedef enum FFLogoSize static void ffLogoPrintCharsRaw(const char* data, size_t length) { FFLogoOptions* options = &instance.config.logo; - fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + + if (instance.config.brightColor) + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + ffPrintCharTimes('\n', options->paddingTop); ffPrintCharTimes(' ', options->paddingLeft); fwrite(data, length, 1, stdout); @@ -34,7 +37,9 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement) uint32_t currentlineLength = 0; - fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + if (instance.config.brightColor) + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + ffPrintCharTimes('\n', options->paddingTop); ffPrintCharTimes(' ', options->paddingLeft); diff --git a/src/modules/title/title.c b/src/modules/title/title.c index c9dc9b8eb..ef3d7abe4 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -10,7 +10,8 @@ static inline void printTitlePart(const FFstrbuf* content, const FFstrbuf* color { if(!instance.config.pipe) { - fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); + if (instance.config.brightColor) + fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); ffPrintColor(color->length > 0 ? color : &instance.config.colorTitle); }