WM: Add support for detecting window manager versions, add support for Hyprland version (#1472)

This commit is contained in:
Christopher Kaster 2025-01-02 11:13:28 +09:00 committed by GitHub
parent d58d786c83
commit f14cd2c6e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 56 additions and 1 deletions

View File

@ -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

View File

@ -3,3 +3,4 @@
#include "fastfetch.h"
const char* ffDetectWMPlugin(FFstrbuf* pluginName);
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FFWMOptions* options);

View File

@ -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";
}

View File

@ -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;
}

View File

@ -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";
}

View File

@ -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";
}

View File

@ -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);