Skip to content

Commit

Permalink
Merge pull request #851 from fastfetch-cli/dev
Browse files Browse the repository at this point in the history
Release: v2.11.2
  • Loading branch information
CarterLi committed May 3, 2024
2 parents 757e627 + 83c1fe2 commit b12a59c
Show file tree
Hide file tree
Showing 31 changed files with 291 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/logo_request.md
Expand Up @@ -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
Expand Down
30 changes: 27 additions & 3 deletions CHANGELOG.md
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion 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"
Expand Down
11 changes: 4 additions & 7 deletions doc/fastfetch.1.in
Expand Up @@ -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:

Expand All @@ -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"
Expand Down
10 changes: 2 additions & 8 deletions src/common/processing.h
Expand Up @@ -8,20 +8,14 @@ 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;
}

static inline const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const argv[])
{
const char* error = ffProcessAppendOutput(buffer, argv, true);
if (!error)
{
ffStrbufTrimRight(buffer, '\n');
ffStrbufTrimRight(buffer, ' ');
}
ffStrbufTrimRightSpace(buffer);
return error;
}
52 changes: 24 additions & 28 deletions 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 <stdlib.h>
#ifdef _WIN32
Expand Down Expand Up @@ -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++)
FF_AUTO_FREE char* line = NULL;
size_t len = 0;

while (getline(&line, &len, file) != -1)
{
if(!unsetValues[i])
continue;
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;
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;
Expand Down
3 changes: 0 additions & 3 deletions src/detection/battery/battery_linux.c
Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion src/detection/gpu/gpu_linux.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
50 changes: 34 additions & 16 deletions src/detection/os/os_linux.c
Expand Up @@ -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},
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},
{"DISTRIB_ID =", &result->id},
{"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},
Expand Down Expand Up @@ -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");
Expand All @@ -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))
return;
// 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);
}

parseFile(FASTFETCH_TARGET_DIR_USR"/lib/os-release", os);
if(allRelevantValuesSet(os))
if(parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os))
return;

parseFile(FASTFETCH_TARGET_DIR_ETC"/lsb-release", os);
parseOsRelease(FASTFETCH_TARGET_DIR_USR "/lib/os-release", os);
}

void ffDetectOSImpl(FFOSResult* os)
Expand Down
31 changes: 30 additions & 1 deletion src/detection/packages/packages_linux.c
Expand Up @@ -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");
}
2 changes: 1 addition & 1 deletion src/detection/publicip/publicip.c
Expand Up @@ -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, '/');

Expand Down
5 changes: 4 additions & 1 deletion src/detection/terminalshell/terminalshell.c
Expand Up @@ -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)
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions 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}..',,.
..,,''........',,,.
......

0 comments on commit b12a59c

Please sign in to comment.