diff --git a/CMakeLists.txt b/CMakeLists.txt index c2b57daaf1..2b552b45e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -534,7 +534,7 @@ if(LINUX) src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_linux.c src/detection/wifi/wifi_linux.c - src/detection/wm/wm_nosupport.c + src/detection/wm/wm_linux.c src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_linux.c diff --git a/src/detection/wm/wm.h b/src/detection/wm/wm.h index 5301cff94e..5f5fa4adfe 100644 --- a/src/detection/wm/wm.h +++ b/src/detection/wm/wm.h @@ -3,3 +3,4 @@ #include "fastfetch.h" const char* ffDetectWMPlugin(FFstrbuf* pluginName); +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FFWMOptions* options); diff --git a/src/detection/wm/wm_apple.c b/src/detection/wm/wm_apple.c index 29b5497f8a..dca3b600b5 100644 --- a/src/detection/wm/wm_apple.c +++ b/src/detection/wm/wm_apple.c @@ -38,3 +38,8 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) return NULL; } + +const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/wm/wm_linux.c b/src/detection/wm/wm_linux.c new file mode 100644 index 0000000000..c5d95dc755 --- /dev/null +++ b/src/detection/wm/wm_linux.c @@ -0,0 +1,30 @@ +#include "wm.h" + +#include "common/processing.h" +#include "detection/displayserver/displayserver.h" + +const char* ffDetectWMPlugin(FF_MAYBE_UNUSED FFstrbuf* pluginName) +{ + return "Not supported on this platform"; +} + +static void getHyprland(FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) +{ + if (ffProcessAppendStdOut(result, (char* const[]){ + "Hyprland", + "--version", + NULL + }) == NULL){ // Hyprland 0.46.2 built from branch v0.46.2-b at... long and multi line + ffStrbufSubstrAfterFirstC(result, ' '); + ffStrbufSubstrBeforeFirstC(result, ' '); + } +} + +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FFWMOptions* options) +{ + if (ffStrbufEqualS(wmName, FF_WM_PRETTY_HYPRLAND)) + getHyprland(result, options); + else + return "Unsupported WM"; + return NULL; +} diff --git a/src/detection/wm/wm_nosupport.c b/src/detection/wm/wm_nosupport.c index 37c0105d71..595cdd9468 100644 --- a/src/detection/wm/wm_nosupport.c +++ b/src/detection/wm/wm_nosupport.c @@ -4,3 +4,8 @@ const char* ffDetectWMPlugin(FF_MAYBE_UNUSED FFstrbuf* pluginName) { return "Not supported on this platform"; } + +const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/wm/wm_windows.cpp b/src/detection/wm/wm_windows.cpp index 583cf21491..f784d3b626 100644 --- a/src/detection/wm/wm_windows.cpp +++ b/src/detection/wm/wm_windows.cpp @@ -64,3 +64,8 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) } return NULL; } + +const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) +{ + return "Not supported on this platform"; +} diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index dc02ba4c0d..f84e503b3a 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -19,12 +19,21 @@ void ffPrintWM(FFWMOptions* options) if(options->detectPlugin) ffDetectWMPlugin(&pluginName); + FF_STRBUF_AUTO_DESTROY version = ffStrbufCreate(); + ffDetectWMVersion(&result->wmPrettyName, &version, options); + if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result->wmPrettyName, stdout); + if(version.length > 0) + { + putchar(' '); + ffStrbufWriteTo(&version, stdout); + } + if(result->wmProtocolName.length > 0) { fputs(" (", stdout);