From ef2a5110fe75834efd0b67aee4fd3001790161b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 10 Jan 2023 19:24:59 +0800 Subject: [PATCH 01/29] TerminalShell: detect terminal version when available --- CHANGELOG.md | 2 ++ src/detection/terminalshell/terminalshell.c | 26 +++++++++++++++++++ src/detection/terminalshell/terminalshell.h | 1 + .../terminalshell/terminalshell_linux.c | 5 ++++ .../terminalshell/terminalshell_windows.cpp | 5 ++++ src/modules/terminal.c | 6 ++++- 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44402b68a..4809204dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Notable Changes: * fastfetch no longer creates a sample config file silently. Use `--gen-config` to generate one. * fastfetch now search for user config file in the order of `fastfetch --list-config-paths` +* Unknown disks are hidden by default. Features: * `--logo-padding-top` option (@CarterLi, #372) @@ -14,6 +15,7 @@ Features: * Add `Brightness` module support * Add `Battery` module support for FreeBSD * Add `--disk-show-unknown` option for Disk module +* Detect terminal version when available Logos: * Raspbian (@IamNoRobot, #373) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index a99c498e4..3a80ce153 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -155,3 +155,29 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) ok = false; return ok; } + +bool fftsGetTerminalVersion(FFstrbuf* processName, FF_UNUSED_PARAM FFstrbuf* exe, FFstrbuf* version) +{ + const char* termProgramVersion = getenv("TERM_PROGRAM_VERSION"); + if(termProgramVersion) + { + const char* termProgram = getenv("TERM_PROGRAM"); + if(termProgram) + { + if(ffStrbufStartsWithIgnCaseS(processName, termProgram) || // processName ends with `.exe` on Windows + (strcmp(termProgram, "vscode") == 0 && ffStrbufStartsWithIgnCaseS(processName, "code")) + ) { + ffStrbufSetS(version, termProgramVersion); + return true; + } + } + } + + #ifdef _WIN32 + + return getFileVersion(exe->chars, version); + + #endif + + return false; +} diff --git a/src/detection/terminalshell/terminalshell.h b/src/detection/terminalshell/terminalshell.h index 8783e3410..a2a1f4200 100644 --- a/src/detection/terminalshell/terminalshell.h +++ b/src/detection/terminalshell/terminalshell.h @@ -17,6 +17,7 @@ typedef struct FFTerminalShellResult FFstrbuf terminalExe; FFstrbuf terminalPrettyName; const char* terminalExeName; //pointer to a char in terminalExe + FFstrbuf terminalVersion; FFstrbuf userShellExe; const char* userShellExeName; //pointer to a char in userShellExe diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 80c0d93d1..fb3ad0a76 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -310,6 +310,8 @@ static void getShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* versio getShellVersionGeneric(exe, exeName, version); } +bool fftsGetTerminalVersion(FFstrbuf* processName, FFstrbuf* exe, FFstrbuf* version); + const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) { FF_UNUSED(instance); @@ -378,6 +380,9 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) else ffStrbufInitCopy(&result.terminalPrettyName, &result.terminalProcessName); + ffStrbufInit(&result.terminalVersion); + fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); + ffThreadMutexUnlock(&mutex); return &result; } diff --git a/src/detection/terminalshell/terminalshell_windows.cpp b/src/detection/terminalshell/terminalshell_windows.cpp index cb2da1ca4..e4355666e 100644 --- a/src/detection/terminalshell/terminalshell_windows.cpp +++ b/src/detection/terminalshell/terminalshell_windows.cpp @@ -263,6 +263,8 @@ static void getTerminalFromEnv(FFTerminalShellResult* result) } } +extern "C" bool fftsGetTerminalVersion(FFstrbuf* processName, FFstrbuf* exe, FFstrbuf* version); + const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) { FF_UNUSED(instance); @@ -302,6 +304,9 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) if(result.terminalProcessName.length == 0) getTerminalFromEnv(&result); + ffStrbufInit(&result.terminalVersion); + fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); + exit: ffThreadMutexUnlock(&mutex); return &result; diff --git a/src/modules/terminal.c b/src/modules/terminal.c index 469ece23b..28e8d14a5 100644 --- a/src/modules/terminal.c +++ b/src/modules/terminal.c @@ -20,7 +20,11 @@ void ffPrintTerminal(FFinstance* instance) if(instance->config.terminal.outputFormat.length == 0) { ffPrintLogoAndKey(instance, FF_TERMINAL_MODULE_NAME, 0, &instance->config.terminal.key); - ffStrbufPutTo(&result->terminalPrettyName, stdout); + + if(result->terminalVersion.length) + printf("%s %s\n", result->terminalPrettyName.chars, result->terminalVersion.chars); + else + ffStrbufPutTo(&result->terminalPrettyName, stdout); } else { From c6365755c742ec336e3f280f543fcca234f404c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 10 Jan 2023 20:56:54 +0800 Subject: [PATCH 02/29] Title: fix computer name being trancated sometime --- src/util/windows/utsname.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/windows/utsname.c b/src/util/windows/utsname.c index a1f68021d..c21389f19 100644 --- a/src/util/windows/utsname.c +++ b/src/util/windows/utsname.c @@ -13,7 +13,7 @@ static int detectSysname(struct utsname *name) static int detectNodename(struct utsname *name) { DWORD bufSize = UTSNAME_MAXLENGTH - 1; - if(!GetComputerNameA(name->nodename, &bufSize)) + if(!GetComputerNameExA(ComputerNameDnsFullyQualified, name->nodename, &bufSize)) return 1; name->nodename[bufSize] = '\0'; return 0; From db17f95ce81909985d72d35caafe0402ed56efed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 10 Jan 2023 21:11:44 +0800 Subject: [PATCH 03/29] TerminalShell: detect Termux version --- src/detection/terminalshell/terminalshell.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 3a80ce153..0b68dfbe0 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -158,6 +158,16 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) bool fftsGetTerminalVersion(FFstrbuf* processName, FF_UNUSED_PARAM FFstrbuf* exe, FFstrbuf* version) { + #ifdef __ANDROID__ + + if(ffStrbufEqualS(processName, "Termux")) + { + ffStrbufSetS(version, getenv("TERMUX_VERSION")); + return true; + } + + #endif + const char* termProgramVersion = getenv("TERM_PROGRAM_VERSION"); if(termProgramVersion) { @@ -177,7 +187,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_UNUSED_PARAM FFstrbuf* exe return getFileVersion(exe->chars, version); - #endif + #else return false; + + #endif } From 8ffbae80b85ee8e231c66e37a01efc0dbaa901fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 01:23:42 +0800 Subject: [PATCH 04/29] Windows: clarify we support Windows 7 and newer only --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 586b0b305..eecedaa4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion") if(WIN32) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -fno-exceptions -fno-rtti") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--tsaware -Wl,--build-id -Wl,--subsystem,console:6.1,--major-os-version,6,--minor-os-version,1 -Wl,--relax") endif() # Used for dlopen finding dylibs installed by homebrew From a67ba713f5239eb9f4307d3542d3196f8079bcb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 09:37:00 +0800 Subject: [PATCH 05/29] Windows: fix CLANG64 build --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eecedaa4b..4abd15ffb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion") if(WIN32) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -fno-exceptions -fno-rtti") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--tsaware -Wl,--build-id -Wl,--subsystem,console:6.1,--major-os-version,6,--minor-os-version,1 -Wl,--relax") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--tsaware -Wl,--build-id -Wl,--subsystem,console:6.1,--major-os-version,6,--minor-os-version,1") endif() # Used for dlopen finding dylibs installed by homebrew From 94a8e0339ed33d00c13b220529947bd7894e3a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 13:51:47 +0800 Subject: [PATCH 06/29] Windows: remove outdated comments --- src/common/processing_windows.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/processing_windows.c b/src/common/processing_windows.c index 30e515734..736c121b3 100644 --- a/src/common/processing_windows.c +++ b/src/common/processing_windows.c @@ -4,7 +4,6 @@ #define WIN32_LEAN_AND_MEAN 1 #include -//We can't use this native version yet because we still use POSIX path ( eg /usr/bin/fish ) at a lot of places. const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]) { SECURITY_ATTRIBUTES saAttr = { From b8393051e430f8aa4e9d0533e22f5d76e492fac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 13:52:14 +0800 Subject: [PATCH 07/29] Battery: add comments for future use (FreeBSD) --- src/detection/battery/battery_bsd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 17ce47a2f..881291af1 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -8,6 +8,9 @@ const char* ffDetectBatteryImpl(FF_UNUSED_PARAM FFinstance* instance, FFlist* results) { + //https://www.freebsd.org/cgi/man.cgi?acpi_battery(4) + //https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c + int acpifd = open("/dev/acpi", O_RDONLY); if(acpifd < 0) return "open(\"/dev/acpi\", O_RDONLY) failed"; From ccdb5c54d02cc4c0926d76df55e29e95bac81e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 13:55:06 +0800 Subject: [PATCH 08/29] Linux: enable FF_*_AUTO_DESTROY They have been on Windows and macOS for sometime and worked well. --- src/util/FFlist.h | 4 +--- src/util/FFstrbuf.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/util/FFlist.h b/src/util/FFlist.h index 86b20bc5c..e65180d3a 100644 --- a/src/util/FFlist.h +++ b/src/util/FFlist.h @@ -51,8 +51,6 @@ static inline void ffListSort(FFlist* list, int(*compar)(const void*, const void itemVarName - (itemType*)(listVar).data < (listVar).length; \ ++itemVarName) -#if defined(_WIN32) || defined(__APPLE__) - #define FF_LIST_AUTO_DESTROY FFlist __attribute__((__cleanup__(ffListDestroy))) -#endif +#define FF_LIST_AUTO_DESTROY FFlist __attribute__((__cleanup__(ffListDestroy))) #endif diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index 94adc6b03..7755225a7 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -310,8 +310,6 @@ static inline FF_C_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf return ffStrbufEndsWithIgnCaseNS(strbuf, end->length, end->chars); } -#if defined(_WIN32) || defined(__APPLE__) - #define FF_STRBUF_AUTO_DESTROY FFstrbuf __attribute__((__cleanup__(ffStrbufDestroy))) -#endif +#define FF_STRBUF_AUTO_DESTROY FFstrbuf __attribute__((__cleanup__(ffStrbufDestroy))) #endif From 54ea9c23864e1aa5a0314a9e05362528358ee881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 13:58:59 +0800 Subject: [PATCH 09/29] TerminalFont: support WezTerm font detection --- CHANGELOG.md | 1 + src/detection/terminalfont/terminalfont.c | 30 +++++++++++++++++++ .../terminalshell/terminalshell_linux.c | 2 ++ 3 files changed, 33 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4809204dc..5c49019b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Features: * Add `Battery` module support for FreeBSD * Add `--disk-show-unknown` option for Disk module * Detect terminal version when available +* Support `WezTerm` terminal font detection (requires [`wezterm` executable](https://wezfurlong.org/wezterm/cli/general.html) being available) Logos: * Raspbian (@IamNoRobot, #373) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 5716b720d..a4a049276 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -320,6 +320,34 @@ static bool detectKitty(const FFinstance* instance, FFTerminalFontResult* result return true; } +static bool detectWezterm(FF_UNUSED_PARAM const FFinstance* instance, FFTerminalFontResult* result) +{ + FF_STRBUF_AUTO_DESTROY fontName; + ffStrbufInit(&fontName); + + ffStrbufSetS(&result->error, ffProcessAppendStdOut(&fontName, (char* const[]){ + "wezterm", + "ls-fonts", + "--text", + "a", + NULL + })); + if(result->error.length) + return false; + + //LeftToRight + // 0 a \u{61} x_adv=7 cells=1 glyph=a,180 wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"}) + // , BuiltIn + ffStrbufSubstrAfterFirstC(&fontName, '"'); + ffStrbufSubstrBeforeFirstC(&fontName, '"'); + + if(!fontName.length) + return false; + + ffFontInitCopy(&result->font, fontName.chars); + return true; +} + void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont); static bool detectTerminalFontCommon(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) @@ -328,6 +356,8 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina detectAlacritty(instance, terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "kitty") == 0) detectKitty(instance, terminalFont); + else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "wezterm-gui") == 0) + detectWezterm(instance, 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 fb3ad0a76..510897287 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -375,6 +375,8 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) ffStrbufInitS(&result.terminalPrettyName, "Apple Terminal"); else if(ffStrbufEqualS(&result.terminalProcessName, "WarpTerminal")) ffStrbufInitS(&result.terminalPrettyName, "Warp"); + else if(ffStrbufEqualS(&result.terminalProcessName, "wezterm-gui")) + ffStrbufInitS(&result.terminalPrettyName, "WezTerm"); else if(strncmp(result.terminalExeName, result.terminalProcessName.chars, result.terminalProcessName.length) == 0) // if exeName starts with processName, print it. Otherwise print processName ffStrbufInitS(&result.terminalPrettyName, result.terminalExeName); else From b1f63ab822a7bfc8ecb610ce39a83912a7d392ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 14:47:10 +0800 Subject: [PATCH 10/29] Global: rename FF_UNUSED_PARAM to FF_MAYBE_UNUSED since it can be used on functions too. --- src/detection/battery/battery_bsd.c | 2 +- src/detection/brightness/brightness_linux.c | 2 +- src/detection/brightness/brightness_nosupport.c | 2 +- src/detection/terminalfont/terminalfont.c | 2 +- src/detection/terminalshell/terminalshell.c | 2 +- src/detection/wifi/wifi_windows.c | 2 +- src/fastfetch.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 881291af1..2cfbe4b7b 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -6,7 +6,7 @@ #include #include -const char* ffDetectBatteryImpl(FF_UNUSED_PARAM FFinstance* instance, FFlist* results) +const char* ffDetectBatteryImpl(FF_MAYBE_UNUSED FFinstance* instance, FFlist* results) { //https://www.freebsd.org/cgi/man.cgi?acpi_battery(4) //https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 31e346062..0f2a9d5fd 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -3,7 +3,7 @@ #include -const char* ffDetectBrightness(FF_UNUSED_PARAM FFlist* result) +const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) { //https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-class-backlight const char* backlightDirPath = "/sys/class/backlight/"; diff --git a/src/detection/brightness/brightness_nosupport.c b/src/detection/brightness/brightness_nosupport.c index 5661c180f..4bd83c4de 100644 --- a/src/detection/brightness/brightness_nosupport.c +++ b/src/detection/brightness/brightness_nosupport.c @@ -1,6 +1,6 @@ #include "brightness.h" -const char* ffDetectBrightness(FF_UNUSED_PARAM FFlist* result) +const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result) { return "Not supported on this platform"; } diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index a4a049276..1dde994bf 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -320,7 +320,7 @@ static bool detectKitty(const FFinstance* instance, FFTerminalFontResult* result return true; } -static bool detectWezterm(FF_UNUSED_PARAM const FFinstance* instance, FFTerminalFontResult* result) +static bool detectWezterm(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminalFontResult* result) { FF_STRBUF_AUTO_DESTROY fontName; ffStrbufInit(&fontName); diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 0b68dfbe0..65b06bc78 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -156,7 +156,7 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) return ok; } -bool fftsGetTerminalVersion(FFstrbuf* processName, FF_UNUSED_PARAM FFstrbuf* exe, FFstrbuf* version) +bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { #ifdef __ANDROID__ diff --git a/src/detection/wifi/wifi_windows.c b/src/detection/wifi/wifi_windows.c index 92322440f..a972939d7 100644 --- a/src/detection/wifi/wifi_windows.c +++ b/src/detection/wifi/wifi_windows.c @@ -40,7 +40,7 @@ static void convertIfStateToString(WLAN_INTERFACE_STATE state, FFstrbuf* result) } } -const char* ffDetectWifi(FF_UNUSED_PARAM const FFinstance* instance, FFlist* result) +const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result) { FF_LIBRARY_LOAD(wlanapi, NULL, "dlopen wlanapi"FF_LIBRARY_EXTENSION" failed", "wlanapi"FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanOpenHandle) diff --git a/src/fastfetch.h b/src/fastfetch.h index e215d3e3f..af9496c8d 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -21,7 +21,7 @@ static inline void ffUnused(int dummy, ...) { (void) dummy; } #define FF_UNUSED(...) ffUnused(0, __VA_ARGS__); -#define FF_UNUSED_PARAM __attribute__ ((__unused__)) +#define FF_MAYBE_UNUSED __attribute__ ((__unused__)) #define FASTFETCH_LOGO_MAX_COLORS 9 //two digits would make parsing much more complicated (index 1 - 9) From a0acfeed56cbebf28db08edc20015fe078209837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 15:03:16 +0800 Subject: [PATCH 11/29] TermiinalShell: code refactor --- src/detection/terminalshell/terminalshell.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 65b06bc78..2c139b5f2 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -156,15 +156,18 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) return ok; } +FF_MAYBE_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version) +{ + ffStrbufSetS(version, getenv("TERMUX_VERSION")); + return true; +} + bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { #ifdef __ANDROID__ if(ffStrbufEqualS(processName, "Termux")) - { - ffStrbufSetS(version, getenv("TERMUX_VERSION")); - return true; - } + return getTerminalVersionTermux(version); #endif From 76d957a144b52b293ab0936e7c47adb72e338d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 15:03:42 +0800 Subject: [PATCH 12/29] TerminalShell: support gnome-terminal version detection --- src/detection/terminalshell/terminalshell.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 2c139b5f2..363fdb418 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -162,6 +162,20 @@ FF_MAYBE_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version) return true; } +FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* version) +{ + if(ffProcessAppendStdOut(version, (char* const[]){ + "gnome-terminal", + "--version", + NULL + })) return false; + + //# GNOME Terminal 3.46.7 using VTE 0.70.2 +BIDI +GNUTLS +ICU +SYSTEMD + ffStrbufSubstrAfterFirstS(version, "Terminal "); + ffStrbufSubstrBeforeFirstC(version, ' '); + return true; +} + bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { #ifdef __ANDROID__ @@ -171,6 +185,13 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe #endif + #if defined(__linux__) || defined(__FreeBSD__) + + if(ffStrbufIgnCaseEqualS(processName, "gnome-terminal-")) + return getTerminalVersionGnome(version); + + #endif + const char* termProgramVersion = getenv("TERM_PROGRAM_VERSION"); if(termProgramVersion) { From b2f978aa7ca9c8dd50dbb3145220132bdd268a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 15:14:29 +0800 Subject: [PATCH 13/29] TerminalShell: support kitty version detection --- src/detection/terminalshell/terminalshell.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 363fdb418..9e1e8c8a8 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -176,6 +176,20 @@ FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* version) return true; } +FF_MAYBE_UNUSED static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdOut(version, (char* const[]){ + exe->chars, + "--version", + NULL + })) return false; + + //kitty 0.21.2 created by Kovid Goyal + ffStrbufSubstrAfterFirstC(version, ' '); + ffStrbufSubstrBeforeFirstC(version, ' '); + return true; +} + bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { #ifdef __ANDROID__ @@ -192,6 +206,13 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe #endif + #ifndef _WIN32 + + if(ffStrbufIgnCaseEqualS(processName, "kitty")) + return getTerminalVersionKitty(exe, version); + + #endif + const char* termProgramVersion = getenv("TERM_PROGRAM_VERSION"); if(termProgramVersion) { From ee903d2d07f1b282f1034ac4defcae2d6ff76dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 15:56:24 +0800 Subject: [PATCH 14/29] TerminalShell: support konsole version detection --- src/detection/terminalshell/terminalshell.c | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 9e1e8c8a8..09ae5ba9f 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -176,6 +176,35 @@ FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* version) return true; } +FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* version) +{ + const char* konsoleVersion = getenv("KONSOLE_VERSION"); + if(konsoleVersion) + { + //221201 + long major = strtol(konsoleVersion, NULL, 10); + if (major >= 0) + { + long patch = major % 100; + major /= 100; + long minor = major % 100; + major /= 100; + ffStrbufSetF(version, "%ld.%ld.%ld", major, minor, patch); + return true; + } + } + + if(ffProcessAppendStdOut(version, (char* const[]){ + exe->chars, + "--version", + NULL + })) return false; + + //konsole 22.12.1 + ffStrbufSubstrAfterFirstC(version, ' '); + return true; +} + FF_MAYBE_UNUSED static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { if(ffProcessAppendStdOut(version, (char* const[]){ @@ -204,6 +233,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "gnome-terminal-")) return getTerminalVersionGnome(version); + if(ffStrbufIgnCaseEqualS(processName, "konsole")) + return getTerminalVersionKonsole(exe, version); + #endif #ifndef _WIN32 From 09ff8d35bc982d5f0685495370a4854f108d91fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 16:07:34 +0800 Subject: [PATCH 15/29] TerminalShell: support xfce4-terminal version detection --- src/detection/terminalshell/terminalshell.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 09ae5ba9f..96b86791c 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -205,6 +205,20 @@ FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* v return true; } +FF_MAYBE_UNUSED static bool getTerminalVersionXfce4(FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdOut(version, (char* const[]){ + exe->chars, + "--version", + NULL + })) return false; + + //xfce4-terminal 1.0.4 (Xfce 4.18)... + ffStrbufSubstrAfterFirstC(version, ' '); + ffStrbufSubstrBeforeFirstC(version, ' '); + return true; +} + FF_MAYBE_UNUSED static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { if(ffProcessAppendStdOut(version, (char* const[]){ @@ -236,6 +250,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "konsole")) return getTerminalVersionKonsole(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "xfce4-terminal")) + return getTerminalVersionXfce4(exe, version); + #endif #ifndef _WIN32 From 9dab23b5fca4a1fb9d3534024ba590b636ee2286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 16:34:37 +0800 Subject: [PATCH 16/29] TerminalShell: code refactor --- src/detection/terminalshell/terminalshell.c | 173 +++++++------------- 1 file changed, 63 insertions(+), 110 deletions(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 96b86791c..133a6281b 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -36,130 +36,119 @@ static bool getFileVersion(const char* exePath, FFstrbuf* version) #endif -static void getShellVersionBash(FFstrbuf* exe, FFstrbuf* version) +static bool getExeVersionRaw(FFstrbuf* exe, FFstrbuf* version) { - ffProcessAppendStdOut(version, (char* const[]) { + return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL - }); // GNU bash, version 5.1.16(1)-release (x86_64-pc-msys)\nCopyright... + }) == NULL; +} + +static bool getExeVersionGeneral(FFstrbuf* exe, FFstrbuf* version) +{ + if(!getExeVersionRaw(exe, version)) + return false; + + ffStrbufSubstrAfterFirstC(version, ' '); + ffStrbufSubstrBeforeFirstC(version, ' '); + return true; +} + +static bool getShellVersionBash(FFstrbuf* exe, FFstrbuf* version) +{ + if(!getExeVersionRaw(exe, version)) + return false; + + // GNU bash, version 5.1.16(1)-release (x86_64-pc-msys)\nCopyright... ffStrbufSubstrBeforeFirstC(version, '\n'); // GNU bash, version 5.1.16(1)-release (x86_64-pc-msys) ffStrbufSubstrBeforeLastC(version, ' '); // GNU bash, version 5.1.16(1)-release ffStrbufSubstrAfterLastC(version, ' '); // 5.1.16(1)-release ffStrbufSubstrBeforeFirstC(version, '('); // 5.1.16 + return true; } -static void getShellVersionZsh(FFstrbuf* exe, FFstrbuf* version) +static bool getShellVersionFish(FFstrbuf* exe, FFstrbuf* version) { - ffProcessAppendStdOut(version, (char* const[]) { - exe->chars, - "--version", - NULL - }); - ffStrbufSubstrBeforeLastC(version, ' '); - ffStrbufSubstrAfterFirstC(version, ' '); -} + if(!getExeVersionRaw(exe, version)) + return false; -static void getShellVersionFish(FFstrbuf* exe, FFstrbuf* version) -{ - ffProcessAppendStdOut(version, (char* const[]) { - exe->chars, - "--version", - NULL - }); + //fish, version 3.6.0 ffStrbufTrimRight(version, '\n'); ffStrbufSubstrAfterLastC(version, ' '); + return true; } -static void getShellVersionTcsh(FFstrbuf* exe, FFstrbuf* version) -{ - ffProcessAppendStdOut(version, (char* const[]) { - exe->chars, - "--version", - NULL - }); // tcsh 6.24.01 (Astron) 2022-05-12 (aarch64-apple-darwin) options wide,nls,dl,al,kan,sm,rh,color,filec - ffStrbufSubstrAfterFirstC(version, ' '); // 6.24.01 (Astron) 2022-05-12 (aarch64-apple-darwin) options wide,nls,dl,al,kan,sm,rh,color,filec - ffStrbufSubstrBeforeFirstC(version, ' '); // 6.24.01 -} - -static void getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) +static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) { #ifdef _WIN32 if(getFileVersion(exe->chars, version)) - return; + { + ffStrbufSubstrBeforeLastC(version, '.'); + return true; + } #endif - ffProcessAppendStdOut(version, (char* const[]) { - exe->chars, - "--version", - NULL - }); + if(!getExeVersionRaw(exe, version)) + return false; + ffStrbufTrimRight(version, '\n'); ffStrbufSubstrAfterLastC(version, ' '); + return true; } #ifdef _WIN32 -static void getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version) +static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version) { - ffProcessAppendStdOut(version, (char* const[]) { + if(ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-NoLogo", "-NoProfile", "-Command", "$PSVersionTable.PSVersion.ToString()", NULL - }); + })) return false; + ffStrbufTrimRight(version, '\n'); ffStrbufSubstrAfterLastC(version, ' '); + return true; } -static void getShellVersionCmd(FFstrbuf* exe, FFstrbuf* version) +static bool getShellVersionCmd(FFstrbuf* exe, FFstrbuf* version) { - getFileVersion(exe->chars, version); + return getFileVersion(exe->chars, version); } #endif -static void getShellVersionNu(FFstrbuf* exe, FFstrbuf* version) -{ - ffProcessAppendStdOut(version, (char* const[]) { - exe->chars, - "--version", - NULL - }); -} - bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) { - bool ok = true; if(strcasecmp(exeName, "bash") == 0 || strcasecmp(exeName, "sh") == 0) - getShellVersionBash(exe, version); - else if(strcasecmp(exeName, "zsh") == 0) - getShellVersionZsh(exe, version); - else if(strcasecmp(exeName, "fish") == 0) - getShellVersionFish(exe, version); - else if(strcasecmp(exeName, "pwsh") == 0) - getShellVersionPwsh(exe, version); - else if(strcasecmp(exeName, "csh") == 0 || strcasecmp(exeName, "tcsh") == 0) - getShellVersionTcsh(exe, version); - else if(strcasecmp(exeName, "nu") == 0) - getShellVersionNu(exe, version); + return getShellVersionBash(exe, version); + if(strcasecmp(exeName, "zsh") == 0) + return getExeVersionGeneral(exe, version); //zsh 5.9 (arm-apple-darwin21.3.0) + if(strcasecmp(exeName, "fish") == 0) + return getShellVersionFish(exe, version); + if(strcasecmp(exeName, "pwsh") == 0) + return getShellVersionPwsh(exe, version); + if(strcasecmp(exeName, "csh") == 0 || strcasecmp(exeName, "tcsh") == 0) + return getExeVersionGeneral(exe, version); //tcsh 6.24.07 (Astron) 2022-12-21 (aarch64-apple-darwin) options wide,nls,dl,al,kan,sm,rh,color,filec + if(strcasecmp(exeName, "nu") == 0) + return getExeVersionRaw(exe, version); //0.73.0 #ifdef _WIN32 - else if(strcasecmp(exeName, "powershell") == 0 || strcasecmp(exeName, "powershell_ise") == 0) - getShellVersionWinPowerShell(exe, version); - else if(strcasecmp(exeName, "cmd") == 0) - getShellVersionCmd(exe, version); + if(strcasecmp(exeName, "powershell") == 0 || strcasecmp(exeName, "powershell_ise") == 0) + return getShellVersionWinPowerShell(exe, version); + if(strcasecmp(exeName, "cmd") == 0) + return getShellVersionCmd(exe, version); #endif - else - ok = false; - return ok; + return false; } FF_MAYBE_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version) { ffStrbufSetS(version, getenv("TERMUX_VERSION")); - return true; + return version->length > 0; } FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* version) @@ -194,43 +183,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* v } } - if(ffProcessAppendStdOut(version, (char* const[]){ - exe->chars, - "--version", - NULL - })) return false; - - //konsole 22.12.1 - ffStrbufSubstrAfterFirstC(version, ' '); - return true; -} - -FF_MAYBE_UNUSED static bool getTerminalVersionXfce4(FFstrbuf* exe, FFstrbuf* version) -{ - if(ffProcessAppendStdOut(version, (char* const[]){ - exe->chars, - "--version", - NULL - })) return false; - - //xfce4-terminal 1.0.4 (Xfce 4.18)... - ffStrbufSubstrAfterFirstC(version, ' '); - ffStrbufSubstrBeforeFirstC(version, ' '); - return true; -} - -FF_MAYBE_UNUSED static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) -{ - if(ffProcessAppendStdOut(version, (char* const[]){ - exe->chars, - "--version", - NULL - })) return false; - - //kitty 0.21.2 created by Kovid Goyal - ffStrbufSubstrAfterFirstC(version, ' '); - ffStrbufSubstrBeforeFirstC(version, ' '); - return true; + return getExeVersionGeneral(exe, version); } bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) @@ -251,14 +204,14 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe return getTerminalVersionKonsole(exe, version); if(ffStrbufIgnCaseEqualS(processName, "xfce4-terminal")) - return getTerminalVersionXfce4(exe, version); + return getExeVersionGeneral(exe, version);//xfce4-terminal 1.0.4 (Xfce 4.18)... #endif #ifndef _WIN32 if(ffStrbufIgnCaseEqualS(processName, "kitty")) - return getTerminalVersionKitty(exe, version); + return getExeVersionGeneral(exe, version); //kitty 0.21.2 created by Kovid Goyal #endif From 7145f5252daba28b9c096691f2d9d54e67ad1584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 17:17:17 +0800 Subject: [PATCH 17/29] TerminalShell: add `--shell-version` and `--terminal-version` options to disable shell / terminal version detection in case that users don't like it --- CHANGELOG.md | 2 ++ completions/bash | 4 ++++ src/common/init.c | 3 +++ src/data/config_user.txt | 12 ++++++++++++ src/data/help.txt | 2 ++ .../terminalshell/terminalshell_linux.c | 19 +++++++++++++------ .../terminalshell/terminalshell_windows.cpp | 6 ++++-- src/fastfetch.c | 4 ++++ src/fastfetch.h | 3 +++ 9 files changed, 47 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c49019b0..983db0620 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,10 @@ Features: * Add `Brightness` module support * Add `Battery` module support for FreeBSD * Add `--disk-show-unknown` option for Disk module +* Add `--disk-show-unknown` option for Disk module * Detect terminal version when available * Support `WezTerm` terminal font detection (requires [`wezterm` executable](https://wezfurlong.org/wezterm/cli/general.html) being available) +* Add `--shell-version` and `--terminal-version` options to disable shell / terminal version detection Logos: * Raspbian (@IamNoRobot, #373) diff --git a/completions/bash b/completions/bash index 5dedf5f6f..e7efe1c18 100644 --- a/completions/bash +++ b/completions/bash @@ -189,8 +189,12 @@ __fastfetch_completion() "--pipe" "--title-fqdn" "--escape-bedrock" + "--shell-version" + "--terminal-version" + "--disk-folders" "--disk-show-removable" "--disk-show-hidden" + "--disk-show-unknown" ) local FF_OPTIONS_STRING=( diff --git a/src/common/init.c b/src/common/init.c index c333e03b6..96939b2ed 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -315,6 +315,9 @@ static void defaultConfig(FFinstance* instance) instance->config.gpuTemp = false; instance->config.batteryTemp = false; + instance->config.shellVersion = true; + instance->config.terminalVersion = true; + instance->config.titleFQDN = false; ffStrbufInitA(&instance->config.diskFolders, 0); diff --git a/src/data/config_user.txt b/src/data/config_user.txt index d2faddb78..6f58aeb0e 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -212,6 +212,18 @@ # Default is auto. #--gl auto +# Shell option +# Sets if shell version should be detected and printed +# Must be either true or false +# Default is true. +#--shell-version true + +# Terminal option +# Sets if terminal version should be detected and printed +# Must be either true or false +# Default is true. +#--terminal-version true + # Disk option # Sets if removable volume should be printed # Must be either true or false diff --git a/src/data/help.txt b/src/data/help.txt index 5fb36821a..a3c5243fb 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -103,6 +103,8 @@ Module specific options: --title-fqdn : Set if the title should use fully qualified domain name. Default is false --separator-string : Set the string printed by the separator module --os-file : Set the path to the file containing OS information + --shell-version : Set if shell version should be detected and printed + --terminal-version : Set if terminal version should be detected and printed --disk-folders : A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows) --disk-show-removable : Set if removable volume should be printed. Default is true --disk-show-hidden : Set if hidden volumes should be printed. Default is false diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 510897287..07b902dac 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -352,12 +352,17 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) getTerminalFromEnv(&result); getUserShellFromEnv(instance, &result); - getShellVersion(&result.shellExe, result.shellExeName, &result.shellVersion); - if(strcasecmp(result.shellExeName, result.userShellExeName) != 0) - getShellVersion(&result.userShellExe, result.userShellExeName, &result.userShellVersion); - else - ffStrbufSet(&result.userShellVersion, &result.shellVersion); + ffStrbufClear(&result.shellVersion); + if(instance->config.shellVersion) + { + getShellVersion(&result.shellExe, result.shellExeName, &result.shellVersion); + + if(strcasecmp(result.shellExeName, result.userShellExeName) != 0) + getShellVersion(&result.userShellExe, result.userShellExeName, &result.userShellVersion); + else + ffStrbufSet(&result.userShellVersion, &result.shellVersion); + } if(ffStrbufEqualS(&result.shellProcessName, "pwsh")) ffStrbufInitS(&result.shellPrettyName, "PowerShell"); @@ -383,7 +388,9 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) ffStrbufInitCopy(&result.terminalPrettyName, &result.terminalProcessName); ffStrbufInit(&result.terminalVersion); - fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); + + if(instance->config.terminalVersion) + fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); ffThreadMutexUnlock(&mutex); return &result; diff --git a/src/detection/terminalshell/terminalshell_windows.cpp b/src/detection/terminalshell/terminalshell_windows.cpp index e4355666e..8dd59c70d 100644 --- a/src/detection/terminalshell/terminalshell_windows.cpp +++ b/src/detection/terminalshell/terminalshell_windows.cpp @@ -132,7 +132,8 @@ static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) } ffStrbufClear(&result->shellVersion); - fftsGetShellVersion(&result->shellExe, result->shellPrettyName.chars, &result->shellVersion); + if(instance->config.shellVersion) + fftsGetShellVersion(&result->shellExe, result->shellPrettyName.chars, &result->shellVersion); if(ffStrbufIgnCaseEqualS(&result->shellPrettyName, "pwsh")) ffStrbufSetS(&result->shellPrettyName, "PowerShell"); @@ -305,7 +306,8 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) getTerminalFromEnv(&result); ffStrbufInit(&result.terminalVersion); - fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); + if(instance->config.terminalVersion) + fftsGetTerminalVersion(&result.terminalProcessName, &result.terminalExe, &result.terminalVersion); exit: ffThreadMutexUnlock(&mutex); diff --git a/src/fastfetch.c b/src/fastfetch.c index 62935fc73..6013a6daa 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1248,6 +1248,10 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con instance->config.batteryTemp = optionParseBoolean(value); else if(strcasecmp(key, "--title-fqdn") == 0) instance->config.titleFQDN = optionParseBoolean(value); + else if(strcasecmp(key, "--shell-version") == 0) + instance->config.shellVersion = optionParseBoolean(value); + else if(strcasecmp(key, "--terminal-version") == 0) + instance->config.terminalVersion = optionParseBoolean(value); else if(strcasecmp(key, "--disk-folders") == 0) optionParseString(key, value, &instance->config.diskFolders); else if(strcasecmp(key, "--disk-show-removable") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index af9496c8d..a12182435 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -177,6 +177,9 @@ typedef struct FFconfig bool titleFQDN; + bool shellVersion; + bool terminalVersion; + FFstrbuf diskFolders; bool diskShowRemovable; bool diskShowHidden; From 99fc4e76ecbd12cc588af5d39d0ffd0275d1b2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 17:27:34 +0800 Subject: [PATCH 18/29] TerminalShell: fix build on Windows --- .../terminalshell/terminalshell_windows.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_windows.cpp b/src/detection/terminalshell/terminalshell_windows.cpp index 8dd59c70d..8541f37f3 100644 --- a/src/detection/terminalshell/terminalshell_windows.cpp +++ b/src/detection/terminalshell/terminalshell_windows.cpp @@ -99,7 +99,7 @@ static bool getProcessInfo(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrb extern "C" bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version); -static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) +static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult* result, uint32_t pid) { uint32_t ppid; @@ -128,7 +128,7 @@ static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) ffStrbufClear(&result->shellPrettyName); ffStrbufClear(&result->shellExe); result->shellExeName = nullptr; - return getShellInfo(result, ppid); + return getShellInfo(instance, result, ppid); } ffStrbufClear(&result->shellVersion); @@ -176,7 +176,7 @@ static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) return ppid; } -static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) +static uint32_t getTerminalInfo(const FFinstance* instance, FFTerminalShellResult* result, uint32_t pid) { uint32_t ppid; @@ -202,7 +202,7 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid) ffStrbufClear(&result->terminalPrettyName); ffStrbufClear(&result->terminalExe); result->terminalExeName = ""; - return getTerminalInfo(result, ppid); + return getTerminalInfo(instance, result, ppid); } if(ffStrbufIgnCaseEqualS(&result->terminalPrettyName, "WindowsTerminal")) @@ -300,8 +300,8 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance) if(!getProcessInfo(0, &ppid, nullptr, nullptr, nullptr)) goto exit; - ppid = getShellInfo(&result, ppid); - getTerminalInfo(&result, ppid); + ppid = getShellInfo(instance, &result, ppid); + getTerminalInfo(instance, &result, ppid); if(result.terminalProcessName.length == 0) getTerminalFromEnv(&result); From a74f813df12bd3f6172f58420535ac0731345942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 17:33:31 +0800 Subject: [PATCH 19/29] CHANGLOG: remove a duplicated entry oops --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 983db0620..0f0fd7867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,6 @@ Features: * Add `Brightness` module support * Add `Battery` module support for FreeBSD * Add `--disk-show-unknown` option for Disk module -* Add `--disk-show-unknown` option for Disk module * Detect terminal version when available * Support `WezTerm` terminal font detection (requires [`wezterm` executable](https://wezfurlong.org/wezterm/cli/general.html) being available) * Add `--shell-version` and `--terminal-version` options to disable shell / terminal version detection From 84a03e80def159cd338fadcfcf20114caa603ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 17:35:44 +0800 Subject: [PATCH 20/29] README: clarify that fastfetch isn't written in pure C Ref: https://github.com/ScoopInstaller/Main/pull/4334#discussion_r1066502517 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 78312f6a8..147977a0d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fastfetch -Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written in pure c, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported. +Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written in C-family languages, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported. From 6ca3b76a424eac963a96f2cc11096f31f799ee5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 18:07:58 +0800 Subject: [PATCH 21/29] Update README --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 147977a0d..ed848668c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fastfetch -Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written in C-family languages, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported. +Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written mainly in C, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported. @@ -112,7 +112,7 @@ KDE Plasma, Gnome, Cinnamon, Mate, XFCE4, LXQt ##### Terminal fonts ``` -Konsole, Gnome Terminal, Tilix, XFCE4 Terminal, Alacritty, Kitty, LXTerminal, Deepin Terminal, iTerm2, Apple Terminal, Warp, TTY, Windows Terminal, Termux, mintty, ConEmu +Konsole, Gnome Terminal, Tilix, XFCE4 Terminal, Alacritty, Kitty, LXTerminal, Deepin Terminal, iTerm2, Apple Terminal, Warp, TTY, Windows Terminal, Termux, mintty, ConEmu, WezTerm ``` ## Building @@ -132,12 +132,13 @@ If the build process fails to find the headers for a library listed in [dependen Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 subsystem (or CLANGARM64 if needed) is suggested (and tested) to build fastfetch. If you need Windows 7 / 8.x support, using MINGW64 is suggested. 1. Install [MSYS2](https://www.msys2.org/#installation) -1. Open `MSYS2 CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime) +1. Open `MSYS2 / CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime) 1. Install dependencies ```bash pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd ``` -1. Follow building instructions of Linux + +Follow the building instructions of Linux next. ## Packaging From cd0b74b0de5a4231e816caad29cfe47cd3ce994d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 18:12:36 +0800 Subject: [PATCH 22/29] TerminalShell: support deepin-terminal version detection --- src/detection/terminalshell/terminalshell.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 133a6281b..2684d04f3 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -206,6 +206,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "xfce4-terminal")) return getExeVersionGeneral(exe, version);//xfce4-terminal 1.0.4 (Xfce 4.18)... + if(ffStrbufIgnCaseEqualS(processName, "deepin-terminal")) + return getExeVersionGeneral(exe, version);//deepin-terminal 5.4.36 + #endif #ifndef _WIN32 From eb02206c05512e80a8b7ab1b35b455d0555a76ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 22:01:37 +0800 Subject: [PATCH 23/29] TerminalShell: support Windows Terminal version detection --- src/detection/terminalshell/terminalshell.c | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 2684d04f3..818e7d640 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -1,5 +1,7 @@ #include "fastfetch.h" +#include "common/io.h" #include "common/processing.h" +#include "common/properties.h" #ifdef _WIN32 @@ -186,6 +188,25 @@ FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* v return getExeVersionGeneral(exe, version); } +#ifdef _WIN32 + +static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version) +{ + FF_STRBUF_AUTO_DESTROY buildInfoPath; + ffStrbufInitNS(&buildInfoPath, ffStrbufLastIndexC(exe, '\\') + 1, exe->chars); + ffStrbufAppendS(&buildInfoPath, "BuildInfo.xml"); + + if(ffParsePropFile(buildInfoPath.chars, "StoreVersion=\"", version)) + { + ffStrbufTrimRight(version, '"'); + return true; + } + + return getFileVersion(exe->chars, version); +} + +#endif + bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { #ifdef __ANDROID__ @@ -211,6 +232,13 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe #endif + #ifdef _WIN32 + + if(ffStrbufIgnCaseEqualS(processName, "WindowsTerminal.exe")) + return getTerminalVersionWindowsTerminal(exe, version); + + #endif + #ifndef _WIN32 if(ffStrbufIgnCaseEqualS(processName, "kitty")) From 66ed9adcda59f3d87e2f97ab0678f4464455b58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 22:14:47 +0800 Subject: [PATCH 24/29] TerminalShell: support ConEmu version detection --- src/detection/terminalshell/terminalshell.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 818e7d640..6965ae0a3 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -205,6 +205,16 @@ static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version) return getFileVersion(exe->chars, version); } +static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version) +{ + ffStrbufSetS(version, getenv("ConEmuBuild")); + + if(version->length) + return true; + + return getFileVersion(exe->chars, version); +} + #endif bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) @@ -237,6 +247,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "WindowsTerminal.exe")) return getTerminalVersionWindowsTerminal(exe, version); + if(ffStrbufStartsWithIgnCaseS(processName, "ConEmuC")) + return getTerminalVersionConEmu(exe, version); + #endif #ifndef _WIN32 From ebfbf108a277d35c1cc4ad4caa2189cee9098651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 23:46:15 +0800 Subject: [PATCH 25/29] TerminalShell: support Alacritty terminal version detection --- src/detection/terminalshell/terminalshell.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 6965ae0a3..aa9d221f3 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -259,6 +259,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe #endif + if(ffStrbufStartsWithIgnCaseS(processName, "alacritty")) + return getExeVersionGeneral(exe, version); + const char* termProgramVersion = getenv("TERM_PROGRAM_VERSION"); if(termProgramVersion) { From c3861954dc76ba3d66b7c8e829ddc7c0a8b701f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Jan 2023 23:46:37 +0800 Subject: [PATCH 26/29] TerminalFont: support Alacritty on Windows --- src/detection/terminalfont/terminalfont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 1dde994bf..b08e39565 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -352,7 +352,7 @@ void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalSh static bool detectTerminalFontCommon(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { - if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "alacritty") == 0) + if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "alacritty")) detectAlacritty(instance, terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "kitty") == 0) detectKitty(instance, terminalFont); From c4aa55d5223a7c9fa4ce87bcd8db81da99fa15ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 12 Jan 2023 00:09:21 +0800 Subject: [PATCH 27/29] TerminalFont: support WezTerm on Windows --- src/detection/terminalfont/terminalfont.c | 2 +- src/detection/terminalshell/terminalshell_windows.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index b08e39565..9e9996304 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -356,7 +356,7 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina detectAlacritty(instance, terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "kitty") == 0) detectKitty(instance, terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "wezterm-gui") == 0) + else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "wezterm-gui")) detectWezterm(instance, terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/tty")) detectTTY(terminalFont); diff --git a/src/detection/terminalshell/terminalshell_windows.cpp b/src/detection/terminalshell/terminalshell_windows.cpp index 8541f37f3..b800228fa 100644 --- a/src/detection/terminalshell/terminalshell_windows.cpp +++ b/src/detection/terminalshell/terminalshell_windows.cpp @@ -218,6 +218,8 @@ static uint32_t getTerminalInfo(const FFinstance* instance, FFTerminalShellResul ffStrbufSetS(&result->terminalPrettyName, "Windows Explorer"); else if(ffStrbufStartsWithIgnCaseS(&result->terminalPrettyName, "ConEmuC")) ffStrbufSetS(&result->terminalPrettyName, "ConEmu"); + else if(ffStrbufEqualS(&result->terminalPrettyName, "wezterm-gui")) + ffStrbufInitS(&result->terminalPrettyName, "WezTerm"); return ppid; } From 387b8298bd57505a15d2a4a540b32541b846f30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 12 Jan 2023 00:11:25 +0800 Subject: [PATCH 28/29] Windows: fix bug that line buffering doesn't work properly --- CHANGELOG.md | 1 + CMakeLists.txt | 6 +++++- src/fastfetch.c | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f0fd7867..c082fa0c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Logos: Bugfixes: * `--logo-type` now does accept `iterm` too (@CarterLi, #374) * Fix mintty terminal font detection +* Fix bug that line buffering doesn't work properly (Windows) Other: * Fixed a Typo in iterm error message (@jessebot, #376) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4abd15ffb..fc0451893 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -645,7 +645,6 @@ if(ENABLE_THREADS) endif() endif() - if(ENABLE_BUFFER) target_compile_definitions(libfastfetch PRIVATE FF_ENABLE_BUFFER) endif() @@ -720,6 +719,11 @@ target_link_libraries(flashfetch PRIVATE libfastfetch ) +if(ENABLE_BUFFER) # FF_ENABLE_BUFFER is used in fastfetch.c + target_compile_definitions(fastfetch PRIVATE FF_ENABLE_BUFFER) + target_compile_definitions(flashfetch PRIVATE FF_ENABLE_BUFFER) +endif() + if(WIN32) set(TARGET_NAME fastfetch) target_sources(fastfetch diff --git a/src/fastfetch.c b/src/fastfetch.c index 6013a6daa..0e8fb855c 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1482,6 +1482,10 @@ int main(int argc, const char** argv) ffStart(&instance); + #if defined(_WIN32) && defined(FF_ENABLE_BUFFER) + fflush(stdout); + #endif + //Parse the structure and call the modules uint32_t startIndex = 0; while (startIndex < data.structure.length) From 46ed8aa87cdc47623e8da7b273d1ff39ed9b6c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 12 Jan 2023 00:18:02 +0800 Subject: [PATCH 29/29] TerminalFont: don't try to detecting kitty and tty fonts on Windows --- src/detection/terminalfont/terminalfont.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 9e9996304..41ff5428b 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -37,7 +37,7 @@ static void detectAlacritty(const FFinstance* instance, FFTerminalFontResult* te ffStrbufDestroy(&fontSize); } -static void detectTTY(FFTerminalFontResult* terminalFont) +FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) { FFstrbuf fontName; ffStrbufInit(&fontName); @@ -291,7 +291,7 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu #endif #endif //defined(_WIN32) || defined(__linux__) -static bool detectKitty(const FFinstance* instance, FFTerminalFontResult* result) +FF_MAYBE_UNUSED static bool detectKitty(const FFinstance* instance, FFTerminalFontResult* result) { FFstrbuf fontName; ffStrbufInit(&fontName); @@ -354,17 +354,20 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina { if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "alacritty")) detectAlacritty(instance, terminalFont); - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "kitty") == 0) - detectKitty(instance, terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "wezterm-gui")) detectWezterm(instance, terminalFont); + + #ifndef _WIN32 + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "kitty")) + detectKitty(instance, terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/tty")) detectTTY(terminalFont); + #endif #if defined(_WIN32) || defined(__linux__) //Used by both Linux (WSL) and Windows - else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "Windows Terminal") == 0 || - ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "WindowsTerminal.exe") == 0) + else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "Windows Terminal") || + ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "WindowsTerminal.exe")) detectFromWindowsTeriminal(instance, &terminalShell->terminalExe, terminalFont); #endif