@@ -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+
179202const 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