From 08cd4ac1ee30d00e4838ce5448f39880eb7f60f7 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 11 Feb 2025 13:41:12 +0800 Subject: [PATCH 01/87] Packaging: update debian stuff [ci skip] --- debian/changelog | 6 ++++++ debian/files | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b710a7b3e..63870842b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +fastfetch (2.36.1) jammy; urgency=medium + + * Update to 2.36.1 + + -- Carter Li Tue, 11 Feb 2025 13:39:55 +0800 + fastfetch (2.36.0) jammy; urgency=medium * Update to 2.36.0 diff --git a/debian/files b/debian/files index 0ec78db67..116398cf1 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -fastfetch_2.36.0_source.buildinfo universe/utils optional +fastfetch_2.36.1_source.buildinfo universe/utils optional From bf707c2e948824af39e842c0830662734607c7e0 Mon Sep 17 00:00:00 2001 From: Shu Niu Date: Tue, 11 Feb 2025 14:15:32 +0800 Subject: [PATCH 02/87] GPU (macOS): fix build error in MacOS 10.13 (#1556) * Fix build error in MacOS 10.13 * Update gpu_apple.m --------- Co-authored-by: Carter Li --- src/detection/gpu/gpu_apple.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/gpu/gpu_apple.m b/src/detection/gpu/gpu_apple.m index 9334c6840..943bd16c5 100644 --- a/src/detection/gpu/gpu_apple.m +++ b/src/detection/gpu/gpu_apple.m @@ -67,10 +67,10 @@ const char* ffGpuDetectMetal(FFlist* gpus) gpu->type = device.location == MTLDeviceLocationBuiltIn ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; gpu->index = (uint32_t) device.locationNumber; - #endif if (device.hasUnifiedMemory && device.recommendedMaxWorkingSetSize > 0) gpu->shared.total = device.recommendedMaxWorkingSetSize; + #endif } return NULL; } From 1fc0f75776a5bf21f82de36d038b4a575cb28e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 11 Feb 2025 16:23:05 +0800 Subject: [PATCH 03/87] GPU (Haiku): add support --- CMakeLists.txt | 4 ++-- src/detection/gpu/gpu.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 731ba32fe..6d0a7cbf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" O cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD OR SunOS OR Haiku" OFF) option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embedded) yyjson library" OFF) option(ENABLE_ASAN "Build fastfetch with ASAN (address sanitizer)" OFF) @@ -1116,7 +1116,7 @@ elseif(Haiku) src/detection/diskio/diskio_nosupport.c src/detection/displayserver/displayserver_haiku.cpp src/detection/font/font_haiku.cpp - src/detection/gpu/gpu_nosupport.c + src/detection/gpu/gpu_general.c src/detection/gpu/gpu_pci.c src/detection/gtk_qt/gtk.c src/detection/host/host_nosupport.c diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 0d5f3dc92..7ed37910f 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -48,6 +48,6 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus); const char* ffGPUGetVendorString(unsigned vendorId); -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) void ffGPUFillVendorAndName(uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu); #endif From ff8bfadd253747808fc3caa4192520896182fdc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 11 Feb 2025 16:24:42 +0800 Subject: [PATCH 04/87] Display (Haiku): trim monitor name --- src/detection/displayserver/displayserver_haiku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection/displayserver/displayserver_haiku.cpp b/src/detection/displayserver/displayserver_haiku.cpp index b6f2e869d..41bdf1717 100644 --- a/src/detection/displayserver/displayserver_haiku.cpp +++ b/src/detection/displayserver/displayserver_haiku.cpp @@ -33,6 +33,7 @@ static void detectDisplays(FFDisplayServerResult* ds) status_t err = s.GetMonitorInfo(&monitor); if (err == B_OK) { ffStrbufSetF(&name, "%s %s", monitor.vendor, monitor.name); + ffStrbufTrimRightSpace(&name); } uint32_t width = (uint32_t) s.Frame().Width() + 1; From 5ca4268be2e15d4046430e0013a5ecd779cc93f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 00:16:23 +0800 Subject: [PATCH 05/87] CMake (Haiku): add more optional dependencies --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d0a7cbf2..88f9eb0ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ include(CheckIncludeFile) include(CMakeDependentOption) -cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS" OFF) +cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS OR Haiku" OFF) cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD" OFF) cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) @@ -68,19 +68,19 @@ cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenB cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX" OFF) -cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR WIN32 OR SunOS" OFF) +cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR WIN32 OR SunOS OR Haiku" OFF) cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR SunOS" OFF) cmake_dependent_option(ENABLE_CHAFA "Enable chafa" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF) cmake_dependent_option(ENABLE_ZLIB "Enable zlib" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF) cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR WIN32 OR SunOS OR Haiku" OFF) -cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR Haiku" OFF) +cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS" OFF) cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR SunOS" OFF) cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF) cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF) -cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly" OFF) +cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly OR Haiku" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD OR SunOS OR Haiku" OFF) From cbc8b1f11d39b443df99f94a4d1874b867f1cc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 00:16:50 +0800 Subject: [PATCH 06/87] CPU (Haiku): add support --- CMakeLists.txt | 2 +- src/detection/cpu/cpu_haiku.c | 64 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/detection/cpu/cpu_haiku.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 88f9eb0ae..2ac35be9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1103,7 +1103,7 @@ elseif(Haiku) src/detection/brightness/brightness_nosupport.c src/detection/btrfs/btrfs_nosupport.c src/detection/chassis/chassis_nosupport.c - src/detection/cpu/cpu_nosupport.c + src/detection/cpu/cpu_haiku.c src/detection/cpucache/cpucache_nosupport.c src/detection/cpuusage/cpuusage_nosupport.c src/detection/cursor/cursor_nosupport.c diff --git a/src/detection/cpu/cpu_haiku.c b/src/detection/cpu/cpu_haiku.c new file mode 100644 index 000000000..ec993a05c --- /dev/null +++ b/src/detection/cpu/cpu_haiku.c @@ -0,0 +1,64 @@ +#include "cpu.h" +#include "util/mallocHelper.h" + +#include +#include + +const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FFCPUResult* cpu) +{ + system_info sysInfo; + if (get_system_info(&sysInfo) != B_OK) + return "get_system_info() failed"; + + uint32_t topoNodeCount = 0; + get_cpu_topology_info(NULL, &topoNodeCount); + if (topoNodeCount == 0) + return "get_cpu_topology_info(NULL) failed"; + + FF_AUTO_FREE cpu_topology_node_info* topology = malloc(sizeof(*topology) * topoNodeCount); + if (get_cpu_topology_info(topology, &topoNodeCount) != B_OK) + return "get_cpu_topology_info(topology) failed"; + + enum cpu_platform platform = B_CPU_UNKNOWN; + enum cpu_vendor cpuVendor = B_CPU_VENDOR_UNKNOWN; + uint32 cpuModel = 0, frequency = 0; + uint16_t packages = 0, cores = 0; + + for (uint32 i = 0; i < topoNodeCount; i++) + { + switch (topology[i].type) { + case B_TOPOLOGY_ROOT: + platform = topology[i].data.root.platform; + break; + + case B_TOPOLOGY_PACKAGE: + cpuVendor = topology[i].data.package.vendor; + ++packages; + break; + + case B_TOPOLOGY_CORE: + cpuModel = topology[i].data.core.model; + uint32_t freq = (uint32_t) (topology[i].data.core.default_frequency / 1000000); + frequency = freq > frequency ? freq : frequency; + ++cores; + break; + + default: + break; + } + } + + const char *model = get_cpu_model_string(platform, cpuVendor, cpuModel); + if (model) + ffStrbufSetS(&cpu->name, model); + else + ffStrbufSetF(&cpu->name, "(Unknown %" B_PRIx32 ")", cpuModel); + ffStrbufSetS(&cpu->vendor, get_cpu_vendor_string(cpuVendor)); + + ffCPUDetectSpeedByCpuid(cpu); + if (cpu->frequencyBase < frequency) cpu->frequencyBase = frequency; + cpu->packages = packages; + cpu->coresPhysical = cores; + cpu->coresOnline = cpu->coresLogical = (uint16_t) sysInfo.cpu_count; + return NULL; +} From da76dcb2fe3807fbe41b5762a6c9aa0964b8e911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 00:17:18 +0800 Subject: [PATCH 07/87] Disk (Haiku): add support --- CMakeLists.txt | 2 +- src/detection/disk/disk_haiku.cpp | 51 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/detection/disk/disk_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ac35be9a..989c9fed9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1109,7 +1109,7 @@ elseif(Haiku) src/detection/cursor/cursor_nosupport.c src/detection/bluetooth/bluetooth_nosupport.c src/detection/bluetoothradio/bluetoothradio_nosupport.c - src/detection/disk/disk_nosupport.c + src/detection/disk/disk_haiku.cpp src/detection/dns/dns_linux.c src/detection/physicaldisk/physicaldisk_nosupport.c src/detection/physicalmemory/physicalmemory_nosupport.c diff --git a/src/detection/disk/disk_haiku.cpp b/src/detection/disk/disk_haiku.cpp new file mode 100644 index 000000000..078284740 --- /dev/null +++ b/src/detection/disk/disk_haiku.cpp @@ -0,0 +1,51 @@ +extern "C" +{ +#include "disk.h" +} +#include +#include +#include + +const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_UNUSED FFlist* disks) +{ + int pos = 0; + + for (dev_t dev; (dev = next_dev(&pos)) >= B_OK;) + { + fs_info fs; + fs_stat_dev(dev, &fs); + + FFDisk* disk = (FFDisk*) ffListAdd(disks); + + disk->bytesTotal = (uint64_t)fs.total_blocks * (uint64_t) fs.block_size; + disk->bytesFree = (uint64_t)fs.free_blocks * (uint64_t) fs.block_size; + disk->bytesAvailable = disk->bytesFree; + disk->bytesUsed = 0; // To be filled in ./disk. c + + disk->filesTotal = (uint32_t) fs.total_nodes; + disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs.free_nodes); + + ffStrbufInitS(&disk->mountFrom, fs.device_name); + ffStrbufInit(&disk->mountpoint); + { + node_ref node(fs.dev, fs.root); + BDirectory dir(&node); + BPath path(&dir); + if (path.InitCheck() == B_OK) + ffStrbufSetS(&disk->mountpoint, path.Path()); + else + ffStrbufSetStatic(&disk->mountpoint, "?"); + } + ffStrbufInitS(&disk->filesystem, fs.fsh_name); + ffStrbufInitS(&disk->name, fs.volume_name); + disk->type = FF_DISK_VOLUME_TYPE_NONE; + if (!(fs.flags & B_FS_IS_PERSISTENT)) + disk->type = (FFDiskVolumeType) (disk->type | FF_DISK_VOLUME_TYPE_HIDDEN_BIT); + if (fs.flags & B_FS_IS_READONLY) + disk->type = (FFDiskVolumeType) (disk->type | FF_DISK_VOLUME_TYPE_READONLY_BIT); + if (fs.flags & B_FS_IS_REMOVABLE) + disk->type = (FFDiskVolumeType) (disk->type | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT); + disk->createTime = 0; + } + return 0; +} From b3e7451a08fce096e84e6a82b215b7764f5835ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 00:17:36 +0800 Subject: [PATCH 08/87] Sound (Haiku): add stub file --- CMakeLists.txt | 3 ++- src/detection/sound/sound_haiku.cpp | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/detection/sound/sound_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 989c9fed9..7cd640d79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1139,7 +1139,7 @@ elseif(Haiku) src/detection/poweradapter/poweradapter_nosupport.c src/detection/processes/processes_haiku.c src/detection/gtk_qt/qt.c - src/detection/sound/sound_nosupport.c + src/detection/sound/sound_haiku.cpp src/detection/swap/swap_haiku.c src/detection/terminalfont/terminalfont_linux.c src/detection/terminalshell/terminalshell_linux.c @@ -1616,6 +1616,7 @@ elseif(ANDROID) elseif(Haiku) target_link_libraries(libfastfetch PRIVATE "network" + PRIVATE "media" PRIVATE "be" PRIVATE "gnu" ) diff --git a/src/detection/sound/sound_haiku.cpp b/src/detection/sound/sound_haiku.cpp new file mode 100644 index 000000000..04dce76d5 --- /dev/null +++ b/src/detection/sound/sound_haiku.cpp @@ -0,0 +1,22 @@ +extern "C" +{ +#include "sound.h" +} +#include + +const char* ffDetectSound(FF_MAYBE_UNUSED FFlist* devices /* List of FFSoundDevice */) +{ + BMediaRoster* roster = BMediaRoster::Roster(); + media_node mediaNode; + + roster->GetAudioOutput(&mediaNode); + + int32_t mediaOutputCount = 0; + roster->GetAllOutputsFor(mediaNode, NULL, 0, &mediaOutputCount); + if (mediaOutputCount == 0) + return NULL; + + // TODO: Implement the rest of the function + + return "Not supported on this platform"; +} From 5c5e12f0a7e031f8f87d1f6dc2a2623355945250 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 12 Feb 2025 00:29:43 +0000 Subject: [PATCH 09/87] Media (Haiku): enable support --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cd640d79..a1bb06a89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBS cmake_dependent_option(ENABLE_DRM_AMDGPU "Enable libdrm_amdgpu" ON "LINUX" OFF) cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR Haiku" OFF) cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX" OFF) @@ -1129,7 +1129,7 @@ elseif(Haiku) src/detection/locale/locale_linux.c src/detection/localip/localip_linux.c src/detection/gamepad/gamepad_nosupport.c - src/detection/media/media_nosupport.c + src/detection/media/media_linux.c src/detection/memory/memory_haiku.c src/detection/mouse/mouse_nosupport.c src/detection/netio/netio_nosupport.c From 565934ba2e32f3edcb468dd8d5c7b40718aaba07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 00:43:33 +0800 Subject: [PATCH 10/87] OS (Haiku): silence warnings --- src/detection/os/os_haiku.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/os/os_haiku.c b/src/detection/os/os_haiku.c index f31fb28fb..bb83ddeb1 100644 --- a/src/detection/os/os_haiku.c +++ b/src/detection/os/os_haiku.c @@ -14,7 +14,7 @@ void ffDetectOSImpl(FFOSResult* os) if (get_system_info(&info) != B_OK) return; - ffStrbufAppendF(&os->version, "R%lld", info.kernel_version); + ffStrbufAppendF(&os->version, "R%ld", info.kernel_version); // TODO: check kernel resources? } From ef60910e51a9616b307330ce485c11a5a0b3b43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 00:44:07 +0800 Subject: [PATCH 11/87] Display (Haiku): code cleanup; detect manufacture date --- .../displayserver/displayserver_haiku.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/detection/displayserver/displayserver_haiku.cpp b/src/detection/displayserver/displayserver_haiku.cpp index 41bdf1717..438bfb09f 100644 --- a/src/detection/displayserver/displayserver_haiku.cpp +++ b/src/detection/displayserver/displayserver_haiku.cpp @@ -1,7 +1,5 @@ extern "C" { #include "displayserver.h" -#include "common/settings.h" -#include "common/processing.h" } #include @@ -31,7 +29,8 @@ static void detectDisplays(FFDisplayServerResult* ds) monitor_info monitor; // WARNING: This is experimental new Haiku API status_t err = s.GetMonitorInfo(&monitor); - if (err == B_OK) { + if (err == B_OK) + { ffStrbufSetF(&name, "%s %s", monitor.vendor, monitor.name); ffStrbufTrimRightSpace(&name); } @@ -39,7 +38,7 @@ static void detectDisplays(FFDisplayServerResult* ds) uint32_t width = (uint32_t) s.Frame().Width() + 1; uint32_t height = (uint32_t) (uint32_t)s.Frame().Height() + 1; double scaleFactor = (double) 1.0; - ffdsAppendDisplay(ds, + FFDisplayResult* res = ffdsAppendDisplay(ds, width, height, (double)mode.timing.pixel_clock * 1000 / (mode.timing.v_total * mode.timing.h_total), @@ -52,11 +51,16 @@ static void detectDisplays(FFDisplayServerResult* ds) &name, FF_DISPLAY_TYPE_UNKNOWN, main, - s.ID().id, + (uint64_t) s.ID().id, 0, 0, "BScreen" ); + if (err == B_OK) + { + res->manufactureWeek = monitor.produced.week; + res->manufactureYear = monitor.produced.year; + } main = false; } while (s.SetToNext() == B_OK); From d3a5f986a8c249a37ec520ab611820aafbea3d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 00:44:41 +0800 Subject: [PATCH 12/87] Terminal (Haiku): add basic support --- src/common/processing_linux.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index b865805c1..f5fb46e1b 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -28,6 +28,8 @@ #elif defined(__NetBSD__) #include #include +#elif defined(__HAIKU__) + #include #endif enum { FF_PIPE_BUFSIZ = 8192 }; @@ -476,6 +478,16 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i if (!proc) return "kvm_getprocs() failed"; + #elif defined(__HAIKU__) + + team_info info; + if (get_team_info(pid, &info) == B_OK) + { + ffStrbufSetS(name, info.name); + if (ppid) + *ppid = info.parent; + } + #else return "Unsupported platform"; From f77a9c185df400eaaceedcad4294c75b5853133d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 00:45:14 +0800 Subject: [PATCH 13/87] Media (Haiku): enable support --- CMakeLists.txt | 1 + src/options/general.c | 10 +++++----- src/options/general.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1bb06a89..769f81806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1092,6 +1092,7 @@ elseif(SunOS) ) elseif(Haiku) list(APPEND LIBFASTFETCH_SRC + src/common/dbus.c src/common/io/io_unix.c src/common/netif/netif_haiku.c src/common/networking_linux.c diff --git a/src/options/general.c b/src/options/general.c index cff518f40..535c02626 100644 --- a/src/options/general.c +++ b/src/options/general.c @@ -30,7 +30,7 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va else if (ffStrEqualsIgnCase(key, "detectVersion")) options->detectVersion = yyjson_get_bool(val); - #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) else if (ffStrEqualsIgnCase(key, "escapeBedrock")) options->escapeBedrock = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "playerName")) @@ -75,7 +75,7 @@ bool ffOptionsParseGeneralCommandLine(FFOptionsGeneral* options, const char* key else if(ffStrEqualsIgnCase(key, "--detect-version")) options->detectVersion = ffOptionParseBoolean(value); - #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) else if(ffStrEqualsIgnCase(key, "--escape-bedrock")) options->escapeBedrock = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--player-name")) @@ -106,7 +106,7 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options) options->multithreading = true; options->detectVersion = true; - #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) options->escapeBedrock = true; ffStrbufInit(&options->playerName); options->dsForceDrm = FF_DS_FORCE_DRM_TYPE_FALSE; @@ -117,7 +117,7 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options) void ffOptionsDestroyGeneral(FF_MAYBE_UNUSED FFOptionsGeneral* options) { - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) ffStrbufDestroy(&options->playerName); #endif } @@ -135,7 +135,7 @@ void ffOptionsGenerateGeneralJsonConfig(FFOptionsGeneral* options, yyjson_mut_do if (options->processingTimeout != defaultOptions.processingTimeout) yyjson_mut_obj_add_int(doc, obj, "processingTimeout", options->processingTimeout); - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) if (options->escapeBedrock != defaultOptions.escapeBedrock) yyjson_mut_obj_add_bool(doc, obj, "escapeBedrock", options->escapeBedrock); diff --git a/src/options/general.h b/src/options/general.h index 8cb0d4884..a4ce0e199 100644 --- a/src/options/general.h +++ b/src/options/general.h @@ -16,7 +16,7 @@ typedef struct FFOptionsGeneral bool detectVersion; // Module options that cannot be put in module option structure - #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) FFstrbuf playerName; bool escapeBedrock; FFDsForceDrmType dsForceDrm; From 3e3dfb4a0255e96cf502c9a04dd33c5ec9653ff5 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 12 Feb 2025 08:53:27 +0800 Subject: [PATCH 14/87] OS: remove option `--escape-bedrock` --- src/data/help.json | 10 ---------- src/detection/os/os_linux.c | 2 +- src/options/general.c | 8 -------- src/options/general.h | 1 - 4 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/data/help.json b/src/data/help.json index 6acbb17bf..70184e529 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -104,16 +104,6 @@ "default": true } }, - { - "long": "escape-bedrock", - "desc": "On Bedrock Linux, whether to escape the bedrock jail", - "remark": "Linux only", - "arg": { - "type": "bool", - "optional": true, - "default": true - } - }, { "long": "wmi-timeout", "desc": "Set the timeout (ms) for WMI queries", diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 487c651a5..44a362605 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -261,7 +261,7 @@ static void detectOS(FFOSResult* os) return; #endif - if(instance.config.general.escapeBedrock && parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock" FASTFETCH_TARGET_DIR_ETC "/bedrock-release", os)) + if(parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock" FASTFETCH_TARGET_DIR_ETC "/bedrock-release", os)) { if(os->id.length == 0) ffStrbufAppendS(&os->id, "bedrock"); diff --git a/src/options/general.c b/src/options/general.c index 535c02626..eb09b127e 100644 --- a/src/options/general.c +++ b/src/options/general.c @@ -31,8 +31,6 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va options->detectVersion = yyjson_get_bool(val); #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) - else if (ffStrEqualsIgnCase(key, "escapeBedrock")) - options->escapeBedrock = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "playerName")) ffStrbufSetS(&options->playerName, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "dsForceDrm")) @@ -76,8 +74,6 @@ bool ffOptionsParseGeneralCommandLine(FFOptionsGeneral* options, const char* key options->detectVersion = ffOptionParseBoolean(value); #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) - else if(ffStrEqualsIgnCase(key, "--escape-bedrock")) - options->escapeBedrock = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--player-name")) ffOptionParseString(key, value, &options->playerName); else if(ffStrEqualsIgnCase(key, "--ds-force-drm")) @@ -107,7 +103,6 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options) options->detectVersion = true; #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) - options->escapeBedrock = true; ffStrbufInit(&options->playerName); options->dsForceDrm = FF_DS_FORCE_DRM_TYPE_FALSE; #elif defined(_WIN32) @@ -137,9 +132,6 @@ void ffOptionsGenerateGeneralJsonConfig(FFOptionsGeneral* options, yyjson_mut_do #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) - if (options->escapeBedrock != defaultOptions.escapeBedrock) - yyjson_mut_obj_add_bool(doc, obj, "escapeBedrock", options->escapeBedrock); - if (!ffStrbufEqual(&options->playerName, &defaultOptions.playerName)) yyjson_mut_obj_add_strbuf(doc, obj, "playerName", &options->playerName); diff --git a/src/options/general.h b/src/options/general.h index a4ce0e199..9e703a946 100644 --- a/src/options/general.h +++ b/src/options/general.h @@ -18,7 +18,6 @@ typedef struct FFOptionsGeneral // Module options that cannot be put in module option structure #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) FFstrbuf playerName; - bool escapeBedrock; FFDsForceDrmType dsForceDrm; #elif defined(_WIN32) int32_t wmiTimeout; From 735a464f68ed4f648be4dbfa7bfff7ff5f0e245f Mon Sep 17 00:00:00 2001 From: Pro-pra Date: Wed, 12 Feb 2025 16:13:17 +0900 Subject: [PATCH 15/87] Logo (Builtin): update Rosa linux logo (#1559) * Update rosa logo * Update rosa colors * replace invisible unicode charactors --------- Co-authored-by: Carter Li --- src/logo/ascii/rosa.txt | 38 ++++++++++++++++++-------------------- src/logo/builtin.c | 7 ++++--- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/logo/ascii/rosa.txt b/src/logo/ascii/rosa.txt index 297c19f39..70c2d8884 100644 --- a/src/logo/ascii/rosa.txt +++ b/src/logo/ascii/rosa.txt @@ -1,20 +1,18 @@ - ROSAROSAROSAROSAR - ROSA AROS - ROS SAROSAROSAROSAR AROS - RO ROSAROSAROSAROSAROSAR RO - ARO AROSAROSAROSARO AROS ROS - ARO ROSAROS OSAR ROSA ROS - RO AROSA ROSAROSAROSA ROSAR RO -RO ROSAR ROSAROSAROSAR R ROSARO RO -RO ROSA AROSAROSAROSA AR ROSARO AR -RO AROS ROSAROSAROSA ROS AROSARO AR -RO AROS ROSAROSARO ROSARO ROSARO AR -RO ROS AROSAROS ROSAROSA AROSAR AR -RO ROSA ROS ROSAROSAR ROSARO RO - RO ROS AROSAROSAROSA ROSARO AR - ARO ROSA ROSAROSAROS AROSAR ARO - ARO OROSA R ROSAROS ROS - RO AROSAROS AROSAROSAR RO - AROS AROSAROSAROSARO AROS - ROSA SARO - ROSAROSAROSAROSAR \ No newline at end of file +${c2} ⢀⣀⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣄ +${c2} ⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇ +${c1} ⢀⣤⣄ ${c2}⣿⣿⣿⡇ +${c1} ⢀⣴⣿⣿⣿⠗ ${c2}⣿⣿⣿⡇ +${c1} ⢠⣾⣿⣿⡿⠁ ${c2}⣿⣿⣿⡇ +${c1} ⢠⣿⣿⣿⡟ ${c2}⣿⣿⣿⡇ +${c1}⢀⣿⣿⣿⡿ ${c2}⣿⣿⣿⡇ +${c1}⢸⣿⣿⣿⠃ ${c2}⣿⣿⣿⡇ +${c1}⢸⣿⣿⣿ ${c2}⣿⣿⣿⡇ +${c1}⢸⣿⣿⣿ ${c2}⣿⣿⣿⡇ +${c1}⢸⣿⣿⣿⡄ ${c2}⠙⢿⡿ +${c1}⠘⣿⣿⣿⣷ + ⠘⣿⣿⣿⣦ + ⠙⣿⣿⣿⣷⡀ ⢀⡀ + ⠘⢿⣿⣿⣿⣦⣄ ⣠⣴⣿⣿⡦ + ⠙⢿⣿⣿⣿⣷⣦⣀⣀⡀ ⢀⣀⣠⣴⣾⣿⣿⣿⠟⠁ + ⠈⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠁ + ⠈⠙⠛⠿⠿⠿⠿⠿⠿⠟⠛⠋⠁ diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 4dc7bf749..4314dac0b 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -4056,10 +4056,11 @@ static const FFlogo R[] = { .names = {"rosa", "rosa-linux", "rosalinux"}, .lines = FASTFETCH_DATATEXT_LOGO_ROSA, .colors = { - FF_COLOR_FG_BLUE, + FF_COLOR_FG_RGB "250;250;250", + FF_COLOR_FG_RGB "100;165;225", }, - .colorKeys = FF_COLOR_FG_BLUE, - .colorTitle = FF_COLOR_FG_BLUE, + .colorKeys = FF_COLOR_FG_RGB "100;165;225", + .colorTitle = FF_COLOR_FG_RGB "100;165;225", }, // RhinoLinux { From 3c45f2e59004843bf538bb1c8eaea3d8b31a7791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 12 Feb 2025 16:16:59 +0800 Subject: [PATCH 16/87] Scripts: download pci.ids by cmake; remove `python-requests` dependency --- .github/workflows/ci.yml | 14 +++++++------- CMakeLists.txt | 7 ++++++- scripts/gen-pciids.py | 16 +++++++--------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2fe017ef..6a8351223 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,7 +80,7 @@ jobs: run: cat /proc/cpuinfo - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev directx-headers-dev python3-requests + run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev directx-headers-dev - name: install linuxbrew packages run: | @@ -149,7 +149,7 @@ jobs: run: cat /proc/cpuinfo - name: install required packages - run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev directx-headers-dev python3-requests libchafa-dev libddcutil-dev rpm + run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev directx-headers-dev libchafa-dev libddcutil-dev rpm - name: configure project run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DCMAKE_INSTALL_PREFIX=/usr . @@ -380,7 +380,7 @@ jobs: run: | cat /etc/alpine-release uname -a - apk add cmake samurai vulkan-loader-dev libxcb-dev wayland-dev libdrm-dev dconf-dev imagemagick-dev chafa-dev zlib-dev dbus-dev mesa-dev opencl-dev xfconf-dev sqlite-dev networkmanager-dev pulseaudio-dev ddcutil-dev elfutils-dev py3-requests gcc g++ + apk add cmake samurai vulkan-loader-dev libxcb-dev wayland-dev libdrm-dev dconf-dev imagemagick-dev chafa-dev zlib-dev dbus-dev mesa-dev opencl-dev xfconf-dev sqlite-dev networkmanager-dev pulseaudio-dev ddcutil-dev elfutils-dev gcc g++ shell: alpine.sh --root {0} - name: build @@ -514,7 +514,7 @@ jobs: run: | uname -a sudo pkg update - sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat py311-requests chafa + sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat chafa cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On . cmake --build . --target package --verbose -j4 ./fastfetch --list-features @@ -547,7 +547,7 @@ jobs: prepare: | uname -a pkg update - pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat py39-requests chafa libelf + pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat chafa libelf run: | cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On . @@ -585,7 +585,7 @@ jobs: version: '7.6' run: | uname -a - sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio hwdata py3-requests + sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio hwdata cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=ON . cmake --build . --target package --verbose -j4 ./fastfetch --list-features @@ -621,7 +621,7 @@ jobs: version: '10.1' run: | uname -a - sudo pkgin -y install cmake git pkgconf wayland vulkan-headers dconf dbus sqlite3 ImageMagick pulseaudio opencl-headers ocl-icd py312-requests + sudo pkgin -y install cmake git pkgconf wayland vulkan-headers dconf dbus sqlite3 ImageMagick pulseaudio opencl-headers ocl-icd cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=ON . cmake --build . --target package --verbose -j4 ./fastfetch --list-features diff --git a/CMakeLists.txt b/CMakeLists.txt index 769f81806..525285009 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,11 +271,16 @@ endif() if(ENABLE_EMBEDDED_PCIIDS AND NOT EXISTS "${PROJECT_BINARY_DIR}/fastfetch_pciids.c.inc") if(Python_FOUND) + if(NOT EXISTS "${PROJECT_BINARY_DIR}/pci.ids") + message(STATUS "'${PROJECT_BINARY_DIR}/pci.ids' is missing, downloading...") + file(DOWNLOAD "https://pci-ids.ucw.cz/v2.2/pci.ids" "${PROJECT_BINARY_DIR}/pci.ids") + endif() message(STATUS "Generating 'fastfetch_pciids.c.inc'") - execute_process(COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen-pciids.py" + execute_process(COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen-pciids.py" "${PROJECT_BINARY_DIR}/pci.ids" OUTPUT_FILE "${PROJECT_BINARY_DIR}/fastfetch_pciids.c.inc" RESULT_VARIABLE PYTHON_PCIIDS_RETCODE) if(NOT PYTHON_PCIIDS_RETCODE EQUAL 0) + file(REMOVE "${PROJECT_BINARY_DIR}/fastfetch_pciids.c.inc") message(FATAL_ERROR "Failed to generate 'fastfetch_pciids.c.inc'") endif() else() diff --git a/scripts/gen-pciids.py b/scripts/gen-pciids.py index 875b8511a..4c1270b9d 100755 --- a/scripts/gen-pciids.py +++ b/scripts/gen-pciids.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from requests import get as http_get +import sys class PciDeviceModel: def __init__(self, id: int, name: str): @@ -13,14 +13,10 @@ class PciVendorModel: self.name = name self.devices = [] -def main(keep_vendor_list: set): +def main(keep_vendor_list: set, pci_ids_path: str): vendors = [] - try: - with open('pci.ids', 'r') as f: - full_text = f.read() - except FileNotFoundError: - response = http_get('https://pci-ids.ucw.cz/v2.2/pci.ids') - full_text = response.text + with open(pci_ids_path, 'r') as f: + full_text = f.read() dev_list_text = full_text[:full_text.rfind('\n\n\n')] # remove known classes for line in dev_list_text.split('\n'): @@ -80,6 +76,8 @@ const FFPciVendor ffPciVendors[] = {{ print(code) if __name__ == '__main__': + len(sys.argv) == 2 or sys.exit('Usage: gen-pciids.py ') + # From main({ 0x106b, # Apple @@ -94,4 +92,4 @@ if __name__ == '__main__': 0x1ab8, # Parallel 0x1414, # Microsoft 0x108e, # Oracle - }) + }, sys.argv[1]) From 1812c30fbfe072a8b27a230bfcc416d8368dde83 Mon Sep 17 00:00:00 2001 From: DrSheppard <60893791+Drsheppard01@users.noreply.github.com> Date: Wed, 12 Feb 2025 11:42:21 +0300 Subject: [PATCH 17/87] Doc: update README.md (#1557) [ci skip] * [chore] Update README.md move repology badge to install section customize with `columns` and `minversion` tags * tweaks --------- Co-authored-by: Carter Li --- README.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 83a08ef41..0649a4b83 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,10 @@ There are [screenshots on different platforms](https://github.com/fastfetch-cli/ Some distros package an outdated fastfetch version. Older versions receive no support, so please try always to use the latest version. + + Packaging status + + * Ubuntu: [`ppa:zhangsongcui3371/fastfetch`](https://launchpad.net/~zhangsongcui3371/+archive/ubuntu/fastfetch) (for Ubuntu 22.04 or newer) * Debian: `apt install fastfetch` (for Debian 13 or newer) * Debian / Ubuntu: Download `fastfetch-linux-.deb` from [Github release page](https://github.com/fastfetch-cli/fastfetch/releases/latest) and double-click it (for Ubuntu 20.04 or newer and Debian 11 or newer). @@ -47,8 +51,6 @@ Some distros package an outdated fastfetch version. Older versions receive no su You may need `sudo`, `doas` or `sup` to run these commands. -[See also if fastfetch has been packaged for your favorite Linux distro](#Packaging). - If fastfetch is not packaged for your distro or an outdated version is packaged, [linuxbrew](https://brew.sh/) is a good alternative: `brew install fastfetch` ### macOS @@ -95,18 +97,6 @@ Fastfetch uses the JSONC (or JSON with comments) for configuration. [See Wiki fo Logos can also be heavily customized; see the [logo documentation](https://github.com/fastfetch-cli/fastfetch/wiki/Logo-options) for more information. - -## Packaging - -### Repositories - -[![Packaging status](https://repology.org/badge/vertical-allrepos/fastfetch.svg?header=)](https://repology.org/project/fastfetch/versions) - -### Manual - -* DEB / RPM package: `cmake --build . --target package` -* Install directly: `cmake --install . --prefix /usr/local` - ## FAQ ### Q: Neofetch is good enough. Why do I need fastfetch? From ef3412f81b2ba69f4b4e23b413159f0105cfcbd9 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 12 Feb 2025 22:22:35 +0000 Subject: [PATCH 18/87] GPU (Haiku): add pci.ids file path --- src/common/init.c | 3 +++ src/detection/gpu/gpu_pci.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/common/init.c b/src/common/init.c index d6adc1342..91d30d64c 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -236,6 +236,9 @@ void ffListFeatures(void) #if FF_HAVE_FREETYPE "freetype\n" #endif + #if FF_HAVE_PCIACCESS + "libpciaccess\n" + #endif #if FF_HAVE_PULSE "libpulse\n" #endif diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index f06358236..acbf3c166 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -45,6 +45,8 @@ static const FFstrbuf* loadPciIds() ffReadFileBuffer(_PATH_LOCALBASE "/share/pciids/pci.ids", &pciids); #elif __sun ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/share/hwdata/pci.ids", &pciids); + #elif __HAIKU__ + ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/system/data/pciutils/pci.ids", &pciids); #endif #endif // FF_CUSTOM_PCI_IDS_PATH From d1a98fe69fa30e2becccfdb7225e56fa02243eea Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 12 Feb 2025 22:47:37 +0000 Subject: [PATCH 19/87] Terminal (Haiku): add pretty name for Haiku Terminal --- src/detection/terminalshell/terminalshell_linux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 45f1ec566..6a99aefe2 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -359,6 +359,11 @@ static void setTerminalInfoDetails(FFTerminalResult* result) else if(ffStrbufEqualS(&result->processName, "WarpTerminal")) ffStrbufInitStatic(&result->prettyName, "Warp"); + #elif defined(__HAIKU__) + + else if(ffStrbufEqualS(&result->processName, "Terminal")) + ffStrbufInitStatic(&result->prettyName, "Haiku Terminal"); + #endif else if(strncmp(result->exeName, result->processName.chars, result->processName.length) == 0) // if exeName starts with processName, print it. Otherwise print processName From f2a41b82bca191e43e29e8ea38f9ffbaf59a5512 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 12 Feb 2025 22:48:24 +0000 Subject: [PATCH 20/87] TerminalFont (Haiku): support Haiku Terminal --- .../terminalfont/terminalfont_linux.c | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 2c0ecd28b..497755bc5 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -418,6 +418,21 @@ static void detectWestonTerminal(FFTerminalFontResult* terminalFont) ffFontInitValues(&terminalFont->font, font.chars, size.chars); } +#ifdef __HAIKU__ +static void detectHaikuTerminal(FFTerminalFontResult* terminalFont) +{ + FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY size = ffStrbufCreate(); + ffParsePropFileConfigValues("Terminal/Default", 2, (FFpropquery[]) { + {"\"Half Font Family\" , ", &font}, + {"\"Half Font Size\" , ", &size}, + }); + if (!font.length) ffStrbufSetStatic(&font, "Noto Sans Mono"); + if (!size.length) ffStrbufSetStatic(&size, "12"); + ffFontInitValues(&terminalFont->font, font.chars, size.chars); +} +#endif + void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseEqualS(&terminal->processName, "konsole")) @@ -455,5 +470,9 @@ void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFo else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "terminator")) detectTerminator(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "sakura")) - detectFromConfigFile("sakura/sakura.conf", "font=", terminalFont);; + detectFromConfigFile("sakura/sakura.conf", "font=", terminalFont); + #ifdef __HAIKU__ + else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "Terminal")) + detectHaikuTerminal(terminalFont); + #endif } From 379c39d8b58d1b946b827fa1ad75cd99ca837cd0 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 12 Feb 2025 23:06:40 +0000 Subject: [PATCH 21/87] GPU (Haiku): change the path of pci.ids to hwdata --- src/detection/gpu/gpu_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index acbf3c166..dfc35558d 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -46,7 +46,7 @@ static const FFstrbuf* loadPciIds() #elif __sun ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/share/hwdata/pci.ids", &pciids); #elif __HAIKU__ - ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/system/data/pciutils/pci.ids", &pciids); + ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/system/data/hwdata/pci.ids", &pciids); #endif #endif // FF_CUSTOM_PCI_IDS_PATH From b8e25bdc4e45c3e79817796826d9b23b94246cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 13 Feb 2025 10:43:11 +0800 Subject: [PATCH 22/87] GPU: support embedding amdgpu.ids into fastfetch --- CMakeLists.txt | 24 ++++++++++++++++++ scripts/gen-amdgpuids.py | 43 ++++++++++++++++++++++++++++++++ src/detection/gpu/gpu.h | 1 + src/detection/gpu/gpu_bsd.c | 7 +----- src/detection/gpu/gpu_general.c | 7 +----- src/detection/gpu/gpu_linux.c | 11 +-------- src/detection/gpu/gpu_pci.c | 44 +++++++++++++++++++++++++++++++++ src/detection/gpu/gpu_sunos.c | 7 +----- 8 files changed, 116 insertions(+), 28 deletions(-) create mode 100755 scripts/gen-amdgpuids.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 525285009..148582670 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by gith option(IS_MUSL "Build with musl libc" OFF) # Used by Github Actions option(INSTALL_LICENSE "Install license into /usr/share/licenses" ON) option(ENABLE_EMBEDDED_PCIIDS "Embed pci.ids into fastfetch, requires `python`" OFF) +option(ENABLE_EMBEDDED_AMDGPUIDS "Embed amdgpu.ids into fastfetch, requires `python`" OFF) set(BINARY_LINK_TYPE_OPTIONS dlopen dynamic static) set(BINARY_LINK_TYPE dlopen CACHE STRING "How to link fastfetch") @@ -289,6 +290,26 @@ if(ENABLE_EMBEDDED_PCIIDS AND NOT EXISTS "${PROJECT_BINARY_DIR}/fastfetch_pciids endif() endif() +if(ENABLE_EMBEDDED_AMDGPUIDS AND NOT EXISTS "${PROJECT_BINARY_DIR}/fastfetch_amdgpuids.c.inc") + if(Python_FOUND) + if(NOT EXISTS "${PROJECT_BINARY_DIR}/amdgpu.ids") + message(STATUS "'${PROJECT_BINARY_DIR}/amdgpu.ids' is missing, downloading...") + file(DOWNLOAD "https://gitlab.freedesktop.org/mesa/drm/-/raw/main/data/amdgpu.ids" "${PROJECT_BINARY_DIR}/amdgpu.ids") + endif() + message(STATUS "Generating 'fastfetch_amdgpuids.c.inc'") + execute_process(COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen-amdgpuids.py" "${PROJECT_BINARY_DIR}/amdgpu.ids" + OUTPUT_FILE "${PROJECT_BINARY_DIR}/fastfetch_amdgpuids.c.inc" + RESULT_VARIABLE PYTHON_AMDGPUIDS_RETCODE) + if(NOT PYTHON_AMDGPUIDS_RETCODE EQUAL 0) + file(REMOVE "${PROJECT_BINARY_DIR}/fastfetch_amdgpuids.c.inc") + message(FATAL_ERROR "Failed to generate 'fastfetch_amdgpuids.c.inc'") + endif() + else() + message(WARNING "Python3 is not found, 'fastfetch_amdgpuids.c.inc' will not be generated") + set(ENABLE_EMBEDDED_AMDGPUIDS OFF) + endif() +endif() + if(Python_FOUND) message(STATUS "Generating 'fastfetch.1'") execute_process(COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen-man.py" @@ -1517,6 +1538,9 @@ endif() if(ENABLE_EMBEDDED_PCIIDS) target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EMBEDDED_PCIIDS=1) endif() +if(ENABLE_EMBEDDED_AMDGPUIDS) + target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EMBEDDED_AMDGPUIDS=1) +endif() if(LINUX) target_link_libraries(libfastfetch diff --git a/scripts/gen-amdgpuids.py b/scripts/gen-amdgpuids.py new file mode 100755 index 000000000..253c3a370 --- /dev/null +++ b/scripts/gen-amdgpuids.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +import sys + +def main(amdgpu_ids_path: str): + with open(amdgpu_ids_path, 'r') as f: + full_text = f.read() + + products = [] + for line in full_text.split('\n'): + if not line or line[0] == '#' or not ',\t' in line: + continue + device, revision, name = line.split(',\t', maxsplit=2) + products.append((device, revision, name)) + + code = """\ +// SPDX-License-Identifier: MIT +// https://opensource.org/license/mit +// Generated from https://gitlab.freedesktop.org/mesa/drm/-/raw/main/data/amdgpu.ids + +#include +#include + +typedef struct FFArmGpuProduct +{ + const uint32_t id; // device << 8 | revision + const char* name; +} FFArmGpuProduct; + +const FFArmGpuProduct ffAmdGpuProducts[] = { +""" + + for device, revision, name in products: + code += f" {{ 0x{device} << 8 | 0x{revision}, \"{name.replace('"', '\\"')}\" }},\n" + + code += "};\n" + + print(code) + +if __name__ == '__main__': + len(sys.argv) == 2 or sys.exit('Usage: gen-amdgpuids.py ') + + main(sys.argv[1]) diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 7ed37910f..bef90b6d5 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -50,4 +50,5 @@ const char* ffGPUGetVendorString(unsigned vendorId); #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) void ffGPUFillVendorAndName(uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu); +void ffGPUQueryAmdGpuName(uint16_t deviceId, uint8_t revisionId, FFGPUResult* gpu); #endif diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index 40821c9b8..1525e9e0e 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -1,7 +1,6 @@ #include "gpu_driver_specific.h" #include "common/io/io.h" -#include "common/properties.h" #include #include @@ -76,11 +75,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) if (gpu->name.length == 0) { if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) - { - char query[32]; - snprintf(query, ARRAY_SIZE(query), "%X,\t%X,", (unsigned) pc->pc_device, (unsigned) pc->pc_revid); - ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); - } + ffGPUQueryAmdGpuName(pc->pc_device, pc->pc_revid, gpu); if (gpu->name.length == 0) ffGPUFillVendorAndName(pc->pc_subclass, pc->pc_vendor, pc->pc_device, gpu); } diff --git a/src/detection/gpu/gpu_general.c b/src/detection/gpu/gpu_general.c index 464cccbef..fdffcdd90 100644 --- a/src/detection/gpu/gpu_general.c +++ b/src/detection/gpu/gpu_general.c @@ -2,7 +2,6 @@ #ifdef FF_HAVE_PCIACCESS -#include "common/properties.h" #include "common/io/io.h" #include "common/library.h" @@ -43,11 +42,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpu->frequency = FF_GPU_FREQUENCY_UNSET; if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) - { - char query[32]; - snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) dev->device_id, (unsigned) dev->revision); - ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); - } + ffGPUQueryAmdGpuName(dev->device_id, dev->revision, gpu); if (gpu->name.length == 0) { diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index cc655e31e..f2563917b 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -4,7 +4,6 @@ #include "detection/gpu/gpu_driver_specific.h" #include "common/io/io.h" #include "common/library.h" -#include "common/properties.h" #include "util/stringUtils.h" #include "util/mallocHelper.h" @@ -491,15 +490,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf char* pend; uint64_t revision = strtoul(buffer->chars, &pend, 16); if (pend != buffer->chars) - { - char query[32]; - snprintf(query, ARRAY_SIZE(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision); - #ifdef FF_CUSTOM_AMDGPU_IDS_PATH - ffParsePropFile(FF_STR(FF_CUSTOM_AMDGPU_IDS_PATH), query, &gpu->name); - #else - ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); - #endif - } + ffGPUQueryAmdGpuName((uint16_t) deviceId, (uint8_t) revision, gpu); } ffStrbufSubstrBefore(deviceDir, drmDirPathLength); } diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index dfc35558d..11fd3ab10 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -1,5 +1,6 @@ #include "gpu.h" #include "common/io/io.h" +#include "common/properties.h" #include #ifdef __FreeBSD__ @@ -16,6 +17,9 @@ #if FF_HAVE_EMBEDDED_PCIIDS #include "fastfetch_pciids.c.inc" #endif +#if FF_HAVE_EMBEDDED_AMDGPUIDS +#include "fastfetch_amdgpuids.c.inc" +#endif #define FF_STR_INDIR(x) #x #define FF_STR(x) FF_STR_INDIR(x) @@ -191,3 +195,43 @@ void ffGPUFillVendorAndName(uint8_t subclass, uint16_t vendor, uint16_t device, #endif return parsePciIdsFile(loadPciIds(), subclass, vendor, device, gpu); } + +#if FF_HAVE_EMBEDDED_AMDGPUIDS +static inline int amdGpuCmp(const uint32_t* key, const FFArmGpuProduct* element) +{ + // Maximum value of *key is 0x00FFFFFF. `(int) *key` should never overflow + return (int) *key - (int) element->id; +} + +static bool loadAmdGpuIdsInc(uint16_t deviceId, uint8_t revision, FFGPUResult* gpu) +{ + uint32_t key = (deviceId << 8u) | revision; + FFArmGpuProduct* product = bsearch(&key, ffAmdGpuProducts, ARRAY_SIZE(ffAmdGpuProducts), sizeof(*ffAmdGpuProducts), (void*) amdGpuCmp); + if (product) + { + ffStrbufSetS(&gpu->name, product->name); + return true; + } + return false; +} +#endif + +static void parseAmdGpuIdsFile(uint16_t deviceId, uint8_t revision, FFGPUResult* gpu) +{ + char query[32]; + snprintf(query, ARRAY_SIZE(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision); + #ifdef FF_CUSTOM_AMDGPU_IDS_PATH + ffParsePropFile(FF_STR(FF_CUSTOM_AMDGPU_IDS_PATH), query, &gpu->name); + #else + ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); + #endif +} + +void ffGPUQueryAmdGpuName(uint16_t deviceId, uint8_t revisionId, FFGPUResult* gpu) +{ + #if FF_HAVE_EMBEDDED_AMDGPUIDS + bool ok = loadAmdGpuIdsInc(deviceId, revisionId, gpu); + if (ok) return; + #endif + return parseAmdGpuIdsFile(deviceId, revisionId, gpu); +} diff --git a/src/detection/gpu/gpu_sunos.c b/src/detection/gpu/gpu_sunos.c index d79f430e2..8c59f7dc6 100644 --- a/src/detection/gpu/gpu_sunos.c +++ b/src/detection/gpu/gpu_sunos.c @@ -1,5 +1,4 @@ #include "gpu.h" -#include "common/properties.h" #include "common/io/io.h" #include "common/processing.h" @@ -65,11 +64,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpu->frequency = FF_GPU_FREQUENCY_UNSET; if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) - { - char query[32]; - snprintf(query, ARRAY_SIZE(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision); - ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); - } + ffGPUQueryAmdGpuName((uint16_t) deviceId, (uint8_t) revision, gpu); if (gpu->name.length == 0) { From 464e00d616459ee96f39fe9a0a617cf6200d5b81 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 12 Feb 2025 21:59:19 +0000 Subject: [PATCH 23/87] GPU (Haiku): use system API to fetch PCI devices --- CMakeLists.txt | 4 ++-- src/detection/gpu/gpu_haiku.c | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/detection/gpu/gpu_haiku.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 148582670..913d06263 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" O cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly OR Haiku" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD OR SunOS OR Haiku" OFF) +cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD OR SunOS" OFF) option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embedded) yyjson library" OFF) option(ENABLE_ASAN "Build fastfetch with ASAN (address sanitizer)" OFF) @@ -1143,7 +1143,7 @@ elseif(Haiku) src/detection/diskio/diskio_nosupport.c src/detection/displayserver/displayserver_haiku.cpp src/detection/font/font_haiku.cpp - src/detection/gpu/gpu_general.c + src/detection/gpu/gpu_haiku.c src/detection/gpu/gpu_pci.c src/detection/gtk_qt/gtk.c src/detection/host/host_nosupport.c diff --git a/src/detection/gpu/gpu_haiku.c b/src/detection/gpu/gpu_haiku.c new file mode 100644 index 000000000..31de1b8b9 --- /dev/null +++ b/src/detection/gpu/gpu_haiku.c @@ -0,0 +1,43 @@ +#include "gpu.h" +#include "common/io/io.h" + +#include + +const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) +{ + FF_AUTO_CLOSE_FD int pokefd = open(POKE_DEVICE_FULLNAME, O_RDWR); + if (pokefd < 0) return "open(POKE_DEVICE_FULLNAME) failed"; + + pci_info dev; + pci_info_args cmd = { + .signature = POKE_SIGNATURE, + .info = &dev, + }; + + for (cmd.index = 0; ioctl(pokefd, POKE_GET_NTH_PCI_INFO, &cmd) == B_OK && cmd.status == B_OK; ++cmd.index) + { + if (dev.class_base != 0x03 /*PCI_BASE_CLASS_DISPLAY*/) + continue; + + FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); + ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(dev.vendor_id)); + ffStrbufInit(&gpu->name); + ffStrbufInit(&gpu->driver); + ffStrbufInit(&gpu->platformApi); + gpu->temperature = FF_GPU_TEMP_UNSET; + gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; + gpu->type = FF_GPU_TYPE_UNKNOWN; + gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; + gpu->deviceId = ((uint64_t) dev.bus << 4) | ((uint64_t) dev.device << 2) | (uint64_t) dev.function; + gpu->frequency = FF_GPU_FREQUENCY_UNSET; + + if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) + ffGPUQueryAmdGpuName(dev.device_id, dev.revision, gpu); + + if (gpu->name.length == 0) + ffGPUFillVendorAndName(dev.class_sub, dev.vendor_id, dev.device_id, gpu); + } + + return NULL; +} + From c585e09ef0b17ac8f03b06c56cc3da2b660861a7 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 13 Feb 2025 22:39:45 +0000 Subject: [PATCH 24/87] Processing (Haiku): support exe path detection --- src/common/processing_linux.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index f5fb46e1b..e4a8f62d5 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -30,6 +30,7 @@ #include #elif defined(__HAIKU__) #include + #include #endif enum { FF_PIPE_BUFSIZ = 8192 }; @@ -312,6 +313,21 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons } kvm_close(kd); + #elif defined(__HAIKU__) + + if (exePath) + { + image_info info; + int32 cookie = 0; + + while (get_next_image_info(pid, &cookie, &info) == B_OK) + { + if (info.type != B_APP_IMAGE) continue; + ffStrbufSetS(exePath, info.name); + break; + } + } + #endif if(exe->length == 0) @@ -488,6 +504,8 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i *ppid = info.parent; } + FF_UNUSED(tty); + #else return "Unsupported platform"; From 452d52c2179bfd5a28a7754e8860d1a9690dc73c Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 13 Feb 2025 22:46:27 +0000 Subject: [PATCH 25/87] InitSystem (Haiku): enable support --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 913d06263..7b8c32ef8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1148,7 +1148,7 @@ elseif(Haiku) src/detection/gtk_qt/gtk.c src/detection/host/host_nosupport.c src/detection/icons/icons_nosupport.c - src/detection/initsystem/initsystem_nosupport.c + src/detection/initsystem/initsystem_linux.c src/detection/keyboard/keyboard_nosupport.c src/detection/libc/libc_nosupport.c src/detection/lm/lm_nosupport.c From e38f094c1683058da32c0afbd82c501be9249951 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 13 Feb 2025 22:56:25 +0000 Subject: [PATCH 26/87] Uptime (Haiku): silence compiler warnings --- src/common/time.h | 6 ++++++ src/detection/uptime/uptime_haiku.c | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/time.h b/src/common/time.h index 588ba7847..a04120905 100644 --- a/src/common/time.h +++ b/src/common/time.h @@ -7,6 +7,8 @@ #include #include #include +#elif defined(__HAIKU__) + #include #endif static inline double ffTimeGetTick(void) //In msec @@ -17,6 +19,8 @@ static inline double ffTimeGetTick(void) //In msec LARGE_INTEGER start; QueryPerformanceCounter(&start); return (double) start.QuadPart * 1000 / (double) frequency.QuadPart; + #elif defined(__HAIKU__) + return (double) system_time() / 1000.; #else struct timespec timeNow; clock_gettime(CLOCK_MONOTONIC, &timeNow); @@ -30,6 +34,8 @@ static inline uint64_t ffTimeGetNow(void) uint64_t timeNow; GetSystemTimeAsFileTime((FILETIME*) &timeNow); return (timeNow - 116444736000000000ull) / 10000ull; + #elif defined(__HAIKU__) + return (uint64_t) real_time_clock_usecs() / 1000u; #else struct timespec timeNow; clock_gettime(CLOCK_REALTIME, &timeNow); diff --git a/src/detection/uptime/uptime_haiku.c b/src/detection/uptime/uptime_haiku.c index 46af1115e..a2c48a5ec 100644 --- a/src/detection/uptime/uptime_haiku.c +++ b/src/detection/uptime/uptime_haiku.c @@ -1,11 +1,9 @@ #include "uptime.h" #include "common/time.h" -#include - const char* ffDetectUptime(FFUptimeResult* result) { - result->uptime = system_time() / 1000; - result->bootTime = (real_time_clock_usecs() / 1000) - result->uptime; + result->uptime = (uint64_t) system_time() / 1000; + result->bootTime = ffTimeGetNow() - result->uptime; return NULL; } From 14aadd5b6127dbb6361ebbea4cb463357f7b7944 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 13 Feb 2025 23:04:20 +0000 Subject: [PATCH 27/87] Logo (Builtin): simplify haiku; add haiku2 from neofetch --- src/logo/ascii/haiku.txt | 12 ++++++------ src/logo/ascii/haiku2.txt | 17 +++++++++++++++++ src/logo/builtin.c | 13 +++++++++++-- 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/logo/ascii/haiku2.txt diff --git a/src/logo/ascii/haiku.txt b/src/logo/ascii/haiku.txt index 36b432aa6..52863ddba 100644 --- a/src/logo/ascii/haiku.txt +++ b/src/logo/ascii/haiku.txt @@ -1,12 +1,12 @@ -$3 MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM - MMMM$4 .ciO| /YMMMMM*" -$3 MMMM$4 .cOMMMMM|/MMMMM/` + MMMM MMMM + MMMM$2 .ciO| /YMMMMM*" +$1 MMMM$2 .cOMMMMM|/MMMMM/` , ,iMM|/MMMMMMMMMMMMMMM* - `*.__,-cMMMMMMMMMMMMMMMMM/`$3.MMM - MM$4MMMMMMM/`:MMM/ $3MMMM + `*.__,-cMMMMMMMMMMMMMMMMM/`$1.MMM + MM$2MMMMMMM/`:MMM/ $1MMMM MMMM MMMM MMMM MMMM - """" """" \ No newline at end of file + """" """" diff --git a/src/logo/ascii/haiku2.txt b/src/logo/ascii/haiku2.txt new file mode 100644 index 000000000..56a7feb4b --- /dev/null +++ b/src/logo/ascii/haiku2.txt @@ -0,0 +1,17 @@ +${c2} :dc' + 'l:;'${c1},${c2}'ck. .;dc:. + co ${c1}..${c2}k. .;; ':o. + co ${c1}..${c2}k. ol ${c1}.${c2}0. + co ${c1}..${c2}k. oc ${c1}..${c2}0. + co ${c1}..${c2}k. oc ${c1}..${c2}0. +.Ol,. co ${c1}...''${c2}Oc;kkodxOdddOoc,. + ';lxxlxOdxkxk0kd${c1}oooll${c2}dl${c1}ccc:${c2}clxd; + ..${c1}oOolllllccccccc:::::${c2}od; + cx:ooc${c1}:::::::;${c2}cooolcX. + cd${c1}.${c2}''cloxdoollc' ${c1}...${c2}0. + cd${c1}......${c2}k;${c1}.${c2}xl${c1}.... .${c2}0. + .::c${c1};..${c2}cx;${c1}.${c2}xo${c1}..... .${c2}0. + '::c'${c1}...${c2}do${c1}..... .${c2}K, + cd,.${c1}....:${c2}O,${c1} + ':clod:'${c1} + ${c1} diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 4314dac0b..78a38bf08 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2006,14 +2006,23 @@ static const FFlogo H[] = { .names = {"Haiku"}, .lines = FASTFETCH_DATATEXT_LOGO_HAIKU, .colors = { - FF_COLOR_FG_RED, - FF_COLOR_FG_YELLOW, FF_COLOR_FG_DEFAULT, FF_COLOR_FG_GREEN, }, .colorKeys = FF_COLOR_FG_RED, .colorTitle = FF_COLOR_FG_YELLOW, }, + // Haiku2 + { + .names = {"Haiku2"}, + .lines = FASTFETCH_DATATEXT_LOGO_HAIKU2, + .colors = { + FF_COLOR_FG_GREEN, + FF_COLOR_FG_DEFAULT, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_YELLOW, + }, // HaikuSmall { .names = {"Haiku-small"}, From c53191a4418a515cf336ed60a7df151e5c251e39 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 13 Feb 2025 23:27:14 +0000 Subject: [PATCH 28/87] Battery (Haiku): add stub file --- CMakeLists.txt | 2 +- src/detection/battery/battery_haiku.c | 31 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/detection/battery/battery_haiku.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8c32ef8..9570926f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1123,7 +1123,7 @@ elseif(Haiku) src/common/netif/netif_haiku.c src/common/networking_linux.c src/common/processing_linux.c - src/detection/battery/battery_nosupport.c + src/detection/battery/battery_haiku.c src/detection/bios/bios_nosupport.c src/detection/board/board_nosupport.c src/detection/bootmgr/bootmgr_nosupport.c diff --git a/src/detection/battery/battery_haiku.c b/src/detection/battery/battery_haiku.c new file mode 100644 index 000000000..abd10b594 --- /dev/null +++ b/src/detection/battery/battery_haiku.c @@ -0,0 +1,31 @@ +#include "fastfetch.h" +#include "battery.h" +#include "common/io/io.h" +#include "util/stringUtils.h" + +void parseBattery(FFstrbuf* content, FFlist* results) +{ + char* line = NULL; + size_t n = 0; + while (ffStrbufGetline(&line, &n, content)) + { + + } +} + +const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) +{ + FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/"); + if (!dir) return "opendir(/dev/power/acpi_battery) failed"; + + FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); + struct dirent* entry; + while ((entry = readdir(dir))) + { + if (entry->d_name[0] == '.') continue; + if (!ffReadFileBufferRelative(dirfd(dir), entry->d_name, &content)) continue; + parseBattery(&content, results); + } + + return "To be supported"; +} From cdc8124883feb9849825cef772bf17ed139d5360 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 14 Feb 2025 00:23:20 +0000 Subject: [PATCH 29/87] Battery (Haiku): add support (untested) --- src/detection/battery/battery_haiku.c | 51 +++++++++++++++++++++------ 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/detection/battery/battery_haiku.c b/src/detection/battery/battery_haiku.c index abd10b594..67b117bdb 100644 --- a/src/detection/battery/battery_haiku.c +++ b/src/detection/battery/battery_haiku.c @@ -1,16 +1,47 @@ #include "fastfetch.h" #include "battery.h" #include "common/io/io.h" -#include "util/stringUtils.h" -void parseBattery(FFstrbuf* content, FFlist* results) +#include +#include +#include + +const char* parseBattery(int dfd, const char* battId, FFlist* results) { - char* line = NULL; - size_t n = 0; - while (ffStrbufGetline(&line, &n, content)) - { + FF_AUTO_CLOSE_FD int fd = openat(dfd, battId, O_RDWR); + if (fd < 0) return "openat() failed"; - } + acpi_battery_info basic = {}; + if (ioctl(fd, GET_BATTERY_INFO, &basic, sizeof(basic)) != 0) + return "ioctl(GET_BATTERY_INFO) failed"; + acpi_extended_battery_info extended = {}; + if (ioctl(fd, GET_EXTENDED_BATTERY_INFO, &extended, sizeof(extended)) != 0) + return "ioctl(GET_EXTENDED_BATTERY_INFO) failed"; + + FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results); + ffStrbufInitS(&battery->modelName, extended.model_number); + ffStrbufInitS(&battery->manufacturer, extended.oem_info); + ffStrbufInit(&battery->manufactureDate); + ffStrbufInitS(&battery->technology, extended.type); // extended.technology? + ffStrbufInit(&battery->status); + ffStrbufInitS(&battery->serial, extended.serial_number); + battery->temperature = FF_BATTERY_TEMP_UNSET; + battery->cycleCount = extended.cycles; + battery->timeRemaining = -1; + battery->capacity = (double) basic.capacity / (double) extended.last_full_charge; + + if (basic.state & BATTERY_DISCHARGING) + ffStrbufAppendS(&battery->status, "Discharging, "); + if (basic.state & BATTERY_CHARGING) + ffStrbufAppendS(&battery->status, "Charging, "); + if (basic.state & BATTERY_CRITICAL_STATE) + ffStrbufAppendS(&battery->status, "Critical, "); + if (basic.state & BATTERY_NOT_CHARGING) + ffStrbufAppendS(&battery->status, "AC Connected, "); + ffStrbufTrimRight(&battery->status, ' '); + ffStrbufTrimRight(&battery->status, ','); + + return NULL; } const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) @@ -18,14 +49,12 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/"); if (!dir) return "opendir(/dev/power/acpi_battery) failed"; - FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate(); struct dirent* entry; while ((entry = readdir(dir))) { if (entry->d_name[0] == '.') continue; - if (!ffReadFileBufferRelative(dirfd(dir), entry->d_name, &content)) continue; - parseBattery(&content, results); + parseBattery(dirfd(dir), entry->d_name, results); } - return "To be supported"; + return NULL; } From f4f1592bfaee5ac09653104070990a98272f6938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 13 Feb 2025 14:14:52 +0800 Subject: [PATCH 30/87] CI: enable `-DENABLE_EMBEDDED_AMDGPUIDS=On` --- .github/workflows/ci.yml | 14 +++++++------- scripts/gen-amdgpuids.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a8351223..9583926bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,7 @@ jobs: languages: c - name: configure project - run: PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DCMAKE_INSTALL_PREFIX=/usr . + run: PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_INSTALL_PREFIX=/usr . - name: build project run: cmake --build . --target package --verbose -j4 @@ -152,7 +152,7 @@ jobs: run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev directx-headers-dev libchafa-dev libddcutil-dev rpm - name: configure project - run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DCMAKE_INSTALL_PREFIX=/usr . + run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_INSTALL_PREFIX=/usr . - name: build project run: cmake --build . --target package --verbose -j4 @@ -385,7 +385,7 @@ jobs: - name: build run: | - cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DIS_MUSL=ON -DENABLE_EMBEDDED_PCIIDS=On -GNinja . + cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DIS_MUSL=ON -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -GNinja . cmake --build . --target package --verbose -j4 shell: alpine.sh {0} @@ -515,7 +515,7 @@ jobs: uname -a sudo pkg update sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat chafa - cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On . + cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On . cmake --build . --target package --verbose -j4 ./fastfetch --list-features time ./fastfetch -c presets/ci.jsonc --stat false @@ -550,7 +550,7 @@ jobs: pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat chafa libelf run: | - cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On . + cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On . cmake --build . --target package --verbose -j4 ./fastfetch --list-features time ./fastfetch -c presets/ci.jsonc --stat false @@ -586,7 +586,7 @@ jobs: run: | uname -a sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio hwdata - cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=ON . + cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On . cmake --build . --target package --verbose -j4 ./fastfetch --list-features time ./fastfetch -c presets/ci.jsonc --stat false @@ -622,7 +622,7 @@ jobs: run: | uname -a sudo pkgin -y install cmake git pkgconf wayland vulkan-headers dconf dbus sqlite3 ImageMagick pulseaudio opencl-headers ocl-icd - cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=ON . + cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On . cmake --build . --target package --verbose -j4 ./fastfetch --list-features time ./fastfetch -c presets/ci.jsonc --stat false diff --git a/scripts/gen-amdgpuids.py b/scripts/gen-amdgpuids.py index 253c3a370..463b42690 100755 --- a/scripts/gen-amdgpuids.py +++ b/scripts/gen-amdgpuids.py @@ -31,7 +31,7 @@ const FFArmGpuProduct ffAmdGpuProducts[] = { """ for device, revision, name in products: - code += f" {{ 0x{device} << 8 | 0x{revision}, \"{name.replace('"', '\\"')}\" }},\n" + code += f" {{ 0x{device} << 8 | 0x{revision}, \"{name}\" }},\n" code += "};\n" From a8afd05d19a6bb317607723cae8d0f17771d7989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 14 Feb 2025 10:30:34 +0800 Subject: [PATCH 31/87] Battery (Haiku): fix capacity calculation --- src/detection/battery/battery_haiku.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/battery/battery_haiku.c b/src/detection/battery/battery_haiku.c index 67b117bdb..60dbde3ea 100644 --- a/src/detection/battery/battery_haiku.c +++ b/src/detection/battery/battery_haiku.c @@ -28,7 +28,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) battery->temperature = FF_BATTERY_TEMP_UNSET; battery->cycleCount = extended.cycles; battery->timeRemaining = -1; - battery->capacity = (double) basic.capacity / (double) extended.last_full_charge; + battery->capacity = (double) basic.capacity * 100. / (double) extended.last_full_charge; if (basic.state & BATTERY_DISCHARGING) ffStrbufAppendS(&battery->status, "Discharging, "); From ba7885913db64bea1183e59f7460a429f21da865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 14 Feb 2025 10:31:13 +0800 Subject: [PATCH 32/87] Weather: honor `display.temp.unit` Fix #1560 --- doc/json_schema.json | 4 ++-- src/common/temps.c | 1 + src/data/help.json | 3 ++- src/detection/weather/weather.c | 11 +++++++++++ src/options/display.c | 9 ++++++++- src/options/display.h | 1 + 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index 61308e83c..23b06183c 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -817,8 +817,8 @@ "unit": { "type": "string", "description": "Set the unit of the temperature", - "enum": ["CELSIUS", "C", "FAHRENHEIT", "F", "KELVIN", "K"], - "default": "C" + "enum": ["D", "Default", "Celsius", "C", "Fahrenheit", "F", "Kelvin", "K"], + "default": "D" }, "ndigits": { "type": "integer", diff --git a/src/common/temps.c b/src/common/temps.c index e413d4c5c..10e11de61 100644 --- a/src/common/temps.c +++ b/src/common/temps.c @@ -39,6 +39,7 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi switch (options->tempUnit) { + case FF_TEMPERATURE_UNIT_DEFAULT: case FF_TEMPERATURE_UNIT_CELSIUS: ffStrbufAppendF(buffer, "%.*f°C", options->tempNdigits, celsius); break; diff --git a/src/data/help.json b/src/data/help.json index 70184e529..35218f5ca 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -722,11 +722,12 @@ "arg": { "type": "enum", "enum": { + "D": "Default", "C": "Celsius", "F": "Fahrenheit", "K": "Kelvin" }, - "default": "C" + "default": "D" } }, { diff --git a/src/detection/weather/weather.c b/src/detection/weather/weather.c index fccdd2d12..c340db636 100644 --- a/src/detection/weather/weather.c +++ b/src/detection/weather/weather.c @@ -19,6 +19,17 @@ void ffPrepareWeather(FFWeatherOptions* options) ffStrbufAppend(&path, &options->location); ffStrbufAppendS(&path, "?format="); ffStrbufAppend(&path, &options->outputFormat); + switch (instance.config.display.tempUnit) + { + case FF_TEMPERATURE_UNIT_CELSIUS: + ffStrbufAppendS(&path, "&m"); + break; + case FF_TEMPERATURE_UNIT_FAHRENHEIT: + ffStrbufAppendS(&path, "&u"); + break; + default: + break; + } status = ffNetworkingSendHttpRequest(&state, "wttr.in", path.chars, "User-Agent: curl/0.0.0\r\n"); } diff --git a/src/options/display.c b/src/options/display.c index 111a5cdfc..247abfc6f 100644 --- a/src/options/display.c +++ b/src/options/display.c @@ -130,6 +130,8 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va { int value; const char* error = ffJsonConfigParseEnum(unit, &value, (FFKeyValuePair[]) { + { "DEFAULT", FF_TEMPERATURE_UNIT_DEFAULT }, + { "D", FF_TEMPERATURE_UNIT_DEFAULT }, { "CELSIUS", FF_TEMPERATURE_UNIT_CELSIUS }, { "C", FF_TEMPERATURE_UNIT_CELSIUS }, { "FAHRENHEIT", FF_TEMPERATURE_UNIT_FAHRENHEIT }, @@ -418,6 +420,8 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key if(ffStrEqualsIgnCase(subkey, "unit")) { options->tempUnit = (FFTemperatureUnit) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "DEFAULT", FF_TEMPERATURE_UNIT_DEFAULT }, + { "D", FF_TEMPERATURE_UNIT_DEFAULT }, { "CELSIUS", FF_TEMPERATURE_UNIT_CELSIUS }, { "C", FF_TEMPERATURE_UNIT_CELSIUS }, { "FAHRENHEIT", FF_TEMPERATURE_UNIT_FAHRENHEIT }, @@ -513,7 +517,7 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options) options->keyPaddingLeft = 0; options->keyType = FF_MODULE_KEY_TYPE_STRING; - options->tempUnit = FF_TEMPERATURE_UNIT_CELSIUS; + options->tempUnit = FF_TEMPERATURE_UNIT_DEFAULT; options->tempNdigits = 1; ffStrbufInitStatic(&options->tempColorGreen, FF_COLOR_FG_GREEN); ffStrbufInitStatic(&options->tempColorYellow, instance.state.terminalLightTheme ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_LIGHT_YELLOW); @@ -643,6 +647,9 @@ void ffOptionsGenerateDisplayJsonConfig(FFOptionsDisplay* options, yyjson_mut_do { switch (options->tempUnit) { + case FF_TEMPERATURE_UNIT_DEFAULT: + yyjson_mut_obj_add_str(doc, temperature, "unit", "DEFAULT"); + break; case FF_TEMPERATURE_UNIT_CELSIUS: yyjson_mut_obj_add_str(doc, obj, "unit", "C"); break; diff --git a/src/options/display.h b/src/options/display.h index 47aaed0d6..ef3c21971 100644 --- a/src/options/display.h +++ b/src/options/display.h @@ -11,6 +11,7 @@ typedef enum __attribute__((__packed__)) FFSizeBinaryPrefixType typedef enum __attribute__((__packed__)) FFTemperatureUnit { + FF_TEMPERATURE_UNIT_DEFAULT, FF_TEMPERATURE_UNIT_CELSIUS, FF_TEMPERATURE_UNIT_FAHRENHEIT, FF_TEMPERATURE_UNIT_KELVIN, From 217ea61568173d3828ee827200790242697046ba Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 14 Feb 2025 14:05:37 +0800 Subject: [PATCH 33/87] Sound: properly round percent values Fix #1558 --- src/detection/sound/sound_linux.c | 2 +- src/detection/sound/sound_nbsd.c | 2 +- src/detection/sound/sound_obsd.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index 8fc371d12..f97379331 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -18,7 +18,7 @@ static void paSinkInfoCallback(pa_context *c, const pa_sink_info *i, int eol, vo ffStrbufInitS(&device->name, i->description); ffStrbufTrimRightSpace(&device->name); ffStrbufTrimLeft(&device->name, ' '); - device->volume = i->mute ? 0 : (uint8_t) (i->volume.values[0] * 100 / PA_VOLUME_NORM); + device->volume = i->mute ? 0 : (uint8_t) ((i->volume.values[0] * 100 + PA_VOLUME_NORM / 2 /*round*/) / PA_VOLUME_NORM); device->active = i->active_port && i->active_port->available != PA_PORT_AVAILABLE_NO; device->main = false; } diff --git a/src/detection/sound/sound_nbsd.c b/src/detection/sound/sound_nbsd.c index 03d76ac86..8ce71d77d 100644 --- a/src/detection/sound/sound_nbsd.c +++ b/src/detection/sound/sound_nbsd.c @@ -41,7 +41,7 @@ const char* ffDetectSound(FFlist* devices) ffStrbufInitS(&device->name, ad.name); ffStrbufTrimRightSpace(&device->name); ffStrbufInitF(&device->platformApi, "%s", "SunAudio"); - device->volume = (uint8_t) (ai.play.gain * 100 / AUDIO_MAX_GAIN); + device->volume = (uint8_t) ((ai.play.gain * 100 + AUDIO_MAX_GAIN / 2) / AUDIO_MAX_GAIN); device->active = true; device->main = defaultDev == idev; } diff --git a/src/detection/sound/sound_obsd.c b/src/detection/sound/sound_obsd.c index baac25dd5..2b19d0eb5 100644 --- a/src/detection/sound/sound_obsd.c +++ b/src/detection/sound/sound_obsd.c @@ -80,7 +80,7 @@ const char* ffDetectSound(FFlist* devices) if (!bundle.mute[i]) totalLevel += bundle.level[i]; } - device->volume = (uint8_t) (totalLevel * 100 / bundle.iLevel); + device->volume = (uint8_t) ((totalLevel * 100 + bundle.iLevel / 2) / bundle.iLevel); return NULL; } From fae8d1dd100f0492bd5e1197166fb96fa02a334d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 14 Feb 2025 19:31:35 +0800 Subject: [PATCH 34/87] PhysicalMemory: fix `--format json` printing --- src/modules/physicalmemory/physicalmemory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/physicalmemory/physicalmemory.c b/src/modules/physicalmemory/physicalmemory.c index 2585a054f..2ee653c59 100644 --- a/src/modules/physicalmemory/physicalmemory.c +++ b/src/modules/physicalmemory/physicalmemory.c @@ -160,6 +160,7 @@ static FFModuleBaseInfo ffModuleInfo = { .parseJsonObject = (void*) ffParsePhysicalMemoryJsonObject, .printModule = (void*) ffPrintPhysicalMemory, .generateJsonConfig = (void*) ffGeneratePhysicalMemoryJsonConfig, + .generateJsonResult = (void*) ffGeneratePhysicalMemoryJsonResult, .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) { {"Size (in bytes)", "bytes"}, {"Size formatted", "size"}, From c081268b7cb6d102b59912d17633d9aa314fb8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 14 Feb 2025 18:40:37 +0800 Subject: [PATCH 35/87] StringUtils: fix a possible segfault --- src/util/stringUtils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/stringUtils.h b/src/util/stringUtils.h index c22d1976e..9a3f43712 100644 --- a/src/util/stringUtils.h +++ b/src/util/stringUtils.h @@ -83,7 +83,7 @@ static inline bool ffCharIsDigit(char c) // Copies at most (dstBufSiz - 1) bytes from src to dst; dst is always null-terminated static inline char* ffStrCopy(char* __restrict__ dst, const char* __restrict__ src, size_t dstBufSiz) { - if (__builtin_expect(dst == NULL, false)) return dst; + if (__builtin_expect(dst == NULL, false) || dstBufSiz == 0) return dst; size_t len = strnlen(src, dstBufSiz - 1); memcpy(dst, src, len); From 8984aa740efbd58ef26f0da26b7d67924bd39861 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 14 Feb 2025 16:47:48 +0800 Subject: [PATCH 36/87] Smbios (Haiku): add support; enable related modules --- CMakeLists.txt | 12 +++++------ src/util/smbiosHelper.c | 47 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9570926f0..875f35a25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1124,14 +1124,14 @@ elseif(Haiku) src/common/networking_linux.c src/common/processing_linux.c src/detection/battery/battery_haiku.c - src/detection/bios/bios_nosupport.c - src/detection/board/board_nosupport.c + src/detection/bios/bios_windows.c + src/detection/board/board_windows.c src/detection/bootmgr/bootmgr_nosupport.c src/detection/brightness/brightness_nosupport.c src/detection/btrfs/btrfs_nosupport.c - src/detection/chassis/chassis_nosupport.c + src/detection/chassis/chassis_windows.c src/detection/cpu/cpu_haiku.c - src/detection/cpucache/cpucache_nosupport.c + src/detection/cpucache/cpucache_shared.c src/detection/cpuusage/cpuusage_nosupport.c src/detection/cursor/cursor_nosupport.c src/detection/bluetooth/bluetooth_nosupport.c @@ -1139,14 +1139,14 @@ elseif(Haiku) src/detection/disk/disk_haiku.cpp src/detection/dns/dns_linux.c src/detection/physicaldisk/physicaldisk_nosupport.c - src/detection/physicalmemory/physicalmemory_nosupport.c + src/detection/physicalmemory/physicalmemory_linux.c src/detection/diskio/diskio_nosupport.c src/detection/displayserver/displayserver_haiku.cpp src/detection/font/font_haiku.cpp src/detection/gpu/gpu_haiku.c src/detection/gpu/gpu_pci.c src/detection/gtk_qt/gtk.c - src/detection/host/host_nosupport.c + src/detection/host/host_windows.c src/detection/icons/icons_nosupport.c src/detection/initsystem/initsystem_linux.c src/detection/keyboard/keyboard_nosupport.c diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index 9366f8a9f..058b64d9d 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -50,7 +50,7 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header) return (const FFSmbiosHeader*) (p + 1); } -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__HAIKU__) #include #include #include @@ -135,6 +135,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() if (buffer.chars == NULL) { + #ifndef __HAIKU__ #ifdef __linux__ if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", &buffer)) #endif @@ -216,6 +217,50 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() munmap(p, tableLength); } } + #else + { + uint32_t tableLength = 0; + off_t tableAddress = 0; + FF_AUTO_CLOSE_FD int fd = open("/dev/misc/mem", O_RDONLY); + if (fd < 0) + return NULL; + FF_AUTO_FREE uint8_t* smBiosBase = malloc(0x10000); + if (pread(fd, smBiosBase, 0x10000, 0xF0000) != 0x10000) + return NULL; + + for (off_t offset = 0; offset <= 0xffe0; offset += 0x10) + { + FFSmbiosEntryPoint* p = (void*)(smBiosBase + offset); + if (memcmp(p, "_SM3_", sizeof(p->Smbios30.AnchorString)) == 0) + { + if (p->Smbios30.EntryPointLength != sizeof(p->Smbios30)) + return NULL; + tableLength = p->Smbios30.StructureTableMaximumSize; + tableAddress = (off_t) p->Smbios30.StructureTableAddress; + break; + } + else if (memcmp(p, "_SM_", sizeof(p->Smbios20.AnchorString)) == 0) + { + if (p->Smbios20.EntryPointLength != sizeof(p->Smbios20)) + return NULL; + tableLength = p->Smbios20.StructureTableLength; + tableAddress = (off_t) p->Smbios20.StructureTableAddress; + break; + } + } + if (tableLength == 0) + return NULL; + + ffStrbufEnsureFixedLengthFree(&buffer, tableLength); + if (pread(fd, buffer.chars, tableLength, tableAddress) == tableLength) + { + buffer.length = tableLength; + buffer.chars[buffer.length] = '\0'; + } + else + return NULL; + } + #endif for ( const FFSmbiosHeader* header = (const FFSmbiosHeader*) buffer.chars; From e8db71fe19414e4ef1535d91a71619c5eb99f378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 14 Feb 2025 22:42:15 +0800 Subject: [PATCH 37/87] Chore (Haiku): silence compiler warnings --- src/common/netif/netif_haiku.c | 4 ++-- src/detection/battery/battery_haiku.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/netif/netif_haiku.c b/src/common/netif/netif_haiku.c index 07185a7e9..daa0cd7a1 100644 --- a/src/common/netif/netif_haiku.c +++ b/src/common/netif/netif_haiku.c @@ -24,10 +24,10 @@ bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex) return false; int size = config.ifc_value; - if (size == 0) + if (size <= 0) return false; - FF_AUTO_FREE void *buffer = malloc(size); + FF_AUTO_FREE void *buffer = malloc((size_t) size); if (buffer == NULL) { return false; } diff --git a/src/detection/battery/battery_haiku.c b/src/detection/battery/battery_haiku.c index 60dbde3ea..09ffa37de 100644 --- a/src/detection/battery/battery_haiku.c +++ b/src/detection/battery/battery_haiku.c @@ -44,7 +44,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) return NULL; } -const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) +const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) { FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/"); if (!dir) return "opendir(/dev/power/acpi_battery) failed"; From 5f3ff07b4b38dcb99fdb52b15d675d937220003a Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 14 Feb 2025 23:51:10 +0800 Subject: [PATCH 38/87] Terminal (Haiku): fix konsole version detection --- src/detection/terminalshell/terminalshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 21c114488..fab4202b4 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -747,7 +747,7 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe #endif - #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun) || defined(__NetBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun) || defined(__NetBSD__) || defined(__HAIKU__) if(ffStrbufStartsWithIgnCaseS(processName, "gnome-terminal")) return getTerminalVersionGnome(exe, version); From f3e54f33c2efb63bf9feb16bc202c8d8e5389cc8 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 15 Feb 2025 11:12:40 +0800 Subject: [PATCH 39/87] Host (Haiku): add debug log --- src/util/smbiosHelper.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index 058b64d9d..290fb6b4a 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -223,42 +223,46 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() off_t tableAddress = 0; FF_AUTO_CLOSE_FD int fd = open("/dev/misc/mem", O_RDONLY); if (fd < 0) - return NULL; + {perror("open(mem)");return NULL;} FF_AUTO_FREE uint8_t* smBiosBase = malloc(0x10000); if (pread(fd, smBiosBase, 0x10000, 0xF0000) != 0x10000) - return NULL; - + {perror("pread(fd)");return NULL;} + puts("read(mem) ok"); for (off_t offset = 0; offset <= 0xffe0; offset += 0x10) { FFSmbiosEntryPoint* p = (void*)(smBiosBase + offset); if (memcmp(p, "_SM3_", sizeof(p->Smbios30.AnchorString)) == 0) { + puts("found SM3"); if (p->Smbios30.EntryPointLength != sizeof(p->Smbios30)) - return NULL; + {puts("invalid sm3 entry length"); return NULL;} tableLength = p->Smbios30.StructureTableMaximumSize; tableAddress = (off_t) p->Smbios30.StructureTableAddress; break; } else if (memcmp(p, "_SM_", sizeof(p->Smbios20.AnchorString)) == 0) { + puts("found SM2"); if (p->Smbios20.EntryPointLength != sizeof(p->Smbios20)) - return NULL; + { + puts("invalid sm2 entry length");return NULL;} tableLength = p->Smbios20.StructureTableLength; tableAddress = (off_t) p->Smbios20.StructureTableAddress; break; } } if (tableLength == 0) - return NULL; - + {puts("nothing found");return NULL;} + printf("found table length: %d\n", (int)tableLength); ffStrbufEnsureFixedLengthFree(&buffer, tableLength); if (pread(fd, buffer.chars, tableLength, tableAddress) == tableLength) { + puts("pread(table) done"); buffer.length = tableLength; buffer.chars[buffer.length] = '\0'; } else - return NULL; + {perror("pread(table)");return NULL;} } #endif @@ -278,6 +282,8 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() } } + puts("Everything is ok"); + return &table; } #elif defined(_WIN32) From c64854804db5bfe24ec22c0c16d0f1a7b65a93dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 15 Feb 2025 01:47:18 +0100 Subject: [PATCH 40/87] Haiku: 32bit fixes For historical reasons int32 and int32_t are not compatible types. --- src/detection/cpu/cpu_haiku.c | 2 +- src/detection/disk/disk_haiku.cpp | 2 +- src/detection/sound/sound_haiku.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/cpu/cpu_haiku.c b/src/detection/cpu/cpu_haiku.c index ec993a05c..17dc1385c 100644 --- a/src/detection/cpu/cpu_haiku.c +++ b/src/detection/cpu/cpu_haiku.c @@ -10,7 +10,7 @@ const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FFCPURe if (get_system_info(&sysInfo) != B_OK) return "get_system_info() failed"; - uint32_t topoNodeCount = 0; + uint32 topoNodeCount = 0; get_cpu_topology_info(NULL, &topoNodeCount); if (topoNodeCount == 0) return "get_cpu_topology_info(NULL) failed"; diff --git a/src/detection/disk/disk_haiku.cpp b/src/detection/disk/disk_haiku.cpp index 078284740..504ec797d 100644 --- a/src/detection/disk/disk_haiku.cpp +++ b/src/detection/disk/disk_haiku.cpp @@ -8,7 +8,7 @@ extern "C" const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_UNUSED FFlist* disks) { - int pos = 0; + int32 pos = 0; for (dev_t dev; (dev = next_dev(&pos)) >= B_OK;) { diff --git a/src/detection/sound/sound_haiku.cpp b/src/detection/sound/sound_haiku.cpp index 04dce76d5..2d35830b7 100644 --- a/src/detection/sound/sound_haiku.cpp +++ b/src/detection/sound/sound_haiku.cpp @@ -11,7 +11,7 @@ const char* ffDetectSound(FF_MAYBE_UNUSED FFlist* devices /* List of FFSoundDevi roster->GetAudioOutput(&mediaNode); - int32_t mediaOutputCount = 0; + int32 mediaOutputCount = 0; roster->GetAllOutputsFor(mediaNode, NULL, 0, &mediaOutputCount); if (mediaOutputCount == 0) return NULL; From 349fdd47e46d99a3864d794bf0c937057d3c299a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 15 Feb 2025 03:06:46 +0100 Subject: [PATCH 41/87] Sound (Haiku): add support --- src/detection/sound/sound_haiku.cpp | 71 +++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 8 deletions(-) diff --git a/src/detection/sound/sound_haiku.cpp b/src/detection/sound/sound_haiku.cpp index 2d35830b7..16cfbf341 100644 --- a/src/detection/sound/sound_haiku.cpp +++ b/src/detection/sound/sound_haiku.cpp @@ -2,21 +2,76 @@ extern "C" { #include "sound.h" } +#include +#include #include +#include -const char* ffDetectSound(FF_MAYBE_UNUSED FFlist* devices /* List of FFSoundDevice */) +const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) { BMediaRoster* roster = BMediaRoster::Roster(); media_node mediaNode; + live_node_info liveInfo; + dormant_node_info dormantInfo; + status_t status; - roster->GetAudioOutput(&mediaNode); - - int32 mediaOutputCount = 0; - roster->GetAllOutputsFor(mediaNode, NULL, 0, &mediaOutputCount); - if (mediaOutputCount == 0) + if (roster->GetAudioOutput(&mediaNode) != B_OK) return NULL; - // TODO: Implement the rest of the function + FFSoundDevice* device = (FFSoundDevice*)ffListAdd(devices); + if (roster->GetDormantNodeFor(mediaNode, &dormantInfo) == B_OK) + { + ffStrbufInitS(&device->identifier, dormantInfo.name); + } + if (roster->GetLiveNodeInfo(mediaNode, &liveInfo) == B_OK) + { + ffStrbufInitS(&device->name, liveInfo.name); + ffStrbufTrimRightSpace(&device->name); + } + ffStrbufInitF(&device->platformApi, "%s", "MediaKit"); + // We'll check the Mixer actually + device->volume = (uint8_t) 100; + device->active = true; + device->main = true; - return "Not supported on this platform"; + roster->ReleaseNode(mediaNode); + + media_node mixer; + status = roster->GetAudioMixer(&mixer); + if (status != B_OK) + return NULL; + + BParameterWeb *web; + status = roster->GetParameterWebFor(mixer, &web); + roster->ReleaseNode(mixer); // the web is all we need :-) + if (status != B_OK) + return NULL; + + BContinuousParameter *gain = NULL; + BParameter *mute = NULL; + BParameter *parameter; + for (int32 index = 0; (parameter = web->ParameterAt(index)) != NULL; index++) { + // assume the mute preceding master gain control + if (!strcmp(parameter->Kind(), B_MUTE)) + mute = parameter; + + if (!strcmp(parameter->Kind(), B_MASTER_GAIN)) { + // Can not use dynamic_cast due to fno-rtti + //gain = dynamic_cast(parameter); + gain = (BContinuousParameter *)(parameter); + break; + } + } + + if (gain == NULL) + return NULL; + + float volume = 0.0; + bigtime_t when; + size_t size = sizeof(volume); + gain->GetValue(&volume, &size, &when); + + device->volume = (uint8_t) (100 * (volume - gain->MinValue()) / (gain->MaxValue() - gain->MinValue())); + + return NULL; } From 1c858ae8351b446e99eb99c95c6b440d440f13c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 15 Feb 2025 04:26:10 +0100 Subject: [PATCH 42/87] InitSystem (Haiku): add support --- CMakeLists.txt | 2 +- src/detection/initsystem/initsystem_haiku.cpp | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/detection/initsystem/initsystem_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 875f35a25..64a5bed20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1148,7 +1148,7 @@ elseif(Haiku) src/detection/gtk_qt/gtk.c src/detection/host/host_windows.c src/detection/icons/icons_nosupport.c - src/detection/initsystem/initsystem_linux.c + src/detection/initsystem/initsystem_haiku.cpp src/detection/keyboard/keyboard_nosupport.c src/detection/libc/libc_nosupport.c src/detection/lm/lm_nosupport.c diff --git a/src/detection/initsystem/initsystem_haiku.cpp b/src/detection/initsystem/initsystem_haiku.cpp new file mode 100644 index 000000000..7714133af --- /dev/null +++ b/src/detection/initsystem/initsystem_haiku.cpp @@ -0,0 +1,52 @@ +extern "C" { +#include "initsystem.h" +#include "common/processing.h" +#include "util/binary.h" +#include "util/stringUtils.h" +}; + +#include +#include +#include +#include +#include +#include + +const char* ffDetectInitSystem(FFInitSystemResult* result) +{ + team_info teamInfo; + int32 cookie = 0; + + // Since it runs first, registrar does not know about it, + // so we can't query be_roster for it. + BPath path("/boot/system/servers/launch_daemon"); + if (path.InitCheck() != B_OK) + return NULL; + + ffStrbufSetS(&result->exe, path.Path()); + ffStrbufSetStatic(&result->name, "launch_daemon"); + + while (get_next_team_info(&cookie, &teamInfo) == B_OK) + { + if (strcmp(teamInfo.args, path.Path()) == 0) + { + result->pid = (int)teamInfo.team; + break; + } + } + + BFile f(path.Path(), B_READ_ONLY); + if (f.InitCheck() != B_OK) + return NULL; + BAppFileInfo fileInfo(&f); + if (f.InitCheck() != B_OK) + return NULL; + + version_info version; + if (fileInfo.GetVersionInfo(&version, B_SYSTEM_VERSION_KIND) != B_OK) + return NULL; + + ffStrbufSetF(&result->version, "%d.%d.%d", (int)version.major, (int)version.middle, (int)version.minor); + + return NULL; +} From 437006f5f104767cceaae6db8c67b6d228e88a4f Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 15 Feb 2025 12:42:26 +0800 Subject: [PATCH 43/87] Sound (Haiku): Init variables unconditionally; fix mute handling --- src/detection/sound/sound_haiku.cpp | 44 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/detection/sound/sound_haiku.cpp b/src/detection/sound/sound_haiku.cpp index 16cfbf341..eb31d76aa 100644 --- a/src/detection/sound/sound_haiku.cpp +++ b/src/detection/sound/sound_haiku.cpp @@ -1,6 +1,7 @@ extern "C" { #include "sound.h" +#include "util/stringUtils.h" } #include #include @@ -13,36 +14,34 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) media_node mediaNode; live_node_info liveInfo; dormant_node_info dormantInfo; - status_t status; if (roster->GetAudioOutput(&mediaNode) != B_OK) return NULL; FFSoundDevice* device = (FFSoundDevice*)ffListAdd(devices); + ffStrbufInit(&device->identifier); if (roster->GetDormantNodeFor(mediaNode, &dormantInfo) == B_OK) - { - ffStrbufInitS(&device->identifier, dormantInfo.name); - } + ffStrbufAppendS(&device->identifier, dormantInfo.name); + ffStrbufInit(&device->name); if (roster->GetLiveNodeInfo(mediaNode, &liveInfo) == B_OK) { - ffStrbufInitS(&device->name, liveInfo.name); + ffStrbufAppendS(&device->name, liveInfo.name); ffStrbufTrimRightSpace(&device->name); } - ffStrbufInitF(&device->platformApi, "%s", "MediaKit"); + ffStrbufInitStatic(&device->platformApi, "MediaKit"); // We'll check the Mixer actually - device->volume = (uint8_t) 100; + device->volume = 0; device->active = true; device->main = true; roster->ReleaseNode(mediaNode); media_node mixer; - status = roster->GetAudioMixer(&mixer); - if (status != B_OK) + if (roster->GetAudioMixer(&mixer) != B_OK) return NULL; BParameterWeb *web; - status = roster->GetParameterWebFor(mixer, &web); + status_t status = roster->GetParameterWebFor(mixer, &web); roster->ReleaseNode(mixer); // the web is all we need :-) if (status != B_OK) return NULL; @@ -50,12 +49,14 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) BContinuousParameter *gain = NULL; BParameter *mute = NULL; BParameter *parameter; - for (int32 index = 0; (parameter = web->ParameterAt(index)) != NULL; index++) { + for (int32 index = 0; (parameter = web->ParameterAt(index)) != NULL; index++) + { // assume the mute preceding master gain control - if (!strcmp(parameter->Kind(), B_MUTE)) + if (ffStrEquals(parameter->Kind(), B_MUTE)) mute = parameter; - if (!strcmp(parameter->Kind(), B_MASTER_GAIN)) { + if (ffStrEquals(parameter->Kind(), B_MASTER_GAIN)) + { // Can not use dynamic_cast due to fno-rtti //gain = dynamic_cast(parameter); gain = (BContinuousParameter *)(parameter); @@ -66,12 +67,21 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) if (gain == NULL) return NULL; - float volume = 0.0; bigtime_t when; - size_t size = sizeof(volume); - gain->GetValue(&volume, &size, &when); + size_t size; - device->volume = (uint8_t) (100 * (volume - gain->MinValue()) / (gain->MaxValue() - gain->MinValue())); + if (mute) + { + bool isMute = false; + size = sizeof(isMute); + if (mute->GetValue(&isMute, &size, &when) == B_OK && isMute) + return NULL; + } + + float volume = 0.0; + size = sizeof(volume); + if (gain->GetValue(&volume, &size, &when) == B_OK) + device->volume = (uint8_t) (100 * (volume - gain->MinValue()) / (gain->MaxValue() - gain->MinValue())); return NULL; } From 532b3cd45733200628385d2e5047fc88e2160c85 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 15 Feb 2025 14:45:09 +0800 Subject: [PATCH 44/87] Smbios (NetBSD): add support --- CMakeLists.txt | 4 ++-- src/util/smbiosHelper.c | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64a5bed20..3cb52dc5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -744,13 +744,13 @@ elseif(NetBSD) src/detection/btrfs/btrfs_nosupport.c src/detection/chassis/chassis_nbsd.c src/detection/cpu/cpu_nbsd.c - src/detection/cpucache/cpucache_nosupport.c + src/detection/cpucache/cpucache_shared.c src/detection/cpuusage/cpuusage_bsd.c src/detection/cursor/cursor_linux.c src/detection/disk/disk_bsd.c src/detection/dns/dns_linux.c src/detection/physicaldisk/physicaldisk_nosupport.c - src/detection/physicalmemory/physicalmemory_nosupport.c + src/detection/physicalmemory/physicalmemory_linux.c src/detection/diskio/diskio_nbsd.c src/detection/displayserver/linux/displayserver_linux.c src/detection/displayserver/linux/drm.c diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index 290fb6b4a..378eda6b0 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -50,7 +50,7 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header) return (const FFSmbiosHeader*) (p + 1); } -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__HAIKU__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__) #include #include #include @@ -63,6 +63,9 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header) #define loff_t off_t // FreeBSD doesn't have loff_t #elif defined(__sun) #define loff_t off_t +#elif defined(__NetBSD__) + #include "common/sysctl.h" + #define loff_t off_t #endif bool ffGetSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) @@ -140,7 +143,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", &buffer)) #endif { - #ifndef __sun + #if !defined(__sun) && !defined(__NetBSD__) FF_STRBUF_AUTO_DESTROY strEntryAddress = ffStrbufCreate(); #ifdef __FreeBSD__ if (!ffSettingsGetFreeBSDKenv("hint.smbios.0.mem", &strEntryAddress)) @@ -177,7 +180,13 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() if (fd < 0) return NULL; FFSmbiosEntryPoint entryPoint; - if (!ffReadFDData(fd, sizeof(entryPoint), &entryPoint)) return NULL; + #ifdef __NetBSD__ + off_t addr = (off_t) ffSysctlGetInt64("machdep.smbios", 0); + if (addr == 0) return NULL; + if (pread(fd, &entryPoint, sizeof(entryPoint), addr) < 1) return NULL; + #else + if (ffReadFDData(fd, sizeof(entryPoint), &entryPoint) < 1) return NULL; + #endif #endif uint32_t tableLength = 0; @@ -196,9 +205,11 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() tableLength = entryPoint.Smbios30.StructureTableMaximumSize; tableAddress = (loff_t) entryPoint.Smbios30.StructureTableAddress; } + else + return NULL; ffStrbufEnsureFixedLengthFree(&buffer, tableLength); - if (pread(fd, buffer.chars, tableLength, tableAddress) == tableLength) + if (pread(fd, buffer.chars, tableLength, tableAddress) == (ssize_t) tableLength) { buffer.length = tableLength; buffer.chars[buffer.length] = '\0'; From 34419d9bcfa8ac5202cbe0399b8b20b6c0004c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Feb 2025 19:47:16 +0800 Subject: [PATCH 45/87] Revert "Host (Haiku): add debug log" This reverts commit f3e54f33c2efb63bf9feb16bc202c8d8e5389cc8. --- src/util/smbiosHelper.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index 378eda6b0..94f99cdbb 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -234,46 +234,42 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() off_t tableAddress = 0; FF_AUTO_CLOSE_FD int fd = open("/dev/misc/mem", O_RDONLY); if (fd < 0) - {perror("open(mem)");return NULL;} + return NULL; FF_AUTO_FREE uint8_t* smBiosBase = malloc(0x10000); if (pread(fd, smBiosBase, 0x10000, 0xF0000) != 0x10000) - {perror("pread(fd)");return NULL;} - puts("read(mem) ok"); + return NULL; + for (off_t offset = 0; offset <= 0xffe0; offset += 0x10) { FFSmbiosEntryPoint* p = (void*)(smBiosBase + offset); if (memcmp(p, "_SM3_", sizeof(p->Smbios30.AnchorString)) == 0) { - puts("found SM3"); if (p->Smbios30.EntryPointLength != sizeof(p->Smbios30)) - {puts("invalid sm3 entry length"); return NULL;} + return NULL; tableLength = p->Smbios30.StructureTableMaximumSize; tableAddress = (off_t) p->Smbios30.StructureTableAddress; break; } else if (memcmp(p, "_SM_", sizeof(p->Smbios20.AnchorString)) == 0) { - puts("found SM2"); if (p->Smbios20.EntryPointLength != sizeof(p->Smbios20)) - { - puts("invalid sm2 entry length");return NULL;} + return NULL; tableLength = p->Smbios20.StructureTableLength; tableAddress = (off_t) p->Smbios20.StructureTableAddress; break; } } if (tableLength == 0) - {puts("nothing found");return NULL;} - printf("found table length: %d\n", (int)tableLength); + return NULL; + ffStrbufEnsureFixedLengthFree(&buffer, tableLength); if (pread(fd, buffer.chars, tableLength, tableAddress) == tableLength) { - puts("pread(table) done"); buffer.length = tableLength; buffer.chars[buffer.length] = '\0'; } else - {perror("pread(table)");return NULL;} + return NULL; } #endif @@ -293,8 +289,6 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() } } - puts("Everything is ok"); - return &table; } #elif defined(_WIN32) From 519dae9462ede0ac8d71e6cfb58bcbdb38675162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 15 Feb 2025 19:50:34 +0800 Subject: [PATCH 46/87] Smbios: don't try to scan memory multiple times --- src/util/smbiosHelper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index 94f99cdbb..be122d3e5 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -138,6 +138,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() if (buffer.chars == NULL) { + ffStrbufInit(&buffer); #ifndef __HAIKU__ #ifdef __linux__ if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", &buffer)) @@ -289,6 +290,9 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() } } + if (buffer.length == 0) + return NULL; + return &table; } #elif defined(_WIN32) From c1c59cff6d09f69e6b5a57a6c9de9a48f68f9188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 15 Feb 2025 15:07:59 +0100 Subject: [PATCH 47/87] Sound (Haiku): fix runtime error getting mute status sizeof(bool) is only 1. --- src/detection/sound/sound_haiku.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/sound/sound_haiku.cpp b/src/detection/sound/sound_haiku.cpp index eb31d76aa..ba2dd7aeb 100644 --- a/src/detection/sound/sound_haiku.cpp +++ b/src/detection/sound/sound_haiku.cpp @@ -72,7 +72,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) if (mute) { - bool isMute = false; + int32 isMute = false; size = sizeof(isMute); if (mute->GetValue(&isMute, &size, &when) == B_OK && isMute) return NULL; From bfa59d2c04a816da0860fffa559f2f0c1108519f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 15 Feb 2025 16:13:19 +0100 Subject: [PATCH 48/87] Mouse (Haiku): add support --- CMakeLists.txt | 2 +- src/detection/mouse/mouse_haiku.cpp | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/detection/mouse/mouse_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cb52dc5d..f6313cc5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1158,7 +1158,7 @@ elseif(Haiku) src/detection/gamepad/gamepad_nosupport.c src/detection/media/media_linux.c src/detection/memory/memory_haiku.c - src/detection/mouse/mouse_nosupport.c + src/detection/mouse/mouse_haiku.cpp src/detection/netio/netio_nosupport.c src/detection/opengl/opengl_linux.c src/detection/os/os_haiku.c diff --git a/src/detection/mouse/mouse_haiku.cpp b/src/detection/mouse/mouse_haiku.cpp new file mode 100644 index 000000000..ca36d0f47 --- /dev/null +++ b/src/detection/mouse/mouse_haiku.cpp @@ -0,0 +1,36 @@ +extern "C" { +#include "mouse.h" +#include "common/io/io.h" +} + +#include +#include + +const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) +{ + BList list; + BInputDevice *device; + + if (get_input_devices(&list) != B_OK) + { + return "get_input_devices() failed"; + } + + int32 i, n = list.CountItems(); + for (i = 0; i < n; i++) + { + device = (BInputDevice *) list.ItemAt(i); + if (device->Type() != B_POINTING_DEVICE) + continue; + + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name()); + if (!device->IsRunning()) + ffStrbufAppendS(&name, " (stopped)"); + + FFMouseDevice* device = (FFMouseDevice*) ffListAdd(devices); + ffStrbufInit(&device->serial); + ffStrbufInitMove(&device->name, &name); + } + + return NULL; +} From 5ebf984e9a68f13cadd85ddafee1c9eeda09d351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 15 Feb 2025 16:22:23 +0100 Subject: [PATCH 49/87] Keyboard (Haiku): add support --- CMakeLists.txt | 2 +- src/detection/keyboard/keyboard_haiku.cpp | 36 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/detection/keyboard/keyboard_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f6313cc5c..5a7d37f3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1149,7 +1149,7 @@ elseif(Haiku) src/detection/host/host_windows.c src/detection/icons/icons_nosupport.c src/detection/initsystem/initsystem_haiku.cpp - src/detection/keyboard/keyboard_nosupport.c + src/detection/keyboard/keyboard_haiku.cpp src/detection/libc/libc_nosupport.c src/detection/lm/lm_nosupport.c src/detection/loadavg/loadavg_nosupport.c diff --git a/src/detection/keyboard/keyboard_haiku.cpp b/src/detection/keyboard/keyboard_haiku.cpp new file mode 100644 index 000000000..777125119 --- /dev/null +++ b/src/detection/keyboard/keyboard_haiku.cpp @@ -0,0 +1,36 @@ +extern "C" { +#include "keyboard.h" +#include "common/io/io.h" +} + +#include +#include + +const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) +{ + BList list; + BInputDevice *device; + + if (get_input_devices(&list) != B_OK) + { + return "get_input_devices() failed"; + } + + int32 i, n = list.CountItems(); + for (i = 0; i < n; i++) + { + device = (BInputDevice *) list.ItemAt(i); + if (device->Type() != B_KEYBOARD_DEVICE) + continue; + + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name()); + if (!device->IsRunning()) + ffStrbufAppendS(&name, " (stopped)"); + + FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices); + ffStrbufInit(&device->serial); + ffStrbufInitMove(&device->name, &name); + } + + return NULL; +} From 1d2b6c0b1a5b2146c9d32c607119320e3430240d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 15 Feb 2025 18:53:59 +0100 Subject: [PATCH 50/87] NetIO (Haiku): add support --- CMakeLists.txt | 3 +- src/detection/netio/netio.c | 2 -- src/detection/netio/netio.h | 1 + src/detection/netio/netio_haiku.cpp | 51 +++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/detection/netio/netio_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a7d37f3e..380f57247 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1159,7 +1159,7 @@ elseif(Haiku) src/detection/media/media_linux.c src/detection/memory/memory_haiku.c src/detection/mouse/mouse_haiku.cpp - src/detection/netio/netio_nosupport.c + src/detection/netio/netio_haiku.cpp src/detection/opengl/opengl_linux.c src/detection/os/os_haiku.c src/detection/packages/packages_haiku.c @@ -1646,6 +1646,7 @@ elseif(ANDROID) elseif(Haiku) target_link_libraries(libfastfetch PRIVATE "network" + PRIVATE "bnetapi" PRIVATE "media" PRIVATE "be" PRIVATE "gnu" diff --git a/src/detection/netio/netio.c b/src/detection/netio/netio.c index 0c4084388..666321c99 100644 --- a/src/detection/netio/netio.c +++ b/src/detection/netio/netio.c @@ -2,8 +2,6 @@ #include "common/time.h" -const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options); - static FFlist ioCounters1; static uint64_t time1; diff --git a/src/detection/netio/netio.h b/src/detection/netio/netio.h index 1dd9586a4..de633a107 100644 --- a/src/detection/netio/netio.h +++ b/src/detection/netio/netio.h @@ -17,3 +17,4 @@ typedef struct FFNetIOResult } FFNetIOResult; const char* ffDetectNetIO(FFlist* result, FFNetIOOptions* options); +const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options); diff --git a/src/detection/netio/netio_haiku.cpp b/src/detection/netio/netio_haiku.cpp new file mode 100644 index 000000000..e58a3362f --- /dev/null +++ b/src/detection/netio/netio_haiku.cpp @@ -0,0 +1,51 @@ +extern "C" { +#include "netio.h" + +#include "common/netif/netif.h" +#include "util/mallocHelper.h" +} + +#include +#include + +const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) +{ + BNetworkRoster& roster = BNetworkRoster::Default(); + + BNetworkInterface interface; + uint32 cookie = 0; + + const char* defaultRouteIfName = ffNetifGetDefaultRouteIfName(); + + while (roster.GetNextInterface(&cookie, interface) == B_OK) + { + if (!interface.Exists()) + continue; + + if (options->defaultRouteOnly && strcmp(interface.Name(), defaultRouteIfName) != 0) + continue; + + if (options->namePrefix.length && strncmp(interface.Name(), options->namePrefix.chars, options->namePrefix.length) != 0) + continue; + + ifreq_stats stats; + memset(&stats, 0, sizeof(stats)); + interface.GetStats(stats); + + FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result); + *counters = (FFNetIOResult) { + .name = ffStrbufCreateS(interface.Name()), + .defaultRoute = strcmp(interface.Name(), defaultRouteIfName) == 0, + .txBytes = stats.send.bytes, + .rxBytes = stats.receive.bytes, + .txPackets = stats.send.packets, + .rxPackets = stats.receive.packets, + .rxErrors = stats.receive.errors, + .txErrors = stats.send.errors, + .rxDrops = stats.receive.dropped, + .txDrops = stats.send.dropped + }; + } + + return NULL; +} From fc3f47742a0c88871dc5177c18e3833a7cd57631 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 10:14:14 +0800 Subject: [PATCH 51/87] NetIO (Haiku): code cleanup --- src/detection/netio/netio_haiku.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/detection/netio/netio_haiku.cpp b/src/detection/netio/netio_haiku.cpp index e58a3362f..e0c62ebf2 100644 --- a/src/detection/netio/netio_haiku.cpp +++ b/src/detection/netio/netio_haiku.cpp @@ -1,8 +1,6 @@ extern "C" { #include "netio.h" - #include "common/netif/netif.h" -#include "util/mallocHelper.h" } #include @@ -15,27 +13,27 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) BNetworkInterface interface; uint32 cookie = 0; - const char* defaultRouteIfName = ffNetifGetDefaultRouteIfName(); + uint32_t defaultRouteIfIndex = ffNetifGetDefaultRouteIfIndex(); while (roster.GetNextInterface(&cookie, interface) == B_OK) { if (!interface.Exists()) continue; - if (options->defaultRouteOnly && strcmp(interface.Name(), defaultRouteIfName) != 0) + bool defaultRoute = interface.Index() == defaultRouteIfIndex; + if (options->defaultRouteOnly && !defaultRoute) continue; if (options->namePrefix.length && strncmp(interface.Name(), options->namePrefix.chars, options->namePrefix.length) != 0) continue; - ifreq_stats stats; - memset(&stats, 0, sizeof(stats)); - interface.GetStats(stats); + ifreq_stats stats = {}; + if (interface.GetStats(stats) != B_OK) continue; FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result); *counters = (FFNetIOResult) { .name = ffStrbufCreateS(interface.Name()), - .defaultRoute = strcmp(interface.Name(), defaultRouteIfName) == 0, + .defaultRoute = defaultRoute, .txBytes = stats.send.bytes, .rxBytes = stats.receive.bytes, .txPackets = stats.send.packets, From f5dbbb70ef3251ff87a66dba6c23a82b7a137278 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 10:22:26 +0800 Subject: [PATCH 52/87] Mouse / Keyboard (Haiku): code cleanup; ignore disabled devices --- src/detection/keyboard/keyboard_haiku.cpp | 21 ++++++--------------- src/detection/mouse/mouse_haiku.cpp | 21 ++++++--------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/detection/keyboard/keyboard_haiku.cpp b/src/detection/keyboard/keyboard_haiku.cpp index 777125119..f165b00fd 100644 --- a/src/detection/keyboard/keyboard_haiku.cpp +++ b/src/detection/keyboard/keyboard_haiku.cpp @@ -1,6 +1,5 @@ extern "C" { #include "keyboard.h" -#include "common/io/io.h" } #include @@ -9,27 +8,19 @@ extern "C" { const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { BList list; - BInputDevice *device; if (get_input_devices(&list) != B_OK) - { return "get_input_devices() failed"; - } - int32 i, n = list.CountItems(); - for (i = 0; i < n; i++) + for (int32 i = 0, n = list.CountItems(); i < n; i++) { - device = (BInputDevice *) list.ItemAt(i); - if (device->Type() != B_KEYBOARD_DEVICE) + BInputDevice *device = (BInputDevice *) list.ItemAt(i); + if (device->Type() != B_KEYBOARD_DEVICE || !device->IsRunning()) continue; - FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name()); - if (!device->IsRunning()) - ffStrbufAppendS(&name, " (stopped)"); - - FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices); - ffStrbufInit(&device->serial); - ffStrbufInitMove(&device->name, &name); + FFKeyboardDevice* item = (FFKeyboardDevice*) ffListAdd(devices); + ffStrbufInit(&item->serial); + ffStrbufInitS(&item->name, device->Name()); } return NULL; diff --git a/src/detection/mouse/mouse_haiku.cpp b/src/detection/mouse/mouse_haiku.cpp index ca36d0f47..1178a25b3 100644 --- a/src/detection/mouse/mouse_haiku.cpp +++ b/src/detection/mouse/mouse_haiku.cpp @@ -1,6 +1,5 @@ extern "C" { #include "mouse.h" -#include "common/io/io.h" } #include @@ -9,27 +8,19 @@ extern "C" { const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { BList list; - BInputDevice *device; if (get_input_devices(&list) != B_OK) - { return "get_input_devices() failed"; - } - int32 i, n = list.CountItems(); - for (i = 0; i < n; i++) + for (int32 i = 0, n = list.CountItems(); i < n; i++) { - device = (BInputDevice *) list.ItemAt(i); - if (device->Type() != B_POINTING_DEVICE) + BInputDevice *device = (BInputDevice *) list.ItemAt(i); + if (device->Type() != B_POINTING_DEVICE || !device->IsRunning()) continue; - FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name()); - if (!device->IsRunning()) - ffStrbufAppendS(&name, " (stopped)"); - - FFMouseDevice* device = (FFMouseDevice*) ffListAdd(devices); - ffStrbufInit(&device->serial); - ffStrbufInitMove(&device->name, &name); + FFMouseDevice* item = (FFMouseDevice*) ffListAdd(devices); + ffStrbufInit(&item->serial); + ffStrbufInitS(&item->name, device->Name()); } return NULL; From 01d37653b0abee06901be1eec681f1397149bc1f Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 10:50:56 +0800 Subject: [PATCH 53/87] Disk (Haiku): code cleanup; honor `option->folders` --- src/detection/disk/disk_haiku.cpp | 36 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/detection/disk/disk_haiku.cpp b/src/detection/disk/disk_haiku.cpp index 504ec797d..69f766fed 100644 --- a/src/detection/disk/disk_haiku.cpp +++ b/src/detection/disk/disk_haiku.cpp @@ -1,19 +1,33 @@ extern "C" { #include "disk.h" +#include "util/stringUtils.h" } #include #include #include -const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_UNUSED FFlist* disks) +const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { int32 pos = 0; for (dev_t dev; (dev = next_dev(&pos)) >= B_OK;) { fs_info fs; - fs_stat_dev(dev, &fs); + if (fs_stat_dev(dev, &fs) < -1) continue; + + if (!ffStrStartsWith(fs.device_name, "/dev/")) continue; // physical disks only + + node_ref node(fs.dev, fs.root); + BDirectory dir(&node); + BPath path(&dir); + if (path.InitCheck() != B_OK) continue; + + if (__builtin_expect(options->folders.length, 0)) + { + if (!ffDiskMatchMountpoint(options, path.Path())) + continue; + } FFDisk* disk = (FFDisk*) ffListAdd(disks); @@ -26,16 +40,7 @@ const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_U disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs.free_nodes); ffStrbufInitS(&disk->mountFrom, fs.device_name); - ffStrbufInit(&disk->mountpoint); - { - node_ref node(fs.dev, fs.root); - BDirectory dir(&node); - BPath path(&dir); - if (path.InitCheck() == B_OK) - ffStrbufSetS(&disk->mountpoint, path.Path()); - else - ffStrbufSetStatic(&disk->mountpoint, "?"); - } + ffStrbufInitS(&disk->mountpoint, path.Path()); ffStrbufInitS(&disk->filesystem, fs.fsh_name); ffStrbufInitS(&disk->name, fs.volume_name); disk->type = FF_DISK_VOLUME_TYPE_NONE; @@ -45,7 +50,12 @@ const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_U disk->type = (FFDiskVolumeType) (disk->type | FF_DISK_VOLUME_TYPE_READONLY_BIT); if (fs.flags & B_FS_IS_REMOVABLE) disk->type = (FFDiskVolumeType) (disk->type | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT); + if (disk->type == FF_DISK_VOLUME_TYPE_NONE) disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; disk->createTime = 0; + + time_t crTime; + if (dir.GetCreationTime(&crTime) == B_OK) + disk->createTime = (uint64_t) crTime * 1000; } - return 0; + return NULL; } From 8e5c2adda3a8628bb8f7d53181d64b6e9e4d18c3 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 11:05:58 +0800 Subject: [PATCH 54/87] Gamepad (Haiku): add support --- src/detection/gamepad/gamepad_haiku.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/detection/gamepad/gamepad_haiku.cpp diff --git a/src/detection/gamepad/gamepad_haiku.cpp b/src/detection/gamepad/gamepad_haiku.cpp new file mode 100644 index 000000000..820836f07 --- /dev/null +++ b/src/detection/gamepad/gamepad_haiku.cpp @@ -0,0 +1,21 @@ +extern "C" { +#include "gamepad.h" +} +#include + +const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) +{ + BJoystick js; + for (int32 i = 0, n = js.CountDevices(); i < n; ++i) + { + char name[B_OS_NAME_LENGTH]; + if (js.GetDeviceName(i, name) == B_OK) + { + FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices); + ffStrbufInit(&device->serial); + ffStrbufInitS(&device->name, name); + device->battery = 0; + } + } + return NULL; +} From 9ff3142b61e03c57f6e006c0a6bff8166b4c7638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Feb 2025 19:13:47 +0800 Subject: [PATCH 55/87] CPUUsage (Haiku): add support --- CMakeLists.txt | 2 +- src/detection/cpuusage/cpuusage_haiku.c | 27 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/detection/cpuusage/cpuusage_haiku.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 380f57247..bd054844d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1132,7 +1132,7 @@ elseif(Haiku) src/detection/chassis/chassis_windows.c src/detection/cpu/cpu_haiku.c src/detection/cpucache/cpucache_shared.c - src/detection/cpuusage/cpuusage_nosupport.c + src/detection/cpuusage/cpuusage_haiku.c src/detection/cursor/cursor_nosupport.c src/detection/bluetooth/bluetooth_nosupport.c src/detection/bluetoothradio/bluetoothradio_nosupport.c diff --git a/src/detection/cpuusage/cpuusage_haiku.c b/src/detection/cpuusage/cpuusage_haiku.c new file mode 100644 index 000000000..88a734ee2 --- /dev/null +++ b/src/detection/cpuusage/cpuusage_haiku.c @@ -0,0 +1,27 @@ +#include "fastfetch.h" +#include "detection/cpuusage/cpuusage.h" +#include "util/mallocHelper.h" + +#include + +const char* ffGetCpuUsageInfo(FFlist* cpuTimes) +{ + system_info sysInfo; + if (get_system_info(&sysInfo) != B_OK) + return "get_system_info() failed"; + + FF_AUTO_FREE cpu_info* cpuInfo = malloc(sizeof(*cpuInfo) * sysInfo.cpu_count); + if (get_cpu_info(0, sysInfo.cpu_count, cpuInfo) != B_OK) + return "get_cpu_info() failed"; + + uint64_t uptime = (uint64_t) system_time(); + + for (uint32_t i = 0; i < sysInfo.cpu_count; ++i) + { + FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes); + info->inUseAll = (uint64_t) cpuInfo[i].active_time; + info->totalAll = uptime; + } + + return NULL; +} From 17711ee5c840dfae432ffdf1cca11b897576116e Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 20:12:06 +0800 Subject: [PATCH 56/87] PhysicalDisk (Haiku): add support --- CMakeLists.txt | 2 +- .../physicaldisk/physicaldisk_haiku.c | 82 +++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/detection/physicaldisk/physicaldisk_haiku.c diff --git a/CMakeLists.txt b/CMakeLists.txt index bd054844d..6eada6544 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1138,7 +1138,7 @@ elseif(Haiku) src/detection/bluetoothradio/bluetoothradio_nosupport.c src/detection/disk/disk_haiku.cpp src/detection/dns/dns_linux.c - src/detection/physicaldisk/physicaldisk_nosupport.c + src/detection/physicaldisk/physicaldisk_haiku.c src/detection/physicalmemory/physicalmemory_linux.c src/detection/diskio/diskio_nosupport.c src/detection/displayserver/displayserver_haiku.cpp diff --git a/src/detection/physicaldisk/physicaldisk_haiku.c b/src/detection/physicaldisk/physicaldisk_haiku.c new file mode 100644 index 000000000..aec47ff77 --- /dev/null +++ b/src/detection/physicaldisk/physicaldisk_haiku.c @@ -0,0 +1,82 @@ +#include "physicaldisk.h" + +#include "common/io/io.h" + +#include +#include +#include +#include + +static const char* detectDisk(int dfd, const char* diskType, const char* diskId, FFlist* result) +{ + char buffer[64]; + snprintf(buffer, sizeof(buffer), "%s/master/raw", diskId); + FF_AUTO_CLOSE_FD int rawfd = openat(dfd, buffer, O_RDONLY); + if (rawfd < 0) + { + snprintf(buffer, sizeof(buffer), "%s/raw", diskId); + rawfd = openat(dfd, buffer, O_RDONLY); + if (rawfd < 0) return "raw device file not found"; + } + + device_geometry geometry; + if (ioctl(rawfd, B_GET_GEOMETRY, &geometry, sizeof(geometry)) < 0) + return "ioctl(B_GET_GEOMETRY) failed"; + + FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result); + + char name[B_OS_NAME_LENGTH]; + if (ioctl(rawfd, B_GET_DEVICE_NAME, name, sizeof(name)) == 0) + ffStrbufInitS(&device->name, name); + else + { + // ioctl reports `not a tty` for NVME drives for some reason + ffStrbufInitF(&device->name, "Unknown %s drive", diskType); + } + + ffStrbufInitF(&device->devPath, "/dev/disk/%s/%s", diskType, buffer); + ffStrbufInit(&device->serial); + ffStrbufInit(&device->revision); + ffStrbufInitS(&device->interconnect, diskType); + device->temperature = 0.0/0.0; + device->type = FF_PHYSICALDISK_TYPE_NONE; + if (geometry.read_only) + device->type |= FF_PHYSICALDISK_TYPE_READONLY; + if (geometry.removable) + device->type |= FF_PHYSICALDISK_TYPE_REMOVABLE; + device->size = (uint64_t) geometry.cylinder_count * geometry.sectors_per_track * geometry.bytes_per_sector; + + return NULL; +} + +static const char* detectDiskType(int dfd, const char* diskType, FFlist* result) +{ + int newfd = openat(dfd, diskType, O_RDONLY); + if (newfd < 0) return "openat(dfd, diskType) failed"; + + FF_AUTO_CLOSE_DIR DIR* dir = fdopendir(newfd); + if (!dir) return "fdopendir(newfd) failed"; + + struct dirent* entry; + while((entry = readdir(dir))) + { + if (entry->d_name[0] == '.') continue; + detectDisk(newfd, diskType, entry->d_name, result); + } + return NULL; +} + +const char* ffDetectPhysicalDisk(FFlist* result, FF_MAYBE_UNUSED FFPhysicalDiskOptions* options) +{ + FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/disk"); + if (!dir) return "opendir(/dev/disk) failed"; + + struct dirent* entry; + while((entry = readdir(dir))) + { + if (entry->d_name[0] == '.') continue; + detectDiskType(dirfd(dir), entry->d_name, result); + } + + return NULL; +} From 5e615d12d527d48558d135da90d2cf7c5b6bf464 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 20:18:04 +0800 Subject: [PATCH 57/87] Gamepad (Haiku): enable --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eada6544..a21434a3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1155,7 +1155,7 @@ elseif(Haiku) src/detection/loadavg/loadavg_nosupport.c src/detection/locale/locale_linux.c src/detection/localip/localip_linux.c - src/detection/gamepad/gamepad_nosupport.c + src/detection/gamepad/gamepad_haiku.cpp src/detection/media/media_linux.c src/detection/memory/memory_haiku.c src/detection/mouse/mouse_haiku.cpp @@ -1648,6 +1648,7 @@ elseif(Haiku) PRIVATE "network" PRIVATE "bnetapi" PRIVATE "media" + PRIVATE "device" PRIVATE "be" PRIVATE "gnu" ) From 41d930b1e1c116b6a952654f744ee69b6ab0740a Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 20:37:21 +0800 Subject: [PATCH 58/87] Bluetooth (Haiku): WIP --- CMakeLists.txt | 3 ++- src/detection/bluetooth/bluetooth_haiku.cpp | 26 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/detection/bluetooth/bluetooth_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a21434a3b..73c421d15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1134,7 +1134,7 @@ elseif(Haiku) src/detection/cpucache/cpucache_shared.c src/detection/cpuusage/cpuusage_haiku.c src/detection/cursor/cursor_nosupport.c - src/detection/bluetooth/bluetooth_nosupport.c + src/detection/bluetooth/bluetooth_haiku.cpp src/detection/bluetoothradio/bluetoothradio_nosupport.c src/detection/disk/disk_haiku.cpp src/detection/dns/dns_linux.c @@ -1649,6 +1649,7 @@ elseif(Haiku) PRIVATE "bnetapi" PRIVATE "media" PRIVATE "device" + PRIVATE "bluetooth" PRIVATE "be" PRIVATE "gnu" ) diff --git a/src/detection/bluetooth/bluetooth_haiku.cpp b/src/detection/bluetooth/bluetooth_haiku.cpp new file mode 100644 index 000000000..ed24521d5 --- /dev/null +++ b/src/detection/bluetooth/bluetooth_haiku.cpp @@ -0,0 +1,26 @@ +extern "C" { +#include "bluetooth.h" +} + +#include + +const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) +{ + using namespace Bluetooth; + LocalDevice* dev = LocalDevice::GetLocalDevice(); + if (!dev) return NULL; + + BString devClass; + dev->GetDeviceClass().DumpDeviceClass(devClass); + + FFBluetoothResult* device = (FFBluetoothResult*) ffListAdd(devices); + ffStrbufInitS(&device->name, dev->GetFriendlyName()); + ffStrbufInitS(&device->address, bdaddrUtils::ToString(dev->GetBluetoothAddress()).String()); + ffStrbufInitS(&device->type, devClass.String()); + device->battery = 0; + device->connected = true; + + // TODO: more devices? + + return NULL; +} From f839fcfa292bb4960985050d3b1382b2819c35e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Feb 2025 21:27:53 +0800 Subject: [PATCH 59/87] Presets: print keyboard & mouse in all.jsonc --- presets/all.jsonc | 2 ++ presets/ci.jsonc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/presets/all.jsonc b/presets/all.jsonc index 6b5469272..d1e30ef4c 100644 --- a/presets/all.jsonc +++ b/presets/all.jsonc @@ -90,6 +90,8 @@ "sound", "camera", "gamepad", + "mouse", + "keyboard", { "type": "weather", "timeout": 1000 diff --git a/presets/ci.jsonc b/presets/ci.jsonc index eb3a0c219..a1e9da42b 100644 --- a/presets/ci.jsonc +++ b/presets/ci.jsonc @@ -92,6 +92,8 @@ "sound", "camera", "gamepad", + "mouse", + "keyboard", { "type": "weather", "timeout": 1000 From 716f0a3bbbe07f10675502cadc859a611a92013e Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 21:39:10 +0800 Subject: [PATCH 60/87] PhysicalDisk (Haiku): report drive type --- src/detection/physicaldisk/physicaldisk_haiku.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/detection/physicaldisk/physicaldisk_haiku.c b/src/detection/physicaldisk/physicaldisk_haiku.c index aec47ff77..fd2361688 100644 --- a/src/detection/physicaldisk/physicaldisk_haiku.c +++ b/src/detection/physicaldisk/physicaldisk_haiku.c @@ -40,10 +40,8 @@ static const char* detectDisk(int dfd, const char* diskType, const char* diskId, ffStrbufInitS(&device->interconnect, diskType); device->temperature = 0.0/0.0; device->type = FF_PHYSICALDISK_TYPE_NONE; - if (geometry.read_only) - device->type |= FF_PHYSICALDISK_TYPE_READONLY; - if (geometry.removable) - device->type |= FF_PHYSICALDISK_TYPE_REMOVABLE; + device->type |= (geometry.read_only ? FF_PHYSICALDISK_TYPE_READONLY : FF_PHYSICALDISK_TYPE_READWRITE) | + (geometry.removable ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED); device->size = (uint64_t) geometry.cylinder_count * geometry.sectors_per_track * geometry.bytes_per_sector; return NULL; From 24e94acbb9fca08466cbd4739c1bd2cb05fc1eae Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 21:39:34 +0800 Subject: [PATCH 61/87] Bluetooth (Haiku): suppress debug output of system API --- src/detection/bluetooth/bluetooth_haiku.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/detection/bluetooth/bluetooth_haiku.cpp b/src/detection/bluetooth/bluetooth_haiku.cpp index ed24521d5..89ae13624 100644 --- a/src/detection/bluetooth/bluetooth_haiku.cpp +++ b/src/detection/bluetooth/bluetooth_haiku.cpp @@ -1,5 +1,6 @@ extern "C" { #include "bluetooth.h" +#include "common/io/io.h" } #include @@ -7,6 +8,8 @@ extern "C" { const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) { using namespace Bluetooth; + FF_SUPPRESS_IO(); + LocalDevice* dev = LocalDevice::GetLocalDevice(); if (!dev) return NULL; From 36a129f66823307baa183815ffaef0793faca1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Feb 2025 21:50:19 +0800 Subject: [PATCH 62/87] GPU: add missing variable inits --- src/detection/gpu/gpu_apple.c | 2 +- src/detection/gpu/gpu_general.c | 1 + src/detection/gpu/gpu_haiku.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 793db62a7..535b8bc3e 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -115,7 +115,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) // For Apple gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; - gpu->coreUsage = 0.0/0.0; + gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; CFDictionaryRef perfStatistics = NULL; uint64_t vramUsed = 0, vramTotal = 0; if (ffCfDictGetDict(properties, CFSTR("PerformanceStatistics"), &perfStatistics) == NULL) diff --git a/src/detection/gpu/gpu_general.c b/src/detection/gpu/gpu_general.c index fdffcdd90..703b0b237 100644 --- a/src/detection/gpu/gpu_general.c +++ b/src/detection/gpu/gpu_general.c @@ -36,6 +36,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* ffStrbufInit(&gpu->platformApi); gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; + gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; gpu->type = FF_GPU_TYPE_UNKNOWN; gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; gpu->deviceId = ((uint64_t) dev->domain << 6) | ((uint64_t) dev->bus << 4) | ((uint64_t) dev->dev << 2) | (uint64_t) dev->func; diff --git a/src/detection/gpu/gpu_haiku.c b/src/detection/gpu/gpu_haiku.c index 31de1b8b9..c1324f761 100644 --- a/src/detection/gpu/gpu_haiku.c +++ b/src/detection/gpu/gpu_haiku.c @@ -26,6 +26,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* ffStrbufInit(&gpu->platformApi); gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; + gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; gpu->type = FF_GPU_TYPE_UNKNOWN; gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; gpu->deviceId = ((uint64_t) dev.bus << 4) | ((uint64_t) dev.device << 2) | (uint64_t) dev.function; @@ -40,4 +41,3 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* return NULL; } - From 76b8b9a44b4210fa5fb9a6a6a0606612134b785d Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 22:51:29 +0800 Subject: [PATCH 63/87] Chore: remove unused `#include`s --- src/detection/font/font_haiku.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/detection/font/font_haiku.cpp b/src/detection/font/font_haiku.cpp index 5f64aecd8..0e0eb6751 100644 --- a/src/detection/font/font_haiku.cpp +++ b/src/detection/font/font_haiku.cpp @@ -1,6 +1,4 @@ extern "C" { -#include "common/font.h" -#include "common/parsing.h" #include "font.h" } From 9018fda92e580b155f6b00d51cce2e2a3cf90d82 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 22:52:51 +0800 Subject: [PATCH 64/87] OpenGL (Haiku): add support --- CMakeLists.txt | 3 ++- src/detection/opengl/opengl_haiku.cpp | 38 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/detection/opengl/opengl_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 73c421d15..1e698be61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1160,7 +1160,7 @@ elseif(Haiku) src/detection/memory/memory_haiku.c src/detection/mouse/mouse_haiku.cpp src/detection/netio/netio_haiku.cpp - src/detection/opengl/opengl_linux.c + src/detection/opengl/opengl_haiku.cpp src/detection/os/os_haiku.c src/detection/packages/packages_haiku.c src/detection/poweradapter/poweradapter_nosupport.c @@ -1650,6 +1650,7 @@ elseif(Haiku) PRIVATE "media" PRIVATE "device" PRIVATE "bluetooth" + PRIVATE "GL" PRIVATE "be" PRIVATE "gnu" ) diff --git a/src/detection/opengl/opengl_haiku.cpp b/src/detection/opengl/opengl_haiku.cpp new file mode 100644 index 000000000..504c47ce2 --- /dev/null +++ b/src/detection/opengl/opengl_haiku.cpp @@ -0,0 +1,38 @@ +#include + +extern "C" { +#include "opengl.h" +#include "common/io/io.h" +#if FF_HAVE_EGL +const char* ffOpenGLDetectByEGL(FFOpenGLResult* result); +#endif +void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString); +} + +static const char* oglDetectOpenGL(FFOpenGLResult* result) +{ + BApplication app("application/x-vnd.fastfetch-cli-fastfetch"); + FF_SUPPRESS_IO(); + + BGLView glView(BRect(), "ff_ogl_view", B_FOLLOW_NONE, B_WILL_DRAW, BGL_RGB); + auto ffglGetString = (decltype(&glGetString)) glView.GetGLProcAddress("glGetString"); + if (!ffglGetString) return "glView.GetGLProcAddress() failed"; + ffOpenGLHandleResult(result, ffglGetString); + return NULL; +} + +const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) +{ + if (options->library == FF_OPENGL_LIBRARY_AUTO) + return oglDetectOpenGL(result); + else if (options->library == FF_OPENGL_LIBRARY_EGL) + { + #if FF_HAVE_EGL + return ffOpenGLDetectByEGL(result); + #else + return "fastfetch was compiled without egl support"; + #endif + } + else + return "Unsupported OpenGL library"; +} From e79b561f2a3a390a5e940c3a8762b870de46e7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Feb 2025 23:25:16 +0800 Subject: [PATCH 65/87] Smbios: add comments about UEFI systems [ci skip] --- src/util/smbiosHelper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index be122d3e5..fd5d29484 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -236,6 +236,9 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() FF_AUTO_CLOSE_FD int fd = open("/dev/misc/mem", O_RDONLY); if (fd < 0) return NULL; + + // Works on legacy BIOS only + // See: https://wiki.osdev.org/System_Management_BIOS#UEFI_systems FF_AUTO_FREE uint8_t* smBiosBase = malloc(0x10000); if (pread(fd, smBiosBase, 0x10000, 0xF0000) != 0x10000) return NULL; From 46f920ae2a1d2ed42bc7ad17c323659b6afda5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Feb 2025 23:29:05 +0800 Subject: [PATCH 66/87] OpenGL (Haiku): report platform API --- src/detection/opengl/opengl_haiku.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection/opengl/opengl_haiku.cpp b/src/detection/opengl/opengl_haiku.cpp index 504c47ce2..ce0103360 100644 --- a/src/detection/opengl/opengl_haiku.cpp +++ b/src/detection/opengl/opengl_haiku.cpp @@ -18,6 +18,7 @@ static const char* oglDetectOpenGL(FFOpenGLResult* result) auto ffglGetString = (decltype(&glGetString)) glView.GetGLProcAddress("glGetString"); if (!ffglGetString) return "glView.GetGLProcAddress() failed"; ffOpenGLHandleResult(result, ffglGetString); + ffStrbufSetStatic(&result->library, "OpenGLKit"); return NULL; } From a13935e2324a213e2144cb79d59d35548b999572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Feb 2025 16:01:47 +0800 Subject: [PATCH 67/87] PhysicalDisk (Haiku): fix SCSI drive detection --- .../physicaldisk/physicaldisk_haiku.c | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/detection/physicaldisk/physicaldisk_haiku.c b/src/detection/physicaldisk/physicaldisk_haiku.c index fd2361688..170c40aa4 100644 --- a/src/detection/physicaldisk/physicaldisk_haiku.c +++ b/src/detection/physicaldisk/physicaldisk_haiku.c @@ -1,44 +1,36 @@ #include "physicaldisk.h" #include "common/io/io.h" +#include "util/stringUtils.h" #include #include #include #include -static const char* detectDisk(int dfd, const char* diskType, const char* diskId, FFlist* result) +static const char* detectDisk(FFstrbuf* path, const char* diskType, FFlist* result) { - char buffer[64]; - snprintf(buffer, sizeof(buffer), "%s/master/raw", diskId); - FF_AUTO_CLOSE_FD int rawfd = openat(dfd, buffer, O_RDONLY); - if (rawfd < 0) - { - snprintf(buffer, sizeof(buffer), "%s/raw", diskId); - rawfd = openat(dfd, buffer, O_RDONLY); - if (rawfd < 0) return "raw device file not found"; - } + FF_AUTO_CLOSE_FD int rawfd = open(path->chars, O_RDONLY); + if (rawfd < 0) return "detectDisk: open(rawfd) failed"; device_geometry geometry; if (ioctl(rawfd, B_GET_GEOMETRY, &geometry, sizeof(geometry)) < 0) return "ioctl(B_GET_GEOMETRY) failed"; - FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result); - char name[B_OS_NAME_LENGTH]; - if (ioctl(rawfd, B_GET_DEVICE_NAME, name, sizeof(name)) == 0) - ffStrbufInitS(&device->name, name); - else + if (ioctl(rawfd, B_GET_DEVICE_NAME, name, sizeof(name)) != 0) { // ioctl reports `not a tty` for NVME drives for some reason - ffStrbufInitF(&device->name, "Unknown %s drive", diskType); + snprintf(name, sizeof(name), "Unknown %s drive", diskType); } - ffStrbufInitF(&device->devPath, "/dev/disk/%s/%s", diskType, buffer); + FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result); + ffStrbufInitS(&device->name, name); + ffStrbufInitCopy(&device->devPath, path); ffStrbufInit(&device->serial); ffStrbufInit(&device->revision); ffStrbufInitS(&device->interconnect, diskType); - device->temperature = 0.0/0.0; + device->temperature = FF_PHYSICALDISK_TEMP_UNSET; device->type = FF_PHYSICALDISK_TYPE_NONE; device->type |= (geometry.read_only ? FF_PHYSICALDISK_TYPE_READONLY : FF_PHYSICALDISK_TYPE_READWRITE) | (geometry.removable ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED); @@ -47,19 +39,32 @@ static const char* detectDisk(int dfd, const char* diskType, const char* diskId, return NULL; } -static const char* detectDiskType(int dfd, const char* diskType, FFlist* result) +static const char* searchRawDeviceFile(FFstrbuf* path, const char* diskType, FFlist* result) { - int newfd = openat(dfd, diskType, O_RDONLY); - if (newfd < 0) return "openat(dfd, diskType) failed"; - - FF_AUTO_CLOSE_DIR DIR* dir = fdopendir(newfd); - if (!dir) return "fdopendir(newfd) failed"; + FF_AUTO_CLOSE_DIR DIR* dir = opendir(path->chars); + if (!dir) return "detectDiskType: opendir() failed"; + uint32_t baseLen = path->length; struct dirent* entry; while((entry = readdir(dir))) { if (entry->d_name[0] == '.') continue; - detectDisk(newfd, diskType, entry->d_name, result); + ffStrbufAppendC(path, '/'); + ffStrbufAppendS(path, entry->d_name); + + struct stat st; + if (stat(path->chars, &st) != 0) + { + ffStrbufSubstrBefore(path, baseLen); + continue; + } + + if (S_ISDIR(st.st_mode)) + searchRawDeviceFile(path, diskType, result); + else if (ffStrEquals(entry->d_name, "raw")) + detectDisk(path, diskType, result); + + ffStrbufSubstrBefore(path, baseLen); } return NULL; } @@ -69,11 +74,17 @@ const char* ffDetectPhysicalDisk(FFlist* result, FF_MAYBE_UNUSED FFPhysicalDiskO FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/disk"); if (!dir) return "opendir(/dev/disk) failed"; + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateA(64); + ffStrbufAppendS(&path, "/dev/disk/"); + uint32_t baseLen = path.length; + struct dirent* entry; while((entry = readdir(dir))) { - if (entry->d_name[0] == '.') continue; - detectDiskType(dirfd(dir), entry->d_name, result); + if (entry->d_name[0] == '.' || ffStrEquals(entry->d_name, "virtual")) continue; + ffStrbufAppendS(&path, entry->d_name); + searchRawDeviceFile(&path, entry->d_name, result); + ffStrbufSubstrBefore(&path, baseLen); } return NULL; From 948a965c7a09a18f2805786aea3098d7df8b93e2 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 17 Feb 2025 21:22:12 +0800 Subject: [PATCH 68/87] Terminal (Haiku): detect terminal version --- CMakeLists.txt | 3 +- src/common/processing_linux.c | 19 +++++++ src/detection/initsystem/initsystem_haiku.c | 34 ++++++++++++ src/detection/initsystem/initsystem_haiku.cpp | 52 ------------------- src/detection/terminalshell/terminalshell.c | 7 +++ src/util/FFstrbuf.h | 2 +- src/util/haiku/version.cpp | 24 +++++++++ src/util/haiku/version.h | 3 ++ 8 files changed, 90 insertions(+), 54 deletions(-) create mode 100644 src/detection/initsystem/initsystem_haiku.c delete mode 100644 src/detection/initsystem/initsystem_haiku.cpp create mode 100644 src/util/haiku/version.cpp create mode 100644 src/util/haiku/version.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e698be61..759d3782f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1148,7 +1148,7 @@ elseif(Haiku) src/detection/gtk_qt/gtk.c src/detection/host/host_windows.c src/detection/icons/icons_nosupport.c - src/detection/initsystem/initsystem_haiku.cpp + src/detection/initsystem/initsystem_haiku.c src/detection/keyboard/keyboard_haiku.cpp src/detection/libc/libc_nosupport.c src/detection/lm/lm_nosupport.c @@ -1184,6 +1184,7 @@ elseif(Haiku) src/detection/zpool/zpool_nosupport.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c + src/util/haiku/version.cpp ) endif() diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index e4a8f62d5..a26e53848 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -315,6 +315,25 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons #elif defined(__HAIKU__) + { + team_info info; + if (get_team_info(pid, &info) == B_OK) + { + // This is tricky. info.args is not encoded, so that we don't know if + // a whitespace in args is part of the file path or an argument separator + if (info.argc == 1) + ffStrbufSetS(exe, info.args); + else + { + int argc = info.argc; + for (const char* p = info.args; (p = strchr(p, ' ')); ++p) + --argc; + if (argc == 1) + ffStrbufSetS(exe, info.args); + } + } + } + if (exePath) { image_info info; diff --git a/src/detection/initsystem/initsystem_haiku.c b/src/detection/initsystem/initsystem_haiku.c new file mode 100644 index 000000000..7a18a8e25 --- /dev/null +++ b/src/detection/initsystem/initsystem_haiku.c @@ -0,0 +1,34 @@ +#include "initsystem.h" +#include "util/stringUtils.h" +#include "util/haiku/version.h" +#include "common/io/io.h" + +#include +#include + +const char* ffDetectInitSystem(FFInitSystemResult* result) +{ + // Since it runs first, registrar does not know about it, + // so we can't query be_roster for it. + const char* path = "/boot/system/servers/launch_daemon"; + if (!ffPathExists(path, FF_PATHTYPE_FILE)) + return "launch_daemon is not found"; + + ffStrbufSetStatic(&result->exe, path); + ffStrbufSetStatic(&result->name, "launch_daemon"); + + team_info teamInfo; + int32 cookie = 0; + while (get_next_team_info(&cookie, &teamInfo) == B_OK) + { + if (ffStrEquals(teamInfo.args, path)) + { + result->pid = (uint32_t) teamInfo.team; + break; + } + } + + ffGetFileVersion(path, &result->version); + + return NULL; +} diff --git a/src/detection/initsystem/initsystem_haiku.cpp b/src/detection/initsystem/initsystem_haiku.cpp deleted file mode 100644 index 7714133af..000000000 --- a/src/detection/initsystem/initsystem_haiku.cpp +++ /dev/null @@ -1,52 +0,0 @@ -extern "C" { -#include "initsystem.h" -#include "common/processing.h" -#include "util/binary.h" -#include "util/stringUtils.h" -}; - -#include -#include -#include -#include -#include -#include - -const char* ffDetectInitSystem(FFInitSystemResult* result) -{ - team_info teamInfo; - int32 cookie = 0; - - // Since it runs first, registrar does not know about it, - // so we can't query be_roster for it. - BPath path("/boot/system/servers/launch_daemon"); - if (path.InitCheck() != B_OK) - return NULL; - - ffStrbufSetS(&result->exe, path.Path()); - ffStrbufSetStatic(&result->name, "launch_daemon"); - - while (get_next_team_info(&cookie, &teamInfo) == B_OK) - { - if (strcmp(teamInfo.args, path.Path()) == 0) - { - result->pid = (int)teamInfo.team; - break; - } - } - - BFile f(path.Path(), B_READ_ONLY); - if (f.InitCheck() != B_OK) - return NULL; - BAppFileInfo fileInfo(&f); - if (f.InitCheck() != B_OK) - return NULL; - - version_info version; - if (fileInfo.GetVersionInfo(&version, B_SYSTEM_VERSION_KIND) != B_OK) - return NULL; - - ffStrbufSetF(&result->version, "%d.%d.%d", (int)version.major, (int)version.middle, (int)version.minor); - - return NULL; -} diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index fab4202b4..6d6f5b6b6 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -27,6 +27,8 @@ static bool getFileVersion(const FFstrbuf* exePath, FFstrbuf* version) if (len <= 0) return false; return ffGetFileVersion(exePathW, version); } +#elif __HAIKU__ + #include "util/haiku/version.h" #endif static bool getExeVersionRaw(FFstrbuf* exe, FFstrbuf* version) @@ -847,6 +849,11 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufStartsWithIgnCaseS(processName, "zed")) return getTerminalVersionZed(exe, version); + #if __HAIKU__ + if(ffStrbufEqualS(processName, "Terminal")) + return ffGetFileVersion(exe->chars, version); + #endif + const char* termProgramVersion = getenv("TERM_PROGRAM_VERSION"); if(termProgramVersion) { diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index a3bce4ca6..cd99c863f 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -233,7 +233,7 @@ static inline void ffStrbufInit(FFstrbuf* strbuf) strbuf->chars = CHAR_NULL_PTR; } -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate() +FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate(void) { FFstrbuf strbuf; ffStrbufInit(&strbuf); diff --git a/src/util/haiku/version.cpp b/src/util/haiku/version.cpp new file mode 100644 index 000000000..8dcf672ee --- /dev/null +++ b/src/util/haiku/version.cpp @@ -0,0 +1,24 @@ +extern "C" { +#include "version.h" +} + +#include +#include + +bool ffGetFileVersion(const char* filePath, FFstrbuf* version) +{ + BFile f(filePath, B_READ_ONLY); + if (f.InitCheck() != B_OK) + return false; + + BAppFileInfo fileInfo(&f); + if (f.InitCheck() != B_OK) + return false; + + version_info info; + if (fileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND) != B_OK) + return false; + + ffStrbufSetF(version, "%d.%d.%d", (int)info.major, (int)info.middle, (int)info.minor); + return true; +} diff --git a/src/util/haiku/version.h b/src/util/haiku/version.h new file mode 100644 index 000000000..829801a88 --- /dev/null +++ b/src/util/haiku/version.h @@ -0,0 +1,3 @@ +#include "util/FFstrbuf.h" + +bool ffGetFileVersion(const char* filePath, FFstrbuf* version); From d1385804bbe096de2472bf37bc8653a1427524ff Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 17 Feb 2025 21:24:35 +0800 Subject: [PATCH 69/87] Bios (Haiku): report BIOS type --- src/detection/bios/bios_windows.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index adabbe2bb..e6737f632 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -89,6 +89,9 @@ const char* ffDetectBios(FFBiosResult* bios) default: break; } } + #elif __HAIKU__ + // Currently SMBIOS detection is supported in legency BIOS only + ffStrbufSetStatic(&bios->type, "BIOS"); #endif return NULL; From 399f2626927ef35244c200e99299f9f5d9db25b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Feb 2025 21:29:27 +0800 Subject: [PATCH 70/87] LocalIP: fix `--localip-default-route-only false not working with --gen-config` Fix #1570 --- src/modules/localip/localip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index d8da04692..855380929 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -419,8 +419,8 @@ void ffGenerateLocalIpJsonConfig(FFLocalIpOptions* options, yyjson_mut_doc* doc, if (defaultOptions.showType != options->showType) { - if (options->showType & FF_LOCALIP_TYPE_IPV4_BIT) - yyjson_mut_obj_add_bool(doc, module, "showIpv4", true); + if (!(options->showType & FF_LOCALIP_TYPE_IPV4_BIT)) + yyjson_mut_obj_add_bool(doc, module, "showIpv4", false); if (options->showType & FF_LOCALIP_TYPE_IPV6_BIT) yyjson_mut_obj_add_bool(doc, module, "showIpv6", true); @@ -446,8 +446,8 @@ void ffGenerateLocalIpJsonConfig(FFLocalIpOptions* options, yyjson_mut_doc* doc, if (options->showType & FF_LOCALIP_TYPE_COMPACT_BIT) yyjson_mut_obj_add_bool(doc, module, "compact", true); - if (options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) - yyjson_mut_obj_add_bool(doc, module, "defaultRouteOnly", true); + if (!(options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT)) + yyjson_mut_obj_add_bool(doc, module, "defaultRouteOnly", false); if (options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT) yyjson_mut_obj_add_bool(doc, module, "showAllIps", true); From ab0240e9b741ef7087b94f816d7ada1d064c7290 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 18 Feb 2025 06:50:19 +0800 Subject: [PATCH 71/87] IO (Haiku): access `/path/to/file/` doesn't work. Work around it --- src/common/io/io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/io/io.h b/src/common/io/io.h index 4cee2e471..4cc65003e 100644 --- a/src/common/io/io.h +++ b/src/common/io/io.h @@ -119,7 +119,7 @@ static inline bool ffPathExists(const char* path, FFPathType pathType) } else { - #if __APPLE__ // #1395 + #if (__APPLE__ || __HAIKU__) // #1395 struct stat fileStat; if(stat(path, &fileStat) != 0) return false; From 8dc4f77f42abf32e5d26bbe751d439eaa49e64bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 18 Feb 2025 09:17:55 +0800 Subject: [PATCH 72/87] Shell (Haiku): fix arg0 detection --- src/common/processing_linux.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index a26e53848..934a1c01b 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -319,17 +319,20 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons team_info info; if (get_team_info(pid, &info) == B_OK) { - // This is tricky. info.args is not encoded, so that we don't know if - // a whitespace in args is part of the file path or an argument separator + // This is tricky. Paths in info.args are not quoted, so that we don't know + // if a whitespace in args is part of the file path or an argument separator if (info.argc == 1) ffStrbufSetS(exe, info.args); else { - int argc = info.argc; - for (const char* p = info.args; (p = strchr(p, ' ')); ++p) + // args = "/bin/bash -l" + // argc = 2 + int argc = info.argc - 1; // 1 + const char* arg0End = strchr(p, ' '); // " -l" + for (const char* p = arg0End + 1; (p = strchr(p, ' ')); ++p) --argc; if (argc == 1) - ffStrbufSetS(exe, info.args); + ffStrbufSetNS(exe, info.args, arg0End - info.args /* /bin/bash */); } } } From 966b8452b7babbffb119e15ba08021d08c39efe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 18 Feb 2025 09:35:56 +0800 Subject: [PATCH 73/87] Disk (Haiku): report all partitions --- src/detection/disk/disk_haiku.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/detection/disk/disk_haiku.cpp b/src/detection/disk/disk_haiku.cpp index 69f766fed..de867d665 100644 --- a/src/detection/disk/disk_haiku.cpp +++ b/src/detection/disk/disk_haiku.cpp @@ -16,8 +16,6 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) fs_info fs; if (fs_stat_dev(dev, &fs) < -1) continue; - if (!ffStrStartsWith(fs.device_name, "/dev/")) continue; // physical disks only - node_ref node(fs.dev, fs.root); BDirectory dir(&node); BPath path(&dir); From 6fd4720faf327829f99396ace2e0fca6e3b972af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 18 Feb 2025 10:13:25 +0800 Subject: [PATCH 74/87] PhysicalDisk (Haiku): fix drive size calcuation --- src/detection/physicaldisk/physicaldisk_haiku.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/physicaldisk/physicaldisk_haiku.c b/src/detection/physicaldisk/physicaldisk_haiku.c index 170c40aa4..a64857114 100644 --- a/src/detection/physicaldisk/physicaldisk_haiku.c +++ b/src/detection/physicaldisk/physicaldisk_haiku.c @@ -34,7 +34,7 @@ static const char* detectDisk(FFstrbuf* path, const char* diskType, FFlist* resu device->type = FF_PHYSICALDISK_TYPE_NONE; device->type |= (geometry.read_only ? FF_PHYSICALDISK_TYPE_READONLY : FF_PHYSICALDISK_TYPE_READWRITE) | (geometry.removable ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED); - device->size = (uint64_t) geometry.cylinder_count * geometry.sectors_per_track * geometry.bytes_per_sector; + device->size = (uint64_t) geometry.cylinder_count *geometry.heads * geometry.sectors_per_track * geometry.bytes_per_sector; return NULL; } From 13723893ba693bec3d41efeb73d8a0af04b92a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 18 Feb 2025 10:38:14 +0800 Subject: [PATCH 75/87] Packages (Haiku): rename package manager name to `hpkg` --- doc/json_schema.json | 1 + src/detection/packages/packages.h | 2 ++ src/detection/packages/packages_haiku.c | 9 +++++---- src/modules/packages/option.h | 1 + src/modules/packages/packages.c | 18 ++++++++++++++++++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index 23b06183c..9b6b2d4c9 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -2641,6 +2641,7 @@ "eopkg", "flatpak", "guix", + "hpkg", "linglong", "lpkg", "lpkgbuild", diff --git a/src/detection/packages/packages.h b/src/detection/packages/packages.h index b4e898d0f..5e91173a6 100644 --- a/src/detection/packages/packages.h +++ b/src/detection/packages/packages.h @@ -18,6 +18,8 @@ typedef struct FFPackagesResult uint32_t guixHome; uint32_t guixSystem; uint32_t guixUser; + uint32_t hpkgSystem; + uint32_t hpkgUser; uint32_t linglong; uint32_t lpkg; uint32_t lpkgbuild; diff --git a/src/detection/packages/packages_haiku.c b/src/detection/packages/packages_haiku.c index b66edefbb..b48062a87 100644 --- a/src/detection/packages/packages_haiku.c +++ b/src/detection/packages/packages_haiku.c @@ -6,8 +6,9 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options) { // TODO: Use the Package Kit C++ API instead (would account for disabled packages) - if (!(options->disabled & FF_PACKAGES_FLAG_PKG_BIT)) - result->pkg = ffPackagesGetNumElements(FASTFETCH_TARGET_DIR_ROOT "/system/packages", false); - if (!(options->disabled & FF_PACKAGES_FLAG_PKGSRC_BIT)) - result->pkgsrc = ffPackagesGetNumElements(FASTFETCH_TARGET_DIR_ROOT "/boot/home/config/packages", false); + if (!(options->disabled & FF_PACKAGES_FLAG_HPKG_BIT)) + { + result->hpkgSystem = ffPackagesGetNumElements(FASTFETCH_TARGET_DIR_ROOT "/system/packages", false); + result->hpkgUser = ffPackagesGetNumElements(FASTFETCH_TARGET_DIR_ROOT "/boot/home/config/packages", false); + } } diff --git a/src/modules/packages/option.h b/src/modules/packages/option.h index 726d74bb1..a7b7255c0 100644 --- a/src/modules/packages/option.h +++ b/src/modules/packages/option.h @@ -36,6 +36,7 @@ typedef enum __attribute__((__packed__)) FFPackagesFlags FF_PACKAGES_FLAG_MPORT_BIT = 1 << 26, FF_PACKAGES_FLAG_QI_BIT = 1 << 27, FF_PACKAGES_FLAG_PKGSRC_BIT = 1 << 28, + FF_PACKAGES_FLAG_HPKG_BIT = 1 << 29, FF_PACKAGES_FLAG_FORCE_UNSIGNED = UINT32_MAX, } FFPackagesFlags; static_assert(sizeof(FFPackagesFlags) == sizeof(uint32_t), ""); diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 6788d37dd..8d8f986ba 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -51,6 +51,8 @@ void ffPrintPackages(FFPackagesOptions* options) FF_PRINT_PACKAGE(apk) FF_PRINT_PACKAGE(pkg) FF_PRINT_PACKAGE(pkgsrc) + FF_PRINT_PACKAGE_NAME(hpkgSystem, counts.hpkgUser ? "hpkg-system" : "hpkg") + FF_PRINT_PACKAGE_NAME(hpkgUser, "hpkg-user") FF_PRINT_PACKAGE_NAME(flatpakSystem, counts.flatpakUser ? "flatpak-system" : "flatpak") FF_PRINT_PACKAGE_NAME(flatpakUser, "flatpak-user") FF_PRINT_PACKAGE(snap) @@ -84,6 +86,7 @@ void ffPrintPackages(FFPackagesOptions* options) uint32_t flatpakAll = counts.flatpakSystem + counts.flatpakUser; uint32_t brewAll = counts.brew + counts.brewCask; uint32_t guixAll = counts.guixSystem + counts.guixUser + counts.guixHome; + uint32_t hpkgAll = counts.hpkgSystem + counts.hpkgUser; FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(counts.all, "all"), FF_FORMAT_ARG(counts.pacman, "pacman"), @@ -123,10 +126,13 @@ void ffPrintPackages(FFPackagesOptions* options) FF_FORMAT_ARG(counts.qi, "qi"), FF_FORMAT_ARG(counts.amUser, "am-user"), FF_FORMAT_ARG(counts.pkgsrc, "pkgsrc"), + FF_FORMAT_ARG(counts.hpkgSystem, "hpkg-system"), + FF_FORMAT_ARG(counts.hpkgUser, "hpkg-user"), FF_FORMAT_ARG(nixAll, "nix-all"), FF_FORMAT_ARG(flatpakAll, "flatpak-all"), FF_FORMAT_ARG(brewAll, "brew-all"), FF_FORMAT_ARG(guixAll, "guix-all"), + FF_FORMAT_ARG(hpkgAll, "hpkg-all"), })); } @@ -178,6 +184,9 @@ bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key, case 'G': if (false); FF_TEST_PACKAGE_NAME(GUIX) break; + case 'H': if (false); + FF_TEST_PACKAGE_NAME(HPKG) + break; case 'L': if (false); FF_TEST_PACKAGE_NAME(LPKG) FF_TEST_PACKAGE_NAME(LPKGBUILD) @@ -293,6 +302,9 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module) case 'G': if (false); FF_TEST_PACKAGE_NAME(GUIX) break; + case 'H': if (false); + FF_TEST_PACKAGE_NAME(HPKG) + break; case 'L': if (false); FF_TEST_PACKAGE_NAME(LPKG) FF_TEST_PACKAGE_NAME(LPKGBUILD) @@ -365,6 +377,7 @@ void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* do FF_TEST_PACKAGE_NAME(EOPKG) FF_TEST_PACKAGE_NAME(FLATPAK) FF_TEST_PACKAGE_NAME(GUIX) + FF_TEST_PACKAGE_NAME(HPKG) FF_TEST_PACKAGE_NAME(LINGLONG) FF_TEST_PACKAGE_NAME(LPKG) FF_TEST_PACKAGE_NAME(LPKGBUILD) @@ -421,6 +434,8 @@ void ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yy FF_APPEND_PACKAGE_COUNT(guixSystem) FF_APPEND_PACKAGE_COUNT(guixUser) FF_APPEND_PACKAGE_COUNT(guixHome) + FF_APPEND_PACKAGE_COUNT(hpkgSystem) + FF_APPEND_PACKAGE_COUNT(hpkgUser) FF_APPEND_PACKAGE_COUNT(linglong) FF_APPEND_PACKAGE_COUNT(mport) FF_APPEND_PACKAGE_COUNT(nixDefault) @@ -491,10 +506,13 @@ static FFModuleBaseInfo ffModuleInfo = { {"Number of qi packages", "qi"}, {"Number of am-user (aka appman) packages", "am-user"}, {"Number of pkgsrc packages", "pkgsrc"}, + {"Number of hpkg-system packages", "hpkg-system"}, + {"Number of hpkg-user packages", "hpkg-user"}, {"Total number of all nix packages", "nix-all"}, {"Total number of all flatpak app packages", "flatpak-all"}, {"Total number of all brew packages", "brew-all"}, {"Total number of all guix packages", "guix-all"}, + {"Total number of all hpkg packages", "hpkg-all"}, })) }; From 7aceb1072a8146ce1ac5832e9c1d04cd0fbb47b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 18 Feb 2025 14:11:46 +0800 Subject: [PATCH 76/87] Doc: update changelog [ci skip] --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c0f3ef70..2244ffcae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +# 2.37.0 + +Changes: +* Option `--escape-bedrock` is removed. The function is always enabled now. + +Features: +* Support for Haiku is greatly improved (Haiku) + * CPU, GPU, Disk, Sound, Terminal, Terminal Font, Init System, Battery, Mouse, Keyboard, NetIO, CPU Usage, Physical Disk and OpenGL should work on Haiku now + * SMBIOS related modules (Host, Bios, Board, Chassis, Physical Memory) should work in platforms with legacy BIOS system. + * Support for Gamepad and Bluetooth are WIP. + * Some bugs are found and fixed. +* Remove `python-requests` dependency in `scripts/gen-*.py`. +* Add cmake option `-DENABLE_EMBEDDED_AMDGPUIDS=BOOL` (disabled by default) +* Weather module now honors `display.temp.unit` option (#1560, Weather) +* Support Physical Memory module in NetBSD (PhysicalMemory, NetBSD) + * Requires root permission + +Bugfixes: +* Fix building in macOS 10.13 (GPU, macOS) +* Properly round percent values when detecting volume (#1558, Sound) +* Fix Physical Memory module doesn't work in `--format json` mode +* Add some missing variable inits (GPU, Linux) +* Fix `--localip-default-route-only false not working` with `--gen-config` (#1570, LocalIP) + +Logo: +* Update Rosa linux +* Add Haiku2 + # 2.36.1 Changes: From b8b2fab4991a6625845e47f291fa2ec4518981b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 18 Feb 2025 15:49:39 +0800 Subject: [PATCH 77/87] Haiku: fix building --- src/common/processing_linux.c | 8 ++++---- src/detection/physicaldisk/physicaldisk_haiku.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 934a1c01b..26112248b 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -327,12 +327,12 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons { // args = "/bin/bash -l" // argc = 2 - int argc = info.argc - 1; // 1 - const char* arg0End = strchr(p, ' '); // " -l" + int argc = info.argc - 1; + const char* arg0End = strchr(info.args, ' '); for (const char* p = arg0End + 1; (p = strchr(p, ' ')); ++p) --argc; - if (argc == 1) - ffStrbufSetNS(exe, info.args, arg0End - info.args /* /bin/bash */); + if (argc == 1) // No whitespace in the file path + ffStrbufSetNS(exe, (uint32_t) (arg0End - info.args), info.args); } } } diff --git a/src/detection/physicaldisk/physicaldisk_haiku.c b/src/detection/physicaldisk/physicaldisk_haiku.c index a64857114..2599387ef 100644 --- a/src/detection/physicaldisk/physicaldisk_haiku.c +++ b/src/detection/physicaldisk/physicaldisk_haiku.c @@ -34,7 +34,7 @@ static const char* detectDisk(FFstrbuf* path, const char* diskType, FFlist* resu device->type = FF_PHYSICALDISK_TYPE_NONE; device->type |= (geometry.read_only ? FF_PHYSICALDISK_TYPE_READONLY : FF_PHYSICALDISK_TYPE_READWRITE) | (geometry.removable ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED); - device->size = (uint64_t) geometry.cylinder_count *geometry.heads * geometry.sectors_per_track * geometry.bytes_per_sector; + device->size = (uint64_t) geometry.cylinder_count * geometry.head_count * geometry.sectors_per_track * geometry.bytes_per_sector; return NULL; } From 95a44d3a33df10de6459a6ca02231152a5927ee4 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 18 Feb 2025 19:49:19 +0800 Subject: [PATCH 78/87] GPU (Haiku): silence warnings --- src/detection/gpu/gpu_haiku.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/gpu/gpu_haiku.c b/src/detection/gpu/gpu_haiku.c index c1324f761..16b40c860 100644 --- a/src/detection/gpu/gpu_haiku.c +++ b/src/detection/gpu/gpu_haiku.c @@ -14,7 +14,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* .info = &dev, }; - for (cmd.index = 0; ioctl(pokefd, POKE_GET_NTH_PCI_INFO, &cmd) == B_OK && cmd.status == B_OK; ++cmd.index) + for (cmd.index = 0; ioctl(pokefd, POKE_GET_NTH_PCI_INFO, &cmd, sizeof(cmd)) == B_OK && cmd.status == B_OK; ++cmd.index) { if (dev.class_base != 0x03 /*PCI_BASE_CLASS_DISPLAY*/) continue; From 1137e8d1c91cbd653f3dd61a33257f145cddebf3 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 18 Feb 2025 19:49:40 +0800 Subject: [PATCH 79/87] Processing (Haiku): fix exe detection --- src/common/processing_linux.c | 38 ++++++++--------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 26112248b..032e774c1 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -315,39 +315,17 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons #elif defined(__HAIKU__) - { - team_info info; - if (get_team_info(pid, &info) == B_OK) - { - // This is tricky. Paths in info.args are not quoted, so that we don't know - // if a whitespace in args is part of the file path or an argument separator - if (info.argc == 1) - ffStrbufSetS(exe, info.args); - else - { - // args = "/bin/bash -l" - // argc = 2 - int argc = info.argc - 1; - const char* arg0End = strchr(info.args, ' '); - for (const char* p = arg0End + 1; (p = strchr(p, ' ')); ++p) - --argc; - if (argc == 1) // No whitespace in the file path - ffStrbufSetNS(exe, (uint32_t) (arg0End - info.args), info.args); - } - } - } + image_info info; + int32 cookie = 0; - if (exePath) + while (get_next_image_info(pid, &cookie, &info) == B_OK) { - image_info info; - int32 cookie = 0; + if (info.type != B_APP_IMAGE) continue; + ffStrbufSetS(exe, info.name); - while (get_next_image_info(pid, &cookie, &info) == B_OK) - { - if (info.type != B_APP_IMAGE) continue; - ffStrbufSetS(exePath, info.name); - break; - } + if (exePath) + ffStrbufSet(exePath, exe); + break; } #endif From bc129a65d91605cda28c0dcbd564738e582f0610 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 18 Feb 2025 20:24:13 +0800 Subject: [PATCH 80/87] OS (Haiku): detect OS beta version --- src/detection/os/os_haiku.c | 85 +++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 8 deletions(-) diff --git a/src/detection/os/os_haiku.c b/src/detection/os/os_haiku.c index bb83ddeb1..82b934a3a 100644 --- a/src/detection/os/os_haiku.c +++ b/src/detection/os/os_haiku.c @@ -1,20 +1,89 @@ #include "os.h" -#include "common/io/io.h" - #include +#include + +// https://github.com/haiku/haiku/blob/e63683b2fb337d2034059a7e053c170eaf978142/headers/os/BeBuild.h#L36 +#ifndef B_HAIKU_VERSION_1_PRE_BETA_6 +#define B_HAIKU_VERSION_1_PRE_BETA_6 0x00000901 +#endif +#ifndef B_HAIKU_VERSION_1_BETA_6 +#define B_HAIKU_VERSION_1_BETA_6 0x00000A00 +#endif +#ifndef B_HAIKU_VERSION_1_PRE_BETA_7 +#define B_HAIKU_VERSION_1_PRE_BETA_7 0x00000A01 +#endif +#ifndef B_HAIKU_VERSION_1_BETA_7 +#define B_HAIKU_VERSION_1_BETA_7 0x00000B00 +#endif +#ifndef B_HAIKU_VERSION_1_PRE_BETA_8 +#define B_HAIKU_VERSION_1_PRE_BETA_8 0x00000B01 +#endif +#ifndef B_HAIKU_VERSION_1_BETA_8 +#define B_HAIKU_VERSION_1_BETA_8 0x00000C00 +#endif +#ifndef B_HAIKU_VERSION_1_PRE_BETA_9 +#define B_HAIKU_VERSION_1_PRE_BETA_9 0x00000C01 +#endif +#ifndef B_HAIKU_VERSION_1_BETA_9 +#define B_HAIKU_VERSION_1_BETA_9 0x00000D00 +#endif +#ifndef B_HAIKU_VERSION_1 +#define B_HAIKU_VERSION_1 0x00010000 +#endif void ffDetectOSImpl(FFOSResult* os) { - system_info info; + system_info sys; ffStrbufSetStatic(&os->name, "Haiku"); - ffStrbufSetStatic(&os->prettyName, "Haiku"); ffStrbufSetStatic(&os->id, "haiku"); - if (get_system_info(&info) != B_OK) - return; - ffStrbufAppendF(&os->version, "R%ld", info.kernel_version); + image_info image; + int32 cookie = 0; + while (get_next_image_info(B_SYSTEM_TEAM, &cookie, &image) == B_OK) + { + if (image.api_version > 0) + { + switch (image.api_version) + { + #define FF_TEST_HAIKU_VERSION(versionNum, versionStr) \ + case B_HAIKU_VERSION_ ## versionNum: \ + ffStrbufSetStatic(&os->version, versionStr); \ + break; - // TODO: check kernel resources? + FF_TEST_HAIKU_VERSION(1_ALPHA_1, "R1A1") + FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_2, "R1AP2") + FF_TEST_HAIKU_VERSION(1_ALPHA_2, "R1A2") + FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_3, "R1AP3") + FF_TEST_HAIKU_VERSION(1_ALPHA_3, "R1A3") + FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_4, "R1AP4") + FF_TEST_HAIKU_VERSION(1_ALPHA_4, "R1A4") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_1, "R1BP1") + FF_TEST_HAIKU_VERSION(1_BETA_1, "R1B1") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_2, "R1BP2") + FF_TEST_HAIKU_VERSION(1_BETA_2, "R1B2") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_3, "R1BP3") + FF_TEST_HAIKU_VERSION(1_BETA_3, "R1B3") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_4, "R1BP4") + FF_TEST_HAIKU_VERSION(1_BETA_4, "R1B4") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_5, "R1BP5") + FF_TEST_HAIKU_VERSION(1_BETA_5, "R1B5") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_6, "R1BP6") + FF_TEST_HAIKU_VERSION(1_BETA_6, "R1B6") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_7, "R1BP7") + FF_TEST_HAIKU_VERSION(1_BETA_7, "R1B7") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_8, "R1BP8") + FF_TEST_HAIKU_VERSION(1_BETA_8, "R1B8") + } + + break; + } + } + + if (!os->version.length) + { + if (get_system_info(&sys) == B_OK) + ffStrbufAppendF(&os->version, "R%ld", sys.kernel_version); + } } From c66b32fc6fb130c72ee1b1c455fa3632a0cc25af Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 18 Feb 2025 20:48:17 +0800 Subject: [PATCH 81/87] CMake (Haiku): enable more optional dependencies --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 759d3782f..61e8baabb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,8 @@ cmake_dependent_option(ENABLE_CHAFA "Enable chafa" ON "ENABLE_IMAGEMAGICK6 OR EN cmake_dependent_option(ENABLE_ZLIB "Enable zlib" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF) cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR WIN32 OR SunOS OR Haiku" OFF) cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS" OFF) -cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS" OFF) +cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR Haiku" OFF) +cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS OR Haiku" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR SunOS" OFF) cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF) From 36a452c852146cfaa15dab7df2fcbc2fb87bed8d Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 19 Feb 2025 08:53:16 +0800 Subject: [PATCH 82/87] CPU (NetBSD): support non-intel CPUs Fix #1573 --- src/detection/cpu/cpu_nbsd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/detection/cpu/cpu_nbsd.c b/src/detection/cpu/cpu_nbsd.c index 4d9530b5a..118887290 100644 --- a/src/detection/cpu/cpu_nbsd.c +++ b/src/detection/cpu/cpu_nbsd.c @@ -42,10 +42,11 @@ static const char* detectCpuTemp(double* current) const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { - if (ffSysctlGetString("machdep.cpu_brand", &cpu->name) != NULL) + if (ffSysctlGetString("machdep.cpu_brand", &cpu->name) != NULL && + ffSysctlGetString("machdep.dmi.processor-version", &cpu->name) != NULL && + ffSysctlGetString("hw.cpu0.name", &cpu->name) != NULL) { - if (ffSysctlGetString("machdep.dmi.processor-version", &cpu->name) != NULL) - return "sysctlbyname(machdep.cpu_brand) failed"; + ffStrbufSetS(&cpu->name, "Unknown CPU"); } if (ffSysctlGetString("machdep.dmi.processor-vendor", &cpu->vendor) == NULL) @@ -58,6 +59,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) ffCPUDetectSpeedByCpuid(cpu); uint32_t freq = (uint32_t) ffSysctlGetInt("machdep.cpu.frequency.target", 0); + if (freq == 0) freq = (uint32_t) (ffSysctlGetInt64("hw.cpu0.clock_frequency", 0) / 1000000); if (freq > cpu->frequencyBase) cpu->frequencyBase = freq; cpu->temperature = FF_CPU_TEMP_UNSET; From 3c5f69b874c5fa56ddbece08a6914abc8985c97e Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 19 Feb 2025 09:00:22 +0800 Subject: [PATCH 83/87] OS (Haiku): report pre version as `-` --- src/detection/os/os_haiku.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/detection/os/os_haiku.c b/src/detection/os/os_haiku.c index 82b934a3a..361353530 100644 --- a/src/detection/os/os_haiku.c +++ b/src/detection/os/os_haiku.c @@ -53,28 +53,31 @@ void ffDetectOSImpl(FFOSResult* os) break; FF_TEST_HAIKU_VERSION(1_ALPHA_1, "R1A1") - FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_2, "R1AP2") + FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_2, "R1A2-") FF_TEST_HAIKU_VERSION(1_ALPHA_2, "R1A2") - FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_3, "R1AP3") + FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_3, "R1A3-") FF_TEST_HAIKU_VERSION(1_ALPHA_3, "R1A3") - FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_4, "R1AP4") + FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_4, "R1A4-") FF_TEST_HAIKU_VERSION(1_ALPHA_4, "R1A4") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_1, "R1BP1") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_1, "R1B1-") FF_TEST_HAIKU_VERSION(1_BETA_1, "R1B1") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_2, "R1BP2") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_2, "R1B2-") FF_TEST_HAIKU_VERSION(1_BETA_2, "R1B2") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_3, "R1BP3") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_3, "R1B3-") FF_TEST_HAIKU_VERSION(1_BETA_3, "R1B3") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_4, "R1BP4") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_4, "R1B4-") FF_TEST_HAIKU_VERSION(1_BETA_4, "R1B4") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_5, "R1BP5") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_5, "R1B5-") FF_TEST_HAIKU_VERSION(1_BETA_5, "R1B5") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_6, "R1BP6") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_6, "R1B6-") FF_TEST_HAIKU_VERSION(1_BETA_6, "R1B6") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_7, "R1BP7") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_7, "R1B7-") FF_TEST_HAIKU_VERSION(1_BETA_7, "R1B7") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_8, "R1BP8") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_8, "R1B8-") FF_TEST_HAIKU_VERSION(1_BETA_8, "R1B8") + FF_TEST_HAIKU_VERSION(1_PRE_BETA_9, "R1B9-") + FF_TEST_HAIKU_VERSION(1_BETA_9, "R1B9") + FF_TEST_HAIKU_VERSION(1, "R1") } break; @@ -84,6 +87,6 @@ void ffDetectOSImpl(FFOSResult* os) if (!os->version.length) { if (get_system_info(&sys) == B_OK) - ffStrbufAppendF(&os->version, "R%ld", sys.kernel_version); + ffStrbufAppendF(&os->version, "R%ldx", sys.kernel_version); } } From c0c59a890ad3a33034efad2458ae5990d1cb5581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Feb 2025 09:58:46 +0800 Subject: [PATCH 84/87] Version: report more CPU arches --- src/detection/version/version.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/detection/version/version.c b/src/detection/version/version.c index ce493344a..4b6c5e1c6 100644 --- a/src/detection/version/version.c +++ b/src/detection/version/version.c @@ -4,6 +4,8 @@ #define FF_ARCHITECTURE "x86_64" #elif defined(__i386__) #define FF_ARCHITECTURE "i386" +#elif defined(__ia64__) + #define FF_ARCHITECTURE "ia64" #elif defined(__aarch64__) #define FF_ARCHITECTURE "aarch64" #elif defined(__arm__) @@ -18,8 +20,16 @@ #define FF_ARCHITECTURE "s390x" #elif defined(__loongarch__) #define FF_ARCHITECTURE "loongarch" +#elif defined(__sparc__) + #define FF_ARCHITECTURE "sparc" +#elif defined(__alpha__) + #define FF_ARCHITECTURE "alpha" +#elif defined(__hppa__) + #define FF_ARCHITECTURE "hppa" +#elif defined(__m68k__) + #define FF_ARCHITECTURE "m68k" #else - #define FF_ARCHITECTURE "unknown" + #define FF_ARCHITECTURE "Unknown" #endif #if defined(__ANDROID__) @@ -45,7 +55,7 @@ #elif defined(__HAIKU__) #define FF_SYSNAME "Haiku" #else - #define FF_SYSNAME "unknown" + #define FF_SYSNAME "Unknown" #endif #define FF_STR_INDIR(x) #x From 143b3df771583816fc1e4270ddd3d32551d9c7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Feb 2025 10:47:21 +0800 Subject: [PATCH 85/87] OS (Haiku): calcuate OS version --- src/detection/os/os_haiku.c | 111 +++++++++++++++--------------------- 1 file changed, 46 insertions(+), 65 deletions(-) diff --git a/src/detection/os/os_haiku.c b/src/detection/os/os_haiku.c index 361353530..561bdcc6e 100644 --- a/src/detection/os/os_haiku.c +++ b/src/detection/os/os_haiku.c @@ -2,39 +2,8 @@ #include #include -// https://github.com/haiku/haiku/blob/e63683b2fb337d2034059a7e053c170eaf978142/headers/os/BeBuild.h#L36 -#ifndef B_HAIKU_VERSION_1_PRE_BETA_6 -#define B_HAIKU_VERSION_1_PRE_BETA_6 0x00000901 -#endif -#ifndef B_HAIKU_VERSION_1_BETA_6 -#define B_HAIKU_VERSION_1_BETA_6 0x00000A00 -#endif -#ifndef B_HAIKU_VERSION_1_PRE_BETA_7 -#define B_HAIKU_VERSION_1_PRE_BETA_7 0x00000A01 -#endif -#ifndef B_HAIKU_VERSION_1_BETA_7 -#define B_HAIKU_VERSION_1_BETA_7 0x00000B00 -#endif -#ifndef B_HAIKU_VERSION_1_PRE_BETA_8 -#define B_HAIKU_VERSION_1_PRE_BETA_8 0x00000B01 -#endif -#ifndef B_HAIKU_VERSION_1_BETA_8 -#define B_HAIKU_VERSION_1_BETA_8 0x00000C00 -#endif -#ifndef B_HAIKU_VERSION_1_PRE_BETA_9 -#define B_HAIKU_VERSION_1_PRE_BETA_9 0x00000C01 -#endif -#ifndef B_HAIKU_VERSION_1_BETA_9 -#define B_HAIKU_VERSION_1_BETA_9 0x00000D00 -#endif -#ifndef B_HAIKU_VERSION_1 -#define B_HAIKU_VERSION_1 0x00010000 -#endif - void ffDetectOSImpl(FFOSResult* os) { - system_info sys; - ffStrbufSetStatic(&os->name, "Haiku"); ffStrbufSetStatic(&os->id, "haiku"); @@ -43,49 +12,61 @@ void ffDetectOSImpl(FFOSResult* os) int32 cookie = 0; while (get_next_image_info(B_SYSTEM_TEAM, &cookie, &image) == B_OK) { - if (image.api_version > 0) + int32 ver = image.api_version; + if (ver == 0) continue; + + // https://github.com/haiku/haiku/blob/e63683b2fb337d2034059a7e053c170eaf978142/headers/os/BeBuild.h#L36 + if (ver < B_HAIKU_VERSION_1_ALPHA_1) { - switch (image.api_version) + switch (ver) { - #define FF_TEST_HAIKU_VERSION(versionNum, versionStr) \ - case B_HAIKU_VERSION_ ## versionNum: \ - ffStrbufSetStatic(&os->version, versionStr); \ - break; - - FF_TEST_HAIKU_VERSION(1_ALPHA_1, "R1A1") - FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_2, "R1A2-") - FF_TEST_HAIKU_VERSION(1_ALPHA_2, "R1A2") - FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_3, "R1A3-") - FF_TEST_HAIKU_VERSION(1_ALPHA_3, "R1A3") - FF_TEST_HAIKU_VERSION(1_PRE_ALPHA_4, "R1A4-") - FF_TEST_HAIKU_VERSION(1_ALPHA_4, "R1A4") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_1, "R1B1-") - FF_TEST_HAIKU_VERSION(1_BETA_1, "R1B1") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_2, "R1B2-") - FF_TEST_HAIKU_VERSION(1_BETA_2, "R1B2") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_3, "R1B3-") - FF_TEST_HAIKU_VERSION(1_BETA_3, "R1B3") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_4, "R1B4-") - FF_TEST_HAIKU_VERSION(1_BETA_4, "R1B4") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_5, "R1B5-") - FF_TEST_HAIKU_VERSION(1_BETA_5, "R1B5") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_6, "R1B6-") - FF_TEST_HAIKU_VERSION(1_BETA_6, "R1B6") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_7, "R1B7-") - FF_TEST_HAIKU_VERSION(1_BETA_7, "R1B7") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_8, "R1B8-") - FF_TEST_HAIKU_VERSION(1_BETA_8, "R1B8") - FF_TEST_HAIKU_VERSION(1_PRE_BETA_9, "R1B9-") - FF_TEST_HAIKU_VERSION(1_BETA_9, "R1B9") - FF_TEST_HAIKU_VERSION(1, "R1") + case B_HAIKU_VERSION_BEOS: + ffStrbufSetStatic(&os->version, "BEOS"); + break; + case B_HAIKU_VERSION_BONE: + ffStrbufSetStatic(&os->version, "BONE"); + break; + case B_HAIKU_VERSION_DANO: + ffStrbufSetStatic(&os->version, "DANO"); + break; } + } + else + { + int32 relVer = ver / 0x10000; + ver %= 0x10000; + if (ver == 0) + { + ffStrbufSetF(&os->version, "R%d", relVer); + } + else + { + relVer++; - break; + bool isPre = !!(ver & 1); + if (ver < B_HAIKU_VERSION_1_PRE_BETA_1) + { + int32 alphaVer = ver / 0x100; + if (isPre) + ffStrbufSetF(&os->version, "R%dA%d-", relVer, alphaVer + 1); + else + ffStrbufSetF(&os->version, "R%dA%d", relVer, alphaVer); + } + else if (ver < 0x00010000 /* B_HAIKU_VERSION_1 */) + { + int32 betaVer = (ver - B_HAIKU_VERSION_1_ALPHA_4) / 0x100; + if (isPre) + ffStrbufSetF(&os->version, "R%dB%d-", relVer, betaVer + 1); + else + ffStrbufSetF(&os->version, "R%dB%d", relVer, betaVer); + } + } } } if (!os->version.length) { + system_info sys; if (get_system_info(&sys) == B_OK) ffStrbufAppendF(&os->version, "R%ldx", sys.kernel_version); } From 3ae7c4f788ad00d9c001af6f18d49f67c69902f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Feb 2025 15:21:01 +0800 Subject: [PATCH 86/87] Release: v2.37.0 --- CHANGELOG.md | 2 ++ CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2244ffcae..d1c9bbc26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,11 @@ Features: * Some bugs are found and fixed. * Remove `python-requests` dependency in `scripts/gen-*.py`. * Add cmake option `-DENABLE_EMBEDDED_AMDGPUIDS=BOOL` (disabled by default) + * If enabled, fastfetch will embed the newest [`amdgpu.ids`](https://gitlab.freedesktop.org/mesa/drm/-/blob/main/data/amdgpu.ids?ref_type=heads) file into fastfetch binary. * Weather module now honors `display.temp.unit` option (#1560, Weather) * Support Physical Memory module in NetBSD (PhysicalMemory, NetBSD) * Requires root permission +* Improve non-intel CPU detection in NetBSD (#1573, CPU, NetBSD) Bugfixes: * Fix building in macOS 10.13 (GPU, macOS) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61e8baabb..d0839a5a1 100644 --- a/CMakeLists.txt +++ b/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.36.1 + VERSION 2.37.0 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" From 959bf769fb56012ce20b15a8b84bffa7e168b736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 19 Feb 2025 15:35:52 +0800 Subject: [PATCH 87/87] Doc: fix typo in changelog [ci skip] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1c9bbc26..f5148becc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ Bugfixes: * Properly round percent values when detecting volume (#1558, Sound) * Fix Physical Memory module doesn't work in `--format json` mode * Add some missing variable inits (GPU, Linux) -* Fix `--localip-default-route-only false not working` with `--gen-config` (#1570, LocalIP) +* Fix `--localip-default-route-only false` not working with `--gen-config` (#1570, LocalIP) Logo: * Update Rosa linux