From ab200d7e4af185fabf9d9155f3ef23aed741ff71 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 2 Dec 2024 19:09:27 +0800 Subject: [PATCH] Terminal: Support sakura version & font detection Fix #1424 --- CHANGELOG.md | 1 + src/detection/terminalfont/terminalfont_linux.c | 2 ++ src/detection/terminalshell/terminalshell.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73f3386e1..c27b86326 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Features: * Detect current Wi-Fi channel and maximum frequency (Wifi) * Report processor package count (#1413, CPU) * Remove duplicate whitespaces in CPU name +* Support sakura terminal version & font detection (Terminal / TerminalFont, Linux) Logo: * Fix LMDE diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 5cdc6bb74..2c0ecd28b 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -454,4 +454,6 @@ void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFo detectWestonTerminal(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "terminator")) detectTerminator(terminalFont); + else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "sakura")) + detectFromConfigFile("sakura/sakura.conf", "font=", terminalFont);; } diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 7ce6854a5..ebacb444f 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -661,6 +661,19 @@ FF_MAYBE_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* ver ffStrbufSubstrAfter(version, index); return true; } + +FF_MAYBE_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdErr(version, (char* const[]) { + exe->chars, + "--version", + NULL + }) != NULL) // sakura version is 3.8.8 + return false; + + ffStrbufSubstrAfterLastC(version, ' '); + return true; +} #endif #ifdef _WIN32 @@ -763,6 +776,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "tilix")) return getTerminalVersionTilix(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "sakura")) + return getTerminalVersionSakura(exe, version); + #endif #ifdef _WIN32