11#include "wm.h"
22
33#include "common/processing.h"
4+ #include "common/io/io.h"
45#include "detection/displayserver/displayserver.h"
56#include "util/binary.h"
67#include "util/path.h"
@@ -22,7 +23,7 @@ static bool extractHyprlandVersion(const char* line, FF_MAYBE_UNUSED uint32_t le
2223 return false;
2324}
2425
25- static const char * getHyprland (FFstrbuf * result , FF_MAYBE_UNUSED FFWMOptions * options )
26+ static const char * getHyprland (FFstrbuf * result )
2627{
2728 FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate ();
2829 const char * error = ffFindExecutableInPath ("Hyprland" , & path );
@@ -53,7 +54,7 @@ static bool extractSwayVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, v
5354 return false;
5455}
5556
56- static const char * getSway (FFstrbuf * result , FF_MAYBE_UNUSED FFWMOptions * options )
57+ static const char * getSway (FFstrbuf * result )
5758{
5859 FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate ();
5960 const char * error = ffFindExecutableInPath ("sway" , & path );
@@ -79,16 +80,34 @@ static const char* getSway(FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* option
7980 return "Failed to run command `sway --version`" ;
8081}
8182
82- const char * ffDetectWMVersion (const FFstrbuf * wmName , FFstrbuf * result , FFWMOptions * options )
83+ static const char * getWslg (FFstrbuf * result )
84+ {
85+ if (!ffAppendFileBuffer ("/mnt/wslg/versions.txt" , result ))
86+ return "Failed to read /mnt/wslg/versions.txt" ;
87+
88+ if (!ffStrbufStartsWithS (result , "WSLg " ))
89+ return "Failed to find WSLg version" ;
90+
91+ ffStrbufSubstrBeforeFirstC (result , '\n' );
92+ ffStrbufSubstrBeforeFirstC (result , '+' );
93+ ffStrbufSubstrAfterFirstC (result , ':' );
94+ ffStrbufTrimLeft (result , ' ' );
95+ return NULL ;
96+ }
97+
98+ const char * ffDetectWMVersion (const FFstrbuf * wmName , FFstrbuf * result , FF_MAYBE_UNUSED FFWMOptions * options )
8399{
84100 if (!wmName )
85101 return "No WM detected" ;
86102
87103 if (ffStrbufEqualS (wmName , "Hyprland" ))
88- return getHyprland (result , options );
104+ return getHyprland (result );
89105
90106 if (ffStrbufEqualS (wmName , "sway" ))
91- return getSway (result , options );
107+ return getSway (result );
108+
109+ if (ffStrbufEqualS (wmName , "WSLg" ))
110+ return getWslg (result );
92111
93112 return "Unsupported WM" ;
94113}
0 commit comments