From 67d0dfcef00907f2c7122f53450f361d797c62ac Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 27 Aug 2024 14:31:05 +0800 Subject: [PATCH] DE (Linux): support unity version detection --- src/detection/de/de_linux.c | 8 ++++++++ src/detection/displayserver/linux/wmde.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c index c17e8ac7f..c31d10b94 100644 --- a/src/detection/de/de_linux.c +++ b/src/detection/de/de_linux.c @@ -178,6 +178,12 @@ static void getBudgie(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) ffParsePropFileData("budgie/budgie-version.xml", "", result); } +static void getUnity(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) +{ + if (ffParsePropFile("/usr/bin/unity", "parser = OptionParser(version= \"%prog ", result)) + ffStrbufSubstrBeforeFirstC(result, '"'); +} + const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOptions* options) { if (!instance.config.general.detectVersion) return "Disabled by config"; @@ -196,6 +202,8 @@ const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOpti getLXQt(result, options); else if (ffStrbufEqualS(deName, FF_DE_PRETTY_BUDGIE)) getBudgie(result, options); + else if (ffStrbufEqualS(deName, FF_DE_PRETTY_UNITY)) + getUnity(result, options); else return "Unsupported DE"; return NULL; diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 8f50b69ab..9d174b5ea 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -238,6 +238,13 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) ffStrbufSetS(&result->deProcessName, "ukui-session"); ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_UKUI); } + + else if( + ffStrStartsWithIgnCase(name, "Unity:Unity") + ) { + ffStrbufSetS(&result->deProcessName, "unity-session"); + ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_UNITY); + } }