From fc3891c91388f96dfd4017367d2afd38b70cbf89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 31 Oct 2023 09:54:12 +0800 Subject: [PATCH] DE: implement `--de-slow-version-detection` --- src/detection/de/de_linux.c | 38 ++++++++++++++++++------------------- src/modules/de/de.c | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c index b96a52399..3d75bcc41 100644 --- a/src/detection/de/de_linux.c +++ b/src/detection/de/de_linux.c @@ -5,7 +5,7 @@ #include "common/processing.h" #include "detection/displayserver/displayserver.h" -static void getKDE(FFstrbuf* result) +static void getKDE(FFstrbuf* result, FFDEOptions* options) { ffParsePropFileValues("/usr/share/xsessions/plasmax11.desktop", 1, (FFpropquery[]) { {"X-KDE-PluginInfo-Version =", result} @@ -25,7 +25,7 @@ static void getKDE(FFstrbuf* result) if(result->length == 0) ffParsePropFileData("wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", result); - if(result->length == 0 && instance.config.general.allowSlowOperations) + if(result->length == 0 && options->slowVersionDetection) { if (ffProcessAppendStdOut(result, (char* const[]){ "plasmashell", @@ -36,7 +36,7 @@ static void getKDE(FFstrbuf* result) } } -static void getGnome(FFstrbuf* result) +static void getGnome(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { ffParsePropFileData("gnome-shell/org.gnome.Extensions", "version :", result); @@ -51,12 +51,12 @@ static void getGnome(FFstrbuf* result) } } -static void getCinnamon(FFstrbuf* result) +static void getCinnamon(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { ffParsePropFileData("applications/cinnamon.desktop", "X-GNOME-Bugzilla-Version =", result); } -static void getMate(FFstrbuf* result) +static void getMate(FFstrbuf* result, FFDEOptions* options) { FF_STRBUF_AUTO_DESTROY major = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate(); @@ -70,7 +70,7 @@ static void getMate(FFstrbuf* result) ffParseSemver(result, &major, &minor, µ); - if(result->length == 0 && instance.config.general.allowSlowOperations) + if(result->length == 0 && options->slowVersionDetection) { ffProcessAppendStdOut(result, (char* const[]){ "mate-session", @@ -83,7 +83,7 @@ static void getMate(FFstrbuf* result) } } -static void getXFCE4(FFstrbuf* result) +static void getXFCE4(FFstrbuf* result, FFDEOptions* options) { ffParsePropFileData("gtk-doc/html/libxfce4ui/index.html", "

Version", result); @@ -104,7 +104,7 @@ static void getXFCE4(FFstrbuf* result) } #endif - if(result->length == 0 && instance.config.general.allowSlowOperations) + if(result->length == 0 && options->slowVersionDetection) { //This is somewhat slow ffProcessAppendStdOut(result, (char* const[]){ @@ -119,7 +119,7 @@ static void getXFCE4(FFstrbuf* result) } } -static void getLXQt(FFstrbuf* result) +static void getLXQt(FFstrbuf* result, FFDEOptions* options) { ffParsePropFileData("gconfig/lxqt.pc", "Version:", result); @@ -128,7 +128,7 @@ static void getLXQt(FFstrbuf* result) if(result->length == 0) ffParsePropFileData("cmake/lxqt/lxqt-config-version.cmake", "set ( PACKAGE_VERSION", result); - if(result->length == 0 && instance.config.general.allowSlowOperations) + if(result->length == 0 && options->slowVersionDetection) { //This is really, really, really slow. Thank you, LXQt developers ffProcessAppendStdOut(result, (char* const[]){ @@ -142,27 +142,27 @@ static void getLXQt(FFstrbuf* result) } } -static void getBudgie(FFstrbuf* result) +static void getBudgie(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { ffParsePropFileData("budgie/budgie-version.xml", "", result); } -const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) +const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOptions* options) { if (ffStrbufEqualS(deName, FF_DE_PRETTY_PLASMA)) - getKDE(result); + getKDE(result, options); else if (ffStrbufEqualS(deName, FF_DE_PRETTY_GNOME) || ffStrbufEqualS(deName, FF_DE_PRETTY_GNOME)) - getGnome(result); + getGnome(result, options); else if (ffStrbufEqualS(deName, FF_DE_PRETTY_CINNAMON)) - getCinnamon(result); + getCinnamon(result, options); else if (ffStrbufEqualS(deName, FF_DE_PRETTY_XFCE4)) - getXFCE4(result); + getXFCE4(result, options); else if (ffStrbufEqualS(deName, FF_DE_PRETTY_MATE)) - getMate(result); + getMate(result, options); else if (ffStrbufEqualS(deName, FF_DE_PRETTY_LXQT)) - getLXQt(result); + getLXQt(result, options); else if (ffStrbufEqualS(deName, FF_DE_PRETTY_BUDGIE)) - getBudgie(result); + getBudgie(result, options); else return "Unsupported DE"; return NULL; diff --git a/src/modules/de/de.c b/src/modules/de/de.c index 7cab66701..f80c059d3 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -51,7 +51,7 @@ bool ffParseDECommandOptions(FFDEOptions* options, const char* key, const char* if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; - if (ffStrEqualsIgnCase(key, "slow-version-detection")) + if (ffStrEqualsIgnCase(subKey, "slow-version-detection")) { options->slowVersionDetection = ffOptionParseBoolean(value); return true;