Skip to content

Commit 2102054

Browse files
author
WolfTech Innovations
authored
Merge branch 'fastfetch-cli:dev' into dev
2 parents 8e1e3eb + f2755a8 commit 2102054

38 files changed

+661
-68
lines changed

CMakeLists.txt

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
3030
set(DragonFly TRUE CACHE BOOL "..." FORCE)
3131
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
3232
set(SunOS TRUE CACHE BOOL "..." FORCE)
33+
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
34+
set(Haiku TRUE CACHE BOOL "..." FORCE)
3335
elseif(NOT APPLE AND NOT WIN32)
3436
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
3537
endif()
@@ -139,7 +141,7 @@ set(WARNING_FLAGS "-Wall -Wextra -Wconversion -Werror=uninitialized -Werror=retu
139141
set(CMAKE_C_STANDARD 11)
140142
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} -Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=int-conversion")
141143

142-
if(WIN32 OR ENABLE_DIRECTX_HEADERS)
144+
if(WIN32 OR HAIKU OR ENABLE_DIRECTX_HEADERS)
143145
enable_language(CXX)
144146
set(CMAKE_CXX_STANDARD 17)
145147
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
@@ -1088,6 +1090,74 @@ elseif(SunOS)
10881090
src/util/platform/FFPlatform_unix.c
10891091
src/util/binary_linux.c
10901092
)
1093+
elseif(Haiku)
1094+
list(APPEND LIBFASTFETCH_SRC
1095+
src/common/io/io_unix.c
1096+
src/common/netif/netif_haiku.c
1097+
src/common/networking_linux.c
1098+
src/common/processing_linux.c
1099+
src/detection/battery/battery_nosupport.c
1100+
src/detection/bios/bios_nosupport.c
1101+
src/detection/board/board_nosupport.c
1102+
src/detection/bootmgr/bootmgr_nosupport.c
1103+
src/detection/brightness/brightness_nosupport.c
1104+
src/detection/btrfs/btrfs_nosupport.c
1105+
src/detection/chassis/chassis_nosupport.c
1106+
src/detection/cpu/cpu_nosupport.c
1107+
src/detection/cpucache/cpucache_nosupport.c
1108+
src/detection/cpuusage/cpuusage_nosupport.c
1109+
src/detection/cursor/cursor_nosupport.c
1110+
src/detection/bluetooth/bluetooth_nosupport.c
1111+
src/detection/bluetoothradio/bluetoothradio_nosupport.c
1112+
src/detection/disk/disk_nosupport.c
1113+
src/detection/dns/dns_linux.c
1114+
src/detection/physicaldisk/physicaldisk_nosupport.c
1115+
src/detection/physicalmemory/physicalmemory_nosupport.c
1116+
src/detection/diskio/diskio_nosupport.c
1117+
src/detection/displayserver/displayserver_haiku.cpp
1118+
src/detection/font/font_haiku.cpp
1119+
src/detection/gpu/gpu_nosupport.c
1120+
src/detection/gpu/gpu_pci.c
1121+
src/detection/gtk_qt/gtk.c
1122+
src/detection/host/host_nosupport.c
1123+
src/detection/icons/icons_nosupport.c
1124+
src/detection/initsystem/initsystem_nosupport.c
1125+
src/detection/keyboard/keyboard_nosupport.c
1126+
src/detection/libc/libc_nosupport.c
1127+
src/detection/lm/lm_nosupport.c
1128+
src/detection/loadavg/loadavg_nosupport.c
1129+
src/detection/locale/locale_linux.c
1130+
src/detection/localip/localip_linux.c
1131+
src/detection/gamepad/gamepad_nosupport.c
1132+
src/detection/media/media_nosupport.c
1133+
src/detection/memory/memory_haiku.c
1134+
src/detection/mouse/mouse_nosupport.c
1135+
src/detection/netio/netio_nosupport.c
1136+
src/detection/opengl/opengl_linux.c
1137+
src/detection/os/os_haiku.c
1138+
src/detection/packages/packages_haiku.c
1139+
src/detection/poweradapter/poweradapter_nosupport.c
1140+
src/detection/processes/processes_haiku.c
1141+
src/detection/gtk_qt/qt.c
1142+
src/detection/sound/sound_nosupport.c
1143+
src/detection/swap/swap_haiku.c
1144+
src/detection/terminalfont/terminalfont_linux.c
1145+
src/detection/terminalshell/terminalshell_linux.c
1146+
src/detection/terminalsize/terminalsize_linux.c
1147+
src/detection/theme/theme_nosupport.c
1148+
src/detection/tpm/tpm_nosupport.c
1149+
src/detection/uptime/uptime_haiku.c
1150+
src/detection/users/users_linux.c
1151+
src/detection/wallpaper/wallpaper_nosupport.c
1152+
src/detection/wifi/wifi_nosupport.c
1153+
src/detection/wm/wm_nosupport.c
1154+
src/detection/de/de_nosupport.c
1155+
src/detection/wmtheme/wmtheme_nosupport.c
1156+
src/detection/camera/camera_nosupport.c
1157+
src/detection/zpool/zpool_nosupport.c
1158+
src/util/platform/FFPlatform_unix.c
1159+
src/util/binary_linux.c
1160+
)
10911161
endif()
10921162

10931163
if(ENABLE_DIRECTX_HEADERS)
@@ -1112,6 +1182,9 @@ endif()
11121182
if(LINUX)
11131183
check_function_exists(statx HAVE_STATX)
11141184
endif()
1185+
if(NOT WIN32)
1186+
check_function_exists(pipe2 HAVE_PIPE2)
1187+
endif()
11151188

11161189
if(ENABLE_SYSTEM_YYJSON)
11171190
find_package(yyjson)
@@ -1226,6 +1299,10 @@ if(HAVE_WCWIDTH)
12261299
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_WCWIDTH)
12271300
endif()
12281301

1302+
if(HAVE_PIPE2)
1303+
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_PIPE2)
1304+
endif()
1305+
12291306
if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "")
12301307
message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}")
12311308
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})
@@ -1534,6 +1611,12 @@ elseif(ANDROID)
15341611
)
15351612
endif()
15361613
endif()
1614+
elseif(Haiku)
1615+
target_link_libraries(libfastfetch
1616+
PRIVATE "network"
1617+
PRIVATE "be"
1618+
PRIVATE "gnu"
1619+
)
15371620
endif()
15381621

15391622
target_include_directories(libfastfetch

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22

33
Copyright (c) 2021-2023 Linus Dierheimer
4-
Copyright (c) 2022-2024 Carter Li
4+
Copyright (c) 2022-2025 Carter Li
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
fastfetch (2.35.0) jammy; urgency=medium
2+
3+
* Update to 2.35.0
4+
5+
-- Carter Li <[email protected]> Sun, 26 Jan 2025 10:15:22 +0800
6+
17
fastfetch (2.34.1) jammy; urgency=medium
28

39
* Update to 2.34.1

debian/files

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fastfetch_2.34.1_source.buildinfo universe/utils optional
1+
fastfetch_2.35.0_source.buildinfo universe/utils optional

src/common/io/io_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indenta
310310
continue;
311311

312312
bool isDir = false;
313-
#ifndef __sun
313+
#if !defined(__sun) && !defined(__HAIKU__)
314314
if(entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK)
315315
isDir = entry->d_type == DT_DIR;
316316
else

src/common/netif/netif_haiku.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "netif.h"
2+
#include "common/io/io.h"
3+
#include "util/mallocHelper.h"
4+
5+
#include <arpa/inet.h>
6+
#include <net/if.h>
7+
#include <net/route.h>
8+
#include <sys/socket.h>
9+
#include <sys/sockio.h>
10+
#include <stdio.h>
11+
12+
// loosely based on Haiku's src/bin/network/route/route.cpp
13+
14+
bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex)
15+
{
16+
// TODO: AF_INET6
17+
FF_AUTO_CLOSE_FD int pfRoute = socket(AF_INET, SOCK_RAW, AF_INET);
18+
if (pfRoute < 0)
19+
return false;
20+
21+
struct ifconf config;
22+
config.ifc_len = sizeof(config.ifc_value);
23+
if (ioctl(pfRoute, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0)
24+
return false;
25+
26+
int size = config.ifc_value;
27+
if (size == 0)
28+
return false;
29+
30+
FF_AUTO_FREE void *buffer = malloc(size);
31+
if (buffer == NULL) {
32+
return false;
33+
}
34+
35+
config.ifc_len = size;
36+
config.ifc_buf = buffer;
37+
if (ioctl(pfRoute, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0)
38+
return false;
39+
40+
struct ifreq *interface = (struct ifreq*)buffer;
41+
struct ifreq *end = (struct ifreq*)((uint8_t*)buffer + size);
42+
43+
while (interface < end) {
44+
if (interface->ifr_route.flags & RTF_DEFAULT) {
45+
strlcpy(iface, interface->ifr_name, IF_NAMESIZE);
46+
*ifIndex = if_nametoindex(interface->ifr_name);
47+
return true;
48+
}
49+
50+
size_t addressSize = 0;
51+
if (interface->ifr_route.destination != NULL)
52+
addressSize += interface->ifr_route.destination->sa_len;
53+
if (interface->ifr_route.mask != NULL)
54+
addressSize += interface->ifr_route.mask->sa_len;
55+
if (interface->ifr_route.gateway != NULL)
56+
addressSize += interface->ifr_route.gateway->sa_len;
57+
58+
interface = (struct ifreq*)((addr_t)interface + IF_NAMESIZE
59+
+ sizeof(struct route_entry) + addressSize);
60+
}
61+
62+
return false;
63+
}

src/common/processing_linux.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
enum { FF_PIPE_BUFSIZ = 8192 };
3434

35-
static inline int ffPipe2(int *fds, int flags)
35+
static inline int ffPipe2(int* fds, int flags)
3636
{
37-
#ifdef __APPLE__
37+
#ifndef FF_HAVE_PIPE2
3838
if(pipe(fds) == -1)
3939
return -1;
4040
fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | flags);
@@ -301,7 +301,12 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
301301
if (proc)
302302
{
303303
char** argv = kvm_getargv(kd, proc, 0);
304-
if (argv) ffStrbufSetS(exe, argv[0]);
304+
if (argv)
305+
{
306+
const char* arg0 = argv[0];
307+
if (arg0[0] == '-') arg0++;
308+
ffStrbufSetS(exe, arg0);
309+
}
305310
}
306311
kvm_close(kd);
307312

src/detection/camera/camera_apple.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
// warning: 'AVCaptureDeviceTypeExternalUnknown' is deprecated
77
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
88

9+
#ifdef MAC_OS_VERSION_14_0
10+
// To make fastfetch compiled on newer macOS versions runs on older ones
11+
AVF_EXPORT __attribute__((weak_import)) AVCaptureDeviceType const AVCaptureDeviceTypeExternal;
12+
#endif
13+
914
const char* ffDetectCamera(FFlist* result)
1015
{
1116
#ifdef MAC_OS_X_VERSION_10_15

src/detection/cpu/cpu_apple.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ static double detectCpuTemp(const FFstrbuf* cpuName)
1515
case 1: error = ffDetectSmcTemps(FF_TEMP_CPU_M1X, &result); break;
1616
case 2: error = ffDetectSmcTemps(FF_TEMP_CPU_M2X, &result); break;
1717
case 3: error = ffDetectSmcTemps(FF_TEMP_CPU_M3X, &result); break;
18+
case 4: error = ffDetectSmcTemps(FF_TEMP_CPU_M4X, &result); break;
1819
default: error = "Unsupported Apple Silicon CPU";
1920
}
2021
}

src/detection/cpu/cpu_linux.c

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <unistd.h>
1111
#include <dirent.h>
1212

13+
#define FF_CPUINFO_PATH "/proc/cpuinfo"
14+
1315
static double parseHwmonDir(FFstrbuf* dir, FFstrbuf* buffer)
1416
{
1517
//https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
@@ -297,30 +299,22 @@ static const char* parseCpuInfo(
297299
(cpu->vendor.length == 0 && ffParsePropLine(line, "vendor_id :", &cpu->vendor)) ||
298300
(physicalCoresBuffer->length == 0 && ffParsePropLine(line, "cpu cores :", physicalCoresBuffer)) ||
299301
(cpuMHz->length == 0 && ffParsePropLine(line, "cpu MHz :", cpuMHz)) ||
300-
#endif
301-
302-
#if __arm__ || __aarch64__
302+
#elif __arm__ || __aarch64__
303303
(cpuImplementer->length == 0 && ffParsePropLine(line, "CPU implementer :", cpuImplementer)) ||
304304
(cpu->name.length == 0 && ffParsePropLine(line, "Hardware :", &cpu->name)) || //For Android devices
305-
#endif
306-
307-
#if __powerpc__ || __powerpc
305+
#elif __powerpc__ || __powerpc
308306
(cpuMHz->length == 0 && ffParsePropLine(line, "clock :", cpuMHz)) || //For POWER
309307
(cpu->name.length == 0 && ffParsePropLine(line, "cpu :", &cpu->name)) || //For POWER
310-
#endif
311-
312-
#if __mips__ || __mips
308+
#elif __mips__ || __mips
313309
(cpu->name.length == 0 && ffParsePropLine(line, "cpu model :", &cpu->name)) || //For MIPS
314-
#endif
315-
316-
#if __loongarch__
310+
#elif __loongarch__
317311
(cpu->name.length == 0 && ffParsePropLine(line, "Model Name :", &cpu->name)) ||
318312
(cpuMHz->length == 0 && ffParsePropLine(line, "CPU MHz :", cpuMHz)) ||
319-
#endif
320-
321-
#if __riscv__ || __loongarch__
313+
#elif __riscv__ || __riscv
322314
(cpuIsa->length == 0 && ffParsePropLine(line, "isa :", cpuIsa)) ||
323315
(cpuUarch->length == 0 && ffParsePropLine(line, "uarch :", cpuUarch)) ||
316+
#else
317+
(cpu->name.length == 0 && ffParsePropLine(line, "model name :", &cpu->name)) ||
324318
#endif
325319

326320
false
@@ -445,8 +439,8 @@ FF_MAYBE_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo)
445439
FF_MAYBE_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFCPUResult* cpu)
446440
{
447441
FF_STRBUF_AUTO_DESTROY cpuinfo = ffStrbufCreateA(PROC_FILE_BUFFSIZ);
448-
if (!ffReadFileBuffer("/proc/cpuinfo", &cpuinfo) || cpuinfo.length == 0)
449-
return "ffReadFileBuffer(\"/proc/cpuinfo\") failed";
442+
if (!ffReadFileBuffer(FF_CPUINFO_PATH, &cpuinfo) || cpuinfo.length == 0)
443+
return "ffReadFileBuffer(\"" FF_CPUINFO_PATH "\") failed";
450444

451445
FF_STRBUF_AUTO_DESTROY physicalCoresBuffer = ffStrbufCreate();
452446
FF_STRBUF_AUTO_DESTROY cpuMHz = ffStrbufCreate();
@@ -575,6 +569,30 @@ FF_MAYBE_UNUSED static void detectSocName(FFCPUResult* cpu)
575569
}
576570
}
577571

572+
#ifdef __loongarch__
573+
FF_MAYBE_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key)
574+
{
575+
const char* p = cpuinfo->chars;
576+
uint64_t low = 0, high = 0;
577+
uint32_t keylen = (uint32_t) strlen(key);
578+
579+
while ((p = memmem(p, cpuinfo->length - (uint32_t) (p - cpuinfo->chars), key, keylen)))
580+
{
581+
if (!p) break;
582+
p += keylen;
583+
char* pend;
584+
unsigned long id = strtoul(p, &pend, 10);
585+
if (__builtin_expect(id > 64, false))
586+
high |= 1 << (id - 64);
587+
else
588+
low |= 1 << id;
589+
p = pend;
590+
}
591+
592+
return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high));
593+
}
594+
#endif
595+
578596
FF_MAYBE_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu)
579597
{
580598
cpu->coresPhysical = cpu->coresLogical = (uint16_t) get_nprocs_conf();
@@ -591,8 +609,8 @@ FF_MAYBE_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options,
591609
if (cpu->name.length == 0)
592610
{
593611
FF_STRBUF_AUTO_DESTROY cpuinfo = ffStrbufCreateA(PROC_FILE_BUFFSIZ);
594-
if (!ffReadFileBuffer("/proc/cpuinfo", &cpuinfo) || cpuinfo.length == 0)
595-
return "ffReadFileBuffer(\"/proc/cpuinfo\") failed";
612+
if (!ffReadFileBuffer(FF_CPUINFO_PATH, &cpuinfo) || cpuinfo.length == 0)
613+
return "ffReadFileBuffer(\"" FF_CPUINFO_PATH "\") failed";
596614

597615
FF_STRBUF_AUTO_DESTROY cpuMHz = ffStrbufCreate();
598616
FF_STRBUF_AUTO_DESTROY cpuIsa = ffStrbufCreate();
@@ -629,6 +647,10 @@ FF_MAYBE_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options,
629647
ffStrbufAppend(&cpu->name, &cpuIsa);
630648
}
631649
}
650+
#elif __loongarch__
651+
cpu->packages = getLoongarchPropCount(&cpuinfo, "\npackage\t\t\t:");
652+
cpu->coresPhysical = getLoongarchPropCount(&cpuinfo, "\ncore\t\t\t:");
653+
if (cpu->packages > 1) cpu->coresPhysical *= cpu->packages;
632654
#endif
633655
}
634656

0 commit comments

Comments
 (0)