From 7609a247788d86701250f3ae5889d30595b6fb9e Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Sat, 8 May 2021 11:20:17 +0200 Subject: [PATCH] Cinnamon support --- README.md | 2 +- src/common/detectGTK.c | 25 +++++++++++++++++++------ src/common/detectWMDE.c | 22 +++++++++++++++++++--- src/common/io.c | 2 +- src/modules/wmtheme.c | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 61c6b8786..1747143b7 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ KWin, Mutter, Muffin, Openbox, XFWM, Sway, Wayfire, Weston ### Window manager themes: ``` -KWin, Mutter, Openbox (LXDE, LXQT & without DE) +KWin, Mutter, Muffin, Openbox (LXDE, LXQT & without DE) ``` ### Terminal fonts: diff --git a/src/common/detectGTK.c b/src/common/detectGTK.c index cb09b25e4..4a608290e 100644 --- a/src/common/detectGTK.c +++ b/src/common/detectGTK.c @@ -27,9 +27,9 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - static const char* themeName; - static const char* iconsName; - static const char* fontName; + static const char* themeName = NULL; + static const char* iconsName = NULL; + static const char* fontName = NULL; static bool init = false; @@ -44,9 +44,22 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result) init = true; - themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme"); - iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme"); - fontName = ffSettingsGet(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name"); + const FFWMDEResult* wmde = ffDetectWMDE(instance); + + if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0) + { + themeName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", NULL, "gtk-theme"); + iconsName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", NULL, "icon-theme"); + fontName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/font-name", "org.cinnamon.desktop.interface", NULL, "font-name"); + } + + //Fallback + Gnome impl + if(themeName == NULL) + themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme"); + if(iconsName == NULL) + iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme"); + if(fontName == NULL) + fontName = ffSettingsGet(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name"); pthread_mutex_unlock(&mutex); applyGTKDConfSettings(result, themeName, iconsName, fontName); diff --git a/src/common/detectWMDE.c b/src/common/detectWMDE.c index 83c69976b..5e746278c 100644 --- a/src/common/detectWMDE.c +++ b/src/common/detectWMDE.c @@ -16,7 +16,8 @@ typedef enum DEHint { FF_DE_HINT_UNKNOWN = 0, FF_DE_HINT_PLASMA, - FF_DE_HINT_GNOME + FF_DE_HINT_GNOME, + FF_DE_HINT_CINNAMON } DEHint; typedef struct ProcData @@ -118,7 +119,7 @@ static bool applyPrettyNameIfWM(FFWMDEResult* result, const FFstrbuf* processNam } else if(ffStrbufIgnCaseCompS(processName, "gnome-session-binary") == 0) ffStrbufSetS(&result->wmPrettyName, "Mutter"); - else if(ffStrbufIgnCaseCompS(processName, "cinnamon") == 0) + else if(ffStrbufIgnCaseCompS(processName, "cinnamon-session") == 0) ffStrbufSetS(&result->wmPrettyName, "Muffin"); if(result->wmPrettyName.length > 0) @@ -136,6 +137,8 @@ static bool applyDEHintIfDE(const FFstrbuf* processName, DEHint* deHint) *deHint = FF_DE_HINT_PLASMA; else if(ffStrbufIgnCaseCompS(processName, "gnome-shell") == 0) *deHint = FF_DE_HINT_GNOME; + else if(ffStrbufIgnCaseCompS(processName, "cinnamon") == 0) + *deHint = FF_DE_HINT_CINNAMON; return *deHint != FF_DE_HINT_UNKNOWN; } @@ -205,13 +208,22 @@ static void getKDE(FFWMDEResult* result) static void getGnome(FFWMDEResult* result) { - ffStrbufSetS(&result->deProcessName, "gnome-session-binary"); + ffStrbufSetS(&result->deProcessName, "gnome-shell"); ffStrbufSetS(&result->dePrettyName, "GNOME"); ffParsePropFile("/usr/share/gnome-shell/org.gnome.Extensions", " version: '%[^']", result->deVersion.chars); ffStrbufRecalculateLength(&result->deVersion); } +static void getCinnamon(FFWMDEResult* result) +{ + ffStrbufSetS(&result->deProcessName, "cinnamon"); + ffStrbufSetS(&result->dePrettyName, "Cinnamon"); + + ffParsePropFile("/usr/share/applications/cinnamon.desktop", " X-GNOME-Bugzilla-Version=%[^\n]", result->deVersion.chars); + ffStrbufRecalculateLength(&result->deVersion); +} + static inline void getDEFromHint(FFWMDEResult* result, ProcData* procData) { getFromProcDir(result, procData, false); @@ -223,6 +235,8 @@ static inline void getDEFromHint(FFWMDEResult* result, ProcData* procData) getKDE(result); else if(procData->deHint == FF_DE_HINT_GNOME) getGnome(result); + else if(procData->deHint == FF_DE_HINT_CINNAMON) + getCinnamon(result); } static inline void getDE(FFWMDEResult* result, ProcData* procData) @@ -242,6 +256,8 @@ static inline void getDE(FFWMDEResult* result, ProcData* procData) getKDE(result); else if(strcasecmp(result->sessionDesktop, "Gnome") == 0 || strcasecmp(result->sessionDesktop, "ubuntu:GNOME") == 0 || strcasecmp(result->sessionDesktop, "ubuntu") == 0) getGnome(result); + else if(strcasecmp(result->sessionDesktop, "X-Cinnamon") == 0 || strcasecmp(result->sessionDesktop, "Cinnamon") == 0) + getCinnamon(result); else { ffStrbufSetS(&result->deProcessName, result->sessionDesktop); diff --git a/src/common/io.c b/src/common/io.c index 7e0fcf12f..29690192e 100644 --- a/src/common/io.c +++ b/src/common/io.c @@ -48,7 +48,7 @@ void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIn ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat); fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout); vprintf(message, arguments); - puts(FASTFETCH_TEXT_MODIFIER_ERROR); + puts(FASTFETCH_TEXT_MODIFIER_RESET); } else { diff --git a/src/modules/wmtheme.c b/src/modules/wmtheme.c index bc6859926..2765972e2 100644 --- a/src/modules/wmtheme.c +++ b/src/modules/wmtheme.c @@ -54,6 +54,36 @@ static void printMutter(FFinstance* instance) printWMTheme(instance, theme); } +static void printMuffin(FFinstance* instance) +{ + const char* name = ffSettingsGet(instance, "/org/cinnamon/theme/name", "org.cinnamon.theme", NULL, "name"); + const char* theme = ffSettingsGet(instance, "/org/cinnamon/desktop/wm/preferences/theme", "org.cinnamon.desktop.wm.preferences", NULL, "theme"); + + if(name == NULL && theme == NULL) + { + ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't find muffin theme in GSettings / DConf"); + return; + } + + if(name == NULL) + printWMTheme(instance, theme); + else if(theme == NULL) + printWMTheme(instance, name); + else + { + FFstrbuf buffer; + ffStrbufInit(&buffer); + ffStrbufAppendS(&buffer, name); + ffStrbufAppendS(&buffer, " ("); + ffStrbufAppendS(&buffer, theme); + ffStrbufAppendC(&buffer, ')'); + + printWMTheme(instance, buffer.chars); + + ffStrbufDestroy(&buffer); + } +} + static void printOpenbox(FFinstance* instance, const FFstrbuf* dePrettyName) { FFstrbuf absolutePath; @@ -132,6 +162,8 @@ void ffPrintWMTheme(FFinstance* instance) printKWin(instance); else if(ffStrbufIgnCaseCompS(&result->wmPrettyName, "Mutter") == 0 || ffStrbufIgnCaseCompS(&result->wmPrettyName, "Gnome") == 0 || ffStrbufIgnCaseCompS(&result->wmPrettyName, "Ubuntu") == 0) printMutter(instance); + else if(ffStrbufIgnCaseCompS(&result->wmPrettyName, "Muffin") == 0) + printMuffin(instance); else if(ffStrbufIgnCaseCompS(&result->wmPrettyName, "Openbox") == 0) printOpenbox(instance, &result->dePrettyName); else