General: rename --ts-version to --detect-version

And use it in more modules
This commit is contained in:
Carter Li
2024-07-10 21:55:37 +08:00
parent 5060c265a9
commit 765c7b42b6
13 changed files with 75 additions and 67 deletions
+6
View File
@@ -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:
+5 -5
View File
@@ -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
}
}
},
+10 -10
View File
@@ -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": [
+2
View File
@@ -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))
+1 -1
View File
@@ -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] != '/')
+28 -25
View File
@@ -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);
}
}
}
}
+13 -10
View File
@@ -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))
+2 -2
View File
@@ -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__
+1 -1
View File
@@ -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');
}
+1 -5
View File
@@ -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)
-1
View File
@@ -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);
+5 -7
View File
@@ -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;
+1
View File
@@ -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)