Skip to content

Commit

Permalink
Merge pull request #758 from fastfetch-cli/dev
Browse files Browse the repository at this point in the history
Release: v2.8.9
  • Loading branch information
CarterLi committed Mar 15, 2024
2 parents 912f6c4 + 72fee13 commit d5b91a8
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 90 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Expand Up @@ -245,8 +245,7 @@ jobs:

- name: install required packages
run: |
brew update
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install vulkan-loader vulkan-headers molten-vk imagemagick chafa
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install --overwrite vulkan-loader vulkan-headers molten-vk imagemagick chafa
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,16 @@
# 2.8.9

Bugfixes:
* Don't detect `SessionLeader` as terminal, actually (Terminal, Linux)
* Fix blurry chafa result when specifying both width and height (#757, Logo)

Features:
* Support new MacBook Air (Host, macOS)
* Distinguish min frequency and base frequency (CPU)

Logo:
* Fix proxmox

# 2.8.8

Bugfixes:
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.8.8
VERSION 2.8.9
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
fastfetch (2.8.8) jammy; urgency=medium

* Update to 2.8.8

-- Carter Li <zhangsongcui@live.cn> Fri, 08 Mar 2024 09:59:41 +0800

fastfetch (2.8.6) jammy; urgency=medium

* Update to 2.8.6
Expand Down
2 changes: 1 addition & 1 deletion debian/files
@@ -1 +1 @@
fastfetch_2.8.6_source.buildinfo universe/utils optional
fastfetch_2.8.8_source.buildinfo universe/utils optional
Binary file modified screenshots/example1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/detection/cpu/cpu.h
Expand Up @@ -13,10 +13,12 @@ typedef struct FFCPUResult
uint16_t coresLogical;
uint16_t coresOnline;

double frequencyMin; // GHz
double frequencyBase; // GHz
double frequencyMax; // GHz
double frequencyMin; // GHz

double temperature;
} FFCPUResult;

const char* ffCPUDetectByCpuid(FFCPUResult* cpu);
const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu);
3 changes: 1 addition & 2 deletions src/detection/cpu/cpu_apple.c
Expand Up @@ -60,14 +60,13 @@ static const char* detectFrequency(FFCPUResult* cpu)
ffCfDictGetData(properties, CFSTR("voltage-states5-sram"), pCoreLength - 8, 4, (uint8_t*) &aMax, NULL);
cpu->frequencyMax = aMax / (1000.0 * 1000 * 1000);
}
else
cpu->frequencyMax = 0.0;

return NULL;
}
#else
static const char* detectFrequency(FFCPUResult* cpu)
{
cpu->frequencyBase = ffSysctlGetInt64("hw.cpufrequency", 0) / 1000.0 / 1000.0 / 1000.0;
cpu->frequencyMin = ffSysctlGetInt64("hw.cpufrequency_min", 0) / 1000.0 / 1000.0 / 1000.0;
cpu->frequencyMax = ffSysctlGetInt64("hw.cpufrequency_max", 0);
if(cpu->frequencyMax > 0.0)
Expand Down
3 changes: 1 addition & 2 deletions src/detection/cpu/cpu_bsd.c
Expand Up @@ -11,8 +11,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
cpu->coresLogical = cpu->coresPhysical;
cpu->coresOnline = cpu->coresPhysical;

cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0;
cpu->frequencyMax = cpu->frequencyMin;
cpu->frequencyBase = ffSysctlGetInt("hw.clockrate", 0) / 1000.0;
cpu->temperature = FF_CPU_TEMP_UNSET;

if (options->temp)
Expand Down
50 changes: 30 additions & 20 deletions src/detection/cpu/cpu_linux.c
Expand Up @@ -94,11 +94,14 @@ static double getFrequency(FFstrbuf* basePath, const char* cpuinfoFileName, cons
if (ok)
return ffStrbufToDouble(buffer) / 1e6;

ffStrbufAppendS(basePath, scalingFileName);
ok = ffReadFileBuffer(basePath->chars, buffer);
ffStrbufSubstrBefore(basePath, baseLen);
if (ok)
return ffStrbufToDouble(buffer) / 1e6;
if (scalingFileName)
{
ffStrbufAppendS(basePath, scalingFileName);
ok = ffReadFileBuffer(basePath->chars, buffer);
ffStrbufSubstrBefore(basePath, baseLen);
if (ok)
return ffStrbufToDouble(buffer) / 1e6;
}

return 0.0/0.0;
}
Expand All @@ -111,34 +114,41 @@ static bool detectFrequency(FFCPUResult* cpu)

FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
uint32_t baseLen = path.length;
bool flag = false;

struct dirent* entry;
while((entry = readdir(dir)) != NULL)
{
if (ffStrStartsWith(entry->d_name, "policy") && isdigit(entry->d_name[strlen("policy")]))
{
ffStrbufAppendS(&path, entry->d_name);
double fmin = getFrequency(&path, "/cpuinfo_min_freq", "/scaling_min_freq", &buffer);
if (fmin != fmin) continue;
double fbase = getFrequency(&path, "/base_frequency", NULL, &buffer);
if (fbase == fbase)
{
if (cpu->frequencyBase == cpu->frequencyBase)
cpu->frequencyBase = cpu->frequencyBase > fbase ? cpu->frequencyBase : fbase;
else
cpu->frequencyBase = fbase;
}
double fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
if (fmax != fmax) continue;

if (flag)
if (fmax == fmax)
{
cpu->frequencyMin = cpu->frequencyMin < fmin ? cpu->frequencyMin : fmin;
cpu->frequencyMax = cpu->frequencyMax > fmax ? cpu->frequencyMax : fmax;
if (cpu->frequencyMax == cpu->frequencyMax)
cpu->frequencyMax = cpu->frequencyMax > fmax ? cpu->frequencyMax : fmax;
else
cpu->frequencyMax = fmax;
}
else
double fmin = getFrequency(&path, "/cpuinfo_min_freq", "/scaling_min_freq", &buffer);
if (fmin == fmin)
{
cpu->frequencyMin = fmin;
cpu->frequencyMax = fmax;
flag = true;
if (cpu->frequencyMin == cpu->frequencyMin)
cpu->frequencyMin = cpu->frequencyMin < fmin ? cpu->frequencyMin : fmin;
else
cpu->frequencyMin = fmin;
}
ffStrbufSubstrBefore(&path, baseLen);
}
}
return flag;
return true;
}

static double detectCPUTemp(void)
Expand Down Expand Up @@ -234,8 +244,8 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
cpu->coresOnline = (uint16_t) get_nprocs();
cpu->coresPhysical = (uint16_t) ffStrbufToUInt(&physicalCoresBuffer, cpu->coresLogical);

if (!detectFrequency(cpu))
cpu->frequencyMin = cpu->frequencyMax = ffStrbufToDouble(&cpuMHz) / 1000;
if (!detectFrequency(cpu) || cpu->frequencyBase != cpu->frequencyBase)
cpu->frequencyBase = ffStrbufToDouble(&cpuMHz) / 1000;

if(cpuUarch.length > 0)
{
Expand Down
79 changes: 46 additions & 33 deletions src/detection/cpu/cpu_windows.c
Expand Up @@ -64,75 +64,88 @@ static const char* detectMaxSpeedBySmbios(FFCPUResult* cpu)
return "No active CPU is found in SMBIOS data";
}

double speed;
if (data->MaxSpeed > 0 && data->MaxSpeed < 30000) // VMware reports weird values
speed = data->MaxSpeed / 1000.0;
else
speed = data->CurrentSpeed / 1000.0;
{
double speed = data->MaxSpeed / 1000.0;
if (cpu->frequencyBase < speed)
cpu->frequencyMax = speed;
}

if (cpu->frequencyMax < speed)
cpu->frequencyMax = speed;

return NULL;
}

static const char* detectByOS(FFCPUResult* cpu)
static const char* detectNCores(FFCPUResult* cpu)
{
DWORD length = 0;
GetLogicalProcessorInformationEx(RelationAll, NULL, &length);
if (length == 0)
return "GetLogicalProcessorInformationEx(RelationAll, NULL, &length) failed";

SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);

if (!pProcessorInfo || !GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length))
return "GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length) failed";

for(
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pProcessorInfo;
(uint8_t*)ptr < ((uint8_t*)pProcessorInfo) + length;
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((uint8_t*)ptr) + ptr->Size)
)
{
DWORD length = 0;
GetLogicalProcessorInformationEx(RelationAll, NULL, &length);
if (length == 0)
return "GetLogicalProcessorInformationEx(RelationAll, NULL, &length) failed";

SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);

if (pProcessorInfo && GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length))
if(ptr->Relationship == RelationProcessorCore)
++cpu->coresPhysical;
else if(ptr->Relationship == RelationGroup)
{
for(
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pProcessorInfo;
(uint8_t*)ptr < ((uint8_t*)pProcessorInfo) + length;
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((uint8_t*)ptr) + ptr->Size)
)
for (uint32_t index = 0; index < ptr->Group.ActiveGroupCount; ++index)
{
if(ptr->Relationship == RelationProcessorCore)
++cpu->coresPhysical;
else if(ptr->Relationship == RelationGroup)
{
cpu->coresOnline += ptr->Group.GroupInfo->ActiveProcessorCount;
cpu->coresLogical += ptr->Group.GroupInfo->MaximumProcessorCount;
}
cpu->coresOnline += ptr->Group.GroupInfo[index].ActiveProcessorCount;
cpu->coresLogical += ptr->Group.GroupInfo[index].MaximumProcessorCount;
}
}
else
return "GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length) failed";
}

return NULL;
}

static const char* detectByRegistry(FFCPUResult* cpu)
{
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL))
return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, NULL) failed";

{
uint32_t mhz;
if(ffRegReadUint(hKey, L"~MHz", &mhz, NULL))
cpu->frequencyMin = cpu->frequencyMax = mhz / 1000.0;
cpu->frequencyBase = mhz / 1000.0;
}

ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL);
ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL);

if (cpu->coresLogical == 0)
{
DWORD cores;
if (RegQueryInfoKeyW(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor", NULL, NULL, &cores, NULL, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
cpu->coresOnline = cpu->coresPhysical = cpu->coresLogical = (uint16_t) cores;
}

return NULL;
}

const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
{
const char* error = detectByOS(cpu);
detectNCores(cpu);

const char* error = detectByRegistry(cpu);
if (error)
return error;

detectMaxSpeedBySmbios(cpu);

if(options->temp)
ffDetectSmbiosTemp(&cpu->temperature, NULL);

detectMaxSpeedBySmbios(cpu);
return NULL;
}
2 changes: 2 additions & 0 deletions src/detection/host/host_apple.c
Expand Up @@ -111,6 +111,8 @@ static const char* getProductNameWithHwModel(const FFstrbuf* hwModel)
else if(ffStrbufStartsWithS(hwModel, "Mac"))
{
const char* version = hwModel->chars + strlen("Mac");
if(ffStrEquals(version, "15,13")) return "MacBook Air (15-inch, M3, 2024)";
if(ffStrEquals(version, "15,2")) return "MacBook Air (13-inch, M3, 2024)";
if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)";
if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)";
if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)";
Expand Down
2 changes: 1 addition & 1 deletion src/detection/terminalshell/terminalshell_linux.c
Expand Up @@ -231,7 +231,6 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
ffStrEquals(name, "ltrace") ||
ffStrEquals(name, "perf") ||
ffStrEquals(name, "guake-wrapped") ||
ffStrEquals(name, "SessionLeader") || // #750
ffStrContainsIgnCase(name, "debug") ||
ffStrContainsIgnCase(name, "not-found") ||
ffStrEndsWith(name, ".sh")
Expand Down Expand Up @@ -342,6 +341,7 @@ static void getTerminalFromEnv(FFTerminalResult* result)
!ffStrbufEqualS(&result->processName, "systemd") &&
!ffStrbufEqualS(&result->processName, "init") &&
!ffStrbufEqualS(&result->processName, "(init)") &&
!ffStrbufEqualS(&result->processName, "SessionLeader") && // #750
#endif

!ffStrbufEqualS(&result->processName, "0")
Expand Down
8 changes: 3 additions & 5 deletions src/fastfetch.c
@@ -1,20 +1,15 @@
#include "fastfetch.h"
#include "common/commandoption.h"
#include "common/printing.h"
#include "common/parsing.h"
#include "common/io/io.h"
#include "common/time.h"
#include "common/jsonconfig.h"
#include "detection/version/version.h"
#include "util/stringUtils.h"
#include "util/mallocHelper.h"
#include "logo/logo.h"
#include "fastfetch_datatext.h"

#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <inttypes.h>

#ifdef WIN32
#include "util/windows/getline.h"
Expand Down Expand Up @@ -824,7 +819,10 @@ static void run(FFdata* data)
ffPrintCommandOption(data, instance.state.resultDoc);

if (instance.state.resultDoc)
{
yyjson_mut_write_fp(stdout, instance.state.resultDoc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL);
putchar('\n');
}
else
ffFinish();
}
Expand Down
22 changes: 11 additions & 11 deletions src/logo/builtin.c
Expand Up @@ -3299,6 +3299,17 @@ static const FFlogo P[] = {
FF_COLOR_FG_WHITE,
},
},
// Proxmox
{
.names = {"proxmox"},
.lines = FASTFETCH_DATATEXT_LOGO_PROXMOX,
.colors = {
FF_COLOR_FG_WHITE,
FF_COLOR_FG_256 "202"
},
.colorKeys = FF_COLOR_FG_WHITE,
.colorTitle = FF_COLOR_FG_256 "202",
},
// PuffOS
{
.names = {"PuffOS"},
Expand Down Expand Up @@ -3558,17 +3569,6 @@ static const FFlogo R[] = {
.colorKeys = FF_COLOR_FG_BLUE,
.colorTitle = FF_COLOR_FG_BLUE,
},
// Proxmox
{
.names = {"proxmox"},
.lines = FASTFETCH_DATATEXT_LOGO_PROXMOX,
.colors = {
FF_COLOR_FG_WHITE,
FF_COLOR_FG_256 "202"
},
.colorKeys = FF_COLOR_FG_WHITE,
.colorTitle = FF_COLOR_FG_256 "202",
},
// LAST
{},
};
Expand Down

0 comments on commit d5b91a8

Please sign in to comment.