@@ -176,7 +176,7 @@ static const char* getWslg(FFstrbuf* result)
176176 return NULL ;
177177}
178178
179- static bool extractCtFvWmVersion (const char * line , FF_MAYBE_UNUSED uint32_t len , void * userdata )
179+ static bool extractCommonWmVersion (const char * line , FF_MAYBE_UNUSED uint32_t len , void * userdata )
180180{
181181 int count = 0 ;
182182 sscanf (line , "%*d.%*d.%*d%n" , & count );
@@ -192,7 +192,7 @@ static const char* getCtwm(FFstrbuf* result)
192192 const char * error = ffFindExecutableInPath ("ctwm" , & path );
193193 if (error ) return "Failed to find ctwm executable path" ;
194194
195- ffBinaryExtractStrings (path .chars , extractCtFvWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
195+ ffBinaryExtractStrings (path .chars , extractCommonWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
196196 if (result -> length > 0 ) return NULL ;
197197
198198 if (ffProcessAppendStdOut (result , (char * const []){
@@ -215,7 +215,7 @@ static const char* getFvwm(FFstrbuf* result)
215215 const char * error = ffFindExecutableInPath ("fvwm" , & path );
216216 if (error ) return "Failed to find fvwm executable path" ;
217217
218- ffBinaryExtractStrings (path .chars , extractCtFvWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
218+ ffBinaryExtractStrings (path .chars , extractCommonWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
219219 if (result -> length > 0 ) return NULL ;
220220
221221 if (ffProcessAppendStdOut (result , (char * const []){
@@ -232,6 +232,29 @@ static const char* getFvwm(FFstrbuf* result)
232232 return "Failed to run command `fvwm -version`" ;
233233}
234234
235+ static const char * getOpenbox (FFstrbuf * result )
236+ {
237+ FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate ();
238+ const char * error = ffFindExecutableInPath ("openbox" , & path );
239+ if (error ) return "Failed to find openbox executable path" ;
240+
241+ ffBinaryExtractStrings (path .chars , extractCommonWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
242+ if (result -> length > 0 ) return NULL ;
243+
244+ if (ffProcessAppendStdOut (result , (char * const []){
245+ path .chars ,
246+ "-version" ,
247+ NULL
248+ }) == NULL )
249+ { // Openbox 3.6.1\n...
250+ ffStrbufSubstrBeforeFirstC (result , '\n' );
251+ ffStrbufSubstrAfterLastC (result , ' ' );
252+ return NULL ;
253+ }
254+
255+ return "Failed to run command `fvwm -version`" ;
256+ }
257+
235258const char * ffDetectWMVersion (const FFstrbuf * wmName , FFstrbuf * result , FF_MAYBE_UNUSED FFWMOptions * options )
236259{
237260 if (!wmName )
@@ -255,5 +278,8 @@ const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE
255278 if (ffStrbufEqualS (wmName , "fvwm" ))
256279 return getFvwm (result );
257280
281+ if (ffStrbufEqualS (wmName , "Openbox" ))
282+ return getOpenbox (result );
283+
258284 return "Unsupported WM" ;
259285}
0 commit comments