Wallpaper (Linux): support KDE

This commit is contained in:
李通洲
2023-06-11 12:16:54 +08:00
parent 977da91aa6
commit f65a3d1e75
5 changed files with 28 additions and 8 deletions
+3
View File
@@ -5,6 +5,9 @@ This release introduces a new configuration file format: JSON config
Changes:
* Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents.
Features:
* Support KDE wallpaper detection (Wallpaper, Linux)
# 1.11.3
Bugfixes:
+1
View File
@@ -21,6 +21,7 @@ typedef struct FFQtResult
FFstrbuf colorScheme;
FFstrbuf icons;
FFstrbuf font;
FFstrbuf wallpaper;
} FFQtResult;
const FFGTKResult* ffDetectGTK2(const FFinstance* instance);
+8 -1
View File
@@ -13,7 +13,8 @@ static inline bool allValuesSet(const FFQtResult* result)
result->widgetStyle.length > 0 &&
result->colorScheme.length > 0 &&
result->icons.length > 0 &&
result->font.length > 0;
result->font.length > 0 &&
result->wallpaper.length > 0;
}
typedef enum PlasmaCategory
@@ -95,6 +96,11 @@ static void detectPlasma(const FFinstance* instance, FFQtResult* result)
if(detectPlasmaFromFile(baseDir.chars, result))
foundAFile = true;
ffStrbufSet(&baseDir, configDir);
ffStrbufAppendS(&baseDir, "plasma-org.kde.plasma.desktop-appletsrc");
ffParsePropFile(baseDir.chars, "Image=", &result->wallpaper);
if(allValuesSet(result))
return;
}
@@ -144,6 +150,7 @@ const FFQtResult* ffDetectQt(const FFinstance* instance)
ffStrbufInit(&result.colorScheme);
ffStrbufInit(&result.icons);
ffStrbufInit(&result.font);
ffStrbufInit(&result.wallpaper);
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
+2 -2
View File
@@ -22,9 +22,9 @@ next:
if(n->ut_type != USER_PROCESS)
continue;
for(uint32_t i = 0; i < users->length; ++i)
FF_LIST_FOR_EACH(FFstrbuf, user, *users)
{
if(ffStrbufCompS((FFstrbuf*)ffListGet(users, i), n->ut_user) == 0)
if(ffStrbufCompS(user, n->ut_user) == 0)
goto next;
}
+14 -5
View File
@@ -4,14 +4,23 @@
const char* ffDetectWallpaper(const FFinstance* instance, FFstrbuf* result)
{
const FFstrbuf* wallpaper = NULL;
const FFGTKResult* gtk = ffDetectGTK4(instance);
if (!gtk->wallpaper.length)
if (gtk->wallpaper.length)
wallpaper = &gtk->wallpaper;
else
{
const FFQtResult* qt = ffDetectQt(instance);
if (qt->wallpaper.length)
wallpaper = &qt->wallpaper;
}
if (!wallpaper)
return "Failed to detect the current wallpaper path";
if (ffStrbufStartsWithS(&gtk->wallpaper, "file:///"))
ffStrbufAppendS(result, gtk->wallpaper.chars + strlen("file://"));
if (ffStrbufStartsWithS(wallpaper, "file:///"))
ffStrbufAppendS(result, wallpaper->chars + strlen("file://"));
else
ffStrbufAppend(result, &gtk->wallpaper);
ffStrbufAppend(result, wallpaper);
return NULL;
}