diff --git a/CHANGELOG.md b/CHANGELOG.md index 7590c997f..2062750e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2.18.1 + +Changes: +* `--ts-version` has been renamed to `--detect-version` + * `general.detectVersion` in JSON config file + # 2.18.0 Changes: diff --git a/doc/json_schema.json b/doc/json_schema.json index 0545cce7f..df76141ec 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -339,6 +339,11 @@ "type": "string", "description": "Set the command to be executed before printing logos", "default": "" + }, + "showVersion": { + "type": "boolean", + "description": "Whether to detect and display component versions. Mainly for benchmarking", + "default": true } } }, @@ -573,11 +578,6 @@ "type": "boolean", "description": "Whether to disable the stdout application buffer", "default": false - }, - "tsVersion": { - "type": "boolean", - "description": "Whether to detect and display the version of terminal, shell and editor. Mainly for benchmarking", - "default": true } } }, diff --git a/src/data/help.json b/src/data/help.json index 3fb1678e6..750b4bd8b 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -148,6 +148,16 @@ "false": "Try `wayland`, then `x11`, then `drm`" } } + }, + { + "long": "detect-version", + "desc": "Whether to detect and display the version of terminal, shell and editor", + "remark": "Mainly for benchmarking", + "arg": { + "type": "bool", + "optional": true, + "default": true + } } ], "Logo": [ @@ -725,16 +735,6 @@ "type": "color", "default": "light_red" } - }, - { - "long": "ts-version", - "desc": "Whether to detect and display the version of terminal, shell and editor", - "remark": "Mainly for benchmarking", - "arg": { - "type": "bool", - "optional": true, - "default": true - } } ], "Library path": [ diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c index a0db88a92..c17e8ac7f 100644 --- a/src/detection/de/de_linux.c +++ b/src/detection/de/de_linux.c @@ -180,6 +180,8 @@ static void getBudgie(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOptions* options) { + if (!instance.config.general.detectVersion) return "Disabled by config"; + if (ffStrbufEqualS(deName, FF_DE_PRETTY_PLASMA)) getKDE(result, options); else if (ffStrbufEqualS(deName, FF_DE_PRETTY_GNOME)) diff --git a/src/detection/editor/editor.c b/src/detection/editor/editor.c index 84b3b2632..f71544d60 100644 --- a/src/detection/editor/editor.c +++ b/src/detection/editor/editor.c @@ -26,7 +26,7 @@ const char* ffDetectEditor(FFEditorResult* result) return "$VISUAL or $EDITOR not set"; } - if (!instance.config.display.tsVersion) return NULL; + if (!instance.config.general.detectVersion) return NULL; #ifndef _WIN32 if (result->name.chars[0] != '/') diff --git a/src/detection/initsystem/initsystem_linux.c b/src/detection/initsystem/initsystem_linux.c index 078d36f1b..9a6023a1c 100644 --- a/src/detection/initsystem/initsystem_linux.c +++ b/src/detection/initsystem/initsystem_linux.c @@ -17,38 +17,41 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) ffStrbufSetS(&result->exe, buf); } - if (ffStrbufEqualS(&result->name, "systemd")) + if (instance.config.general.detectVersion) { - if (ffProcessAppendStdOut(&result->version, (char* const[]) { - ffStrbufEndsWithS(&result->exe, "/systemd") ? result->exe.chars : "systemctl", // use exe path in case users have another systemd installed - "--version", - NULL, - }) == NULL && result->version.length) + if (ffStrbufEqualS(&result->name, "systemd")) { - uint32_t iStart = ffStrbufFirstIndexC(&result->version, '('); - if (iStart < result->version.length) + if (ffProcessAppendStdOut(&result->version, (char* const[]) { + ffStrbufEndsWithS(&result->exe, "/systemd") ? result->exe.chars : "systemctl", // use exe path in case users have another systemd installed + "--version", + NULL, + }) == NULL && result->version.length) { - uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ')'); - ffStrbufSubstrBefore(&result->version, iEnd); - ffStrbufSubstrAfter(&result->version, iStart); + uint32_t iStart = ffStrbufFirstIndexC(&result->version, '('); + if (iStart < result->version.length) + { + uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ')'); + ffStrbufSubstrBefore(&result->version, iEnd); + ffStrbufSubstrAfter(&result->version, iStart); + } } } - } - else if (ffStrbufEqualS(&result->name, "launchd")) - { - if (ffProcessAppendStdOut(&result->version, (char* const[]) { - "/bin/launchctl", - "version", - NULL, - }) == NULL && result->version.length) + else if (ffStrbufEqualS(&result->name, "launchd")) { - uint32_t iStart = ffStrbufFirstIndexS(&result->version, "Version "); - if (iStart < result->version.length) + if (ffProcessAppendStdOut(&result->version, (char* const[]) { + "/bin/launchctl", + "version", + NULL, + }) == NULL && result->version.length) { - iStart += (uint32_t) strlen("Version"); - uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ':'); - ffStrbufSubstrBefore(&result->version, iEnd); - ffStrbufSubstrAfter(&result->version, iStart); + uint32_t iStart = ffStrbufFirstIndexS(&result->version, "Version "); + if (iStart < result->version.length) + { + iStart += (uint32_t) strlen("Version"); + uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ':'); + ffStrbufSubstrBefore(&result->version, iEnd); + ffStrbufSubstrAfter(&result->version, iStart); + } } } } diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index 4adc9ec82..fc5ff4bbe 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -163,16 +163,19 @@ const char* ffDetectLM(FFLMResult* result) })) return "Failed to parse " FF_SYSTEMD_SESSIONS_PATH "$XDG_SESSION_ID"; - if (ffStrbufStartsWithS(&result->service, "gdm")) - getGdmVersion(&result->version); - else if (ffStrbufStartsWithS(&result->service, "sddm")) - getSddmVersion(&result->version); - else if (ffStrbufStartsWithS(&result->service, "xfwm")) - getXfwmVersion(&result->version); - else if (ffStrbufStartsWithS(&result->service, "lightdm")) - getLightdmVersion(&result->version); - else if (ffStrbufStartsWithS(&result->service, "sshd")) - getSshdVersion(&result->version); + if (instance.config.general.detectVersion) + { + if (ffStrbufStartsWithS(&result->service, "gdm")) + getGdmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "sddm")) + getSddmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "xfwm")) + getXfwmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "lightdm")) + getLightdmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "sshd")) + getSshdVersion(&result->version); + } // Correct char cases if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_WAYLAND)) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 57ccb6a89..f125523ec 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -226,7 +226,7 @@ static bool getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf* bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) { - if (!instance.config.display.tsVersion) return false; + if (!instance.config.general.detectVersion) return false; if(ffStrEqualsIgnCase(exeName, "sh")) // #849 return false; @@ -546,7 +546,7 @@ static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version) bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { - if (!instance.config.display.tsVersion) return false; + if (!instance.config.general.detectVersion) return false; #ifdef __ANDROID__ diff --git a/src/modules/initsystem/initsystem.c b/src/modules/initsystem/initsystem.c index ec3fa6034..b9e7edfc6 100644 --- a/src/modules/initsystem/initsystem.c +++ b/src/modules/initsystem/initsystem.c @@ -29,7 +29,7 @@ void ffPrintInitSystem(FFInitSystemOptions* options) ffPrintLogoAndKey(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result.name, stdout); if (result.version.length) - printf(" (%s)\n", result.version.chars); + printf(" %s\n", result.version.chars); else putchar('\n'); } diff --git a/src/options/display.c b/src/options/display.c index b50488c9e..23fb3273c 100644 --- a/src/options/display.c +++ b/src/options/display.c @@ -200,7 +200,7 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va else if (ffStrEqualsIgnCase(key, "keyWidth")) options->keyWidth = (uint32_t) yyjson_get_uint(val); else if (ffStrEqualsIgnCase(key, "tsVersion")) - options->tsVersion = yyjson_get_bool(val); + return "display.tsVersion has been renamed to general.detectVersion"; else return "Unknown display property"; } @@ -357,8 +357,6 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key else return false; } - else if(ffStrEqualsIgnCase(key, "--ts-version")) - options->tsVersion = ffOptionParseBoolean(value); else return false; return true; @@ -406,8 +404,6 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options) ffStrbufInitStatic(&options->percentColorGreen, FF_COLOR_FG_GREEN); ffStrbufInitStatic(&options->percentColorYellow, instance.state.terminalLightTheme ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_LIGHT_YELLOW); ffStrbufInitStatic(&options->percentColorRed, instance.state.terminalLightTheme ? FF_COLOR_FG_RED : FF_COLOR_FG_LIGHT_RED); - - options->tsVersion = true; } void ffOptionsDestroyDisplay(FFOptionsDisplay* options) diff --git a/src/options/display.h b/src/options/display.h index 7f248042b..a3be9baf8 100644 --- a/src/options/display.h +++ b/src/options/display.h @@ -53,7 +53,6 @@ typedef struct FFOptionsDisplay FFstrbuf percentColorRed; bool noBuffer; uint32_t keyWidth; - bool tsVersion; } FFOptionsDisplay; const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_val* root); diff --git a/src/options/general.c b/src/options/general.c index b2fe71150..c1eabf9cd 100644 --- a/src/options/general.c +++ b/src/options/general.c @@ -36,6 +36,8 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va if (error) return "Failed to execute preRun command"; } + else if (ffStrEqualsIgnCase(key, "detectVersion")) + options->detectVersion = yyjson_get_bool(val); #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) else if (ffStrEqualsIgnCase(key, "escapeBedrock")) @@ -66,13 +68,6 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va options->wmiTimeout = (int32_t) yyjson_get_int(val); #endif - else if (ffStrEqualsIgnCase(key, "stat")) - return "Property `general.stat` has been changed to `display.stat`"; - else if (ffStrEqualsIgnCase(key, "pipe")) - return "Property `general.pipe` has been changed to `display.pipe`"; - else if (ffStrEqualsIgnCase(key, "allowSlowOperations")) - return "Property `general.allowSlowOperations` has been obsoleted. See CHANGELOG for detail"; - else return "Unknown general property"; } @@ -86,6 +81,8 @@ bool ffOptionsParseGeneralCommandLine(FFOptionsGeneral* options, const char* key options->multithreading = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--processing-timeout")) options->processingTimeout = ffOptionParseInt32(key, value); + else if(ffStrEqualsIgnCase(key, "--detect-version")) + options->detectVersion = ffOptionParseBoolean(value); #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) else if(ffStrEqualsIgnCase(key, "--escape-bedrock")) @@ -116,6 +113,7 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options) { options->processingTimeout = 1000; options->multithreading = true; + options->detectVersion = true; #if defined(__linux__) || defined(__FreeBSD__) options->escapeBedrock = true; diff --git a/src/options/general.h b/src/options/general.h index b388f3f43..8b14283d8 100644 --- a/src/options/general.h +++ b/src/options/general.h @@ -13,6 +13,7 @@ typedef struct FFOptionsGeneral { bool multithreading; int32_t processingTimeout; + bool detectVersion; // Module options that cannot be put in module option structure #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)