Merge pull request #851 from fastfetch-cli/dev

Release: v2.11.2
This commit is contained in:
Carter Li 2024-05-03 14:36:04 +08:00 committed by GitHub
commit b12a59cdaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 293 additions and 172 deletions

View File

@ -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

View File

@ -1,21 +1,45 @@
# 2.11.2
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
* Fix name of DraugerOS
* Add missing `FF_LOGO_LINE_TYPE_SMALL_BIT` flags
* Add MX2
# 2.11.1
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:

View File

@ -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"

View File

@ -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"

View File

@ -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;
}

View File

@ -1,5 +1,7 @@
#include "fastfetch.h"
#include "common/properties.h"
#include "common/io/io.h"
#include "util/mallocHelper.h"
#include <stdlib.h>
#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;

View File

@ -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;
}

View File

@ -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)
{
@ -256,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);

View File

@ -15,18 +15,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},
@ -136,11 +143,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");
@ -150,22 +158,32 @@ 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(parseOsRelease("/bedrock" FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os))
return;
}
parseFile(FASTFETCH_TARGET_DIR_ETC"/os-release", os);
if(allRelevantValuesSet(os))
// Refer: https://gist.github.com/natefoo/814c5bf936922dad97ff
// 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;
}
// For archlinux
if (ffStrbufEqualS(&os->version, "rolling"))
ffStrbufClear(&os->version);
}
if(parseOsRelease(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);
parseOsRelease(FASTFETCH_TARGET_DIR_USR "/lib/os-release", os);
}
void ffDetectOSImpl(FFOSResult* os)

View File

@ -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");
}

View File

@ -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, '/');

View File

@ -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)

View File

@ -0,0 +1,19 @@
.''''....''''.
.''... ...''.
''.. ..''
'.. ..''
.'. .,,'.. .',,,' ..'.
.'. .,,,,' .,,,,,' .'.
.'. .,,,,' .,,,,,. .'.
'.. .,,,,'',,,,;. .''
.'. .,,,,,,,;;. ..'
.'. .,,,,;;;;;${c2}, ${c1}..'.
'.. .,;;;,${c2}';;;;;, ${c1}..'
.'. .;;${c2};;' .;;:::: ${c1}.,.
'.. ${c2}.;;;;' .::::::. ${c1}.,'
'.. ${c2}.;;;;' .::::::. ${c1}.,${c2}'${c1}
.'.. ${c2}.',.
${c1}',.. ${c2}.','
${c1}.,,... ${c2}..',,.
..,,''........',,,.
......

18
src/logo/ascii/mx2.txt Normal file
View File

@ -0,0 +1,18 @@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@%*+--:------=+*%@@@@@@@@@@@@
@@@@@@@@@#=. .-+#%@@@@@%#*+--=#@@@@@@@@@
@@@@@@@+. .=%@@@@@@@@@@@@@@@@*-:+@@@@@@@
@@@@@*. *@@@@@@@@@@@@@@@@@@@@@%-.*@@@@@
@@@@- -@@@@@@@@@@@@@@@@@@@@@@@#: -@@@@
@@@: -@@@@@@@=.*@@@@@@@@@@@@%- = :@@@
@@= .@@@@@@@@%- :%@@@@@@@@@+ -%@# =@@
@% +@@@@@@@@@@#. =@@@@@@*. .*@@@@. %@
@+ *@@@@@@*..*@@+ *@@%- =@@@@@@- +@
@= *@@@@%- -%@@- := -%@@@@@@@: +@
@+ :@@@= +@@= .#@@@@@@@@% *@
@% +*. .: *@@#: +@@: @@
@@+ :%@- :- :: +@@
@@@- .=@@= -@@@
@@+. . +@@
%=..:.................::...........:..-%
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

View File

@ -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,
@ -875,7 +877,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,
@ -1241,9 +1243,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,
@ -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,
@ -2089,6 +2092,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"},
@ -2462,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,
@ -2649,7 +2662,7 @@ static const FFlogo M[] = {
},
// MX
{
.names = {"MX"},
.names = {"MX", "MX Linux"},
.lines = FASTFETCH_DATATEXT_LOGO_MX,
.colors = {
FF_COLOR_FG_WHITE,
@ -2659,7 +2672,8 @@ 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 = {
FF_COLOR_FG_WHITE,
@ -2667,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
{},
};
@ -2730,6 +2755,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,
@ -3301,6 +3327,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,
@ -3560,6 +3587,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,

View File

@ -1,6 +1,7 @@
#include "image.h"
#include "common/io/io.h"
#include "common/printing.h"
#include "util/stringUtils.h"
#include <limits.h>
#include <math.h>
@ -53,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;
}
@ -134,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)
@ -839,11 +849,27 @@ 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();
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)

View File

@ -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)

View File

@ -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);
}
}

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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);

View File

@ -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);
@ -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)
{

View File

@ -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);
}
}

View File

@ -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)
{

View File

@ -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);

View File

@ -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)

View File

@ -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