Files
Astral/patches/fastfetch/jinx-working-patch.patch
T
2026-05-12 22:21:03 -03:00

485 lines
17 KiB
Diff

diff --git fastfetch-clean/CMakeLists.txt fastfetch-workdir/CMakeLists.txt
index 725b2b6..c5891a3 100644
--- fastfetch-clean/CMakeLists.txt
+++ fastfetch-workdir/CMakeLists.txt
@@ -45,6 +45,8 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
set(Haiku TRUE CACHE BOOL "..." FORCE)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
set(GNU TRUE CACHE BOOL "..." FORCE)
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Astral")
+ set(ASTRAL TRUE CACHE BOOL "..." FORCE)
elseif(NOT APPLE AND NOT WIN32)
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()
@@ -72,7 +74,7 @@ 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 OR Haiku OR GNU" OFF)
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR GNU" OFF)
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU" OFF)
-cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU" OFF)
+cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU OR ASTRAL" OFF)
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF)
cmake_dependent_option(ENABLE_DRM_AMDGPU "Enable libdrm_amdgpu" ON "LINUX OR FreeBSD OR GNU" OFF)
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU" OFF)
@@ -1301,6 +1303,79 @@ elseif(GNU)
src/detection/wmtheme/wmtheme_linux.c
src/detection/camera/camera_nosupport.c
)
+elseif(ASTRAL)
+ list(APPEND LIBFASTFETCH_SRC
+ src/common/impl/dbus.c
+ src/common/impl/io_unix.c
+ src/common/impl/netif_gnu.c
+ src/common/impl/networking_linux.c
+ src/common/impl/processing_linux.c
+ src/common/impl/FFPlatform_unix.c
+ src/common/impl/binary_linux.c
+ src/detection/battery/battery_nosupport.c
+ src/detection/bios/bios_nosupport.c
+ src/detection/bluetooth/bluetooth_nosupport.c
+ src/detection/bluetoothradio/bluetoothradio_nosupport.c
+ src/detection/board/board_nosupport.c
+ src/detection/bootmgr/bootmgr_nosupport.c
+ src/detection/brightness/brightness_nosupport.c
+ src/detection/btrfs/btrfs_nosupport.c
+ src/detection/camera/camera_nosupport.c
+ src/detection/command/command.c
+ src/detection/chassis/chassis_nosupport.c
+ src/detection/cpu/cpu_astral.c
+ src/detection/cpucache/cpucache_nosupport.c
+ src/detection/cpuusage/cpuusage_nosupport.c
+ src/detection/cursor/cursor_nosupport.c
+ src/detection/de/de_nosupport.c
+ src/detection/disk/disk_astral.c
+ src/detection/diskio/diskio_nosupport.c
+ src/detection/displayserver/linux/common.c
+ src/detection/displayserver/linux/displayserver_linux.c
+ src/detection/displayserver/linux/wayland/wayland.c
+ src/detection/displayserver/linux/drm.c
+ src/detection/displayserver/linux/wmde.c
+ src/detection/displayserver/linux/xlib.c
+ src/detection/displayserver/linux/xcb.c
+ src/detection/dns/dns_linux.c
+ src/detection/editor/editor.c
+ src/detection/font/font_nosupport.c
+ src/detection/gamepad/gamepad_nosupport.c
+ src/detection/gpu/gpu_nosupport.c
+ src/detection/host/host_nosupport.c
+ src/detection/icons/icons_nosupport.c
+ src/detection/initsystem/initsystem_nosupport.c
+ src/detection/keyboard/keyboard_nosupport.c
+ src/detection/libc/libc_astral.c
+ src/detection/lm/lm_nosupport.c
+ src/detection/loadavg/loadavg_astral.c
+ src/detection/locale/locale_linux.c
+ src/detection/localip/localip_linux.c
+ src/detection/media/media_nosupport.c
+ src/detection/memory/memory_astral.c
+ src/detection/mouse/mouse_nosupport.c
+ src/detection/netio/netio_nosupport.c
+ src/detection/opengl/opengl_linux.c
+ src/detection/os/os_linux.c
+ src/detection/packages/packages_astral.c
+ src/detection/physicaldisk/physicaldisk_nosupport.c
+ src/detection/physicalmemory/physicalmemory_nosupport.c
+ src/detection/poweradapter/poweradapter_nosupport.c
+ src/detection/processes/processes_astral.c
+ src/detection/sound/sound_nosupport.c
+ src/detection/terminalfont/terminalfont_linux.c
+ src/detection/terminalsize/terminalsize_linux.c
+ src/detection/terminalshell/terminalshell_linux.c
+ src/detection/swap/swap_astral.c
+ src/detection/theme/theme_nosupport.c
+ src/detection/uptime/uptime_linux.c
+ src/detection/users/users_linux.c
+ src/detection/tpm/tpm_nosupport.c
+ src/detection/wallpaper/wallpaper_nosupport.c
+ src/detection/wifi/wifi_nosupport.c
+ src/detection/wm/wm_nosupport.c
+ src/detection/wmtheme/wmtheme_nosupport.c
+ )
endif()
if(ENABLE_DIRECTX_HEADERS)
@@ -1437,6 +1512,8 @@ elseif(Haiku)
elseif(GNU)
# On Hurd PATH_MAX is not defined. Set an arbitrary limit as workaround.
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE PATH_MAX=4096 O_PATH=0)
+elseif(ASTRAL)
+ target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
endif()
if(APPLE)
diff --git fastfetch-clean/src/common/impl/FFPlatform_unix.c fastfetch-workdir/src/common/impl/FFPlatform_unix.c
index 985494b..97a141d 100644
--- fastfetch-clean/src/common/impl/FFPlatform_unix.c
+++ fastfetch-workdir/src/common/impl/FFPlatform_unix.c
@@ -62,6 +62,8 @@ static void getExePath(FFPlatform* platform)
break;
}
}
+ #elif defined(__astral__) // TODO: implement similar to how openbsd does it with argv
+ ssize_t exePathLen = 0;
#endif
if (exePathLen > 0)
{
diff --git fastfetch-workdir/src/detection/cpu/cpu_astral.c fastfetch-workdir/src/detection/cpu/cpu_astral.c
new file mode 100644
index 0000000..0814baa
--- /dev/null
+++ fastfetch-workdir/src/detection/cpu/cpu_astral.c
@@ -0,0 +1,44 @@
+#include "cpu.h"
+#include <cpuid.h>
+
+void cpuid_brand_string(char buffer[49]) {
+ uint32_t regs[12];
+
+ __get_cpuid(0x80000000, regs + 0, regs + 1, regs + 2, regs + 3);
+ if (regs[0] < 0x80000004) {
+ strcpy(buffer, "Unknown");
+ return;
+ }
+
+ __get_cpuid(0x80000002, regs + 0, regs + 1, regs + 2, regs + 3);
+ __get_cpuid(0x80000003, regs + 4, regs + 5, regs + 6, regs + 7);
+ __get_cpuid(0x80000004, regs + 8, regs + 9, regs + 10, regs + 11);
+
+ memcpy(buffer, regs, sizeof(regs));
+ buffer[sizeof(regs)] = '\0';
+}
+
+void cpuid_vendor_string(char buffer[13]) {
+ uint32_t regs[4];
+
+ __get_cpuid(0x0, regs + 3, regs + 0, regs + 2, regs + 1);
+
+ memcpy(buffer, regs, sizeof(uint32_t) * 3);
+ buffer[12] = '\0';
+}
+
+const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FF_MAYBE_UNUSED FFCPUResult* cpu)
+{
+ // Brand/Model
+ char brandBuffer[49];
+ cpuid_brand_string(brandBuffer);
+ ffStrbufSetS(&cpu->name, brandBuffer);
+
+ // Vendor String
+ char vendorBuffer[13];
+ cpuid_vendor_string(vendorBuffer);
+ ffStrbufSetS(&cpu->vendor, vendorBuffer);
+
+ ffCPUDetectByCpuid(cpu);
+ return NULL;
+}
diff --git fastfetch-workdir/src/detection/disk/disk_astral.c fastfetch-workdir/src/detection/disk/disk_astral.c
new file mode 100644
index 0000000..2f94822
--- /dev/null
+++ fastfetch-workdir/src/detection/disk/disk_astral.c
@@ -0,0 +1,88 @@
+#include "disk.h"
+
+#include "common/stringUtils.h"
+
+#include <mntent.h>
+#include <string.h>
+#include <sys/statvfs.h>
+
+static bool isPhysicalDevice(const struct mntent* device)
+{
+ if(ffStrEquals(device->mnt_dir, "/"))
+ return true;
+
+ return ffStrStartsWith(device->mnt_fsname, "/dev/");
+}
+
+static void detectName(FFDisk* disk)
+{
+ if(!ffStrbufStartsWithS(&disk->mountFrom, "/dev/"))
+ return;
+
+ const char* slash = strrchr(disk->mountFrom.chars, '/');
+ if(slash != NULL && slash[1] != '\0')
+ ffStrbufAppendS(&disk->name, slash + 1);
+}
+
+static void detectStats(FFDisk* disk)
+{
+ struct statvfs fs;
+ if(statvfs(disk->mountpoint.chars, &fs) != 0)
+ memset(&fs, 0, sizeof(fs));
+
+ disk->bytesTotal = fs.f_blocks * (uint64_t) fs.f_frsize;
+ disk->bytesFree = fs.f_bfree * (uint64_t) fs.f_frsize;
+ disk->bytesAvailable = fs.f_bavail * (uint64_t) fs.f_frsize;
+ disk->bytesUsed = 0;
+
+ if(fs.f_files >= fs.f_ffree)
+ {
+ disk->filesTotal = (uint32_t) fs.f_files;
+ disk->filesUsed = (uint32_t) (fs.f_files - fs.f_ffree);
+ }
+
+ disk->createTime = 0;
+}
+
+const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
+{
+ FILE* mountsFile = setmntent(FASTFETCH_TARGET_DIR_ROOT "/etc/mtab", "r");
+ if(mountsFile == NULL)
+ return "setmntent(\"/etc/mtab\", \"r\") == NULL";
+
+ struct mntent* device;
+ while((device = getmntent(mountsFile)) != NULL)
+ {
+ if(__builtin_expect(options->folders.length > 0, false))
+ {
+ if(!ffStrbufSeparatedContainS(&options->folders, device->mnt_dir, FF_DISK_FOLDER_SEPARATOR))
+ continue;
+ }
+ else if(!isPhysicalDevice(device))
+ continue;
+
+ if(options->hideFolders.length && ffDiskMatchesFolderPatterns(&options->hideFolders, device->mnt_dir, FF_DISK_FOLDER_SEPARATOR))
+ continue;
+
+ if(options->hideFS.length && ffStrbufSeparatedContainS(&options->hideFS, device->mnt_type, ':'))
+ continue;
+
+ FFDisk* disk = ffListAdd(disks);
+ disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
+
+ ffStrbufInitS(&disk->mountFrom, device->mnt_fsname);
+ ffStrbufInitS(&disk->mountpoint, device->mnt_dir);
+ ffStrbufInitS(&disk->filesystem, device->mnt_type);
+
+ ffStrbufInit(&disk->name);
+ detectName(disk);
+
+ if(hasmntopt(device, MNTOPT_RO))
+ disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
+
+ detectStats(disk);
+ }
+
+ endmntent(mountsFile);
+ return NULL;
+}
diff --git fastfetch-workdir/src/detection/libc/libc_astral.c fastfetch-workdir/src/detection/libc/libc_astral.c
new file mode 100644
index 0000000..d5344f6
--- /dev/null
+++ fastfetch-workdir/src/detection/libc/libc_astral.c
@@ -0,0 +1,8 @@
+#include "libc.h"
+
+const char* ffDetectLibc(FFLibcResult* result)
+{
+ result->name = "mlibc";
+ result->version = NULL;
+ return NULL;
+}
diff --git fastfetch-workdir/src/detection/loadavg/loadavg_astral.c fastfetch-workdir/src/detection/loadavg/loadavg_astral.c
new file mode 100644
index 0000000..762524a
--- /dev/null
+++ fastfetch-workdir/src/detection/loadavg/loadavg_astral.c
@@ -0,0 +1,15 @@
+#include "loadavg.h"
+
+#include <sys/sysinfo.h>
+
+const char* ffDetectLoadavg(double result[3])
+{
+ struct sysinfo si;
+ if(sysinfo(&si) < 0)
+ return "sysinfo() failed";
+
+ for(int i = 0; i < 3; ++i)
+ result[i] = (double) si.loads[i] / (1 << SI_LOAD_SHIFT);
+
+ return NULL;
+}
diff --git fastfetch-workdir/src/detection/memory/memory_astral.c fastfetch-workdir/src/detection/memory/memory_astral.c
new file mode 100644
index 0000000..3eb849c
--- /dev/null
+++ fastfetch-workdir/src/detection/memory/memory_astral.c
@@ -0,0 +1,16 @@
+#include "memory.h"
+#include <sys/sysinfo.h>
+#include <unistd.h>
+
+const char* ffDetectMemory(FFMemoryResult* ram)
+{
+ struct sysinfo info;
+ if(sysinfo(&info)) {
+ return "sysinfo() failed";
+ }
+
+ ram->bytesTotal = (uint64_t)(info.totalram * info.mem_unit);
+ ram->bytesUsed = (uint64_t)((info.totalram - info.freeram) * info.mem_unit);
+
+ return NULL;
+}
diff --git fastfetch-workdir/src/detection/packages/packages_astral.c fastfetch-workdir/src/detection/packages/packages_astral.c
new file mode 100644
index 0000000..04b46bf
--- /dev/null
+++ fastfetch-workdir/src/detection/packages/packages_astral.c
@@ -0,0 +1,57 @@
+#include "packages.h"
+
+#include "common/io.h"
+#include "common/stringUtils.h"
+
+#include <dirent.h>
+#include <string.h>
+
+static uint32_t countStrings(const char* path, const char* needle)
+{
+ FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
+ if(!ffReadFileBuffer(path, &content))
+ return 0;
+
+ uint32_t count = 0;
+ char* iter = content.chars;
+ size_t needleLength = strlen(needle);
+
+ while((iter = memmem(iter, content.length - (size_t) (iter - content.chars), needle, needleLength)) != NULL)
+ {
+ ++count;
+ iter += needleLength;
+ }
+
+ return count;
+}
+
+static uint32_t getXBPS(void)
+{
+ FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateStatic(FASTFETCH_TARGET_DIR_ROOT "/var/db/xbps");
+ uint32_t baseLength = path.length;
+
+ FF_AUTO_CLOSE_DIR DIR* dir = opendir(path.chars);
+ if(dir == NULL)
+ return 0;
+
+ struct dirent* entry;
+ while((entry = readdir(dir)) != NULL)
+ {
+ if(!ffStrStartsWithIgnCase(entry->d_name, "pkgdb-"))
+ continue;
+
+ ffStrbufAppendC(&path, '/');
+ ffStrbufAppendS(&path, entry->d_name);
+ uint32_t result = countStrings(path.chars, "<key>pkgver</key>");
+ ffStrbufSubstrBefore(&path, baseLength);
+ return result;
+ }
+
+ return 0;
+}
+
+void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
+{
+ if(!(options->disabled & FF_PACKAGES_FLAG_XBPS_BIT))
+ result->xbps = getXBPS();
+}
diff --git fastfetch-workdir/src/detection/processes/processes_astral.c fastfetch-workdir/src/detection/processes/processes_astral.c
new file mode 100644
index 0000000..59380e5
--- /dev/null
+++ fastfetch-workdir/src/detection/processes/processes_astral.c
@@ -0,0 +1,13 @@
+#include "processes.h"
+
+#include <sys/sysinfo.h>
+
+const char* ffDetectProcesses(uint32_t* result)
+{
+ struct sysinfo si;
+ if(sysinfo(&si) < 0)
+ return "sysinfo() failed";
+
+ *result = si.procs;
+ return NULL;
+}
diff --git fastfetch-workdir/src/detection/swap/swap_astral.c fastfetch-workdir/src/detection/swap/swap_astral.c
new file mode 100644
index 0000000..f75b857
--- /dev/null
+++ fastfetch-workdir/src/detection/swap/swap_astral.c
@@ -0,0 +1,18 @@
+#include "swap.h"
+#include <sys/sysinfo.h>
+
+const char* ffDetectSwap(FFlist* result)
+{
+ struct sysinfo info;
+ if(sysinfo(&info)) {
+ return "sysinfo() failed";
+ }
+
+ FFSwapResult* swap = ffListAdd(result);
+
+ ffStrbufInitStatic(&swap->name, "Total");
+ swap->bytesTotal = (uint64_t)(info.totalswap * info.mem_unit);
+ swap->bytesUsed = (uint64_t)((info.totalswap - info.freeswap) * info.mem_unit);
+
+ return NULL;
+}
diff --git fastfetch-workdir/src/logo/ascii/astral.txt fastfetch-workdir/src/logo/ascii/astral.txt
new file mode 100644
index 0000000..7afd656
--- /dev/null
+++ fastfetch-workdir/src/logo/ascii/astral.txt
@@ -0,0 +1,11 @@
+$2 .::.
+ .:' .:
+ * $1MMM8&&$2.::' .:'
+ $1MMMM$2.::'$1&&$2 .:'
+ $1MM$2..:'$188&&&&&&
+ $1M$2.:'$1MM88&&&&&&
+ $2.:'$1MMMM88&&&&&& $2*
+ $2.:' $1MMMMM88&&&&
+$2.:' * .:'$1MMM8&&&'
+$2:' .:'
+$2'::' *
\ No newline at end of file
diff --git fastfetch-clean/src/logo/builtin.c fastfetch-workdir/src/logo/builtin.c
index c2f2207..06ecef1 100644
--- fastfetch-clean/src/logo/builtin.c
+++ fastfetch-workdir/src/logo/builtin.c
@@ -679,6 +679,17 @@ static const FFlogo A[] = {
.colorKeys = FF_COLOR_FG_RED,
.colorTitle = FF_COLOR_FG_DEFAULT,
},
+ // Astral
+ {
+ .names = {"Astral"},
+ .lines = FASTFETCH_DATATEXT_LOGO_ASTRAL,
+ .colors = {
+ FF_COLOR_FG_BLUE,
+ FF_COLOR_FG_WHITE,
+ },
+ .colorKeys = FF_COLOR_FG_BLUE,
+ .colorTitle = FF_COLOR_FG_WHITE,
+ },
// Ataraxia
{
.names = {"Ataraxia Linux", "Ataraxia"},
diff --git fastfetch-clean/src/options/general.h fastfetch-workdir/src/options/general.h
index 2248201..d0153ac 100644
--- fastfetch-clean/src/options/general.h
+++ fastfetch-workdir/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__) || defined(__HAIKU__) || defined(__GNU__)
+ #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(__GNU__) || defined(__astral__)
FFstrbuf playerName;
FFDsForceDrmType dsForceDrm;
#elif defined(_WIN32)