From b7a9fe58b42eac4a7dff0f4a34c1814c740bc97e Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 15 Nov 2024 16:18:43 +0800 Subject: [PATCH] Terminal (Linux): support tilix version detection --- CHANGELOG.md | 1 + src/detection/terminalshell/terminalshell.c | 23 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45309bc4f..379c12bcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Features: * Generate manual pages from `help.json` (Doc) * Detect marketing name of vivo smartphone (Host, Android) * Add txDrops detection if supported (NetIO, *BSD) +* Support tilix version detection (Terminal, Linux) * Support percent type config in module level. Example: ```json diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index b8f6e1159..7ce6854a5 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -641,6 +641,26 @@ FF_MAYBE_UNUSED static bool getTerminalVersionPtyxis(FF_MAYBE_UNUSED FFstrbuf* e ffStrbufSubstrAfterFirstC(version, ' '); return true; } + +FF_MAYBE_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdOut(version, (char* const[]) { + exe->chars, + "--version", + NULL + }) != NULL) + return false; + + uint32_t index = ffStrbufFirstIndexS(version, "Tilix version: "); + if (index == version->length) return false; + + index += (uint32_t) strlen("Tilix version:"); + uint32_t end = ffStrbufNextIndexC(version, index, '\n'); + + ffStrbufSubstrBefore(version, end); + ffStrbufSubstrAfter(version, index); + return true; +} #endif #ifdef _WIN32 @@ -740,6 +760,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "ptyxis-agent")) return getTerminalVersionPtyxis(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "tilix")) + return getTerminalVersionTilix(exe, version); + #endif #ifdef _WIN32