From 125759dc75d30330f959a7c89a6a8932849a0523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 19 Aug 2023 10:02:07 +0800 Subject: [PATCH] Terminal: correctly detecting version and font on NixOS --- src/detection/terminalfont/terminalfont.c | 2 +- src/detection/terminalshell/terminalshell_linux.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index c080fdd7e..8fcb7db6c 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -354,7 +354,7 @@ static bool detectTerminalFontCommon(const FFTerminalShellResult* terminalShell, #ifndef _WIN32 else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/pts/")) ffStrbufAppendS(&terminalFont->error, "Terminal font detection is not supported on PTS"); - else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalPrettyName, "kitty")) + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "kitty")) detectKitty(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/tty")) detectTTY(terminalFont); diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index fa8be7e72..fb2f7d755 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -375,12 +375,19 @@ const FFTerminalShellResult* ffDetectTerminalShell() ffStrbufInitS(&result.shellPrettyName, result.shellExeName); } + if(result.terminalExeName[0] == '.' && ffStrEndsWith(result.terminalExeName, "-wrapper")) + { + // For NixOS. Ref: #510 and https://github.com/NixOS/nixpkgs/pull/249428 + // We use terminalProcessName when detecting version and font, overriding it for simplication + ffStrbufSetNS( + &result.terminalProcessName, + (uint32_t) (strlen(result.terminalExeName) - strlen(".-wrapper")), + result.terminalExeName + 1); + } + if(ffStrbufEqualS(&result.terminalProcessName, "wezterm-gui")) ffStrbufInitStatic(&result.terminalPrettyName, "WezTerm"); - else if(ffStrbufEqualS(&result.terminalProcessName, ".kitty-wrapped")) - ffStrbufInitStatic(&result.terminalPrettyName, "kitty"); // #510 - #if defined(__linux__) || defined(__FreeBSD__) else if(ffStrbufStartsWithS(&result.terminalProcessName, "gnome-terminal-"))