Merge pull request #1086 from fastfetch-cli/dev

Release: v2.18.1
This commit is contained in:
Carter Li 2024-07-11 10:43:24 +08:00 committed by GitHub
commit efd9e94138
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 131 additions and 98 deletions

View File

@ -416,9 +416,9 @@ jobs:
with:
operating_system: freebsd
architecture: x86-64
cpu_count: 3
cpu_count: 4
shell: bash
version: '13.2'
version: '14.1'
run: |
uname -a
sudo pkg update

View File

@ -1,3 +1,14 @@
# 2.18.1
Fix a regression introduced in v2.18.0
Changes:
* `--ts-version` has been renamed to `--detect-version`
* `general.detectVersion` in JSON config file
Bugfixes:
* Fix and improve GPU driver detection (#1084, GPU, Linux)
# 2.18.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.18.0
VERSION 2.18.1
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"

View File

@ -339,6 +339,11 @@
"type": "string",
"description": "Set the command to be executed before printing logos",
"default": ""
},
"showVersion": {
"type": "boolean",
"description": "Whether to detect and display component versions. Mainly for benchmarking",
"default": true
}
}
},
@ -573,11 +578,6 @@
"type": "boolean",
"description": "Whether to disable the stdout application buffer",
"default": false
},
"tsVersion": {
"type": "boolean",
"description": "Whether to detect and display the version of terminal, shell and editor. Mainly for benchmarking",
"default": true
}
}
},

View File

@ -148,6 +148,16 @@
"false": "Try `wayland`, then `x11`, then `drm`"
}
}
},
{
"long": "detect-version",
"desc": "Whether to detect and display the version of terminal, shell and editor",
"remark": "Mainly for benchmarking",
"arg": {
"type": "bool",
"optional": true,
"default": true
}
}
],
"Logo": [
@ -725,16 +735,6 @@
"type": "color",
"default": "light_red"
}
},
{
"long": "ts-version",
"desc": "Whether to detect and display the version of terminal, shell and editor",
"remark": "Mainly for benchmarking",
"arg": {
"type": "bool",
"optional": true,
"default": true
}
}
],
"Library path": [

View File

@ -180,6 +180,8 @@ static void getBudgie(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options)
const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOptions* options)
{
if (!instance.config.general.detectVersion) return "Disabled by config";
if (ffStrbufEqualS(deName, FF_DE_PRETTY_PLASMA))
getKDE(result, options);
else if (ffStrbufEqualS(deName, FF_DE_PRETTY_GNOME))

View File

@ -26,7 +26,7 @@ const char* ffDetectEditor(FFEditorResult* result)
return "$VISUAL or $EDITOR not set";
}
if (!instance.config.display.tsVersion) return NULL;
if (!instance.config.general.detectVersion) return NULL;
#ifndef _WIN32
if (result->name.chars[0] != '/')

View File

@ -32,29 +32,42 @@
static bool pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey)
{
uint32_t pciDirLength = pciDir->length;
ffStrbufAppendS(pciDir, "/driver");
char pathBuf[PATH_MAX];
ssize_t resultLength = readlink(pciDir->chars, pathBuf, sizeof(pathBuf));
if(resultLength > 0)
{
const char* slash = memrchr(pathBuf, '/', (size_t) resultLength);
if (slash)
{
slash++;
ffStrbufSetNS(&gpu->driver, (uint32_t) (resultLength - (slash - pathBuf)), slash);
}
if(resultLength <= 0) return false;
const char* slash = memrchr(pathBuf, '/', (size_t) resultLength);
if (slash)
{
slash++;
ffStrbufSetNS(&gpu->driver, (uint32_t) (resultLength - (slash - pathBuf)), slash);
}
if (instance.config.general.detectVersion)
{
ffStrbufAppendS(pciDir, "/module/version");
if (ffReadFileBuffer(pciDir->chars, buffer))
{
ffStrbufTrimRightSpace(buffer);
ffStrbufAppendC(&gpu->driver, ' ');
ffStrbufAppend(&gpu->driver, buffer);
return true;
}
else if (ffStrbufEqualS(&gpu->driver, "zx"))
{
ffStrbufSubstrBefore(pciDir, pciDirLength);
ffStrbufAppendS(pciDir, "/zx_info/driver_version");
if (ffReadFileBuffer(pciDir->chars, buffer))
{
ffStrbufTrimRightSpace(buffer);
ffStrbufAppendC(&gpu->driver, ' ');
ffStrbufAppend(&gpu->driver, buffer);
}
}
}
return false;
return true;
}
static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer)
@ -198,6 +211,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
if (!ffStrbufStartsWithC(buffer, '1'))
return "GPU disabled";
}
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
ffStrbufInitStatic(&gpu->vendor, ffGetGPUVendorString((uint16_t) vendorId));

View File

@ -78,12 +78,15 @@ const char* ffDetectHost(FFHostResult* host)
ffStrbufAppendF(&host->name, " - %s", wslDistroName);
ffStrbufAppendS(&host->family, "WSL");
ffProcessAppendStdOut(&host->version, (char* const[]){
"wslinfo",
"--wsl-version",
"-n",
NULL,
}); // supported in 2.2.3 and later
if (instance.config.general.detectVersion)
{
ffProcessAppendStdOut(&host->version, (char* const[]){
"wslinfo",
"--wsl-version",
"-n",
NULL,
}); // supported in 2.2.3 and later
}
}
}

View File

@ -17,38 +17,41 @@ const char* ffDetectInitSystem(FFInitSystemResult* result)
ffStrbufSetS(&result->exe, buf);
}
if (ffStrbufEqualS(&result->name, "systemd"))
if (instance.config.general.detectVersion)
{
if (ffProcessAppendStdOut(&result->version, (char* const[]) {
ffStrbufEndsWithS(&result->exe, "/systemd") ? result->exe.chars : "systemctl", // use exe path in case users have another systemd installed
"--version",
NULL,
}) == NULL && result->version.length)
if (ffStrbufEqualS(&result->name, "systemd"))
{
uint32_t iStart = ffStrbufFirstIndexC(&result->version, '(');
if (iStart < result->version.length)
if (ffProcessAppendStdOut(&result->version, (char* const[]) {
ffStrbufEndsWithS(&result->exe, "/systemd") ? result->exe.chars : "systemctl", // use exe path in case users have another systemd installed
"--version",
NULL,
}) == NULL && result->version.length)
{
uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ')');
ffStrbufSubstrBefore(&result->version, iEnd);
ffStrbufSubstrAfter(&result->version, iStart);
uint32_t iStart = ffStrbufFirstIndexC(&result->version, '(');
if (iStart < result->version.length)
{
uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ')');
ffStrbufSubstrBefore(&result->version, iEnd);
ffStrbufSubstrAfter(&result->version, iStart);
}
}
}
}
else if (ffStrbufEqualS(&result->name, "launchd"))
{
if (ffProcessAppendStdOut(&result->version, (char* const[]) {
"/bin/launchctl",
"version",
NULL,
}) == NULL && result->version.length)
else if (ffStrbufEqualS(&result->name, "launchd"))
{
uint32_t iStart = ffStrbufFirstIndexS(&result->version, "Version ");
if (iStart < result->version.length)
if (ffProcessAppendStdOut(&result->version, (char* const[]) {
"/bin/launchctl",
"version",
NULL,
}) == NULL && result->version.length)
{
iStart += (uint32_t) strlen("Version");
uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ':');
ffStrbufSubstrBefore(&result->version, iEnd);
ffStrbufSubstrAfter(&result->version, iStart);
uint32_t iStart = ffStrbufFirstIndexS(&result->version, "Version ");
if (iStart < result->version.length)
{
iStart += (uint32_t) strlen("Version");
uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ':');
ffStrbufSubstrBefore(&result->version, iEnd);
ffStrbufSubstrAfter(&result->version, iStart);
}
}
}
}

View File

@ -163,16 +163,19 @@ const char* ffDetectLM(FFLMResult* result)
}))
return "Failed to parse " FF_SYSTEMD_SESSIONS_PATH "$XDG_SESSION_ID";
if (ffStrbufStartsWithS(&result->service, "gdm"))
getGdmVersion(&result->version);
else if (ffStrbufStartsWithS(&result->service, "sddm"))
getSddmVersion(&result->version);
else if (ffStrbufStartsWithS(&result->service, "xfwm"))
getXfwmVersion(&result->version);
else if (ffStrbufStartsWithS(&result->service, "lightdm"))
getLightdmVersion(&result->version);
else if (ffStrbufStartsWithS(&result->service, "sshd"))
getSshdVersion(&result->version);
if (instance.config.general.detectVersion)
{
if (ffStrbufStartsWithS(&result->service, "gdm"))
getGdmVersion(&result->version);
else if (ffStrbufStartsWithS(&result->service, "sddm"))
getSddmVersion(&result->version);
else if (ffStrbufStartsWithS(&result->service, "xfwm"))
getXfwmVersion(&result->version);
else if (ffStrbufStartsWithS(&result->service, "lightdm"))
getLightdmVersion(&result->version);
else if (ffStrbufStartsWithS(&result->service, "sshd"))
getSshdVersion(&result->version);
}
// Correct char cases
if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_WAYLAND))

View File

@ -226,7 +226,7 @@ static bool getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf*
bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
{
if (!instance.config.display.tsVersion) return false;
if (!instance.config.general.detectVersion) return false;
if(ffStrEqualsIgnCase(exeName, "sh")) // #849
return false;
@ -546,7 +546,7 @@ static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version)
bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version)
{
if (!instance.config.display.tsVersion) return false;
if (!instance.config.general.detectVersion) return false;
#ifdef __ANDROID__

View File

@ -99,21 +99,24 @@ static void setShellInfoDetails(FFShellResult* result)
{
ffStrbufSetS(&result->prettyName, "CMD");
FF_AUTO_CLOSE_FD HANDLE snapshot = NULL;
while(!(snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, result->pid)) && GetLastError() == ERROR_BAD_LENGTH) {}
if(snapshot)
if (instance.config.general.detectVersion)
{
MODULEENTRY32W module;
module.dwSize = sizeof(module);
for(BOOL success = Module32FirstW(snapshot, &module); success; success = Module32NextW(snapshot, &module))
FF_AUTO_CLOSE_FD HANDLE snapshot = NULL;
while(!(snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, result->pid)) && GetLastError() == ERROR_BAD_LENGTH) {}
if(snapshot)
{
if(wcsncmp(module.szModule, L"clink_dll_", strlen("clink_dll_")) == 0)
MODULEENTRY32W module;
module.dwSize = sizeof(module);
for(BOOL success = Module32FirstW(snapshot, &module); success; success = Module32NextW(snapshot, &module))
{
ffStrbufAppendS(&result->prettyName, " (with Clink ");
getProductVersion(module.szExePath, &result->prettyName);
ffStrbufAppendC(&result->prettyName, ')');
break;
if(wcsncmp(module.szModule, L"clink_dll_", strlen("clink_dll_")) == 0)
{
ffStrbufAppendS(&result->prettyName, " (with Clink ");
getProductVersion(module.szExePath, &result->prettyName);
ffStrbufAppendC(&result->prettyName, ')');
break;
}
}
}
}

View File

@ -29,7 +29,7 @@ void ffPrintInitSystem(FFInitSystemOptions* options)
ffPrintLogoAndKey(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufWriteTo(&result.name, stdout);
if (result.version.length)
printf(" (%s)\n", result.version.chars);
printf(" %s\n", result.version.chars);
else
putchar('\n');
}

View File

@ -200,7 +200,7 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
else if (ffStrEqualsIgnCase(key, "keyWidth"))
options->keyWidth = (uint32_t) yyjson_get_uint(val);
else if (ffStrEqualsIgnCase(key, "tsVersion"))
options->tsVersion = yyjson_get_bool(val);
return "display.tsVersion has been renamed to general.detectVersion";
else
return "Unknown display property";
}
@ -357,8 +357,6 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
else
return false;
}
else if(ffStrEqualsIgnCase(key, "--ts-version"))
options->tsVersion = ffOptionParseBoolean(value);
else
return false;
return true;
@ -406,8 +404,6 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
ffStrbufInitStatic(&options->percentColorGreen, FF_COLOR_FG_GREEN);
ffStrbufInitStatic(&options->percentColorYellow, instance.state.terminalLightTheme ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_LIGHT_YELLOW);
ffStrbufInitStatic(&options->percentColorRed, instance.state.terminalLightTheme ? FF_COLOR_FG_RED : FF_COLOR_FG_LIGHT_RED);
options->tsVersion = true;
}
void ffOptionsDestroyDisplay(FFOptionsDisplay* options)

View File

@ -53,7 +53,6 @@ typedef struct FFOptionsDisplay
FFstrbuf percentColorRed;
bool noBuffer;
uint32_t keyWidth;
bool tsVersion;
} FFOptionsDisplay;
const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_val* root);

View File

@ -36,6 +36,8 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va
if (error)
return "Failed to execute preRun command";
}
else if (ffStrEqualsIgnCase(key, "detectVersion"))
options->detectVersion = yyjson_get_bool(val);
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
else if (ffStrEqualsIgnCase(key, "escapeBedrock"))
@ -66,13 +68,6 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va
options->wmiTimeout = (int32_t) yyjson_get_int(val);
#endif
else if (ffStrEqualsIgnCase(key, "stat"))
return "Property `general.stat` has been changed to `display.stat`";
else if (ffStrEqualsIgnCase(key, "pipe"))
return "Property `general.pipe` has been changed to `display.pipe`";
else if (ffStrEqualsIgnCase(key, "allowSlowOperations"))
return "Property `general.allowSlowOperations` has been obsoleted. See CHANGELOG for detail";
else
return "Unknown general property";
}
@ -86,6 +81,8 @@ bool ffOptionsParseGeneralCommandLine(FFOptionsGeneral* options, const char* key
options->multithreading = ffOptionParseBoolean(value);
else if(ffStrEqualsIgnCase(key, "--processing-timeout"))
options->processingTimeout = ffOptionParseInt32(key, value);
else if(ffStrEqualsIgnCase(key, "--detect-version"))
options->detectVersion = ffOptionParseBoolean(value);
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
else if(ffStrEqualsIgnCase(key, "--escape-bedrock"))
@ -116,6 +113,7 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options)
{
options->processingTimeout = 1000;
options->multithreading = true;
options->detectVersion = true;
#if defined(__linux__) || defined(__FreeBSD__)
options->escapeBedrock = true;

View File

@ -13,6 +13,7 @@ typedef struct FFOptionsGeneral
{
bool multithreading;
int32_t processingTimeout;
bool detectVersion;
// Module options that cannot be put in module option structure
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)