mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Terminal (Linux): adds kmscon version detection support
This commit is contained in:
@@ -503,6 +503,36 @@ FF_A_UNUSED static bool getTerminalVersionWeston(FF_A_UNUSED FFstrbuf* exe, FFst
|
||||
return version->length > 0;
|
||||
}
|
||||
|
||||
FF_A_UNUSED static bool extractKmsconVersion(const char* str, FF_A_UNUSED uint32_t len, void* userdata) {
|
||||
if (!ffStrStartsWith(str, "v")) {
|
||||
return true;
|
||||
}
|
||||
int count = 0;
|
||||
sscanf(str, "v%*d.%*d.%*d%n", &count);
|
||||
if (count == 0) {
|
||||
return true;
|
||||
}
|
||||
ffStrbufSetNS((FFstrbuf*) userdata, (uint32_t) count - 1, str + 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
FF_A_UNUSED static bool getTerminalVersionKmscon(FFstrbuf* exe, FFstrbuf* version) {
|
||||
if (ffIsAbsolutePath(exe->chars)) {
|
||||
ffBinaryExtractStrings(exe->chars, extractKmsconVersion, version, (uint32_t) strlen("v0.0.0"));
|
||||
if (version->length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getExeVersionRaw(exe, version)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// kmscon version v10.0.0
|
||||
ffStrbufSubstrAfterLastC(version, ' ');
|
||||
return version->length > 0;
|
||||
}
|
||||
|
||||
static bool getTerminalVersionContour(FFstrbuf* exe, FFstrbuf* version) {
|
||||
const char* env = getenv("TERMINAL_VERSION_STRING");
|
||||
if (env) {
|
||||
@@ -840,6 +870,14 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_A_UNUSED FFstrbuf* exe, FF
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
if (ffStrbufIgnCaseEqualS(processName, "kmscon")) {
|
||||
return getTerminalVersionKmscon(exe, version);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
if (ffStrbufIgnCaseEqualS(processName, "WindowsTerminal.exe")) {
|
||||
|
||||
Reference in New Issue
Block a user