DE (Linux): adds Trinity version detection support

This commit is contained in:
Carter Li
2025-08-21 18:19:23 +08:00
parent 8331242f42
commit 784a7a92c8
+43 -1
View File
@@ -6,8 +6,9 @@
#include "common/parsing.h"
#include "common/properties.h"
#include "common/processing.h"
#include "util/binary.h"
#include "util/path.h"
#include "detection/displayserver/displayserver.h"
#include "util/stringUtils.h"
#include <ctype.h>
#ifdef __FreeBSD__
@@ -195,6 +196,45 @@ static void getUnity(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options)
ffStrbufSubstrBeforeFirstC(result, '"');
}
static bool extractTdeVersion(const char* line, uint32_t len, void *userdata)
{
int count = 0;
sscanf(line, "R%*d.%*d.%*d%n", &count);
if (count == 0) return true;
ffStrbufSetNS((FFstrbuf*) userdata, len, line);
return false;
}
static const char* getTrinity(FFstrbuf* result, FFDEOptions* options)
{
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
const char* error = ffFindExecutableInPath("tde-config", &path);
if (error) return "Failed to find tde-config path";
ffStrbufSubstrBeforeLastC(&path, '/');
ffStrbufAppendS(&path, "/../lib/libtdecore.so");
if (ffBinaryExtractStrings(path.chars, extractTdeVersion, result, strlen("R0.0.0")) == NULL)
return NULL;
if (options->slowVersionDetection)
{
ffStrbufClear(&path);
ffProcessAppendStdOut(&path, (char* const[]){
"tde-config",
"--version",
NULL
});
ffParsePropLines(path.chars , "TDE: ", result);
return NULL;
}
return "All methods failed";
}
const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOptions* options)
{
if (!instance.config.general.detectVersion) return "Disabled by config";
@@ -215,6 +255,8 @@ const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOpti
getBudgie(result, options);
else if (ffStrbufEqualS(deName, FF_DE_PRETTY_UNITY))
getUnity(result, options);
else if (ffStrbufEqualS(deName, "trinity"))
getTrinity(result, options);
else
return "Unsupported DE";
return NULL;