DE: implement --de-slow-version-detection

This commit is contained in:
李通洲
2023-10-31 09:54:12 +08:00
parent cd07354b6f
commit fc3891c913
2 changed files with 20 additions and 20 deletions
+19 -19
View File
@@ -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, &micro);
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", "<div><p class=\"releaseinfo\">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", "<str>", 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;
+1 -1
View File
@@ -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;