Skip to content

Commit 22de71e

Browse files
authored
Merge pull request #617 from fastfetch-cli/dev
Release v2.2.3
2 parents 1837446 + ac654ff commit 22de71e

File tree

15 files changed

+100
-45
lines changed

15 files changed

+100
-45
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 2.2.3
2+
3+
Features:
4+
* Update the latest mac models (Host, macOS)
5+
6+
Bugfixes:
7+
* Fix local ips detection on Android. Regression from `2.0.0` (LocalIP, Android)
8+
* Fix terminal detection on NixOS (Terminal)
9+
110
# 2.2.2
211

312
Changes:

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
22

33
project(fastfetch
4-
VERSION 2.2.2
4+
VERSION 2.2.3
55
LANGUAGES C
66
DESCRIPTION "Fast neofetch-like system information tool"
77
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"

src/data/help.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ Module specific options:
162162
--localip-show-mac <?value>: Show mac addresses in local ip module. Default is false
163163
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
164164
--localip-name-prefix <str>: Show interfaces with given interface name prefix only. Default is empty
165-
--localip-default-route-only <?value>: Show the interface that is used for default routing only. Default is true
165+
--localip-default-route-only <?value>: Show the interface that is used for default routing only. Default is true on non-android platforms
166166
--localip-compact <?value>: Show all IPs in one line. Default is false
167167
--netio-name-prefix <str>: Show interfaces with given name prefix only. Default is empty
168-
--netio-default-route-only <?value>: Show the interfac that is used for default routing only. Default is true
168+
--netio-default-route-only <?value>: Show the interfac that is used for default routing only. Default is true on non-android platforms
169169
--publicip-timeout <num>: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
170170
--publicip-url <str>: The URL of public IP detection server to be used.
171171
--weather-location <str>: Set the location to be used. It must be URI encoded (eg a whitespace must be encoded as `+`).

src/detection/host/host_apple.c

+9
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ static const char* getProductName(const FFstrbuf* hwModel)
108108
else if(ffStrbufStartsWithS(hwModel, "Mac"))
109109
{
110110
const char* version = hwModel->chars + strlen("Mac");
111+
if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)";
112+
if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)";
113+
if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)";
114+
if(ffStrEquals(version, "15,6") ||
115+
ffStrEquals(version, "15,8") ||
116+
ffStrEquals(version, "15,10")) return "MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)";
117+
if(ffStrEquals(version, "15,7") ||
118+
ffStrEquals(version, "15,9") ||
119+
ffStrEquals(version, "15,11")) return "MacBook Pro (16-inch, Nov 2023, Three Thunderbolt 4 ports)";
111120
if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)";
112121
if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)";
113122
if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)";

src/detection/memory/memory_apple.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@ const char* ffDetectMemory(FFMemoryResult* ram)
1111
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0))
1212
return "Failed to read hw.memsize";
1313

14-
uint32_t pagesize;
15-
length = sizeof(pagesize);
16-
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pagesize, &length, NULL, 0))
17-
return "Failed to read hw.pagesize";
18-
1914
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
2015
vm_statistics64_data_t vmstat;
2116
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
2217
return "Failed to read host_statistics64";
2318

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

2621
return NULL;
2722
}

src/detection/memory/memory_bsd.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@ const char* ffDetectMemory(FFMemoryResult* ram)
77
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
88
return "Failed to read hw.physmem";
99

10-
uint32_t pageSize;
11-
length = sizeof(pageSize);
12-
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pageSize, &length, NULL, 0))
13-
return "Failed to read hw.pagesize";
14-
1510
// vm.stats.vm.* are int values
1611
int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0)
1712
+ ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0)
1813
+ ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);
1914

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

2217
return NULL;
2318
}

src/detection/swap/swap_windows.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
const char* ffDetectSwap(FFSwapResult* swap)
99
{
10-
SYSTEM_INFO sysInfo;
11-
GetNativeSystemInfo(&sysInfo);
12-
1310
ULONG size = sizeof(SYSTEM_PAGEFILE_INFORMATION);
1411
SYSTEM_PAGEFILE_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PAGEFILE_INFORMATION*)malloc(size);
1512
while(true)
@@ -24,8 +21,10 @@ const char* ffDetectSwap(FFSwapResult* swap)
2421
return "NtQuerySystemInformation(SystemPagefileInformation, size) failed";
2522
break;
2623
}
27-
swap->bytesUsed = (uint64_t)pstart->TotalUsed * sysInfo.dwPageSize;
28-
swap->bytesTotal = (uint64_t)pstart->CurrentSize * sysInfo.dwPageSize;
24+
25+
uint32_t pageSize = instance.state.platform.pageSize;
26+
swap->bytesUsed = (uint64_t)pstart->TotalUsed * pageSize;
27+
swap->bytesTotal = (uint64_t)pstart->CurrentSize * pageSize;
2928

3029
return NULL;
3130
}

src/detection/terminalshell/terminalshell_linux.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ const FFTerminalShellResult* ffDetectTerminalShell()
361361
ffStrbufInitS(&result.shellPrettyName, result.shellExeName);
362362
}
363363

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

src/logo/image/image.c

+36-18
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,45 @@
1111
#include <windows.h>
1212
#endif
1313

14-
static FFstrbuf base64Encode(const FFstrbuf* in)
14+
// https://github.com/kostya/benchmarks/blob/master/base64/test-nolib.c#L145
15+
static void base64EncodeRaw(uint32_t size, const char *str, uint32_t *out_size, char *output)
1516
{
16-
const char* base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
17-
18-
FFstrbuf out = ffStrbufCreateA(8 * (1 + in->length / 6));
17+
static const char chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
18+
char *out = output;
19+
const char *ends = str + (size - size % 3);
20+
while (str != ends) {
21+
uint32_t n = __builtin_bswap32(*(uint32_t*) str);
22+
*out++ = chars[(n >> 26) & 63];
23+
*out++ = chars[(n >> 20) & 63];
24+
*out++ = chars[(n >> 14) & 63];
25+
*out++ = chars[(n >> 8) & 63];
26+
str += 3;
27+
}
1928

20-
unsigned val = 0;
21-
int valb = -6;
22-
for (uint32_t i = 0; i < in->length; ++i)
23-
{
24-
unsigned char c = (unsigned char) in->chars[i];
25-
val = (val << 8) + c;
26-
valb += 8;
27-
while (valb >= 0)
28-
{
29-
ffStrbufAppendC(&out, base64Chars[(val>>valb)&0x3F]);
30-
valb -= 6;
31-
}
29+
if (size % 3 == 1) {
30+
uint64_t n = (uint64_t)*str << 16;
31+
*out++ = chars[(n >> 18) & 63];
32+
*out++ = chars[(n >> 12) & 63];
33+
*out++ = '=';
34+
*out++ = '=';
35+
} else if (size % 3 == 2) {
36+
uint64_t n = (uint64_t)*str++ << 16;
37+
n |= (uint64_t)*str << 8;
38+
*out++ = chars[(n >> 18) & 63];
39+
*out++ = chars[(n >> 12) & 63];
40+
*out++ = chars[(n >> 6) & 63];
41+
*out++ = '=';
3242
}
33-
if (valb > -6) ffStrbufAppendC(&out, base64Chars[((val<<8)>>(valb+8))&0x3F]);
34-
while (out.length % 4) ffStrbufAppendC(&out, '=');
43+
*out = '\0';
44+
*out_size = (uint32_t) (out - output);
45+
}
46+
47+
static FFstrbuf base64Encode(const FFstrbuf* in)
48+
{
49+
FFstrbuf out = ffStrbufCreateA(10 + in->length * 4 / 3);
50+
base64EncodeRaw(in->length, in->chars, &out.length, out.chars);
51+
assert(out.length < out.allocated);
52+
3553
return out;
3654
}
3755

src/modules/localip/localip.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,13 @@ void ffInitLocalIpOptions(FFLocalIpOptions* options)
370370

371371
options->showType = FF_LOCALIP_TYPE_IPV4_BIT;
372372
ffStrbufInit(&options->namePrefix);
373-
options->defaultRouteOnly = true;
373+
options->defaultRouteOnly =
374+
#ifdef __ANDROID__
375+
false
376+
#else
377+
true
378+
#endif
379+
;
374380
}
375381

376382
void ffDestroyLocalIpOptions(FFLocalIpOptions* options)

src/modules/netio/netio.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ void ffInitNetIOOptions(FFNetIOOptions* options)
230230
ffOptionInitModuleArg(&options->moduleArgs);
231231

232232
ffStrbufInit(&options->namePrefix);
233-
options->defaultRouteOnly = true;
233+
options->defaultRouteOnly =
234+
#ifdef __ANDROID__
235+
false
236+
#else
237+
true
238+
#endif
239+
;
234240
}
235241

236242
void ffDestroyNetIOOptions(FFNetIOOptions* options)

src/modules/title/title.c

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ void ffGenerateTitleJsonResult(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_m
176176
yyjson_mut_obj_add_strbuf(doc, obj, "homeDir", &instance.state.platform.homeDir);
177177
yyjson_mut_obj_add_strbuf(doc, obj, "exePath", &instance.state.platform.exePath);
178178
yyjson_mut_obj_add_strbuf(doc, obj, "userShell", &instance.state.platform.userShell);
179+
yyjson_mut_obj_add_uint(doc, obj, "pageSize", instance.state.platform.pageSize);
179180
}
180181

181182
void ffPrintTitleHelpFormat(void)

src/util/platform/FFPlatform.h

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ typedef struct FFPlatform {
2222
FFstrbuf systemVersion;
2323
FFstrbuf systemArchitecture;
2424
FFstrbuf systemDisplayVersion;
25+
26+
uint32_t pageSize;
2527
} FFPlatform;
2628

2729
void ffPlatformInit(FFPlatform* platform);

src/util/platform/FFPlatform_unix.c

+13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#ifdef __APPLE__
1212
#include <libproc.h>
13+
#include <sys/sysctl.h>
1314
#elif defined(__FreeBSD__)
1415
#include <sys/sysctl.h>
1516
#endif
@@ -153,6 +154,16 @@ static void getUserShell(FFPlatform* platform, const struct passwd* pwd)
153154
ffStrbufAppendS(&platform->userShell, shell);
154155
}
155156

157+
static void getPageSize(FFPlatform* platform)
158+
{
159+
#if defined(__FreeBSD__) || defined(__APPLE__)
160+
size_t length = sizeof(platform->pageSize);
161+
sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &platform->pageSize, &length, NULL, 0);
162+
#else
163+
platform->pageSize = (uint32_t) sysconf(_SC_PAGESIZE);
164+
#endif
165+
}
166+
156167
void ffPlatformInitImpl(FFPlatform* platform)
157168
{
158169
struct passwd* pwd = getpwuid(getuid());
@@ -176,4 +187,6 @@ void ffPlatformInitImpl(FFPlatform* platform)
176187
ffStrbufAppendS(&platform->systemVersion, uts.version);
177188
ffStrbufAppendS(&platform->systemArchitecture, uts.machine);
178189
ffStrbufInit(&platform->systemDisplayVersion);
190+
191+
getPageSize(platform);
179192
}

src/util/platform/FFPlatform_windows.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ static void getSystemReleaseAndVersion(FFPlatform* platform)
183183
}
184184
}
185185

186-
static void getSystemArchitecture(FFPlatform* platform)
186+
static void getSystemArchitectureAndPageSize(FFPlatform* platform)
187187
{
188-
SYSTEM_INFO sysInfo = {0};
188+
SYSTEM_INFO sysInfo;
189189
GetNativeSystemInfo(&sysInfo);
190190

191191
switch(sysInfo.wProcessorArchitecture)
@@ -215,6 +215,8 @@ static void getSystemArchitecture(FFPlatform* platform)
215215
default:
216216
break;
217217
}
218+
219+
platform->pageSize = sysInfo.dwPageSize;
218220
}
219221

220222
void ffPlatformInitImpl(FFPlatform* platform)
@@ -230,5 +232,5 @@ void ffPlatformInitImpl(FFPlatform* platform)
230232
getUserShell(platform);
231233

232234
getSystemReleaseAndVersion(platform);
233-
getSystemArchitecture(platform);
235+
getSystemArchitectureAndPageSize(platform);
234236
}

0 commit comments

Comments
 (0)