Skip to content

Commit

Permalink
Merge pull request fastfetch-cli#617 from fastfetch-cli/dev
Browse files Browse the repository at this point in the history
Release v2.2.3
  • Loading branch information
CarterLi authored Nov 8, 2023
2 parents 1837446 + ac654ff commit 22de71e
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 45 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2.2.3

Features:
* Update the latest mac models (Host, macOS)

Bugfixes:
* Fix local ips detection on Android. Regression from `2.0.0` (LocalIP, Android)
* Fix terminal detection on NixOS (Terminal)

# 2.2.2

Changes:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url

project(fastfetch
VERSION 2.2.2
VERSION 2.2.3
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
Expand Down
4 changes: 2 additions & 2 deletions src/data/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ Module specific options:
--localip-show-mac <?value>: Show mac addresses in local ip module. Default is false
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
--localip-name-prefix <str>: Show interfaces with given interface name prefix only. Default is empty
--localip-default-route-only <?value>: Show the interface that is used for default routing only. Default is true
--localip-default-route-only <?value>: Show the interface that is used for default routing only. Default is true on non-android platforms
--localip-compact <?value>: Show all IPs in one line. Default is false
--netio-name-prefix <str>: Show interfaces with given name prefix only. Default is empty
--netio-default-route-only <?value>: Show the interfac that is used for default routing only. Default is true
--netio-default-route-only <?value>: Show the interfac that is used for default routing only. Default is true on non-android platforms
--publicip-timeout <num>: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--publicip-url <str>: The URL of public IP detection server to be used.
--weather-location <str>: Set the location to be used. It must be URI encoded (eg a whitespace must be encoded as `+`).
Expand Down
9 changes: 9 additions & 0 deletions src/detection/host/host_apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ static const char* getProductName(const FFstrbuf* hwModel)
else if(ffStrbufStartsWithS(hwModel, "Mac"))
{
const char* version = hwModel->chars + strlen("Mac");
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)";
if(ffStrEquals(version, "15,6") ||
ffStrEquals(version, "15,8") ||
ffStrEquals(version, "15,10")) return "MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)";
if(ffStrEquals(version, "15,7") ||
ffStrEquals(version, "15,9") ||
ffStrEquals(version, "15,11")) return "MacBook Pro (16-inch, Nov 2023, Three Thunderbolt 4 ports)";
if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)";
if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)";
if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)";
Expand Down
7 changes: 1 addition & 6 deletions src/detection/memory/memory_apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ const char* ffDetectMemory(FFMemoryResult* ram)
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0))
return "Failed to read hw.memsize";

uint32_t pagesize;
length = sizeof(pagesize);
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pagesize, &length, NULL, 0))
return "Failed to read hw.pagesize";

mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
vm_statistics64_data_t vmstat;
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
return "Failed to read host_statistics64";

ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * pagesize;
ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * instance.state.platform.pageSize;

return NULL;
}
7 changes: 1 addition & 6 deletions src/detection/memory/memory_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ const char* ffDetectMemory(FFMemoryResult* ram)
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
return "Failed to read hw.physmem";

uint32_t pageSize;
length = sizeof(pageSize);
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pageSize, &length, NULL, 0))
return "Failed to read hw.pagesize";

// vm.stats.vm.* are int values
int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0)
+ ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0)
+ ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);

ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * pageSize;
ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * instance.state.platform.pageSize;

return NULL;
}
9 changes: 4 additions & 5 deletions src/detection/swap/swap_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

const char* ffDetectSwap(FFSwapResult* swap)
{
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);

ULONG size = sizeof(SYSTEM_PAGEFILE_INFORMATION);
SYSTEM_PAGEFILE_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PAGEFILE_INFORMATION*)malloc(size);
while(true)
Expand All @@ -24,8 +21,10 @@ const char* ffDetectSwap(FFSwapResult* swap)
return "NtQuerySystemInformation(SystemPagefileInformation, size) failed";
break;
}
swap->bytesUsed = (uint64_t)pstart->TotalUsed * sysInfo.dwPageSize;
swap->bytesTotal = (uint64_t)pstart->CurrentSize * sysInfo.dwPageSize;

uint32_t pageSize = instance.state.platform.pageSize;
swap->bytesUsed = (uint64_t)pstart->TotalUsed * pageSize;
swap->bytesTotal = (uint64_t)pstart->CurrentSize * pageSize;

return NULL;
}
4 changes: 2 additions & 2 deletions src/detection/terminalshell/terminalshell_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ const FFTerminalShellResult* ffDetectTerminalShell()
ffStrbufInitS(&result.shellPrettyName, result.shellExeName);
}

if(result.terminalExeName[0] == '.' && ffStrEndsWith(result.terminalExeName, "-wrapper"))
if(result.terminalExeName[0] == '.' && ffStrEndsWith(result.terminalExeName, "-wrapped"))
{
// For NixOS. Ref: #510 and https://github.com/NixOS/nixpkgs/pull/249428
// We use terminalProcessName when detecting version and font, overriding it for simplication
ffStrbufSetNS(
&result.terminalProcessName,
(uint32_t) (strlen(result.terminalExeName) - strlen(".-wrapper")),
(uint32_t) (strlen(result.terminalExeName) - strlen(".-wrapped")),
result.terminalExeName + 1);
}

Expand Down
54 changes: 36 additions & 18 deletions src/logo/image/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,45 @@
#include <windows.h>
#endif

static FFstrbuf base64Encode(const FFstrbuf* in)
// https://github.com/kostya/benchmarks/blob/master/base64/test-nolib.c#L145
static void base64EncodeRaw(uint32_t size, const char *str, uint32_t *out_size, char *output)
{
const char* base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

FFstrbuf out = ffStrbufCreateA(8 * (1 + in->length / 6));
static const char chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *out = output;
const char *ends = str + (size - size % 3);
while (str != ends) {
uint32_t n = __builtin_bswap32(*(uint32_t*) str);
*out++ = chars[(n >> 26) & 63];
*out++ = chars[(n >> 20) & 63];
*out++ = chars[(n >> 14) & 63];
*out++ = chars[(n >> 8) & 63];
str += 3;
}

unsigned val = 0;
int valb = -6;
for (uint32_t i = 0; i < in->length; ++i)
{
unsigned char c = (unsigned char) in->chars[i];
val = (val << 8) + c;
valb += 8;
while (valb >= 0)
{
ffStrbufAppendC(&out, base64Chars[(val>>valb)&0x3F]);
valb -= 6;
}
if (size % 3 == 1) {
uint64_t n = (uint64_t)*str << 16;
*out++ = chars[(n >> 18) & 63];
*out++ = chars[(n >> 12) & 63];
*out++ = '=';
*out++ = '=';
} else if (size % 3 == 2) {
uint64_t n = (uint64_t)*str++ << 16;
n |= (uint64_t)*str << 8;
*out++ = chars[(n >> 18) & 63];
*out++ = chars[(n >> 12) & 63];
*out++ = chars[(n >> 6) & 63];
*out++ = '=';
}
if (valb > -6) ffStrbufAppendC(&out, base64Chars[((val<<8)>>(valb+8))&0x3F]);
while (out.length % 4) ffStrbufAppendC(&out, '=');
*out = '\0';
*out_size = (uint32_t) (out - output);
}

static FFstrbuf base64Encode(const FFstrbuf* in)
{
FFstrbuf out = ffStrbufCreateA(10 + in->length * 4 / 3);
base64EncodeRaw(in->length, in->chars, &out.length, out.chars);
assert(out.length < out.allocated);

return out;
}

Expand Down
8 changes: 7 additions & 1 deletion src/modules/localip/localip.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,13 @@ void ffInitLocalIpOptions(FFLocalIpOptions* options)

options->showType = FF_LOCALIP_TYPE_IPV4_BIT;
ffStrbufInit(&options->namePrefix);
options->defaultRouteOnly = true;
options->defaultRouteOnly =
#ifdef __ANDROID__
false
#else
true
#endif
;
}

void ffDestroyLocalIpOptions(FFLocalIpOptions* options)
Expand Down
8 changes: 7 additions & 1 deletion src/modules/netio/netio.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,13 @@ void ffInitNetIOOptions(FFNetIOOptions* options)
ffOptionInitModuleArg(&options->moduleArgs);

ffStrbufInit(&options->namePrefix);
options->defaultRouteOnly = true;
options->defaultRouteOnly =
#ifdef __ANDROID__
false
#else
true
#endif
;
}

void ffDestroyNetIOOptions(FFNetIOOptions* options)
Expand Down
1 change: 1 addition & 0 deletions src/modules/title/title.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void ffGenerateTitleJsonResult(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_m
yyjson_mut_obj_add_strbuf(doc, obj, "homeDir", &instance.state.platform.homeDir);
yyjson_mut_obj_add_strbuf(doc, obj, "exePath", &instance.state.platform.exePath);
yyjson_mut_obj_add_strbuf(doc, obj, "userShell", &instance.state.platform.userShell);
yyjson_mut_obj_add_uint(doc, obj, "pageSize", instance.state.platform.pageSize);
}

void ffPrintTitleHelpFormat(void)
Expand Down
2 changes: 2 additions & 0 deletions src/util/platform/FFPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ typedef struct FFPlatform {
FFstrbuf systemVersion;
FFstrbuf systemArchitecture;
FFstrbuf systemDisplayVersion;

uint32_t pageSize;
} FFPlatform;

void ffPlatformInit(FFPlatform* platform);
Expand Down
13 changes: 13 additions & 0 deletions src/util/platform/FFPlatform_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#ifdef __APPLE__
#include <libproc.h>
#include <sys/sysctl.h>
#elif defined(__FreeBSD__)
#include <sys/sysctl.h>
#endif
Expand Down Expand Up @@ -153,6 +154,16 @@ static void getUserShell(FFPlatform* platform, const struct passwd* pwd)
ffStrbufAppendS(&platform->userShell, shell);
}

static void getPageSize(FFPlatform* platform)
{
#if defined(__FreeBSD__) || defined(__APPLE__)
size_t length = sizeof(platform->pageSize);
sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &platform->pageSize, &length, NULL, 0);
#else
platform->pageSize = (uint32_t) sysconf(_SC_PAGESIZE);
#endif
}

void ffPlatformInitImpl(FFPlatform* platform)
{
struct passwd* pwd = getpwuid(getuid());
Expand All @@ -176,4 +187,6 @@ void ffPlatformInitImpl(FFPlatform* platform)
ffStrbufAppendS(&platform->systemVersion, uts.version);
ffStrbufAppendS(&platform->systemArchitecture, uts.machine);
ffStrbufInit(&platform->systemDisplayVersion);

getPageSize(platform);
}
8 changes: 5 additions & 3 deletions src/util/platform/FFPlatform_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ static void getSystemReleaseAndVersion(FFPlatform* platform)
}
}

static void getSystemArchitecture(FFPlatform* platform)
static void getSystemArchitectureAndPageSize(FFPlatform* platform)
{
SYSTEM_INFO sysInfo = {0};
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);

switch(sysInfo.wProcessorArchitecture)
Expand Down Expand Up @@ -215,6 +215,8 @@ static void getSystemArchitecture(FFPlatform* platform)
default:
break;
}

platform->pageSize = sysInfo.dwPageSize;
}

void ffPlatformInitImpl(FFPlatform* platform)
Expand All @@ -230,5 +232,5 @@ void ffPlatformInitImpl(FFPlatform* platform)
getUserShell(platform);

getSystemReleaseAndVersion(platform);
getSystemArchitecture(platform);
getSystemArchitectureAndPageSize(platform);
}

0 comments on commit 22de71e

Please sign in to comment.