WM: support FVWM version detection

This commit is contained in:
李通洲
2025-05-31 10:16:26 +08:00
parent b9317734b9
commit f389864e17
2 changed files with 29 additions and 3 deletions
+1 -1
View File
@@ -884,7 +884,7 @@ elseif(OpenBSD)
src/detection/users/users_obsd.c
src/detection/wallpaper/wallpaper_linux.c
src/detection/wifi/wifi_obsd.c
src/detection/wm/wm_nosupport.c
src/detection/wm/wm_linux.c
src/detection/de/de_linux.c
src/detection/wmtheme/wmtheme_linux.c
src/detection/camera/camera_linux.c
+28 -2
View File
@@ -143,7 +143,7 @@ static const char* getWslg(FFstrbuf* result)
return NULL;
}
static bool extractCtwmVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void *userdata)
static bool extractCtFvWmVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void *userdata)
{
int count = 0;
sscanf(line, "%*d.%*d.%*d%n", &count);
@@ -159,7 +159,7 @@ static const char* getCtwm(FFstrbuf* result)
const char* error = ffFindExecutableInPath("ctwm", &path);
if (error) return "Failed to find ctwm executable path";
ffBinaryExtractStrings(path.chars, extractCtwmVersion, result, (uint32_t) strlen("0.0.0"));
ffBinaryExtractStrings(path.chars, extractCtFvWmVersion, result, (uint32_t) strlen("0.0.0"));
if (result->length > 0) return NULL;
if (ffProcessAppendStdOut(result, (char* const[]){
@@ -176,6 +176,29 @@ static const char* getCtwm(FFstrbuf* result)
return "Failed to run command `ctwm --version`";
}
static const char* getFvwm(FFstrbuf* result)
{
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
const char* error = ffFindExecutableInPath("fvwm", &path);
if (error) return "Failed to find fvwm executable path";
ffBinaryExtractStrings(path.chars, extractCtFvWmVersion, result, (uint32_t) strlen("0.0.0"));
if (result->length > 0) return NULL;
if (ffProcessAppendStdOut(result, (char* const[]){
path.chars,
"-version",
NULL
}) == NULL)
{ // [FVWM][main]: fvwm Version 2.2.5\n...
ffStrbufSubstrBeforeFirstC(result, '\n');
ffStrbufSubstrAfterLastC(result, ' ');
return NULL;
}
return "Failed to run command `fvwm -version`";
}
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options)
{
if (!wmName)
@@ -193,5 +216,8 @@ const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE
if (ffStrbufEqualS(wmName, "ctwm"))
return getCtwm(result);
if (ffStrbufEqualS(wmName, "fvwm"))
return getFvwm(result);
return "Unsupported WM";
}