From ed5d0551ea170b0140a37303bcbb54b750935593 Mon Sep 17 00:00:00 2001 From: Joseph Crowell Date: Sun, 25 Oct 2026 17:12:56 +1000 Subject: [PATCH] add SonicDE window manager and desktop environment detection Signed-off-by: Joseph Crowell --- src/detection/cursor/cursor_linux.c | 2 ++ src/detection/de/de_linux.c | 18 ++++++++++++++++- src/detection/displayserver/displayserver.h | 2 ++ src/detection/displayserver/linux/wmde.c | 22 ++++++++++++++++++++- src/detection/gtk_qt/qt.c | 15 ++++++++------ src/detection/wmtheme/wmtheme_linux.c | 3 ++- 6 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/detection/cursor/cursor_linux.c b/src/detection/cursor/cursor_linux.c index 89dabbc371..76ae326413 100644 --- a/src/detection/cursor/cursor_linux.c +++ b/src/detection/cursor/cursor_linux.c @@ -86,6 +86,8 @@ void ffDetectCursor(FFCursorResult* result) { ffStrbufAppendS(&result->error, "Cursor isn't supported in TTY"); } else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA)) { detectCursorFromConfigFile("kcminputrc", "cursorTheme =", "Breeze", "cursorSize =", "24", result); + } else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_SONICDE)) { + detectCursorFromConfigFile("kcminputrc", "cursorTheme =", "silver_cursors_light", "cursorSize =", "24", result); } else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT)) { detectCursorFromConfigFile("lxqt/session.conf", "cursor_theme =", "Adwaita", "cursor_size =", "24", result); } else if (ffStrbufIgnCaseEqualS(&wmde->wmPrettyName, FF_WM_PRETTY_HYPRLAND) && detectCursorHyprcursor(result)) { diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c index 6426a25b60..b9c028bdaf 100644 --- a/src/detection/de/de_linux.c +++ b/src/detection/de/de_linux.c @@ -40,6 +40,20 @@ static void getKDE(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { } } +static void getSonicDE(FFstrbuf* result) { + ffParsePropFile(FF_PATH_PKG_BASE "/share/xsessions/sonicde.desktop", "X-KDE-PluginInfo-Version =", result); + if (result->length == 0) { + ffParsePropFileData("xsessions/sonicde.desktop", "X-KDE-PluginInfo-Version =", result); + } + if (result->length == 0) { + if (ffProcessAppendStdOut(result, (char* const[]) { "sonicshell", "--version", nullptr }) == nullptr) { + ffStrbufSubstrAfterLastC(result, ' '); + } else { + ffStrbufClear(result); + } + } +} + static const char* getGnomeByDbus([[maybe_unused]] FFstrbuf* result) { #ifdef FF_HAVE_DBUS FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; @@ -257,7 +271,9 @@ const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOpti return "Disabled by config"; } - if (ffStrbufEqualS(deName, FF_DE_PRETTY_PLASMA)) { + if (ffStrbufEqualS(deName, FF_DE_PRETTY_SONICDE)) { + getSonicDE(result); + } else if (ffStrbufEqualS(deName, FF_DE_PRETTY_PLASMA)) { getKDE(result, options); } else if (ffStrbufEqualS(deName, FF_DE_PRETTY_GNOME)) { getGnome(result, options); diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index 5ce08c386d..7c54a637cc 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -4,6 +4,7 @@ #include "modules/display/option.h" #define FF_DE_PRETTY_PLASMA "KDE Plasma" +#define FF_DE_PRETTY_SONICDE "SonicDE" #define FF_DE_PRETTY_GNOME "GNOME" #define FF_DE_PRETTY_GNOME_CLASSIC "GNOME Classic" #define FF_DE_PRETTY_XFCE4 "Xfce4" @@ -20,6 +21,7 @@ #define FF_DE_PRETTY_COSMIC "COSMIC" #define FF_WM_PRETTY_KWIN "KWin" +#define FF_WM_PRETTY_SONICWIN "SonicWin" #define FF_WM_PRETTY_MUTTER "Mutter" #define FF_WM_PRETTY_MUFFIN "Muffin" #define FF_WM_PRETTY_MARCO "Marco" diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index ed994fc7f6..ad872e4566 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -95,7 +95,9 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name) return; } - if ( + if (ffStrEqualsIgnCase(name, "SonicWin") || ffStrEqualsIgnCase(name, "sonic-win")) { + ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_SONICWIN); + } else if ( ffStrEqualsIgnCase(name, "kwin") || ffStrStartsWithIgnCase(name, "kwin_") || ffStrEndsWithIgnCase(name, "-kwin_wayland") || @@ -178,11 +180,29 @@ static void applyBetterWM(FFDisplayServerResult* result, const char* processName } } +static bool hasDesktopToken(const char* desktops, const char* token) { + size_t length = strlen(token); + for (const char* desktop = desktops; desktop && *desktop;) { + const char* end = strchr(desktop, ':'); + size_t desktopLength = end ? (size_t) (end - desktop) : strlen(desktop); + if (desktopLength == length && strncasecmp(desktop, token, length) == 0) { + return true; + } + desktop = end ? end + 1 : nullptr; + } + return false; +} + static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) { if (!ffStrSet(name)) { return; } + if (hasDesktopToken(name, "SonicDE") || ffStrEqualsIgnCase(name, "sonicshell")) { + ffStrbufSetStatic(&result->deProcessName, "sonicshell"); + ffStrbufSetStatic(&result->dePrettyName, FF_DE_PRETTY_SONICDE); + } + else if ( ffStrEqualsIgnCase(name, "KDE") || ffStrEqualsIgnCase(name, "plasma") || diff --git a/src/detection/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index 74046ed2b4..1565549b9b 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -77,7 +77,7 @@ static bool detectPlasmaFromFile(const char* filename, FFQtResult* result) { return true; } -static void detectPlasma(FFQtResult* result) { +static void detectDesktopQt(FFQtResult* result, const char* layoutFile) { bool foundAFile = false; // We need to do this because we use multiple threads on configDirs @@ -91,10 +91,11 @@ static void detectPlasma(FFQtResult* result) { foundAFile = true; } - ffStrbufSet(&baseDir, configDir); - ffStrbufAppendS(&baseDir, "plasma-org.kde.plasma.desktop-appletsrc"); - - ffParsePropFile(baseDir.chars, "Image=", &result->wallpaper); + if (layoutFile) { + ffStrbufSet(&baseDir, configDir); + ffStrbufAppendS(&baseDir, layoutFile); + ffParsePropFile(baseDir.chars, "Image=", &result->wallpaper); + } if (allValuesSet(result)) { return; @@ -184,7 +185,9 @@ static void initQtResult(void* storage) { const FFDisplayServerResult* wmde = ffConnectDisplayServer(); if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_PLASMA)) { - detectPlasma(qt); + detectDesktopQt(qt, "plasma-org.kde.plasma.desktop-appletsrc"); + } else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_SONICDE)) { + detectDesktopQt(qt, "sonic-org.sonicde.desktop-appletsrc"); } else if (ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_LXQT)) { detectLXQt(qt); } else { diff --git a/src/detection/wmtheme/wmtheme_linux.c b/src/detection/wmtheme/wmtheme_linux.c index 1c46e78221..ab4ab878c9 100644 --- a/src/detection/wmtheme/wmtheme_linux.c +++ b/src/detection/wmtheme/wmtheme_linux.c @@ -294,7 +294,8 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) { return false; } - if (ffStrbufIgnCaseEqualS(&wm->wmPrettyName, FF_WM_PRETTY_KWIN)) { + if (ffStrbufIgnCaseEqualS(&wm->wmPrettyName, FF_WM_PRETTY_KWIN) || + ffStrbufIgnCaseEqualS(&wm->wmPrettyName, FF_WM_PRETTY_SONICWIN)) { return detectWMThemeFromConfigFile("kwinrc", "theme =", "Breeze", themeOrError); }