diff --git a/.editorconfig b/.editorconfig index c65cfad7bc..3e19f507c9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,10 +7,10 @@ tab_width = 4 insert_final_newline = true trim_trailing_whitespace = true -[*.{md,fflogo}] +[*.md] trim_trailing_whitespace = false -[*.{fflogo}] +[*.txt] insert_final_newline = false [*.yml] diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d6a0354162..183ade6423 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -github: [LinusDierheimer, CarterLi] +github: [CarterLi, LinusDierheimer] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5fe55b6c8..9dedbf8546 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: run: uname -a - name: configure project - run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_XFCONF=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OSMESA=OFF -DENABLE_OPENCL=OFF -DENABLE_FREETYPE=OFF -DENABLE_PULSE=OFF -DENABLE_DDCUTIL=OFF -DENABLE_DIRECTX_HEADERS=OFF -DENABLE_THREADS=OFF + run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_XFCONF=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OSMESA=OFF -DENABLE_OPENCL=OFF -DENABLE_FREETYPE=OFF -DENABLE_PULSE=OFF -DENABLE_DDCUTIL=OFF -DENABLE_ELF=OFF -DENABLE_DIRECTX_HEADERS=OFF -DENABLE_THREADS=OFF - name: build project run: cmake --build . --target package --verbose -j4 @@ -74,7 +74,7 @@ jobs: run: uname -a - 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 directx-headers-dev + 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: | @@ -142,7 +142,7 @@ jobs: githubToken: ${{ github.token }} run: | uname -a - apt-get update && apt-get install -y cmake make g++ 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 directx-headers-dev rpm + apt-get update && apt-get install -y cmake make g++ 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 rpm cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . cmake --build . --target package --verbose -j4 ./fastfetch --list-features @@ -181,7 +181,7 @@ jobs: # CMake installed by apt has bug `list sub-command REMOVE_ITEM requires two or more arguments` wget --no-check-certificate https://apt.kitware.com/ubuntu/pool/main/c/cmake/{cmake_3.29.2-0kitware1ubuntu20.04.1_armhf.deb,cmake-data_3.29.2-0kitware1ubuntu20.04.1_all.deb} dpkg -i *.deb - apt-get install -y make g++ 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 directx-headers-dev rpm + apt-get install -y make g++ 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 rpm cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . cmake --build . --target package --verbose -j4 ./fastfetch --list-features @@ -216,7 +216,7 @@ jobs: githubToken: ${{ github.token }} run: | uname -a - apt-get update && apt-get install -y cmake make g++ 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 libddcutil-dev libchafa-dev directx-headers-dev rpm + apt-get update && apt-get install -y cmake make g++ 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 libddcutil-dev libchafa-dev libelf-dev directx-headers-dev rpm cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . cmake --build . --target package --verbose -j4 ./fastfetch --list-features @@ -247,7 +247,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 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 @@ -288,7 +288,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 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 @@ -422,7 +422,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 ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd v4l_compat + sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm libelf glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd v4l_compat cmake -DSET_TWEAK=Off -DBUILD_TESTS=On . cmake --build . --target package --verbose -j4 ./fastfetch --list-features diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a475abd0f..24fe40cf89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +# 2.21.1 + +Hotfix for a regression that breaks WM detection when running `startx` from TTY (Regression from 2.21.0, #1172 / #1162) + +Changes: +* On Linux, FreeBSD and SunOS, a new recommended dependency `libelf` is introduced to extract strings in ELF binary, used for + * st term font detection when the term font is compiled directly into the binary + * fast path of systemd version detection + +Features: +* Improve performance of + * kitty version detection (Terminal, Linux) + * st term font detection (TerminalFont, Linux) + * systemd version detection (InitSystem, Linux) + +Bugfixes: +* Fix building error without `linux/wireless.h` (Wifi, Linux) +* Fix wrong GPU max frequency on Asahi Linux (GPU, Linux) +* Don't rely `$XDG_SESSION_TYPE` for detecting wm protocol (#1172 / #1162, WM, Linux) +* Fix light color doesn't work on Linux console (Colors, Linux) +* `LC_ALL`, if set, overrides every other locale-related environment variable (Locale) +* Increase timeout of DBus calls (Linux) + +Logos: +* Add vanilla_small and vanilla2 +* Add LFS (Linux From Scratch) + # 2.21.0 Changes: diff --git a/CMakeLists.txt b/CMakeLists.txt index 713ec814b8..c08ead2534 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.21.0 + VERSION 2.21.1 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" @@ -69,6 +69,7 @@ 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 FreeBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embedded) yyjson library" OFF) @@ -201,10 +202,10 @@ if (SET_TWEAK AND EXISTS "${CMAKE_SOURCE_DIR}/.git") execute_process( COMMAND git describe --tags WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - OUTPUT_VARIABLE PROJECT_VERSION_TWEAK + OUTPUT_VARIABLE PROJECT_VERSION_GIT OUTPUT_STRIP_TRAILING_WHITESPACE ) - string(REGEX MATCH "-[0-9]+" PROJECT_VERSION_TWEAK "${PROJECT_VERSION_TWEAK}") + string(REGEX MATCH "-[0-9]+" PROJECT_VERSION_TWEAK "${PROJECT_VERSION_GIT}") endif() if(PROJECT_VERSION_TWEAK) string(REGEX MATCH "[0-9]+" PROJECT_VERSION_TWEAK_NUM "${PROJECT_VERSION_TWEAK}") @@ -480,6 +481,7 @@ if(LINUX) src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_linux.c src/util/platform/FFPlatform_unix.c + src/util/linux/elf.c ) elseif(ANDROID) list(APPEND LIBFASTFETCH_SRC @@ -619,6 +621,7 @@ elseif(FreeBSD) src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_linux.c src/util/platform/FFPlatform_unix.c + src/util/linux/elf.c ) elseif(APPLE) list(APPEND LIBFASTFETCH_SRC @@ -826,6 +829,7 @@ elseif(SunOS) src/detection/wmtheme/wmtheme_linux.c src/detection/camera/camera_nosupport.c src/util/platform/FFPlatform_unix.c + src/util/linux/elf.c ) endif() @@ -1075,6 +1079,10 @@ ff_lib_enable(DDCUTIL "ddcutil" "Ddcutil" ) +ff_lib_enable(ELF + "libelf" + "libelf" +) ff_lib_enable(DIRECTX_HEADERS "DirectX-Headers" "DirectX-Headers" diff --git a/debian/changelog b/debian/changelog index 995208e807..90f04afb8c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +fastfetch (2.21.0) jammy; urgency=medium + + * Update to 2.21.0 + + -- Carter Li Mon, 05 Aug 2024 14:35:43 +0800 + +fastfetch (2.20.0) jammy; urgency=medium + + * Update to 2.20.0 + + -- Carter Li Fri, 26 Jul 2024 14:02:50 +0800 + fastfetch (2.19.1) jammy; urgency=medium * Update to 2.19.1 diff --git a/debian/files b/debian/files index 0e001f544a..4bba4091cf 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -fastfetch_2.19.1_source.buildinfo universe/utils optional +fastfetch_2.20.0_source.buildinfo universe/utils optional diff --git a/doc/json_schema.json b/doc/json_schema.json index 4af7a84df5..a6e0bca2be 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -730,6 +730,10 @@ "ddcutil": { "description": "Used for brightness detection of external displays (Linux)", "type": "string" + }, + "elf": { + "description": "Used for st terminal font detection and systemd version detection (Linux)", + "type": "string" } } }, diff --git a/presets/all.jsonc b/presets/all.jsonc index e19041c208..7a473bf7a7 100644 --- a/presets/all.jsonc +++ b/presets/all.jsonc @@ -58,7 +58,10 @@ "poweradapter", "player", "media", - "publicip", + { + "type": "publicip", + "timeout": 1000 + }, { "type": "localip", "showIpv6": true, diff --git a/presets/archey.jsonc b/presets/archey.jsonc index e6824d37fc..bd99c3552e 100644 --- a/presets/archey.jsonc +++ b/presets/archey.jsonc @@ -75,7 +75,8 @@ }, { "type": "publicip", - "key": "WAN IP" + "key": "WAN IP", + "timeout": 1000 } ] } diff --git a/presets/ci.jsonc b/presets/ci.jsonc index 2f3512ce24..d5774c5eb8 100644 --- a/presets/ci.jsonc +++ b/presets/ci.jsonc @@ -60,7 +60,10 @@ "poweradapter", "player", "media", - "publicip", + { + "type": "publicip", + "timeout": 1000 + }, { "type": "localip", "showIpv6": true, diff --git a/presets/examples/12.jsonc b/presets/examples/12.jsonc index f4c44cf46c..d1dbbcc695 100644 --- a/presets/examples/12.jsonc +++ b/presets/examples/12.jsonc @@ -97,7 +97,8 @@ { "key": "Public IP ", "keyColor": "cyan", - "type": "publicip" + "type": "publicip", + "timeout": 1000 }, "break", { diff --git a/presets/examples/2.jsonc b/presets/examples/2.jsonc index 55d2789342..0ed382ad97 100644 --- a/presets/examples/2.jsonc +++ b/presets/examples/2.jsonc @@ -66,7 +66,10 @@ "type": "localip", "compact": true }, - "publicip", + { + "type": "publicip", + "timeout": 1000 + }, { "type": "wifi", "format": "{ssid}" diff --git a/presets/examples/23.jsonc b/presets/examples/23.jsonc new file mode 100644 index 0000000000..c075b741b8 --- /dev/null +++ b/presets/examples/23.jsonc @@ -0,0 +1,57 @@ +// designed for presenting Vanilla Linux +// inspired from imstilllearnin's Vanilla Logo Ultra +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "small" + }, + "display": { + "color": { + "output": "cyan" + }, + "separator": "" + }, + "modules": [ + { + "type": "kernel", + "key": "Vanilla ", + "keyColor": "blue" + }, + { + "type": "packages", + "key": " [_Packages_> ", + "keyColor": "green" + }, + { + "type": "localip", + "key": " [_Local_IP_> ", + "keyColor": "green" + }, + { + "type": "cpu", + "key": " [_CPU______> ", + "keyColor": "magenta" + }, + { + "type": "memory", + "key": " [_RAM______> ", + "keyColor": "magenta" + }, + { + "type": "swap", + "key": " [_SWAP_____> ", + "keyColor": "magenta" + }, + { + "type": "disk", + "key": " [_Disk_____> ", + "keyColor": "magenta" + }, + "break", + { + "type":"colors", + "paddingLeft": 9, + "symbol": "circle" + } + ] +} diff --git a/presets/examples/6.jsonc b/presets/examples/6.jsonc index 21aae35ef3..5eba94e5ae 100644 --- a/presets/examples/6.jsonc +++ b/presets/examples/6.jsonc @@ -161,7 +161,8 @@ { "type": "publicip", "key": "├─󰩠", - "keyColor": "blue" + "keyColor": "blue", + "timeout": 1000 }, { "type": "wifi", diff --git a/src/common/dbus.h b/src/common/dbus.h index 876ef355c6..282f008d92 100644 --- a/src/common/dbus.h +++ b/src/common/dbus.h @@ -6,7 +6,8 @@ #include "util/FFstrbuf.h" #include "common/library.h" -#define FF_DBUS_TIMEOUT_MILLISECONDS 35 +#define FF_DBUS_TIMEOUT_MILLISECONDS 100 + typedef struct FFDBusLibrary { FF_LIBRARY_SYMBOL(dbus_bus_get) diff --git a/src/common/init.c b/src/common/init.c index 96d1702918..b4d5c1721d 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -248,6 +248,9 @@ void ffListFeatures(void) #if FF_HAVE_DDCUTIL "libddcutil\n" #endif + #if FF_HAVE_ELF + "libelf\n" + #endif #if FF_HAVE_DIRECTX_HEADERS "Directx Headers\n" #endif diff --git a/src/data/help.json b/src/data/help.json index 814409158f..43d501209f 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -935,6 +935,13 @@ "arg": { "type": "path" } + }, + { + "long": "lib-elf", + "desc": "Used for st terminal font detection and systemd version detection", + "arg": { + "type": "path" + } } ], "Module specific": [ diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index d8336f3a92..de006c56b4 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -46,9 +46,7 @@ static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) { - getWMProtocolNameFromEnv(ds); - - if (!ffStrbufEqualS(&ds->wmProtocolName, FF_WM_PROTOCOL_TTY) &&instance.config.general.dsForceDrm == FF_DS_FORCE_DRM_TYPE_FALSE) + if (instance.config.general.dsForceDrm == FF_DS_FORCE_DRM_TYPE_FALSE) { //We try wayland as our preferred display server, as it supports the most features. //This method can't detect the name of our WM / DE @@ -96,6 +94,9 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) } #endif + if (ds->wmProtocolName.length == 0) + getWMProtocolNameFromEnv(ds); + if(!ffStrbufEqualS(&ds->wmProtocolName, FF_WM_PROTOCOL_TTY)) { //This fills in missing information about WM / DE by using env vars and iterating processes diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 0dd04bc10c..f469d08ccf 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -14,11 +14,12 @@ #include #include - #if __has_include() - #include - #else + // https://github.com/AsahiLinux/linux/blob/asahi/include/uapi/drm/asahi_drm.h /* SPDX-License-Identifier: MIT */ /* Copyright (C) The Asahi Linux Contributors */ + + #define DRM_ASAHI_UNSTABLE_UABI_VERSION 10011 + #define DRM_ASAHI_GET_PARAMS 0x00 #define DRM_ASAHI_MAX_CLUSTERS 32 struct drm_asahi_params_global @@ -46,8 +47,9 @@ __u32 pad1; __u64 vm_user_start; __u64 vm_user_end; - __u64 vm_shader_start; - __u64 vm_shader_end; + __u64 vm_usc_start; + __u64 vm_usc_end; + __u64 vm_kernel_min_size; __u32 max_syncs_per_submission; __u32 max_commands_per_submission; @@ -61,6 +63,8 @@ __u32 result_render_size; __u32 result_compute_size; + + __u32 firmware_version[4]; }; struct drm_asahi_get_params @@ -85,7 +89,6 @@ { DRM_IOCTL_ASAHI_GET_PARAMS = DRM_IOWR(DRM_COMMAND_BASE + DRM_ASAHI_GET_PARAMS, struct drm_asahi_get_params), }; - #endif #endif #define FF_STR_INDIR(x) #x @@ -424,9 +427,14 @@ FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, F .size = sizeof(paramsGlobal), }) >= 0) { - gpu->coreCount = (int) paramsGlobal.num_cores_total_active; - gpu->frequency = paramsGlobal.max_frequency_khz / 1000; - gpu->deviceId = paramsGlobal.chip_id; + // FIXME: They will introduce ABI breaking changes. Always check the latest version + // https://www.reddit.com/r/AsahiLinux/comments/1ei2qiv/comment/lgm0v5s/ + if (paramsGlobal.unstable_uabi_version == DRM_ASAHI_UNSTABLE_UABI_VERSION) + { + gpu->coreCount = (int) paramsGlobal.num_cores_total_active; + gpu->frequency = paramsGlobal.max_frequency_khz / 1000; + gpu->deviceId = paramsGlobal.chip_id; + } } } #endif @@ -516,14 +524,14 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus) const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { + #ifdef FF_HAVE_DIRECTX_HEADERS + const char* ffGPUDetectByDirectX(const FFGPUOptions* options, FFlist* gpus); + if (ffGPUDetectByDirectX(options, gpus) == NULL) + return NULL; + #endif + if (options->detectionMethod == FF_GPU_DETECTION_METHOD_AUTO) { - #ifdef FF_HAVE_DIRECTX_HEADERS - const char* ffGPUDetectByDirectX(const FFGPUOptions* options, FFlist* gpus); - if (ffGPUDetectByDirectX(options, gpus) == NULL) - return NULL; - #endif - if (drmDetectGPUs(options, gpus) == NULL && gpus->length > 0) return NULL; } diff --git a/src/detection/gpu/gpu_wsl.cpp b/src/detection/gpu/gpu_wsl.cpp index 152b7dba08..bc41d351dc 100644 --- a/src/detection/gpu/gpu_wsl.cpp +++ b/src/detection/gpu/gpu_wsl.cpp @@ -28,7 +28,7 @@ struct on_scope_exit { extern "C" const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { - FF_LIBRARY_LOAD(libdxcore, nullptr, "dlopen libdxcore.so failed. Make sure WSLg is enabled", "/usr/lib/wsl/lib/libdxcore" FF_LIBRARY_EXTENSION, 4) + FF_LIBRARY_LOAD(libdxcore, nullptr, "dlopen libdxcore.so failed", "/usr/lib/wsl/lib/libdxcore" FF_LIBRARY_EXTENSION, 4) // DXCoreCreateAdapterFactory is a reloaded function, so we can't use FF_LIBRARY_LOAD_SYMBOL_MESSAGE here typedef HRESULT (*DXCoreCreateAdapterFactory_t)(REFIID riid, void** ppvFactory); diff --git a/src/detection/initsystem/initsystem_linux.c b/src/detection/initsystem/initsystem_linux.c index d5fa8452ab..a162545958 100644 --- a/src/detection/initsystem/initsystem_linux.c +++ b/src/detection/initsystem/initsystem_linux.c @@ -1,7 +1,22 @@ #include "initsystem.h" #include "common/processing.h" +#include "util/linux/elf.h" #include +FF_MAYBE_UNUSED static bool elfExtractStringsCallBack(const char* str, uint32_t len, void* data) +{ + if (len > strlen("systemd 0.0 running in ") && memcmp(str, "systemd ", strlen("systemd ")) == 0) + { + const char* pend = memmem(str + strlen("systemd "), len - strlen("systemd "), " running in ", strlen(" running in ")); + if (pend) + { + ffStrbufSetNS((FFstrbuf*) data, (uint32_t) (pend - str) - (uint32_t) strlen("systemd "), str + strlen("systemd ")); + return false; + } + } + return true; +} + const char* ffDetectInitSystem(FFInitSystemResult* result) { const char* error = ffProcessGetBasicInfoLinux((int) result->pid, &result->name, NULL, NULL); @@ -31,24 +46,30 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) if (instance.config.general.detectVersion) { + #if __linux__ && !__ANDROID__ if (ffStrbufEqualS(&result->name, "systemd")) { - if (ffProcessAppendStdOut(&result->version, (char* const[]) { - ffStrbufEndsWithS(&result->exe, "/systemd") ? result->exe.chars : "systemctl", // use exe path in case users have another systemd installed - "--version", - NULL, - }) == NULL && result->version.length) + ffElfExtractStrings(result->exe.chars, elfExtractStringsCallBack, &result->version); + if (result->version.length == 0) { - uint32_t iStart = ffStrbufFirstIndexC(&result->version, '('); - if (iStart < result->version.length) + if (ffProcessAppendStdOut(&result->version, (char* const[]) { + ffStrbufEndsWithS(&result->exe, "/systemd") ? result->exe.chars : "systemctl", // use exe path in case users have another systemd installed + "--version", + NULL, + }) == NULL && result->version.length) { - uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ')'); - ffStrbufSubstrBefore(&result->version, iEnd); - ffStrbufSubstrAfter(&result->version, iStart); + uint32_t iStart = ffStrbufFirstIndexC(&result->version, '('); + if (iStart < result->version.length) + { + uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ')'); + ffStrbufSubstrBefore(&result->version, iEnd); + ffStrbufSubstrAfter(&result->version, iStart); + } } } } - else if (ffStrbufEqualS(&result->name, "launchd")) + #elif __APPLE__ + if (ffStrbufEqualS(&result->name, "launchd")) { if (ffProcessAppendStdOut(&result->version, (char* const[]) { "/bin/launchctl", @@ -66,6 +87,7 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) } } } + #endif } return NULL; diff --git a/src/detection/locale/locale_linux.c b/src/detection/locale/locale_linux.c index 65b4f92890..4b5123059c 100644 --- a/src/detection/locale/locale_linux.c +++ b/src/detection/locale/locale_linux.c @@ -4,6 +4,10 @@ void ffDetectLocale(FFstrbuf* result) { + ffStrbufAppendS(result, getenv("LC_ALL")); + if(result->length > 0) + return; + ffStrbufAppendS(result, getenv("LC_MESSAGES")); if(result->length > 0) return; diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index 83949bcdff..43e3f21157 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -5,7 +5,6 @@ #include #define FF_DBUS_MPRIS_PREFIX "org.mpris.MediaPlayer2." -#define FF_DBUS_TIMEOUT_MILLISECONDS 35 #ifdef FF_HAVE_DBUS #include "common/dbus.h" diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 634160bcfe..271243354f 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -8,6 +8,7 @@ #include "detection/displayserver/displayserver.h" #include "util/mallocHelper.h" #include "util/stringUtils.h" +#include "util/linux/elf.h" static const char* getSystemMonospaceFont(void) { @@ -286,6 +287,13 @@ static void detectXterm(FFTerminalFontResult* terminalFont) ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); } +static bool elfExtractStringsCallBack(const char* str, uint32_t len, void* userData) +{ + if (!ffStrContains(str, "size=")) return true; + ffStrbufSetNS((FFstrbuf*) userData, len, str); + return false; +} + static void detectSt(FFTerminalFontResult* terminalFont, const FFTerminalResult* terminal) { FF_STRBUF_AUTO_DESTROY size = ffStrbufCreateF("/proc/%u/cmdline", terminal->pid); @@ -306,30 +314,18 @@ static void detectSt(FFTerminalFontResult* terminalFont, const FFTerminalResult* else { ffStrbufClear(&font); - if (ffProcessAppendStdOut(&font, (char* const[]) { - "strings", - terminal->exePath.chars, - NULL, - }) != NULL || font.length == 0) + + const char* error = ffElfExtractStrings(terminal->exePath.chars, elfExtractStringsCallBack, &font); + if (error) { - ffStrbufAppendS(&terminalFont->error, "Failed to run `strings st`"); + ffStrbufAppendS(&terminalFont->error, error); return; } - - // Search font config string in st binary - uint32_t middleIndex = ffStrbufFirstIndexS(&font, "size="); - if (middleIndex == font.length) + if (font.length == 0) { ffStrbufAppendS(&terminalFont->error, "No font config found in st binary"); return; } - - uint32_t startIndex = ffStrbufPreviousIndexC(&font, middleIndex, '\n'); - if (startIndex == font.length) startIndex = 0; - uint32_t endIndex = ffStrbufNextIndexC(&font, middleIndex, '\n'); - - ffStrbufSubstrBefore(&font, endIndex); - ffStrbufSubstrAfter(&font, startIndex); } // JetBrainsMono Nerd Font Mono:pixelsize=12:antialias=true:autohint=true diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 9d65bde3aa..4d0adf4147 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -485,6 +485,33 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version) #ifndef _WIN32 static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { + #if defined(__linux__) || defined(__FreeBSD__) + char buffer[1024] = {}; + if ( + #ifdef __linux__ + ffReadFileData(FASTFETCH_TARGET_DIR_USR "/lib64/kitty/kitty/constants.py", sizeof(buffer) - 1, buffer) || + ffReadFileData(FASTFETCH_TARGET_DIR_USR "/lib/kitty/kitty/constants.py", sizeof(buffer) - 1, buffer) + #else + ffReadFileData(_PATH_LOCALBASE "/share/kitty/kitty/constants.py", sizeof(buffer) - 1, buffer) + #endif + ) + { + // Starts from version 0.17.0 + // https://github.com/kovidgoyal/kitty/blob/master/kitty/constants.py#L25 + const char* p = memmem(buffer, sizeof(buffer) - 1, "version: Version = Version(", strlen("version: Version = Version(")); + if (p) + { + p += strlen("version: Version = Version("); + int major, minor, patch; + if (sscanf(p, "%d,%d,%d", &major, &minor, &patch) == 3) + { + ffStrbufSetF(version, "%d.%d.%d", major, minor, patch); + return true; + } + } + } + #endif + char versionHex[64]; // https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233 if (ffGetTerminalResponse( diff --git a/src/detection/version/version.c b/src/detection/version/version.c index b6d6e7d777..5c1fb0ae49 100644 --- a/src/detection/version/version.c +++ b/src/detection/version/version.c @@ -44,6 +44,7 @@ FFVersionResult ffVersionResult = { .architecture = FF_ARCHITECTURE, .version = FASTFETCH_PROJECT_VERSION, .versionTweak = FASTFETCH_PROJECT_VERSION_TWEAK, + .versionGit = FASTFETCH_PROJECT_VERSION_GIT, .cmakeBuiltType = FASTFETCH_PROJECT_CMAKE_BUILD_TYPE, .compileTime = __DATE__ ", " __TIME__, .compiler = diff --git a/src/detection/version/version.h b/src/detection/version/version.h index 7bb9bd56d5..272e87bc3e 100644 --- a/src/detection/version/version.h +++ b/src/detection/version/version.h @@ -9,6 +9,7 @@ typedef struct FFVersionResult const char* architecture; const char* version; const char* versionTweak; + const char* versionGit; const char* cmakeBuiltType; const char* compileTime; const char* compiler; diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 1848c236d9..b2e6e464fb 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -1,5 +1,6 @@ #include "wifi.h" #include "common/dbus.h" +#include "common/io/io.h" #include "common/processing.h" #include "common/properties.h" #include "util/stringUtils.h" @@ -177,8 +178,6 @@ static const char* detectWifiWithIw(FFWifiResult* item, FFstrbuf* buffer) } #if FF_HAVE_LINUX_WIRELESS -#include "common/io/io.h" - #include #include #include diff --git a/src/fastfetch_config.h.in b/src/fastfetch_config.h.in index 2092c91d3a..6d86f3e0b3 100644 --- a/src/fastfetch_config.h.in +++ b/src/fastfetch_config.h.in @@ -8,6 +8,7 @@ #define FASTFETCH_PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ #define FASTFETCH_PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@ #define FASTFETCH_PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define FASTFETCH_PROJECT_VERSION_GIT "@PROJECT_VERSION_GIT@" #define FASTFETCH_PROJECT_VERSION_TWEAK "@PROJECT_VERSION_TWEAK@" #define FASTFETCH_PROJECT_VERSION_TWEAK_NUM @PROJECT_VERSION_TWEAK_NUM@ #define FASTFETCH_PROJECT_CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@" diff --git a/src/logo/ascii/lfs.txt b/src/logo/ascii/lfs.txt new file mode 100644 index 0000000000..6f8b4059e0 --- /dev/null +++ b/src/logo/ascii/lfs.txt @@ -0,0 +1,18 @@ +$2 :@@@@@@@: +$2 @@@@@@@@@- +$2 .:%. @@@@@@@@@+. @% +$2 *@@@%+: :@@@@@@@%=: .=%@@@@@@= +$2 :@@@@@@##@@@@@@@@@%*+%@%+@@@@@@@+ +$2 @@#$1####$2+@@@@@@@%:$1######$2=@@@@@@@@@- +$2 *@%$1######$2.@@@@@#$1#########$2-@@@@@@@@#. +$2 %@-$1#$2.@$1=$2:$1##$2+@@@@-$1###$2%@$1:$2=$1###$2*@#*+=-+#: +$2 @@.$1#$2@@*$1=$2:$1#$2-%%**-$1##$2%@@%$1*$2*$1###$2#=- +$2 @@-$1#$2@@@@+.-$3...$2:=.$1#$2%@@@@%$1###$2#- +$2 %@%$1##$2*#:$3.o.....o...$2-%@+$1###$2#@+ -: +$2 +@@*$1#$3....................$2+@@@@@@@@+ +$2 @%:$3....................._:$2@@@@@@@=. +$2 .=:$3...............__*-=`.$2=@@@@@@#=. +$2 :+:$3....:==*__*-=`:..==-:$2#@@@@@%+: +$2 .--=-: $3+..::.....-: $2=%@*=: +$2 :........- +$2 .:...--. diff --git a/src/logo/ascii/vanilla2.txt b/src/logo/ascii/vanilla2.txt new file mode 100644 index 0000000000..97e051d57b --- /dev/null +++ b/src/logo/ascii/vanilla2.txt @@ -0,0 +1,16 @@ + . + x/A\x + Z#@#?P`. + /@$R/.:.', + _ ($@`.:::.) _ +_-=t'''`-.g$(.::::.!-aZ#$#Kko, +V$#6..::::.~l.::.<&#p***q##$p' +'9#$b,:::::::::.%P~'.:::.`~v' + "<#$&b,.':::'./'.:::::::.>' + `~*q@#&b+=- -=+x.,''_.' + z+'.:::',).:.`~q@6x, + /.:::::',Z!.:::.`*q&x + i'.:::',symbol == FF_COLORS_SYMBOL_BACKGROUND) + ffStrbufAppendS(&result, "\e[5m"); + #endif + // 9%d: Set the foreground to the bright color for(uint8_t i = max(options->block.range[0], 8); i <= options->block.range[1]; i++) { diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 0765c8af1c..3115f966e3 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -421,7 +421,13 @@ void ffInitGPUOptions(FFGPUOptions* options) ffOptionInitModuleArg(&options->moduleArgs, "󰾲"); options->driverSpecific = false; - options->detectionMethod = FF_GPU_DETECTION_METHOD_AUTO; + options->detectionMethod = + #if defined(__x86_64__) || defined(__i386__) + FF_GPU_DETECTION_METHOD_PCI + #else + FF_GPU_DETECTION_METHOD_AUTO + #endif + ; options->temp = false; options->hideType = FF_GPU_TYPE_UNKNOWN; options->tempConfig = (FFColorRangeConfig) { 60, 80 }; diff --git a/src/modules/version/version.c b/src/modules/version/version.c index 7382a97fca..f3df9f3991 100644 --- a/src/modules/version/version.c +++ b/src/modules/version/version.c @@ -89,7 +89,7 @@ void ffGenerateVersionJsonResult(FF_MAYBE_UNUSED FFVersionOptions* options, yyjs yyjson_mut_obj_add_str(doc, obj, "sysName", result->sysName); yyjson_mut_obj_add_str(doc, obj, "architecture", result->architecture); yyjson_mut_obj_add_str(doc, obj, "version", result->version); - yyjson_mut_obj_add_str(doc, obj, "versionTweak", result->versionTweak); + yyjson_mut_obj_add_str(doc, obj, "versionGit", result->versionGit); yyjson_mut_obj_add_str(doc, obj, "cmakeBuiltType", result->cmakeBuiltType); yyjson_mut_obj_add_str(doc, obj, "compileTime", result->compileTime); yyjson_mut_obj_add_str(doc, obj, "compiler", result->compiler); diff --git a/src/options/library.c b/src/options/library.c index c718f6bbc7..6ca05b573d 100644 --- a/src/options/library.c +++ b/src/options/library.c @@ -66,6 +66,8 @@ const char* ffOptionsParseLibraryJsonConfig(FFOptionsLibrary* options, yyjson_va ffStrbufSetS(&options->libDdcutil, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "drm")) ffStrbufSetS(&options->libdrm, yyjson_get_str(val)); + else if (ffStrEqualsIgnCase(key, "elf")) + ffStrbufSetS(&options->libelf, yyjson_get_str(val)); #endif else @@ -131,6 +133,8 @@ bool ffOptionsParseLibraryCommandLine(FFOptionsLibrary* options, const char* key ffOptionParseString(key, value, &options->libDdcutil); else if(ffStrEqualsIgnCase(subkey, "drm")) ffOptionParseString(key, value, &options->libdrm); + else if(ffStrEqualsIgnCase(subkey, "elf")) + ffOptionParseString(key, value, &options->libelf); #endif else diff --git a/src/options/library.h b/src/options/library.h index 14d38a7289..db96af2a57 100644 --- a/src/options/library.h +++ b/src/options/library.h @@ -32,6 +32,7 @@ typedef struct FFOptionsLibrary FFstrbuf libPulse; FFstrbuf libDdcutil; FFstrbuf libdrm; + FFstrbuf libelf; #endif } FFOptionsLibrary; diff --git a/src/util/linux/elf.c b/src/util/linux/elf.c new file mode 100644 index 0000000000..4e65c15dba --- /dev/null +++ b/src/util/linux/elf.c @@ -0,0 +1,84 @@ +#include "elf.h" + +#ifdef FF_HAVE_ELF + +#include "common/io/io.h" +#include "common/library.h" +#include "util/stringUtils.h" + +#include +#include + +const char* ffElfExtractStrings(const char* elfFile, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata) +{ + FF_LIBRARY_LOAD(libelf, &instance.config.library.libelf, "dlopen libelf" FF_LIBRARY_EXTENSION " failed", "libelf" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf_version) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf_begin) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf_getshdrstrndx) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf_nextscn) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf64_getshdr) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf32_getshdr) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf_getdata) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf_strptr) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libelf, elf_end) + + if (ffelf_version(EV_CURRENT) == EV_NONE) return "elf_version() failed"; + + FF_AUTO_CLOSE_FD int fd = open(elfFile, O_RDONLY, 0); + if (fd < 0) return "open() failed"; + + Elf* elf = ffelf_begin(fd, ELF_C_READ, NULL); + if (elf == NULL) return "elf_begin() failed"; + + size_t shstrndx = 0; + if (ffelf_getshdrstrndx(elf, &shstrndx) < 0) + { + ffelf_end(elf); + return "elf_getshdrstrndx() failed"; + } + + Elf_Scn* scn = NULL; + while ((scn = ffelf_nextscn(elf, scn)) != NULL) + { + Elf64_Shdr* shdr64 = ffelf64_getshdr(scn); + Elf32_Shdr* shdr32 = NULL; + if (shdr64 == NULL) + { + shdr32 = ffelf32_getshdr(scn); + if (shdr32 == NULL) continue; + } + + const char* name = ffelf_strptr(elf, shstrndx, shdr64 ? shdr64->sh_name : shdr32->sh_name); + if (name == NULL || !ffStrEquals(name, ".rodata")) continue; + + Elf_Data* data = ffelf_getdata(scn, NULL); + if (data == NULL) continue; + + for (size_t off = 0; off < data->d_size; ++off) + { + const char* p = (const char*) data->d_buf + off; + if (*p == '\0') continue; + uint32_t len = (uint32_t) strlen(p); + if (*p >= ' ' && *p <= '~') // Ignore control characters + { + if (!cb(p, len, userdata)) break; + } + off += len; + } + + break; + } + + ffelf_end(elf); + return NULL; +} + +#else + +const char* ffElfExtractStrings(const char* elfFile, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata) +{ + FF_UNUSED(elfFile, cb, userdata); + return "Fastfetch was built without libelf support"; +} + +#endif diff --git a/src/util/linux/elf.h b/src/util/linux/elf.h new file mode 100644 index 0000000000..4cfdaeb459 --- /dev/null +++ b/src/util/linux/elf.h @@ -0,0 +1,5 @@ +#pragma once + +#include "fastfetch.h" + +const char* ffElfExtractStrings(const char* elfFile, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata);