Skip to content

Commit aae7404

Browse files
committed
Wallpaper (Linux): add support for gnome
1 parent 8f9beb2 commit aae7404

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ if(LINUX)
361361
src/detection/terminalshell/terminalshell_linux.c
362362
src/detection/uptime/uptime_linux.c
363363
src/detection/users/users_linux.c
364-
src/detection/wallpaper/wallpaper_nosupport.c
364+
src/detection/wallpaper/wallpaper_linux.c
365365
src/detection/wifi/wifi_linux.c
366366
src/detection/wmtheme/wmtheme_linux.c
367367
src/util/platform/FFPlatform_unix.c
@@ -451,7 +451,7 @@ elseif(BSD)
451451
src/detection/terminalshell/terminalshell_linux.c
452452
src/detection/uptime/uptime_bsd.c
453453
src/detection/users/users_linux.c
454-
src/detection/wallpaper/wallpaper_nosupport.c
454+
src/detection/wallpaper/wallpaper_linux.c
455455
src/detection/wifi/wifi_nosupport.c
456456
src/detection/wmtheme/wmtheme_linux.c
457457
src/util/platform/FFPlatform_unix.c

src/detection/gtk_qt/gtk.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static inline bool allPropertiesSet(FFGTKResult* result)
1313
result->font.length > 0;
1414
}
1515

16-
static inline void applyGTKSettings(FFGTKResult* result, const char* themeName, const char* iconsName, const char* fontName, const char* cursorTheme, int cursorSize)
16+
static inline void applyGTKSettings(FFGTKResult* result, const char* themeName, const char* iconsName, const char* fontName, const char* cursorTheme, int cursorSize, const char* wallpaper)
1717
{
1818
if(result->theme.length == 0)
1919
ffStrbufAppendS(&result->theme, themeName);
@@ -29,6 +29,9 @@ static inline void applyGTKSettings(FFGTKResult* result, const char* themeName,
2929

3030
if(result->cursorSize.length == 0 && cursorSize > 0)
3131
ffStrbufAppendF(&result->cursorSize, "%i", cursorSize);
32+
33+
if(result->wallpaper.length == 0)
34+
ffStrbufAppendS(&result->wallpaper, wallpaper);
3235
}
3336

3437
static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* result)
@@ -40,6 +43,7 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul
4043
static const char* fontName = NULL;
4144
static const char* cursorTheme = NULL;
4245
static int cursorSize = 0;
46+
static const char* wallpaper = NULL;
4347

4448
static bool init = false;
4549

@@ -48,7 +52,7 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul
4852
if(init)
4953
{
5054
ffThreadMutexUnlock(&mutex);
51-
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
55+
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize, wallpaper);
5256
return;
5357
}
5458

@@ -90,10 +94,12 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul
9094
fontName = ffSettingsGet(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
9195
cursorTheme = ffSettingsGet(instance, "/org/gnome/desktop/interface/cursor-theme", "org.gnome.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
9296
cursorSize = ffSettingsGet(instance, "/org/gnome/desktop/interface/cursor-size", "org.gnome.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
97+
wallpaper = ffSettingsGet(instance, "/org/gnome/desktop/background/picture-uri", "org.gnome.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue;
98+
// TODO: support other DEs for wallpaper
9399
}
94100

95101
ffThreadMutexUnlock(&mutex);
96-
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
102+
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize, wallpaper);
97103
}
98104

99105
static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result)
@@ -184,6 +190,7 @@ static void detectGTK(const FFinstance* instance, const char* version, FFGTKResu
184190
ffStrbufInit(&result.font); \
185191
ffStrbufInit(&result.cursor); \
186192
ffStrbufInit(&result.cursorSize); \
193+
ffStrbufInit(&result.wallpaper); \
187194
detectGTK(instance, #version, &result); \
188195
ffThreadMutexUnlock(&mutex); \
189196
return &result;

src/detection/gtk_qt/gtk_qt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ typedef struct FFGTKResult
1212
FFstrbuf font;
1313
FFstrbuf cursor;
1414
FFstrbuf cursorSize;
15+
FFstrbuf wallpaper;
1516
} FFGTKResult;
1617

1718
typedef struct FFQtResult
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "wallpaper.h"
2+
#include "common/settings.h"
3+
#include "detection/gtk_qt/gtk_qt.h"
4+
5+
const char* ffDetectWallpaper(const FFinstance* instance, FFstrbuf* result)
6+
{
7+
const FFGTKResult* gtk = ffDetectGTK4(instance);
8+
if (!gtk->wallpaper.length)
9+
return "Failed to detect the current wallpaper path";
10+
11+
if (ffStrbufStartsWithS(&gtk->wallpaper, "file:///"))
12+
ffStrbufAppendS(result, gtk->wallpaper.chars + strlen("file://"));
13+
else
14+
ffStrbufAppend(result, &gtk->wallpaper);
15+
16+
return NULL;
17+
}

0 commit comments

Comments
 (0)