Skip to content

Commit f389864

Browse files
committed
WM: support FVWM version detection
1 parent b931773 commit f389864

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ elseif(OpenBSD)
884884
src/detection/users/users_obsd.c
885885
src/detection/wallpaper/wallpaper_linux.c
886886
src/detection/wifi/wifi_obsd.c
887-
src/detection/wm/wm_nosupport.c
887+
src/detection/wm/wm_linux.c
888888
src/detection/de/de_linux.c
889889
src/detection/wmtheme/wmtheme_linux.c
890890
src/detection/camera/camera_linux.c

src/detection/wm/wm_linux.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static const char* getWslg(FFstrbuf* result)
143143
return NULL;
144144
}
145145

146-
static bool extractCtwmVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void *userdata)
146+
static bool extractCtFvWmVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void *userdata)
147147
{
148148
int count = 0;
149149
sscanf(line, "%*d.%*d.%*d%n", &count);
@@ -159,7 +159,7 @@ static const char* getCtwm(FFstrbuf* result)
159159
const char* error = ffFindExecutableInPath("ctwm", &path);
160160
if (error) return "Failed to find ctwm executable path";
161161

162-
ffBinaryExtractStrings(path.chars, extractCtwmVersion, result, (uint32_t) strlen("0.0.0"));
162+
ffBinaryExtractStrings(path.chars, extractCtFvWmVersion, result, (uint32_t) strlen("0.0.0"));
163163
if (result->length > 0) return NULL;
164164

165165
if (ffProcessAppendStdOut(result, (char* const[]){
@@ -176,6 +176,29 @@ static const char* getCtwm(FFstrbuf* result)
176176
return "Failed to run command `ctwm --version`";
177177
}
178178

179+
static const char* getFvwm(FFstrbuf* result)
180+
{
181+
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
182+
const char* error = ffFindExecutableInPath("fvwm", &path);
183+
if (error) return "Failed to find fvwm executable path";
184+
185+
ffBinaryExtractStrings(path.chars, extractCtFvWmVersion, result, (uint32_t) strlen("0.0.0"));
186+
if (result->length > 0) return NULL;
187+
188+
if (ffProcessAppendStdOut(result, (char* const[]){
189+
path.chars,
190+
"-version",
191+
NULL
192+
}) == NULL)
193+
{ // [FVWM][main]: fvwm Version 2.2.5\n...
194+
ffStrbufSubstrBeforeFirstC(result, '\n');
195+
ffStrbufSubstrAfterLastC(result, ' ');
196+
return NULL;
197+
}
198+
199+
return "Failed to run command `fvwm -version`";
200+
}
201+
179202
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options)
180203
{
181204
if (!wmName)
@@ -193,5 +216,8 @@ const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE
193216
if (ffStrbufEqualS(wmName, "ctwm"))
194217
return getCtwm(result);
195218

219+
if (ffStrbufEqualS(wmName, "fvwm"))
220+
return getFvwm(result);
221+
196222
return "Unsupported WM";
197223
}

0 commit comments

Comments
 (0)