Compare commits

...

8 Commits

Author SHA1 Message Date
Carter Li 22de71efeb Merge pull request #617 from fastfetch-cli/dev
Release v2.2.3
2023-11-08 12:33:16 +08:00
李通洲 ac654ff346 Host (macOS): update the latest models 2023-11-08 10:43:17 +08:00
李通洲 df2fdf05e6 Release v2.2.3 2023-11-08 10:14:31 +08:00
李通洲 788307e98d Doc: update changelog 2023-11-08 09:11:16 +08:00
李通洲 f93341ac61 TerminalShell: fix terminal name detection on NixOS
oops. No one report that...
2023-11-08 09:02:52 +08:00
李通洲 3e0d97db2e Platform: detect system page size 2023-11-08 00:10:16 +08:00
李通洲 864e707224 LocalIP (Android): don't set --default-route-only to true by default on Android
As we can't detect default route on that platform
2023-11-07 20:17:08 +08:00
李通洲 c42b68404f Logo (Image): try improving performace of base64 encoding 2023-11-07 19:04:16 +08:00
15 changed files with 100 additions and 45 deletions
+9
View File
@@ -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:
+1 -1
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.2.2
VERSION 2.2.3
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
+2 -2
View File
@@ -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 `+`).
+9
View File
@@ -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)";
+1 -6
View File
@@ -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;
}
+1 -6
View File
@@ -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;
}
+4 -5
View File
@@ -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)
@@ -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;
}
@@ -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);
}
+36 -18
View File
@@ -11,27 +11,45 @@
#include <windows.h>
#endif
// 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)
{
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;
}
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++ = '=';
}
*out = '\0';
*out_size = (uint32_t) (out - output);
}
static FFstrbuf base64Encode(const FFstrbuf* in)
{
const char* base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
FFstrbuf out = ffStrbufCreateA(10 + in->length * 4 / 3);
base64EncodeRaw(in->length, in->chars, &out.length, out.chars);
assert(out.length < out.allocated);
FFstrbuf out = ffStrbufCreateA(8 * (1 + in->length / 6));
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 (valb > -6) ffStrbufAppendC(&out, base64Chars[((val<<8)>>(valb+8))&0x3F]);
while (out.length % 4) ffStrbufAppendC(&out, '=');
return out;
}
+7 -1
View File
@@ -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)
+7 -1
View File
@@ -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)
+1
View File
@@ -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)
+2
View File
@@ -22,6 +22,8 @@ typedef struct FFPlatform {
FFstrbuf systemVersion;
FFstrbuf systemArchitecture;
FFstrbuf systemDisplayVersion;
uint32_t pageSize;
} FFPlatform;
void ffPlatformInit(FFPlatform* platform);
+13
View File
@@ -10,6 +10,7 @@
#ifdef __APPLE__
#include <libproc.h>
#include <sys/sysctl.h>
#elif defined(__FreeBSD__)
#include <sys/sysctl.h>
#endif
@@ -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());
@@ -176,4 +187,6 @@ void ffPlatformInitImpl(FFPlatform* platform)
ffStrbufAppendS(&platform->systemVersion, uts.version);
ffStrbufAppendS(&platform->systemArchitecture, uts.machine);
ffStrbufInit(&platform->systemDisplayVersion);
getPageSize(platform);
}
+5 -3
View File
@@ -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)
@@ -215,6 +215,8 @@ static void getSystemArchitecture(FFPlatform* platform)
default:
break;
}
platform->pageSize = sysInfo.dwPageSize;
}
void ffPlatformInitImpl(FFPlatform* platform)
@@ -230,5 +232,5 @@ void ffPlatformInitImpl(FFPlatform* platform)
getUserShell(platform);
getSystemReleaseAndVersion(platform);
getSystemArchitecture(platform);
getSystemArchitectureAndPageSize(platform);
}