From 526324be38ebb7f933a3e69763c439eaa538c54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 19 Apr 2024 15:19:46 +0800 Subject: [PATCH] Terminal (FreeBSD): implement kitty version fast path for FreeBSD --- src/detection/terminalshell/terminalshell.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 521ea0bde..68ff5313a 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -5,6 +5,9 @@ #include "util/stringUtils.h" #include +#ifdef __FreeBSD__ + #include +#endif #ifdef _WIN32 @@ -474,11 +477,17 @@ static bool getTerminalVersionZellij(FFstrbuf* exe, FFstrbuf* version) #ifndef _WIN32 static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { - #ifdef __linux__ + #if defined(__linux__) || defined(__FreeBSD__) // kitty is written in python. `kitty --version` can be expensive char buffer[1024] = {}; - if (ffReadFileData(FASTFETCH_TARGET_DIR_USR "/lib64/kitty/kitty/constants.py", sizeof(buffer) - 1, buffer) || - ffReadFileData(FASTFETCH_TARGET_DIR_USR "/lib/kitty/kitty/constants.py", sizeof(buffer) - 1, buffer)) + if ( + #ifdef __linux__ + ffReadFileData(FASTFETCH_TARGET_DIR_USR "/lib64/kitty/kitty/constants.py", sizeof(buffer) - 1, buffer) || + ffReadFileData(FASTFETCH_TARGET_DIR_USR "/lib/kitty/kitty/constants.py", sizeof(buffer) - 1, buffer) + #else + ffReadFileData(_PATH_LOCALBASE "/share/kitty/kitty/constants.py", sizeof(buffer) - 1, buffer) + #endif + ) { // Starts from version 0.17.0 // https://github.com/kovidgoyal/kitty/blob/master/kitty/constants.py#L25