diff --git a/CMakeLists.txt b/CMakeLists.txt index 376f47783..14e80c6b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/detection/wm/wm_linux.c b/src/detection/wm/wm_linux.c index 6cdc3e9f7..718353b60 100644 --- a/src/detection/wm/wm_linux.c +++ b/src/detection/wm/wm_linux.c @@ -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"; }