Skip to content

Commit 2d76b25

Browse files
committed
WM: Add support for detecting window manager versions, add support for Hyprland version
1 parent d58d786 commit 2d76b25

File tree

7 files changed

+56
-1
lines changed

7 files changed

+56
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ if(LINUX)
534534
src/detection/users/users_linux.c
535535
src/detection/wallpaper/wallpaper_linux.c
536536
src/detection/wifi/wifi_linux.c
537-
src/detection/wm/wm_nosupport.c
537+
src/detection/wm/wm_linux.c
538538
src/detection/de/de_linux.c
539539
src/detection/wmtheme/wmtheme_linux.c
540540
src/detection/camera/camera_linux.c

src/detection/wm/wm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
#include "fastfetch.h"
44

55
const char* ffDetectWMPlugin(FFstrbuf* pluginName);
6+
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FFWMOptions* options);

src/detection/wm/wm_apple.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName)
3838

3939
return NULL;
4040
}
41+
42+
const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options)
43+
{
44+
return "Not supported on this platform";
45+
}

src/detection/wm/wm_linux.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "wm.h"
2+
3+
#include "common/processing.h"
4+
#include "detection/displayserver/displayserver.h"
5+
6+
const char* ffDetectWMPlugin(FF_MAYBE_UNUSED FFstrbuf* pluginName)
7+
{
8+
return "Not supported on this platform";
9+
}
10+
11+
static void getHyprland(FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options)
12+
{
13+
if (ffProcessAppendStdOut(result, (char* const[]){
14+
"Hyprland",
15+
"--version",
16+
NULL
17+
}) == NULL){ // Hyprland 0.46.2 built from branch v0.46.2-b at... long and multi line
18+
ffStrbufSubstrAfterFirstC(result, ' ');
19+
ffStrbufSubstrBeforeFirstC(result, ' ');
20+
}
21+
}
22+
23+
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FFWMOptions* options)
24+
{
25+
if (ffStrbufEqualS(wmName, FF_WM_PRETTY_HYPRLAND))
26+
getHyprland(result, options);
27+
else
28+
return "Unsupported WM";
29+
return NULL;
30+
}

src/detection/wm/wm_nosupport.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ const char* ffDetectWMPlugin(FF_MAYBE_UNUSED FFstrbuf* pluginName)
44
{
55
return "Not supported on this platform";
66
}
7+
8+
const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options)
9+
{
10+
return "Not supported on this platform";
11+
}

src/detection/wm/wm_windows.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName)
6464
}
6565
return NULL;
6666
}
67+
68+
const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options)
69+
{
70+
return "Not supported on this platform";
71+
}

src/modules/wm/wm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ void ffPrintWM(FFWMOptions* options)
1919
if(options->detectPlugin)
2020
ffDetectWMPlugin(&pluginName);
2121

22+
FF_STRBUF_AUTO_DESTROY version = ffStrbufCreate();
23+
ffDetectWMVersion(&result->wmPrettyName, &version, options);
24+
2225
if(options->moduleArgs.outputFormat.length == 0)
2326
{
2427
ffPrintLogoAndKey(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
2528

2629
ffStrbufWriteTo(&result->wmPrettyName, stdout);
2730

31+
if(version.length > 0)
32+
{
33+
putchar(' ');
34+
ffStrbufWriteTo(&version, stdout);
35+
}
36+
2837
if(result->wmProtocolName.length > 0)
2938
{
3039
fputs(" (", stdout);

0 commit comments

Comments
 (0)