@@ -176,7 +176,7 @@ static const char* getWslg(FFstrbuf* result)
176
176
return NULL ;
177
177
}
178
178
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 )
180
180
{
181
181
int count = 0 ;
182
182
sscanf (line , "%*d.%*d.%*d%n" , & count );
@@ -192,7 +192,7 @@ static const char* getCtwm(FFstrbuf* result)
192
192
const char * error = ffFindExecutableInPath ("ctwm" , & path );
193
193
if (error ) return "Failed to find ctwm executable path" ;
194
194
195
- ffBinaryExtractStrings (path .chars , extractCtFvWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
195
+ ffBinaryExtractStrings (path .chars , extractCommonWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
196
196
if (result -> length > 0 ) return NULL ;
197
197
198
198
if (ffProcessAppendStdOut (result , (char * const []){
@@ -215,7 +215,7 @@ static const char* getFvwm(FFstrbuf* result)
215
215
const char * error = ffFindExecutableInPath ("fvwm" , & path );
216
216
if (error ) return "Failed to find fvwm executable path" ;
217
217
218
- ffBinaryExtractStrings (path .chars , extractCtFvWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
218
+ ffBinaryExtractStrings (path .chars , extractCommonWmVersion , result , (uint32_t ) strlen ("0.0.0" ));
219
219
if (result -> length > 0 ) return NULL ;
220
220
221
221
if (ffProcessAppendStdOut (result , (char * const []){
@@ -232,6 +232,29 @@ static const char* getFvwm(FFstrbuf* result)
232
232
return "Failed to run command `fvwm -version`" ;
233
233
}
234
234
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
+
235
258
const char * ffDetectWMVersion (const FFstrbuf * wmName , FFstrbuf * result , FF_MAYBE_UNUSED FFWMOptions * options )
236
259
{
237
260
if (!wmName )
@@ -255,5 +278,8 @@ const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE
255
278
if (ffStrbufEqualS (wmName , "fvwm" ))
256
279
return getFvwm (result );
257
280
281
+ if (ffStrbufEqualS (wmName , "Openbox" ))
282
+ return getOpenbox (result );
283
+
258
284
return "Unsupported WM" ;
259
285
}
0 commit comments