From 1c891015229a361f0414b9ea2f9d9877a2863053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 2 May 2024 20:45:46 +0800 Subject: [PATCH 01/23] Doc: update changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7146589f..7273c34bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,18 +4,18 @@ Hotfix for Android Bugfixes: * Fix uninitialized variables which can cause crashes (#760 #838, Battery, Android) -* Don't detect hyfetch as shell when used as a backend of hyfetch -* Fix incorrect information in man page +* Don't detect hyfetch as shell when used as backend of [hyfetch](https://github.com/hykilpikonna/hyfetch) +* Fix incorrect information in man page (#828) Features: * Support sorcery package manager detection (Packages, Linux) * Make `--custom-format` optional (Custom) * Make `/` an alias of `C:\` for `--disk-folders` (Disk, Windows) +* Build for Linux armv7 Logo: * Fix colors of Source Mage logo - # 2.11.0 Changes: From 3e98034e55ff7ff5b23e076be85d67fbb223ab34 Mon Sep 17 00:00:00 2001 From: Juan <38849891+xoltia@users.noreply.github.com> Date: Thu, 2 May 2024 09:55:50 -0500 Subject: [PATCH 02/23] Packages (Linux): check xdg state home for nix user packages (#844) Check $XDG_STATE_HOME/nix/profile if ~/.nix-profile is not found as addressed in #837. Fix #837 --- src/detection/packages/packages_linux.c | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 775fb2607..0e19043a4 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -502,7 +502,36 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options) ffStrbufSet(&baseDir, &instance.state.platform.homeDir); if (!(options->disabled & FF_PACKAGES_FLAG_NIX_BIT)) - result->nixUser = getNixPackages(&baseDir, "/.nix-profile"); + { + // check if ~/.nix-profile exists + FF_STRBUF_AUTO_DESTROY profilePath = ffStrbufCreateCopy(&baseDir); + ffStrbufAppendS(&profilePath, ".nix-profile"); + if (ffPathExists(profilePath.chars, FF_PATHTYPE_DIRECTORY)) + { + result->nixUser = getNixPackages(&baseDir, ".nix-profile"); + } + // check if $XDG_STATE_HOME/nix/profile exists + else + { + FF_STRBUF_AUTO_DESTROY stateDir = ffStrbufCreate(); + const char* stateHome = getenv("XDG_STATE_HOME"); + if(ffStrSet(stateHome)) + { + ffStrbufSetS(&stateDir, stateHome); + ffStrbufEnsureEndsWithC(&stateDir, '/'); + } + else + { + ffStrbufSet(&stateDir, &instance.state.platform.homeDir); + ffStrbufAppendS(&stateDir, ".local/state/"); + } + + ffStrbufSet(&profilePath, &stateDir); + ffStrbufAppendS(&profilePath, "nix/profile"); + result->nixUser = getNixPackages(&stateDir, "nix/profile"); + } + } + if (!(options->disabled & FF_PACKAGES_FLAG_FLATPAK_BIT)) result->flatpakUser = getFlatpak(&baseDir, "/.local/share/flatpak"); } From ef3b5df048b2c322c67cb069a7a6dffb00337546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 2 May 2024 21:54:46 +0800 Subject: [PATCH 03/23] Doc: update man page --- doc/fastfetch.1.in | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/fastfetch.1.in b/doc/fastfetch.1.in index ab39ae0b4..aa937f336 100644 --- a/doc/fastfetch.1.in +++ b/doc/fastfetch.1.in @@ -107,12 +107,12 @@ To list all available modules, use \fB \-\-list\-modules \fR .SS "Config Files" -fastfetch supports two types of config files. The legacy -configuration files and a JSONC based format. +Fastfetch uses JSONC based format for configuration. Fastfetch doesn't generate +config file automatically; it should be generated manually by \fB \-\-gen\-config\fR. +The config file will be saved in \fB~/.config/fastfetch/config.jsonc\fR by default. A JSONC config file is a JSON file that also supports comments with (//). Those -files must have the extension '.jsonc'. You can migrate a legacy config -file to the JSONC format by using \fB\-\-gen\-config\fR. +files must have the extension '.jsonc'. The specified configuration/preset files are searched in the following order: @@ -122,9 +122,6 @@ The specified configuration/preset files are searched in the following order: 3. relative to /usr/share/fastfetch/presets/ -When both a '.jsonc' and a '.conf' file with the same name is found, -the '.jsonc' file is preferred. - Fastfetch provides some default presets. List them with \fB\-\-list\-presets\fR. .SH "SEE ALSO" From 71cba2451a13fdb56bbbdca943a3fb8fd194d901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 01:08:14 +0800 Subject: [PATCH 04/23] Logo: disable image logos in ssh and tmux sessions --- src/logo/image/image.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 12c7711f6..ebeb2c2fe 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -1,6 +1,7 @@ #include "image.h" #include "common/io/io.h" #include "common/printing.h" +#include "util/stringUtils.h" #include #include @@ -839,6 +840,22 @@ bool ffLogoPrintImageIfExists(FFLogoType type, bool printError) return false; } + if (getenv("SSH_TTY")) + { + if(printError) + fputs("Logo: Image logo is not supported in SSH sessions\n", stderr); + return false; + } + + const char* term = getenv("TERM"); + if((term && ffStrEquals(term, "screen")) || getenv("ZELLIJ") || getenv("TMUX")) + { + if(printError) + fputs("Logo: Image logo is not supported in terminal multiplexers\n", stderr); + return false; + } + + if(type == FF_LOGO_TYPE_IMAGE_ITERM) return printImageIterm(); From 4c0ea7354d249ae4266855ab8db9b9297e258a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 07:56:43 +0800 Subject: [PATCH 05/23] Logo (Image): only print error if `--show-error` is specified --- src/logo/image/image.c | 19 ++++++++++++++----- src/logo/logo.c | 5 +++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/logo/image/image.c b/src/logo/image/image.c index ebeb2c2fe..ea848a16d 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -54,13 +54,14 @@ static FFstrbuf base64Encode(const FFstrbuf* in) return out; } -static bool printImageIterm(void) +static bool printImageIterm(bool printError) { const FFOptionsLogo* options = &instance.config.logo; FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); if(!ffAppendFileBuffer(options->source.chars, &buf)) { - fputs("Logo: Failed to load image file\n", stderr); + if (printError) + fputs("Logo (iterm): Failed to load image file\n", stderr); return false; } @@ -135,9 +136,17 @@ static bool printImageIterm(void) return true; } -static bool printImageKittyDirect(void) +static bool printImageKittyDirect(bool printError) { const FFOptionsLogo* options = &instance.config.logo; + + if (!ffPathExists(options->source.chars, FF_PATHTYPE_FILE)) + { + if (printError) + fputs("Logo (kitty-direct): Failed to load image file\n", stderr); + return false; + } + FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&options->source); if (!options->width || !options->height) @@ -857,10 +866,10 @@ bool ffLogoPrintImageIfExists(FFLogoType type, bool printError) if(type == FF_LOGO_TYPE_IMAGE_ITERM) - return printImageIterm(); + return printImageIterm(printError); if(type == FF_LOGO_TYPE_IMAGE_KITTY_DIRECT) - return printImageKittyDirect(); + return printImageKittyDirect(printError); #if !defined(FF_HAVE_CHAFA) if(type == FF_LOGO_TYPE_IMAGE_CHAFA) diff --git a/src/logo/logo.c b/src/logo/logo.c index 708bc6c7f..d9af22a90 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -393,7 +393,8 @@ static bool logoPrintFileIfExists(bool doColorReplacement, bool raw) : !ffAppendFileBuffer(options->source.chars, &content) ) { - fprintf(stderr, "Logo: Failed to load file content from logo source: %s \n", options->source.chars); + if (instance.config.display.showErrors) + fprintf(stderr, "Logo: Failed to load file content from logo source: %s \n", options->source.chars); return false; } @@ -448,7 +449,7 @@ static bool logoTryKnownType(void) if(options->type == FF_LOGO_TYPE_IMAGE_RAW) return logoPrintFileIfExists(false, true); - return logoPrintImageIfExists(options->type, true); + return logoPrintImageIfExists(options->type, instance.config.display.showErrors); } static void logoPrintKnownType(void) From 1449290e9e4f7abb34e71ca70c220718d7d1d9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 08:28:20 +0800 Subject: [PATCH 06/23] GPU (Linux): check NULL returned by opendir Fix #845 --- src/detection/gpu/gpu_linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index a8801cb31..65566cb8a 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -46,6 +46,8 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu, ffStrbufAppendS(pciDir, "/hwmon/"); FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDir->chars); + if (!dirp) return; + struct dirent* entry; while ((entry = readdir(dirp)) != NULL) { From 407bfa8c9558515fb2052c566d304665a397d76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 08:36:06 +0800 Subject: [PATCH 07/23] Shell: don't try detecting version of raw `sh` shell Fix #849 --- src/detection/terminalshell/terminalshell.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 68ff5313a..8c497e5a9 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -228,7 +228,10 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) { if (!instance.config.display.tsVersion) return false; - if(strcasecmp(exeName, "bash") == 0 || strcasecmp(exeName, "sh") == 0) + if(ffStrEqualsIgnCase(exeName, "sh")) // #849 + return false; + + if(strcasecmp(exeName, "bash") == 0) return getShellVersionBash(exe, version); if(strcasecmp(exeName, "zsh") == 0) return getExeVersionGeneral(exe, version); //zsh 5.9 (arm-apple-darwin21.3.0) From 158db9d7c7d88e716e412d87fb487be638f8fc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 08:42:22 +0800 Subject: [PATCH 08/23] Logo (Builtin): add KernelOS Fix #848 --- src/logo/ascii/kernelos.txt | 19 +++++++++++++++++++ src/logo/builtin.c | 9 +++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/logo/ascii/kernelos.txt diff --git a/src/logo/ascii/kernelos.txt b/src/logo/ascii/kernelos.txt new file mode 100644 index 000000000..e04094271 --- /dev/null +++ b/src/logo/ascii/kernelos.txt @@ -0,0 +1,19 @@ + .''''....''''. + .''... ...''. + ''.. ..'' + '.. ..'' + .'. .,,'.. .',,,' ..'. + .'. .,,,,' .,,,,,' .'. + .'. .,,,,' .,,,,,. .'. + '.. .,,,,'',,,,;. .'' +.'. .,,,,,,,;;. ..' +.'. .,,,,;;;;;${c2}, ${c1}..'. + '.. .,;;;,${c2}';;;;;, ${c1}..' + .'. .;;${c2};;' .;;:::: ${c1}.,. + '.. ${c2}.;;;;' .::::::. ${c1}.,' + '.. ${c2}.;;;;' .::::::. ${c1}.,${c2}'${c1} + .'.. ${c2}.',. + ${c1}',.. ${c2}.',' + ${c1}.,,... ${c2}..',,. + ..,,''........',,,. + ...... diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 019aa07d2..e307e6b3a 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2089,6 +2089,15 @@ static const FFlogo K[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_WHITE, }, + // KernelOS + { + .names = {"KernelOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_KERNELOS, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_MAGENTA, + } + }, // KDENeon { .names = {"KDE", "kde-neon"}, From b386365d95b9bcd975acc020e88906b2019693b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 08:46:57 +0800 Subject: [PATCH 09/23] Logo (Builtin): fix ascii file name --- src/logo/ascii/{ChimeraLinux.txt => chimera_linux.txt} | 0 src/logo/builtin.c | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/logo/ascii/{ChimeraLinux.txt => chimera_linux.txt} (100%) diff --git a/src/logo/ascii/ChimeraLinux.txt b/src/logo/ascii/chimera_linux.txt similarity index 100% rename from src/logo/ascii/ChimeraLinux.txt rename to src/logo/ascii/chimera_linux.txt diff --git a/src/logo/builtin.c b/src/logo/builtin.c index e307e6b3a..cbf88c3f2 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -875,7 +875,7 @@ static const FFlogo C[] = { // Chimera Linux { .names = {"Chimera Linux"}, - .lines = FASTFETCH_DATATEXT_LOGO_CHIMERALINUX, + .lines = FASTFETCH_DATATEXT_LOGO_CHIMERA_LINUX, .colors = { FF_COLOR_FG_RED, FF_COLOR_FG_MAGENTA, From a462a12370f902121b2106f804b5a0167960f945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 08:50:41 +0800 Subject: [PATCH 10/23] Logo (Builtin): fix distro name of DraugerOS --- src/logo/builtin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logo/builtin.c b/src/logo/builtin.c index cbf88c3f2..f8c29a0db 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -1241,9 +1241,9 @@ static const FFlogo D[] = { .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_WHITE, }, - // Drauger + // DraugerOS { - .names = {"Drauger"}, + .names = {"DraugerOS", "Drauger"}, .lines = FASTFETCH_DATATEXT_LOGO_DRAUGER, .colors = { FF_COLOR_FG_RED, From 030c05429af5e647fc05f41abc4228c70b51780f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 08:57:53 +0800 Subject: [PATCH 11/23] Logo (Builtin): add missing `FF_LOGO_LINE_TYPE_SMALL_BIT` flags --- src/logo/builtin.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/logo/builtin.c b/src/logo/builtin.c index f8c29a0db..f024d1300 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -209,6 +209,7 @@ static const FFlogo A[] = { // AoscOsRetro_small { .names = {"Aosc OS/Retro_small", "aoscosretro_small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_AOSCOSRETRO_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -764,6 +765,7 @@ static const FFlogo C[] = { // CalinixOSSmall { .names = {"Calinix_small", "calinixos_small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_CALINIXOS_SMALL, .colors = { FF_COLOR_FG_MAGENTA, @@ -1336,8 +1338,8 @@ static const FFlogo E[] = { // EndeavourSmall { .names = {"Endeavour_small", "endeavour-linux_small", "endeavouros_small", "endeavouros-linux_small"}, - .lines = FASTFETCH_DATATEXT_LOGO_ENDEAVOUR_SMALL, .type = FF_LOGO_LINE_TYPE_SMALL_BIT, + .lines = FASTFETCH_DATATEXT_LOGO_ENDEAVOUR_SMALL, .colors = { FF_COLOR_FG_RED, FF_COLOR_FG_MAGENTA, @@ -1823,6 +1825,7 @@ static const FFlogo G[] = { // GuixSmall { .names = {"Guix_small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_GUIX_SMALL, .colors = { FF_COLOR_FG_YELLOW, @@ -2471,6 +2474,7 @@ static const FFlogo M[] = { // MageiaSmall { .names = {"Mageia_small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MAGEIA_SMALL, .colors = { FF_COLOR_FG_CYAN, @@ -2669,6 +2673,7 @@ static const FFlogo M[] = { // MXSmall { .names = {"MX_small", "mx-small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MX_SMALL, .colors = { FF_COLOR_FG_WHITE, @@ -2739,6 +2744,7 @@ static const FFlogo N[] = { // NixOSSmall { .names = {"NixOS_small", "nix_small", "nixos-linux-small", "nix-linux-small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL, .colors = { FF_COLOR_FG_BLUE, @@ -3310,6 +3316,7 @@ static const FFlogo P[] = { // PostMarketOSSmall { .names = {"PostMarketOS_small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_POSTMARKETOS_SMALL, .colors = { FF_COLOR_FG_GREEN, @@ -3569,6 +3576,7 @@ static const FFlogo R[] = { // RockyLinuxSmall { .names = {"rocky_small", "rocky-linux_small", "rockylinux_small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_ROCKY_SMALL, .colors = { FF_COLOR_FG_GREEN, From 36dadcdc7f176b6ab0a9c73eca92c2902b01f3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 08:58:13 +0800 Subject: [PATCH 12/23] Logo (Builtin): add MX2 & fix mx distro detection Fix: #847 --- src/logo/ascii/mx2.txt | 18 ++++++++++++++++++ src/logo/builtin.c | 15 +++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/logo/ascii/mx2.txt diff --git a/src/logo/ascii/mx2.txt b/src/logo/ascii/mx2.txt new file mode 100644 index 000000000..b2132fbbd --- /dev/null +++ b/src/logo/ascii/mx2.txt @@ -0,0 +1,18 @@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@@@@@@@@@@@%*+--:------=+*%@@@@@@@@@@@@ +@@@@@@@@@#=. .-+#%@@@@@%#*+--=#@@@@@@@@@ +@@@@@@@+. .=%@@@@@@@@@@@@@@@@*-:+@@@@@@@ +@@@@@*. *@@@@@@@@@@@@@@@@@@@@@%-.*@@@@@ +@@@@- -@@@@@@@@@@@@@@@@@@@@@@@#: -@@@@ +@@@: -@@@@@@@=.*@@@@@@@@@@@@%- = :@@@ +@@= .@@@@@@@@%- :%@@@@@@@@@+ -%@# =@@ +@% +@@@@@@@@@@#. =@@@@@@*. .*@@@@. %@ +@+ *@@@@@@*..*@@+ *@@%- =@@@@@@- +@ +@= *@@@@%- -%@@- := -%@@@@@@@: +@ +@+ :@@@= +@@= .#@@@@@@@@% *@ +@% +*. .: *@@#: +@@: @@ +@@+ :%@- :- :: +@@ +@@@- .=@@= -@@@ +@@+. . +@@ +%=..:.................::...........:..-% +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ diff --git a/src/logo/builtin.c b/src/logo/builtin.c index f024d1300..3b0d2ab18 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2662,7 +2662,7 @@ static const FFlogo M[] = { }, // MX { - .names = {"MX"}, + .names = {"MX", "MX Linux"}, .lines = FASTFETCH_DATATEXT_LOGO_MX, .colors = { FF_COLOR_FG_WHITE, @@ -2672,7 +2672,7 @@ static const FFlogo M[] = { }, // MXSmall { - .names = {"MX_small", "mx-small"}, + .names = {"MX_small", "mx linux_small"}, .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .lines = FASTFETCH_DATATEXT_LOGO_MX_SMALL, .colors = { @@ -2681,6 +2681,17 @@ static const FFlogo M[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_CYAN, }, + // MX2 + { + .names = {"MX2"}, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, + .lines = FASTFETCH_DATATEXT_LOGO_MX2, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_CYAN, + }, // LAST {}, }; From 82285ebeb443b44799f03f1d84ff8922500c3509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 09:21:15 +0800 Subject: [PATCH 13/23] Release: 2.11.2 --- CHANGELOG.md | 21 +++++++++++++++++++++ CMakeLists.txt | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7273c34bc..0fcba7517 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +# 2.11.2 + +Hotfix V2 for old kernel + +Changes: +* Error messages when trying to print image logo will only be printed with `--show-errors` + +Bugfixes: +* Fix segfault in Debian 11 and some old kernels. Regression in 2.11.0 (#845, GPU, Linux) +* Don't try detecting version of raw `sh` shell (#849, Shell, Linux) + +Features: +* Check xdg state home for nix user packages (#837, Packages, Linux) +* Disable image logos in ssh and tmux sessions (#839) + +Logo: +* Add KernelOS +* Fix name of DraugerOS +* Add missing `FF_LOGO_LINE_TYPE_SMALL_BIT` flags +* Add MX2 + # 2.11.1 Hotfix for Android diff --git a/CMakeLists.txt b/CMakeLists.txt index 23f578245..b0ff2ce40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 2.11.1 + VERSION 2.11.2 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" From c4a876f6aabb2b7990ccdddc1242ac20e9cf6c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 09:47:55 +0800 Subject: [PATCH 14/23] OS (Linux): Prioritize `lsb-release` over `os-release` Fix #847 --- src/common/properties.c | 54 +++++++++++++++++-------------------- src/detection/os/os_linux.c | 17 ++++++------ 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/src/common/properties.c b/src/common/properties.c index 3dead5045..f45c9928c 100644 --- a/src/common/properties.c +++ b/src/common/properties.c @@ -1,5 +1,7 @@ #include "fastfetch.h" #include "common/properties.h" +#include "common/io/io.h" +#include "util/mallocHelper.h" #include #ifdef _WIN32 @@ -95,50 +97,44 @@ bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer) bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries) { - FILE* file = fopen(filename, "r"); - if(file == NULL) + FF_AUTO_CLOSE_FILE FILE* file = fopen(filename, "r"); + if (file == NULL) return false; - bool valueStorage[4]; - bool* unsetValues; + bool valueStorage[32]; + bool* unsetValues = valueStorage; - if(numQueries > sizeof(valueStorage) / sizeof(valueStorage[0])) + if (numQueries > sizeof(valueStorage) / sizeof(valueStorage[0])) unsetValues = malloc(sizeof(bool) * numQueries); - else - unsetValues = valueStorage; bool allSet = true; - for(uint32_t i = 0; i < numQueries; i++) + for (uint32_t i = 0; i < numQueries; i++) { - if((unsetValues[i] = queries[i].buffer->length == 0)) + unsetValues[i] = queries[i].buffer->length == 0; + if (unsetValues[i]) allSet = false; } - if(allSet) - goto done; - - char* line = NULL; - size_t len = 0; - - while (getline(&line, &len, file) != -1) + if (!allSet) { - for(uint32_t i = 0; i < numQueries; i++) - { - if(!unsetValues[i]) - continue; + FF_AUTO_FREE char* line = NULL; + size_t len = 0; - uint32_t currentLength = queries[i].buffer->length; - queries[i].buffer->length = 0; - if(!ffParsePropLine(line, queries[i].start, queries[i].buffer)) - queries[i].buffer->length = currentLength; + while (getline(&line, &len, file) != -1) + { + for(uint32_t i = 0; i < numQueries; i++) + { + if(!unsetValues[i]) + continue; + + uint32_t currentLength = queries[i].buffer->length; + queries[i].buffer->length = 0; + if(!ffParsePropLine(line, queries[i].start, queries[i].buffer)) + queries[i].buffer->length = currentLength; + } } } - if(line != NULL) - free(line); - -done: - fclose(file); if(unsetValues != valueStorage) free(unsetValues); return true; diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 74e9f1475..69fe1ddad 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -12,6 +12,7 @@ static inline bool allRelevantValuesSet(const FFOSResult* result) return result->id.length > 0 && result->name.length > 0 && result->prettyName.length > 0 + && result->version.length > 0 ; } @@ -150,22 +151,20 @@ static void detectOS(FFOSResult* os) if(os->prettyName.length == 0) ffStrbufAppendS(&os->prettyName, "Bedrock Linux"); - - parseFile("/bedrock"FASTFETCH_TARGET_DIR_ETC"/os-release", os); - if(allRelevantValuesSet(os)) + if(parseFile("/bedrock"FASTFETCH_TARGET_DIR_ETC"/os-release", os) && allRelevantValuesSet(os)) return; } - parseFile(FASTFETCH_TARGET_DIR_ETC"/os-release", os); - if(allRelevantValuesSet(os)) + // Seems some distros contain real distro name only in lsb-release + // https://github.com/fastfetch-cli/fastfetch/issues/847#issuecomment-2091999419 + if(parseFile(FASTFETCH_TARGET_DIR_ETC"/lsb-release", os) && allRelevantValuesSet(os)) + return; + + if(parseFile(FASTFETCH_TARGET_DIR_ETC"/os-release", os) && allRelevantValuesSet(os)) return; parseFile(FASTFETCH_TARGET_DIR_USR"/lib/os-release", os); - if(allRelevantValuesSet(os)) - return; - - parseFile(FASTFETCH_TARGET_DIR_ETC"/lsb-release", os); } void ffDetectOSImpl(FFOSResult* os) From 903ecf37f7786f1f846fa1f80c68376635bcdaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 10:07:16 +0800 Subject: [PATCH 15/23] Chore: silience some warnings --- src/detection/gpu/gpu_linux.c | 2 +- src/detection/publicip/publicip.c | 2 +- src/util/edidHelper.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 65566cb8a..ff4decbba 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -258,7 +258,7 @@ FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, F { uint32_t index = ffStrbufFirstIndexS(buffer, "apple,agx-t"); if (index == buffer->length) return "display-subsystem?"; - index += strlen("apple,agx-t"); + index += (uint32_t) strlen("apple,agx-t"); FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); gpu->deviceId = strtoul(buffer->chars + index, NULL, 10); diff --git a/src/detection/publicip/publicip.c b/src/detection/publicip/publicip.c index b5038e66e..d144f7219 100644 --- a/src/detection/publicip/publicip.c +++ b/src/detection/publicip/publicip.c @@ -28,7 +28,7 @@ void ffPreparePublicIp(FFPublicIpOptions* options) fputs("Error: only http: protocol is supported. Use `Command` module with `curl` if needed\n", stderr); exit(1); } - ffStrbufSubstrAfter(&host, hostStartIndex + (strlen("://") - 1)); + ffStrbufSubstrAfter(&host, hostStartIndex + (uint32_t) (strlen("://") - 1)); } uint32_t pathStartIndex = ffStrbufFirstIndexC(&host, '/'); diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index 7724c6136..adf621197 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -73,8 +73,8 @@ void ffEdidGetSerialAndManufactureDate(const uint8_t edid[128], uint32_t* serial { if (edid[17] > 0 && edid[17] < 0xFF) { - *year = edid[17] + 1990; - *week = edid[16]; + *year = (uint16_t) edid[17] + 1990; + *week = (uint16_t) edid[16]; if (*week == 0xFF) *week = 0; } else From a789b8330aa7227c1d68c0af65db5e2d128af9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 10:10:13 +0800 Subject: [PATCH 16/23] Doc: update logo_request.md --- .github/ISSUE_TEMPLATE/logo_request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/logo_request.md b/.github/ISSUE_TEMPLATE/logo_request.md index 697223798..98bfff898 100644 --- a/.github/ISSUE_TEMPLATE/logo_request.md +++ b/.github/ISSUE_TEMPLATE/logo_request.md @@ -11,7 +11,7 @@ Tip: A logo can be displayed by fastfetch without getting into fastfetch's offic # OS ``` -Paste content of /etc/os-release here. If this file doesn't exist, describe a way to identify the distro. +Paste content of /etc/os-release and /etc/lsb-release here. If none of these files exist, describe a way to identify the distro ``` # Ascii From 22d9d8e196d4e1456d950b270c5091b89df485a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 11:22:06 +0800 Subject: [PATCH 17/23] OS (Linux): fix OS detection for MX Linux (2nd attempt) Ref: #847 --- src/detection/os/os_linux.c | 40 ++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 69fe1ddad..a734f8a63 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -16,18 +16,25 @@ static inline bool allRelevantValuesSet(const FFOSResult* result) ; } -static bool parseFile(const char* fileName, FFOSResult* result) +static bool parseLsbRelease(const char* fileName, FFOSResult* result) { - return ffParsePropFileValues(fileName, 13, (FFpropquery[]) { - {"NAME =", &result->name}, - {"DISTRIB_DESCRIPTION =", &result->prettyName}, - {"PRETTY_NAME =", &result->prettyName}, + return ffParsePropFileValues(fileName, 4, (FFpropquery[]) { {"DISTRIB_ID =", &result->id}, + {"DISTRIB_DESCRIPTION =", &result->prettyName}, + {"DISTRIB_RELEASE =", &result->version}, + {"DISTRIB_CODENAME =", &result->codename}, + }); +} + +static bool parseOsRelease(const char* fileName, FFOSResult* result) +{ + return ffParsePropFileValues(fileName, 10, (FFpropquery[]) { + {"PRETTY_NAME =", &result->prettyName}, + {"NAME =", &result->name}, {"ID =", &result->id}, {"ID_LIKE =", &result->idLike}, {"VARIANT =", &result->variant}, {"VARIANT_ID =", &result->variantID}, - {"DISTRIB_RELEASE =", &result->version}, {"VERSION =", &result->version}, {"VERSION_ID =", &result->versionID}, {"VERSION_CODENAME =", &result->codename}, @@ -137,11 +144,12 @@ static void detectOS(FFOSResult* os) { if(instance.config.general.osFile.length > 0) { - parseFile(instance.config.general.osFile.chars, os); + parseLsbRelease(instance.config.general.osFile.chars, os); + parseOsRelease(instance.config.general.osFile.chars, os); return; } - if(instance.config.general.escapeBedrock && parseFile(FASTFETCH_TARGET_DIR_ROOT"/bedrock"FASTFETCH_TARGET_DIR_ETC"/bedrock-release", os)) + if(instance.config.general.escapeBedrock && parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock" FASTFETCH_TARGET_DIR_ETC "/bedrock-release", os)) { if(os->id.length == 0) ffStrbufAppendS(&os->id, "bedrock"); @@ -152,19 +160,23 @@ static void detectOS(FFOSResult* os) if(os->prettyName.length == 0) ffStrbufAppendS(&os->prettyName, "Bedrock Linux"); - if(parseFile("/bedrock"FASTFETCH_TARGET_DIR_ETC"/os-release", os) && allRelevantValuesSet(os)) + if(parseOsRelease("/bedrock" FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os)) return; } - // Seems some distros contain real distro name only in lsb-release - // https://github.com/fastfetch-cli/fastfetch/issues/847#issuecomment-2091999419 - if(parseFile(FASTFETCH_TARGET_DIR_ETC"/lsb-release", os) && allRelevantValuesSet(os)) + // Refer: https://gist.github.com/natefoo/814c5bf936922dad97ff + + // For MX Linux. Should not exist in other distros. See #847 + if(parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/initrd-release", os) && allRelevantValuesSet(os)) return; - if(parseFile(FASTFETCH_TARGET_DIR_ETC"/os-release", os) && allRelevantValuesSet(os)) + if(parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os)) return; - parseFile(FASTFETCH_TARGET_DIR_USR"/lib/os-release", os); + if(parseOsRelease(FASTFETCH_TARGET_DIR_USR "/lib/os-release", os) && allRelevantValuesSet(os)) + return; + + parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os); } void ffDetectOSImpl(FFOSResult* os) From 8b838cef61a4012c4887d72492e93f17fe3ca30e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 11:57:01 +0800 Subject: [PATCH 18/23] OS (Linux): fix name detection for MX Fix #847 --- src/detection/os/os_linux.c | 18 +++++++++++------- src/modules/os/os.c | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index a734f8a63..f0bc35a45 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -166,17 +166,21 @@ static void detectOS(FFOSResult* os) // Refer: https://gist.github.com/natefoo/814c5bf936922dad97ff - // For MX Linux. Should not exist in other distros. See #847 - if(parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/initrd-release", os) && allRelevantValuesSet(os)) - return; + // Hack for MX Linux. See #847 + if(parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os)) + { + if (ffStrbufEqualS(&os->id, "MX")) + { + ffStrbufSetStatic(&os->name, "MX"); + ffStrbufSetStatic(&os->idLike, "debian"); + return; + } + } if(parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os)) return; - if(parseOsRelease(FASTFETCH_TARGET_DIR_USR "/lib/os-release", os) && allRelevantValuesSet(os)) - return; - - parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os); + parseOsRelease(FASTFETCH_TARGET_DIR_USR "/lib/os-release", os); } void ffDetectOSImpl(FFOSResult* os) diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 2bcc6f00a..b1ccf1a97 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -22,7 +22,7 @@ static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result) ffStrbufAppend(result, &instance.state.platform.systemName); //Append code name if it is missing - if(os->codename.length > 0 && !ffStrbufContain(result, &os->versionID)) + if(os->codename.length > 0 && !ffStrbufContain(result, &os->codename)) { ffStrbufAppendC(result, ' '); ffStrbufAppend(result, &os->codename); From 5e9fcaf7cac65f162a703ba21628aec69d2f6287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 13:08:24 +0800 Subject: [PATCH 19/23] OS (Linux): don't use `rolling` as os version --- src/detection/os/os_linux.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index f0bc35a45..9d0ad5185 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -12,7 +12,6 @@ static inline bool allRelevantValuesSet(const FFOSResult* result) return result->id.length > 0 && result->name.length > 0 && result->prettyName.length > 0 - && result->version.length > 0 ; } @@ -175,6 +174,10 @@ static void detectOS(FFOSResult* os) ffStrbufSetStatic(&os->idLike, "debian"); return; } + + // For archlinux + if (ffStrbufEqualS(&os->version, "rolling")) + ffStrbufClear(&os->version); } if(parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os)) From 08c6a6e4cb2e854ebfd3b0b3f86630404b15bb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 13:20:23 +0800 Subject: [PATCH 20/23] OS (macOS): don't print build id Remove special handling --- src/modules/os/os.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/modules/os/os.c b/src/modules/os/os.c index b1ccf1a97..40fbb7fde 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -40,14 +40,6 @@ static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result) ffStrbufAppend(result, &os->version); } - #ifdef __APPLE__ - if(os->buildID.length > 0) - { - ffStrbufAppendC(result, ' '); - ffStrbufAppend(result, &os->buildID); - } - #endif - //Append variant if it is missing if(os->variant.length > 0 && ffStrbufFirstIndex(result, &os->variant) == result->length) { From 1011e21ba8cb7e6f181f681aafd84c736315f3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 13:46:28 +0800 Subject: [PATCH 21/23] Processing: trim `\r` on Windows --- src/common/processing.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/common/processing.h b/src/common/processing.h index 98b9fe09f..ff2689a52 100644 --- a/src/common/processing.h +++ b/src/common/processing.h @@ -8,10 +8,7 @@ static inline const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const ar { const char* error = ffProcessAppendOutput(buffer, argv, false); if (!error) - { - ffStrbufTrimRight(buffer, '\n'); - ffStrbufTrimRight(buffer, ' '); - } + ffStrbufTrimRightSpace(buffer); return error; } @@ -19,9 +16,6 @@ static inline const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const ar { const char* error = ffProcessAppendOutput(buffer, argv, true); if (!error) - { - ffStrbufTrimRight(buffer, '\n'); - ffStrbufTrimRight(buffer, ' '); - } + ffStrbufTrimRightSpace(buffer); return error; } From 217f98a36c2fb1238b7fe23161db224c90369c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 13:56:19 +0800 Subject: [PATCH 22/23] Global: tidy json result formats --- src/detection/battery/battery_linux.c | 3 --- src/modules/battery/battery.c | 33 ++++++++++++++----------- src/modules/bluetooth/bluetooth.c | 22 ++++++++--------- src/modules/brightness/brightness.c | 6 ----- src/modules/datetime/datetime.c | 2 +- src/modules/display/display.c | 1 + src/modules/gamepad/gamepad.c | 6 ----- src/modules/localip/localip.c | 9 +------ src/modules/poweradapter/poweradapter.c | 32 +++++++++++++----------- src/modules/sound/sound.c | 6 ----- src/modules/users/users.c | 3 +-- src/modules/wifi/wifi.c | 5 ---- 12 files changed, 51 insertions(+), 77 deletions(-) diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index 080183c8d..d77968a37 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -170,8 +170,5 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) ffStrbufSubstrBefore(&baseDir, baseDirLength); } - if(results->length == 0) - return "\"/sys/class/power_supply/\" doesn't contain any battery folder"; - return NULL; } diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 7a5c82ebb..ee82e42d5 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -84,23 +84,28 @@ void ffPrintBattery(FFBatteryOptions* options) if (error) { ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error); + return; } - else + if(results.length == 0) { - for(uint8_t i = 0; i < (uint8_t) results.length; i++) - { - FFBatteryResult* result = ffListGet(&results, i); - printBattery(options, result, i); + ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", "No batteries found"); + return; + } - ffStrbufDestroy(&result->manufacturer); - ffStrbufDestroy(&result->modelName); - ffStrbufDestroy(&result->technology); - ffStrbufDestroy(&result->status); - ffStrbufDestroy(&result->serial); - ffStrbufDestroy(&result->manufactureDate); - } - if(results.length == 0) - ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No batteries found"); + for(uint32_t i = 0; i < results.length; i++) + { + FFBatteryResult* result = ffListGet(&results, i); + printBattery(options, result, (uint8_t) i); + } + + FF_LIST_FOR_EACH(FFBatteryResult, result, results) + { + ffStrbufDestroy(&result->manufacturer); + ffStrbufDestroy(&result->modelName); + ffStrbufDestroy(&result->technology); + ffStrbufDestroy(&result->status); + ffStrbufDestroy(&result->serial); + ffStrbufDestroy(&result->manufactureDate); } } diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 37f62bb60..c638252e7 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -150,19 +150,17 @@ void ffGenerateBluetoothJsonResult(FF_MAYBE_UNUSED FFBluetoothOptions* options, yyjson_mut_obj_add_str(doc, module, "error", error); return; } - else - { - yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); - FF_LIST_FOR_EACH(FFBluetoothResult, item, results) - { - yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr); - yyjson_mut_obj_add_strbuf(doc, obj, "address", &item->address); - yyjson_mut_obj_add_uint(doc, obj, "battery", item->battery); - yyjson_mut_obj_add_bool(doc, obj, "connected", item->connected); - yyjson_mut_obj_add_strbuf(doc, obj, "name", &item->name); - yyjson_mut_obj_add_strbuf(doc, obj, "type", &item->type); - } + yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); + + FF_LIST_FOR_EACH(FFBluetoothResult, item, results) + { + yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr); + yyjson_mut_obj_add_strbuf(doc, obj, "address", &item->address); + yyjson_mut_obj_add_uint(doc, obj, "battery", item->battery); + yyjson_mut_obj_add_bool(doc, obj, "connected", item->connected); + yyjson_mut_obj_add_strbuf(doc, obj, "name", &item->name); + yyjson_mut_obj_add_strbuf(doc, obj, "type", &item->type); } FF_LIST_FOR_EACH(FFBluetoothResult, device, results) diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 55548f902..f5defe068 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -154,12 +154,6 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options return; } - if(result.length == 0) - { - yyjson_mut_obj_add_str(doc, module, "error", "No result is detected."); - return; - } - yyjson_mut_val* arr = yyjson_mut_arr(doc); yyjson_mut_obj_add_val(doc, module, "result", arr); diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index edaca593d..5027cc803 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -152,7 +152,7 @@ void ffGenerateDateTimeJsonConfig(FFDateTimeOptions* options, yyjson_mut_doc* do void ffGenerateDateTimeJsonResult(FF_MAYBE_UNUSED FFDateTimeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { - yyjson_mut_obj_add_uint(doc, module, "result", ffTimeGetNow()); + yyjson_mut_obj_add_strcpy(doc, module, "result", ffTimeToFullStr(ffTimeGetNow())); } void ffPrintDateTimeHelpFormat(void) diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 98bc3ac35..0ca9e0748 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -279,6 +279,7 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs yyjson_mut_obj_add_str(doc, module, "error", "Couldn't detect display"); return; } + yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); FF_LIST_FOR_EACH(FFDisplayResult, item, dsResult->displays) { diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index ccba952b2..d14beb279 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -118,12 +118,6 @@ void ffGenerateGamepadJsonResult(FF_MAYBE_UNUSED FFGamepadOptions* options, yyjs return; } - if(!result.length) - { - yyjson_mut_obj_add_str(doc, module, "error", "No devices detected"); - return; - } - yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); FF_LIST_FOR_EACH(FFGamepadDevice, device, result) { diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index f301c7e9d..6f02338ad 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -334,13 +334,7 @@ void ffGenerateLocalIpJsonResult(FF_MAYBE_UNUSED FFLocalIpOptions* options, yyjs if(error) { yyjson_mut_obj_add_str(doc, module, "error", error); - goto exit; - } - - if(results.length == 0) - { - yyjson_mut_obj_add_str(doc, module, "error", "Failed to detect any IPs"); - goto exit; + return; } yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); @@ -354,7 +348,6 @@ void ffGenerateLocalIpJsonResult(FF_MAYBE_UNUSED FFLocalIpOptions* options, yyjs yyjson_mut_obj_add_strbuf(doc, obj, "name", &ip->name); } -exit: FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) { ffStrbufDestroy(&ip->name); diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 6fbf87d3e..e07e15a11 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -101,24 +101,28 @@ void ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* opt if (error) { yyjson_mut_obj_add_str(doc, module, "error", error); + return; } - else if(results.length == 0) + + yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); + FF_LIST_FOR_EACH(FFPowerAdapterResult, item, results) { - yyjson_mut_obj_add_str(doc, module, "error", "No power adapters found"); + yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr); + yyjson_mut_obj_add_strbuf(doc, obj, "description", &item->description); + yyjson_mut_obj_add_strbuf(doc, obj, "manufacturer", &item->manufacturer); + yyjson_mut_obj_add_strbuf(doc, obj, "modelName", &item->modelName); + yyjson_mut_obj_add_strbuf(doc, obj, "name", &item->name); + yyjson_mut_obj_add_strbuf(doc, obj, "serial", &item->serial); + yyjson_mut_obj_add_int(doc, obj, "watts", item->watts); } - else + + FF_LIST_FOR_EACH(FFPowerAdapterResult, item, results) { - yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); - FF_LIST_FOR_EACH(FFPowerAdapterResult, item, results) - { - yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr); - yyjson_mut_obj_add_strbuf(doc, obj, "description", &item->description); - yyjson_mut_obj_add_strbuf(doc, obj, "manufacturer", &item->manufacturer); - yyjson_mut_obj_add_strbuf(doc, obj, "modelName", &item->modelName); - yyjson_mut_obj_add_strbuf(doc, obj, "name", &item->name); - yyjson_mut_obj_add_strbuf(doc, obj, "serial", &item->serial); - yyjson_mut_obj_add_int(doc, obj, "watts", item->watts); - } + ffStrbufDestroy(&item->manufacturer); + ffStrbufDestroy(&item->description); + ffStrbufDestroy(&item->modelName); + ffStrbufDestroy(&item->name); + ffStrbufDestroy(&item->serial); } } diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 39b9c3ec3..0cea6b4e0 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -200,12 +200,6 @@ void ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_m return; } - if(result.length == 0) - { - yyjson_mut_obj_add_str(doc, module, "error", "No active sound devices found"); - return; - } - yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); FF_LIST_FOR_EACH(FFSoundDevice, item, result) { diff --git a/src/modules/users/users.c b/src/modules/users/users.c index f2aa3e527..f3068ab26 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -146,7 +146,7 @@ void ffGenerateUsersJsonResult(FF_MAYBE_UNUSED FFUsersOptions* options, yyjson_m if(error) { yyjson_mut_obj_add_str(doc, module, "error", error); - goto exit; + return; } yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); @@ -164,7 +164,6 @@ void ffGenerateUsersJsonResult(FF_MAYBE_UNUSED FFUsersOptions* options, yyjson_m yyjson_mut_obj_add_null(doc, obj, "loginTime"); } -exit: FF_LIST_FOR_EACH(FFUserResult, user, results) { ffStrbufDestroy(&user->clientIp); diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index 49367e101..0edc32d54 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -114,11 +114,6 @@ void ffGenerateWifiJsonResult(FF_MAYBE_UNUSED FFWifiOptions* options, yyjson_mut yyjson_mut_obj_add_str(doc, module, "error", error); return; } - if(!result.length) - { - yyjson_mut_obj_add_str(doc, module, "error", "No Wifi interfaces found"); - return; - } yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); FF_LIST_FOR_EACH(FFWifiResult, wifi, result) From 83c1fe26e6b5599afad4fe6551305cd587e820f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 3 May 2024 14:14:13 +0800 Subject: [PATCH 23/23] Doc: update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fcba7517..addf5b2d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,17 @@ Hotfix V2 for old kernel Changes: * Error messages when trying to print image logo will only be printed with `--show-errors` +* When generating JSON output, fastfetch will generate an empty array when no result is detected, instead of an error. Bugfixes: * Fix segfault in Debian 11 and some old kernels. Regression in 2.11.0 (#845, GPU, Linux) * Don't try detecting version of raw `sh` shell (#849, Shell, Linux) +* Trim `\r` on Windows Features: * Check xdg state home for nix user packages (#837, Packages, Linux) * Disable image logos in ssh and tmux sessions (#839) +* Support MX Linux distro detection (OS, Linux) Logo: * Add KernelOS