mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 18:32:10 +02:00
Compare commits
131 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 43bdb68cbf | |||
| 8b43e331e3 | |||
| 302716fa61 | |||
| 188b6aba10 | |||
| 7af9cab688 | |||
| 714b88c638 | |||
| d9f1db10aa | |||
| bb10e1c9a3 | |||
| 264b6794f3 | |||
| a8b734c877 | |||
| 10ca77610e | |||
| c2eaea3665 | |||
| 1619f0ab6c | |||
| aba211221b | |||
| 81485baadb | |||
| 1b4fc38330 | |||
| 3571d9277d | |||
| e9b535d277 | |||
| 09ffd32144 | |||
| 27aa5c0343 | |||
| 1d95f9b224 | |||
| 4f1cb779ab | |||
| 758ddae344 | |||
| 14969b31d0 | |||
| d88e2eeb36 | |||
| 7946e69a66 | |||
| 15766f5266 | |||
| ed02845c40 | |||
| 4ffa0ffcb7 | |||
| c04c040713 | |||
| c763896b49 | |||
| e9a44f71b2 | |||
| 5078c8d910 | |||
| f9e0efb7ee | |||
| 926390508e | |||
| 45446c1c1d | |||
| b79c47cac9 | |||
| fd16e69464 | |||
| 92abf3e063 | |||
| 90a242a4aa | |||
| 1118c57d8f | |||
| eda9496479 | |||
| 0b94ff5adb | |||
| 62bf3ec021 | |||
| ab2268a927 | |||
| 1421627a47 | |||
| 02e5232bda | |||
| 289d03cfb2 | |||
| 965ab1abc4 | |||
| 06b2ff9a08 | |||
| b4a6606faf | |||
| def758580f | |||
| 5ea2b2ecc9 | |||
| b3886c6c47 | |||
| bc76220a5b | |||
| 60fa7946f5 | |||
| b6a703bd56 | |||
| 462c3b0e06 | |||
| 72138dbde5 | |||
| b2ea5d8f3e | |||
| 49080c5361 | |||
| 445dd94b53 | |||
| 7c03fc1550 | |||
| 06a8f12d6a | |||
| 8c7edf4d2d | |||
| 85b4679373 | |||
| 215029ea27 | |||
| 533f54fb73 | |||
| a6212c5b01 | |||
| ba76b18367 | |||
| 4290efb49d | |||
| 30b85fc169 | |||
| dc94ac8d0c | |||
| 1d9e612262 | |||
| be1791e386 | |||
| 3b8c2d6ee6 | |||
| c661e55053 | |||
| 56403bab5c | |||
| caef317ade | |||
| 131e01f35b | |||
| c8e3c6882a | |||
| c985bdbbfd | |||
| b80eb47ecd | |||
| 68942c1d3f | |||
| b36b74448f | |||
| 217bb6657e | |||
| df2862996b | |||
| df6ab6427e | |||
| 82d848727c | |||
| d0d6323b1f | |||
| 6439921f85 | |||
| d28907ee9d | |||
| 41f0971570 | |||
| ab0bd79bb8 | |||
| 07747aa819 | |||
| 68efcdd0dd | |||
| fef3100fd7 | |||
| 08a940bfd4 | |||
| d6a99c631e | |||
| 3d4077c2d0 | |||
| ce6b595421 | |||
| 7d8c085254 | |||
| ec0af17fb5 | |||
| 2accfbc894 | |||
| 01d2fa1228 | |||
| f16843d60f | |||
| acc77ebddd | |||
| 7eb145fb7f | |||
| 34a6eb13c6 | |||
| 0f5e746fe2 | |||
| b62ad16aa6 | |||
| f79498e4b5 | |||
| 31c433b353 | |||
| 852c6abf2e | |||
| df3fa6f8a8 | |||
| 738daa1c77 | |||
| 4204cfc500 | |||
| 9cb08d115a | |||
| 459f159b1b | |||
| 2880536513 | |||
| 64cb1bfdfd | |||
| b80c30ace3 | |||
| 19b8849bfc | |||
| 8f457f047c | |||
| 299bc7468f | |||
| c213b0769b | |||
| 260c883d07 | |||
| da0db042fa | |||
| ae5732e2a8 | |||
| 1f05a33807 | |||
| f090951abc |
@@ -7,6 +7,8 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Be sure to read [FAQ](https://github.com/fastfetch-cli/fastfetch?tab=readme-ov-file#faq) before submitting a new issue.
|
||||
|
||||
<!-- We will try hard to solve the issue. However since platforms and hardwares vary greatly, it can be hard to find the root cause is. Providing following information may help us greatly. Thanks in advance -->
|
||||
|
||||
# General description of bug:
|
||||
@@ -74,10 +76,5 @@ Use `time fastfetch --stat` to show time usage for each module.
|
||||
|
||||
## If fastfetch behaves incorrectly on shell starting
|
||||
|
||||
<!-- NOTE for zsh / p10k users:
|
||||
There are known incompatibility between fastfetch and p10k instant prompt.
|
||||
The p10k doc clearly states that you should NOT print anything to stdout after p10k-instant-prompt is initialized.
|
||||
You should either put `fastfetch` before initialization of p10k-instant-prompt (recommended), remove it or use `fastfetch --pipe false` -->
|
||||
|
||||
* The bug is reproduceable with fresh / clean shell configuration (i.e. `fastfetch` is the single line of `.zshrc` or `~/.config/fish/config.fish`):
|
||||
* Does `sleep 1` before running `fastfetch` work?
|
||||
|
||||
@@ -484,7 +484,7 @@ jobs:
|
||||
with:
|
||||
msystem: CLANG32
|
||||
update: true
|
||||
install: git mingw-w64-clang-i686-7zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-vulkan-headers mingw-w64-clang-i686-opencl-icd
|
||||
install: git p7zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-vulkan-headers mingw-w64-clang-i686-opencl-icd
|
||||
|
||||
- name: print msys version
|
||||
run: uname -a
|
||||
|
||||
+80
-8
@@ -1,27 +1,99 @@
|
||||
# 2.13.0
|
||||
|
||||
Changes:
|
||||
* Option `--gpu-force-vulkan <?bool>` has been changed to `--gpu-detection-method <enum>`
|
||||
* Use `--gpu-detection-method vulkan` to get the old behavior
|
||||
* See `fastfetch -h gpu-detection-method` for detail
|
||||
* In Linux, BIOS limited CPU frequency is printed by default to match the behavior of neofetch (CPU, Linux, #947)
|
||||
|
||||
Features:
|
||||
* Add new module `Bootmgr` which prints information of stage 2 bootloader (grub, system-boot, etc)
|
||||
* Requires root permission to work on Windows and FreeBSD
|
||||
* Requires booting in UEFI mode
|
||||
* Add package manager lpkg and lpkg-build support (Packages, Linux)
|
||||
* Improve macOS 10.13 compatibility (macOS)
|
||||
* Detect core count for performance / efficiency cores (CPU)
|
||||
* Test it with `fastfetch -s cpu --cpu-format '{9}'`
|
||||
* Support min / max frequency and physical core count detection in FreeBSD, if kernel supports it (CPU, FreeBSD)
|
||||
* Detect DRM driver version if DRM detection method is used (GPU, Linux)
|
||||
|
||||
Bugfixes:
|
||||
* Don't detect `clifm` and `valgrind` as a terminal (Terminal, Linux)
|
||||
* Improve stability (PhysicalMemory, FreeBSD)
|
||||
* Fix bssid & status detection (Wifi, FreeBSD)
|
||||
* Ensure createTime is correctly initialized (Disk, FreeBSD / macOS)
|
||||
* Fix `--cpu-freq-ndigits` not working if `--cpu-format` is used
|
||||
* Fix `nix-user` package count detection (Packages, Linux)
|
||||
* Fix some memory leaks
|
||||
|
||||
Logos:
|
||||
* Fix Manjaro logo not displayed
|
||||
* Add SpoinkOS
|
||||
* Add Loc-OS
|
||||
* Add Furreto Linux
|
||||
* Fix TorizonCore logo colors
|
||||
* Fix KDE neon logo not displayed
|
||||
|
||||
# 2.12.0
|
||||
|
||||
Changes:
|
||||
* The long deprecated flag based config files are removed.
|
||||
* They can still be used with `xargs fastfetch < /path/to/config.conf`
|
||||
* `--gen-config` can be used to migrate them to json based config files
|
||||
* The long deprecated options `--set` and `--set-keyless` are removed.
|
||||
* `Kernel` module now prints kernel name by default
|
||||
|
||||
Features:
|
||||
* Support `st` terminal font detection for font configuration compiled in `st` binary (TerminalFont, Linux)
|
||||
* Add option `--color-output` to change output color of all modules except `Title`, `Separator`
|
||||
* `display.color.output` in JSONC config file
|
||||
* Add option `--<module>-output-color` to change output color of one specified module, which overrides the global option `--color-output`
|
||||
* Add option `--publicip-ipv6` to print IPv6 address (PublicIP)
|
||||
* Add new module `Loadavg` to print load averages (Loadavg)
|
||||
* Add new module `PhysicalMemory` to print information of physical memory devices (PhysicalMemory)
|
||||
* Requires root permission to work on Linux and FreeBSD
|
||||
* Support specifying `--logo-width` only for `--kitty-direct` and `--iterm` (Logo)
|
||||
* Add option `--localip-show-all-ips` to show all IPs assigned to the same interface (LocalIP)
|
||||
* Default to `false`
|
||||
* Improve compatibility with `(*term)` (#909, Terminal, macOS)
|
||||
* Support GPU core count and frequency detection for Asahi Linux (GPU, Linux)
|
||||
|
||||
Bugfixes:
|
||||
* Rename option `--temperature-unit` to `--temp-unit` as documented in help messages
|
||||
* Fix alternate logo doesn't work with `{ "type": "builtin" }` (#914, Logo)
|
||||
|
||||
Logos:
|
||||
* Fix DahliaOS detection
|
||||
* Add openSUSE Slowroll
|
||||
* Add macOS3
|
||||
* Add Quirinux
|
||||
|
||||
# 2.11.5
|
||||
|
||||
Bugfix:
|
||||
* Fix logo printing for OpenMandriva (#896)
|
||||
* Remove `--os-file` in help messages
|
||||
|
||||
# 2.11.4
|
||||
|
||||
Changes:
|
||||
|
||||
* Fastfetch will print a colorless ascii logo in `--pipe` mode for better `lolcat` compatibility. `fastfetch | lolcat` should work and no `--pipe false` needed.
|
||||
* Previously the logo would be disabled in `--pipe` mode.
|
||||
* `--os-file` was removed and CMake option `-DCUSTOM_OS_RELEASE_PATH=/path/to/os-release` was added. This option should not used in most cases.
|
||||
* Use `--pipe -l none` to get the old beheavior
|
||||
* `--os-file` was removed and CMake option `-DCUSTOM_OS_RELEASE_PATH=/path/to/os-release` was introduced for configuring at compile time by package managers if needed. This option should not used in most cases.
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Fix possible out-of-bound memory access (#868)
|
||||
* Fix Apple Terminal detection (macOS, Terminal)
|
||||
* Fix doubled output in custom formation (#852)
|
||||
* Fix Apple Terminal detection (#878, macOS, Terminal)
|
||||
* Fix deprecation warning for macOS 14.0 hopefully (#860, macOS, Camera)
|
||||
* Fix memory leaks when passing informative options
|
||||
* Fix memory leaks when passing informative options (#888)
|
||||
* Fix JSON config `size.ndigits` doesn't work
|
||||
|
||||
Features:
|
||||
|
||||
* Enable `--pipe` mode if environment variable `$NO_COLOR` is set
|
||||
* Support Armbian and Proxmox distro detection (OS, Linux)
|
||||
|
||||
Logo:
|
||||
|
||||
* Add Armbian
|
||||
|
||||
# 2.11.3
|
||||
|
||||
+24
-4
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
|
||||
|
||||
project(fastfetch
|
||||
VERSION 2.11.4
|
||||
VERSION 2.13.0
|
||||
LANGUAGES C
|
||||
DESCRIPTION "Fast neofetch-like system information tool"
|
||||
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
|
||||
@@ -115,7 +115,7 @@ endif()
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--tsaware -Wl,--build-id -Wl,--subsystem,console:6.1,--major-os-version,6,--minor-os-version,1")
|
||||
elseif(APPLE)
|
||||
elseif(APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-arc")
|
||||
endif()
|
||||
|
||||
@@ -284,6 +284,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/common/properties.c
|
||||
src/common/settings.c
|
||||
src/common/temps.c
|
||||
src/detection/bootmgr/bootmgr.c
|
||||
src/detection/chassis/chassis.c
|
||||
src/detection/cpu/cpu.c
|
||||
src/detection/cpuusage/cpuusage.c
|
||||
@@ -297,6 +298,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/detection/opencl/opencl.c
|
||||
src/detection/os/os.c
|
||||
src/detection/packages/packages.c
|
||||
src/detection/physicalmemory/physicalmemory.c
|
||||
src/detection/publicip/publicip.c
|
||||
src/detection/terminaltheme/terminaltheme.c
|
||||
src/detection/terminalfont/terminalfont.c
|
||||
@@ -313,6 +315,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/modules/bios/bios.c
|
||||
src/modules/bluetooth/bluetooth.c
|
||||
src/modules/board/board.c
|
||||
src/modules/bootmgr/bootmgr.c
|
||||
src/modules/brightness/brightness.c
|
||||
src/modules/break/break.c
|
||||
src/modules/camera/camera.c
|
||||
@@ -334,6 +337,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/modules/gamepad/gamepad.c
|
||||
src/modules/kernel/kernel.c
|
||||
src/modules/lm/lm.c
|
||||
src/modules/loadavg/loadavg.c
|
||||
src/modules/locale/locale.c
|
||||
src/modules/localip/localip.c
|
||||
src/modules/memory/memory.c
|
||||
@@ -344,6 +348,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/modules/os/os.c
|
||||
src/modules/packages/packages.c
|
||||
src/modules/physicaldisk/physicaldisk.c
|
||||
src/modules/physicalmemory/physicalmemory.c
|
||||
src/modules/processes/processes.c
|
||||
src/modules/player/player.c
|
||||
src/modules/poweradapter/poweradapter.c
|
||||
@@ -391,6 +396,7 @@ if(LINUX)
|
||||
src/detection/battery/battery_linux.c
|
||||
src/detection/bios/bios_linux.c
|
||||
src/detection/board/board_linux.c
|
||||
src/detection/bootmgr/bootmgr_linux.c
|
||||
src/detection/brightness/brightness_linux.c
|
||||
src/detection/chassis/chassis_linux.c
|
||||
src/detection/cpu/cpu_linux.c
|
||||
@@ -399,6 +405,7 @@ if(LINUX)
|
||||
src/detection/bluetooth/bluetooth_linux.c
|
||||
src/detection/disk/disk_linux.c
|
||||
src/detection/physicaldisk/physicaldisk_linux.c
|
||||
src/detection/physicalmemory/physicalmemory_linux.c
|
||||
src/detection/diskio/diskio_linux.c
|
||||
src/detection/displayserver/linux/displayserver_linux.c
|
||||
src/detection/displayserver/linux/drm.c
|
||||
@@ -417,6 +424,7 @@ if(LINUX)
|
||||
src/detection/icons/icons_linux.c
|
||||
src/detection/libc/libc_linux.c
|
||||
src/detection/lm/lm_linux.c
|
||||
src/detection/loadavg/loadavg_linux.c
|
||||
src/detection/locale/locale_linux.c
|
||||
src/detection/localip/localip_linux.c
|
||||
src/detection/gamepad/gamepad_linux.c
|
||||
@@ -457,6 +465,7 @@ elseif(ANDROID)
|
||||
src/detection/bios/bios_android.c
|
||||
src/detection/bluetooth/bluetooth_nosupport.c
|
||||
src/detection/board/board_android.c
|
||||
src/detection/bootmgr/bootmgr_nosupport.c
|
||||
src/detection/brightness/brightness_nosupport.c
|
||||
src/detection/chassis/chassis_nosupport.c
|
||||
src/detection/cpu/cpu_linux.c
|
||||
@@ -464,6 +473,7 @@ elseif(ANDROID)
|
||||
src/detection/cpuusage/cpuusage_linux.c
|
||||
src/detection/disk/disk_linux.c
|
||||
src/detection/physicaldisk/physicaldisk_linux.c
|
||||
src/detection/physicalmemory/physicalmemory_nosupport.c
|
||||
src/detection/diskio/diskio_linux.c
|
||||
src/detection/displayserver/displayserver_android.c
|
||||
src/detection/font/font_nosupport.c
|
||||
@@ -472,6 +482,7 @@ elseif(ANDROID)
|
||||
src/detection/icons/icons_nosupport.c
|
||||
src/detection/libc/libc_android.c
|
||||
src/detection/lm/lm_nosupport.c
|
||||
src/detection/loadavg/loadavg_linux.c
|
||||
src/detection/locale/locale_linux.c
|
||||
src/detection/localip/localip_linux.c
|
||||
src/detection/gamepad/gamepad_nosupport.c
|
||||
@@ -513,6 +524,7 @@ elseif(BSD)
|
||||
src/detection/bios/bios_bsd.c
|
||||
src/detection/bluetooth/bluetooth_linux.c
|
||||
src/detection/board/board_bsd.c
|
||||
src/detection/bootmgr/bootmgr_bsd.c
|
||||
src/detection/brightness/brightness_bsd.c
|
||||
src/detection/chassis/chassis_bsd.c
|
||||
src/detection/cpu/cpu_bsd.c
|
||||
@@ -520,6 +532,7 @@ elseif(BSD)
|
||||
src/detection/cursor/cursor_linux.c
|
||||
src/detection/disk/disk_bsd.c
|
||||
src/detection/physicaldisk/physicaldisk_bsd.c
|
||||
src/detection/physicalmemory/physicalmemory_linux.c
|
||||
src/detection/diskio/diskio_bsd.c
|
||||
src/detection/displayserver/linux/displayserver_linux.c
|
||||
src/detection/displayserver/linux/drm.c
|
||||
@@ -538,6 +551,7 @@ elseif(BSD)
|
||||
src/detection/lm/lm_linux.c
|
||||
src/detection/icons/icons_linux.c
|
||||
src/detection/libc/libc_bsd.c
|
||||
src/detection/loadavg/loadavg_bsd.c
|
||||
src/detection/locale/locale_linux.c
|
||||
src/detection/localip/localip_linux.c
|
||||
src/detection/gamepad/gamepad_bsd.c
|
||||
@@ -579,6 +593,7 @@ elseif(APPLE)
|
||||
src/detection/bios/bios_apple.c
|
||||
src/detection/bluetooth/bluetooth_apple.m
|
||||
src/detection/board/board_apple.c
|
||||
src/detection/bootmgr/bootmgr_apple.c
|
||||
src/detection/brightness/brightness_apple.c
|
||||
src/detection/chassis/chassis_nosupport.c
|
||||
src/detection/cpu/cpu_apple.c
|
||||
@@ -586,14 +601,16 @@ elseif(APPLE)
|
||||
src/detection/cursor/cursor_apple.m
|
||||
src/detection/disk/disk_bsd.c
|
||||
src/detection/physicaldisk/physicaldisk_apple.c
|
||||
src/detection/physicalmemory/physicalmemory_apple.m
|
||||
src/detection/diskio/diskio_apple.c
|
||||
src/detection/displayserver/displayserver_apple.c
|
||||
src/detection/font/font_apple.m
|
||||
src/detection/gpu/gpu_apple.c
|
||||
src/detection/gpu/gpu_apple.m
|
||||
src/detection/host/host_apple.c
|
||||
src/detection/lm/lm_nosupport.c
|
||||
src/detection/icons/icons_nosupport.c
|
||||
src/detection/lm/lm_nosupport.c
|
||||
src/detection/loadavg/loadavg_bsd.c
|
||||
src/detection/libc/libc_apple.c
|
||||
src/detection/locale/locale_linux.c
|
||||
src/detection/localip/localip_linux.c
|
||||
@@ -636,6 +653,7 @@ elseif(WIN32)
|
||||
src/detection/bios/bios_windows.c
|
||||
src/detection/bluetooth/bluetooth_windows.c
|
||||
src/detection/board/board_windows.c
|
||||
src/detection/bootmgr/bootmgr_windows.c
|
||||
src/detection/brightness/brightness_windows.cpp
|
||||
src/detection/chassis/chassis_windows.c
|
||||
src/detection/cpu/cpu_windows.c
|
||||
@@ -651,11 +669,13 @@ elseif(WIN32)
|
||||
src/detection/icons/icons_windows.c
|
||||
src/detection/libc/libc_windows.cpp
|
||||
src/detection/lm/lm_nosupport.c
|
||||
src/detection/loadavg/loadavg_nosupport.c
|
||||
src/detection/locale/locale_windows.c
|
||||
src/detection/localip/localip_windows.c
|
||||
src/detection/gamepad/gamepad_windows.c
|
||||
src/detection/media/media_nosupport.c
|
||||
src/detection/memory/memory_windows.c
|
||||
src/detection/physicalmemory/physicalmemory_linux.c
|
||||
src/detection/monitor/monitor_windows.c
|
||||
src/detection/netio/netio_windows.c
|
||||
src/detection/opengl/opengl_windows.c
|
||||
@@ -767,7 +787,7 @@ if(BSD AND EXISTS "/usr/local/bin/objdump")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__=1)
|
||||
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__=1 _FILE_OFFSET_BITS=64)
|
||||
if(WIN32)
|
||||
target_compile_definitions(libfastfetch PUBLIC WIN32_LEAN_AND_MEAN=1)
|
||||
elseif(APPLE)
|
||||
|
||||
@@ -101,11 +101,90 @@ Logos can be heavily customized too; see the [logo documentation](https://github
|
||||
|
||||
## FAQ
|
||||
|
||||
Q: Why do you need a very performant version of neofetch?
|
||||
> I like putting neofetch in my ~/.bashrc to have a system overview whenever I use the terminal, but the slow speed annoyed me, so I created this. Also neofetch didn't output everything correctly (e.g Font is displayed as "[Plasma], Noto Sans, 10 [GTK2/3]") and writing my own tool gave me the possibility to fine tune it to run perfectly on at least my configuration.
|
||||
### Q: Neofetch is good enough. Why do I need fastfetch?
|
||||
|
||||
Q: It does not display [*] correctly for me, what can I do?
|
||||
> This is most likely because your system is not implemented (yet). At the moment I am focusing more on making the core app better, than adding more configurations. Feel free to open a pull request if you want to add support for your configuration
|
||||
1. Fastfetch is actively maintained.
|
||||
2. Fastfetch is faster. As the name suggests.
|
||||
3. Fastfetch is more feature-rich. By default fastfetch only has a few modules enabled. Use `fastfetch -c all` to find what you want.
|
||||
4. Fastfetch is more configurable. You can find more information in the Wiki: <https://github.com/fastfetch-cli/fastfetch/wiki/Configuration>
|
||||
5. Fastfetch is more polished. For example, neofetch prints `555MiB` in `Memory` module and `23G` in `Disk` module (notibily the difference of `MiB` and `G`), while fastfetch prints `555.00 MiB` and `22.97 GiB` respectively.
|
||||
6. Fastfetch is more accurate. For example, [neofetch never actually supports Wayland protocol](https://github.com/dylanaraps/neofetch/pull/2395).
|
||||
|
||||
### Q: Fastfetch shows my local IP address. It leaks my privacy!
|
||||
|
||||
A local IP (10.x.x.x, 172.x.x.x, 192.168.x.x) has nothing to do with privacy. It only makes sense if you are on the same network, for example, if you connect to the same Wi-Fi network.
|
||||
|
||||
Actually the `Local IP` module is the most useful module for me personally. I (@CarterLi) have several VMs installed to test fastfetch and often need to SSH into them. I have fastfetch running on shell startup and I never need to type `ip addr` manually.
|
||||
|
||||
If you really don't like it, you can disable the `Local IP` module in `config.jsonc`.
|
||||
|
||||
### Q: Where is the config file? I can't find it.
|
||||
|
||||
`Fastfetch` don't generate config file automatically. You can use `fastfetch --gen-config` to generate one. The config file will be saved in `~/.config/fastfetch/config.jsonc` by default. See [Wiki for detail](https://github.com/fastfetch-cli/fastfetch/wiki/Configuration).
|
||||
|
||||
### Q: The configuration is so complex. Where is the documentation?
|
||||
|
||||
Fastfetch uses JSON (with comments) for configuration. I suggest you use an IDE with JSON schema support (like VSCode) to edit it.
|
||||
|
||||
Alternatively, you can refer to the presets in [`presets` directory](https://github.com/fastfetch-cli/fastfetch/tree/dev/presets).
|
||||
|
||||
### Q: I WANT THE DOCUMENTATION!
|
||||
|
||||
[Here is the documentation](https://github.com/fastfetch-cli/fastfetch/wiki/Json-Schema). It is generated from [JSON schema](https://github.com/fastfetch-cli/fastfetch/blob/dev/doc/json_schema.json) but you won't like it.
|
||||
|
||||
### Q: How can I customize the module output?
|
||||
|
||||
Fastfetch uses `format` to generate output. For example to make `GPU` module show GPU name only and ignore other information, you can use
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"modules": [
|
||||
{
|
||||
"type": "gpu",
|
||||
"format": "{2}" // See `fastfetch -h gpu-format` for detail
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
which is equivalent to `fastfetch -s gpu --gpu-format '{2}'`
|
||||
|
||||
See `fastfetch -h format` for basic usage. For module specific formattion, see `fastfetch -h <module>-format`
|
||||
|
||||
### Q: I have my own ascii-art / image file. How can I show it with fastfetch?
|
||||
|
||||
Try `fastfetch -l /path/to/logo`. See [logo documentation](https://github.com/fastfetch-cli/fastfetch/wiki/Logo-options) for detail.
|
||||
|
||||
### Q: Fastfetch runs in white and black on shell startup. Why?
|
||||
|
||||
This issue usually happens when using fastfetch with `p10k`. There are known incompatibility between fastfetch and p10k instant prompt.
|
||||
The p10k doc clearly states that you should NOT print anything to stdout after `p10k-instant-prompt` is initialized. You should either put `fastfetch` before initialization of `p10k-instant-prompt` (recommended)
|
||||
|
||||
You can always use `fastfetch --pipe false` to force fastfetch running in colorful mode.
|
||||
|
||||
### Q: I want feature A / B / C. Will fastfetch support it?
|
||||
|
||||
Fastfetch is a system information tool. We only accept hardware or system level software feature requests. For most personal uses, I recommend using `Command` module to detect it yourself, which can be used to grab output from a custom shell script:
|
||||
|
||||
```jsonc
|
||||
// This module shows the default editor
|
||||
{
|
||||
"modules": [
|
||||
{
|
||||
"type": "command",
|
||||
"text": "$EDITOR --version | head -1",
|
||||
"key": "Editor"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Otherwise, open a feature request in [GitHub Issues](https://github.com/fastfetch-cli/fastfetch/issues).
|
||||
|
||||
### Q: I have questions. Where can I get help?
|
||||
|
||||
* For usage questions, please start a discussion in [GitHub Discussions](https://github.com/fastfetch-cli/fastfetch/discussions).
|
||||
* For possible bugs, please open an issue in [GitHub Issues](https://github.com/fastfetch-cli/fastfetch/issues). Be sure to fill the bug-report template carefully for developers to investigate.
|
||||
|
||||
## Star History
|
||||
|
||||
|
||||
+1
-5
@@ -191,14 +191,13 @@ __fastfetch_completion()
|
||||
"--escape-bedrock"
|
||||
"--pipe"
|
||||
"--title-fqdn"
|
||||
"--escape-bedrock"
|
||||
"--disk-folders"
|
||||
"--disk-show-external"
|
||||
"--disk-show-hidden"
|
||||
"--disk-show-subvolumes"
|
||||
"--gpu-hide-integrated"
|
||||
"--gpu-hide-discrete"
|
||||
"--gpu-force-vulkan"
|
||||
"--gpu-force-method"
|
||||
"--disk-show-unknown"
|
||||
"--bluetooth-show-disconnected"
|
||||
)
|
||||
@@ -227,8 +226,6 @@ __fastfetch_completion()
|
||||
"--separator"
|
||||
"-s"
|
||||
"--structure"
|
||||
"--set"
|
||||
"--set-keyless"
|
||||
"--player-name"
|
||||
"--percent-type"
|
||||
"--publicip-url"
|
||||
@@ -360,7 +357,6 @@ __fastfetch_completion()
|
||||
local FF_OPTIONS_PATH=(
|
||||
"-c"
|
||||
"--config"
|
||||
"--os-file"
|
||||
"--lib-pci"
|
||||
"--lib-vulkan"
|
||||
"--lib-wayland"
|
||||
|
||||
+1
-2
@@ -85,8 +85,7 @@ string match -r -a -g "^###> ?(.*)" < (status -f) | string collect | python3 | s
|
||||
###> elif type == 'config':
|
||||
###> print(f'{command_prefix} -x -a "(__fastfetch_complete_config)"')
|
||||
###> elif type == 'enum':
|
||||
###> temp: str = ' '.join(map(lambda x: f"{x[0]}\\t{x[1]}", flag["arg"]["enum"].items()))
|
||||
###> print(f'{command_prefix} -x -a "{temp}"')
|
||||
###> print(f'{command_prefix} -x -a "{' '.join(flag["arg"]["enum"])}"')
|
||||
###> elif type == 'logo':
|
||||
###> print(f'{command_prefix} -x -a "(__fastfetch_complete_logo)"')
|
||||
###> elif type == 'structure':
|
||||
|
||||
+169
-9
@@ -4,9 +4,8 @@
|
||||
"colors": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"reset_", "bright_", "dim_",
|
||||
"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "default",
|
||||
"bright_black", "bright_red", "bright_green", "bright_yellow", "bright_blue", "bright_magenta", "bright_cyan", "bright_white"
|
||||
"reset_", "bright_", "dim_", "italic_", "underline_", "blink_", "inverse_", "hidden_", "strike_", "light_",
|
||||
"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "default"
|
||||
]
|
||||
},
|
||||
"key": {
|
||||
@@ -24,9 +23,13 @@
|
||||
"default": 0
|
||||
},
|
||||
"format": {
|
||||
"description": "Output format of the module",
|
||||
"description": "Output format of the module. See `-h <module>-format` for detail",
|
||||
"type": "string"
|
||||
},
|
||||
"outputColor": {
|
||||
"description": "Output color of the module. Left empty to use `display.color.output`",
|
||||
"$ref": "#/$defs/colors"
|
||||
},
|
||||
"percent": {
|
||||
"description": "Threshold of percentage colors",
|
||||
"type": "object",
|
||||
@@ -380,6 +383,10 @@
|
||||
"title": {
|
||||
"description": "Set the color of the title",
|
||||
"$ref": "#/$defs/colors"
|
||||
},
|
||||
"output": {
|
||||
"description": "Set the color of the module output",
|
||||
"$ref": "#/$defs/colors"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -673,6 +680,7 @@
|
||||
"bios",
|
||||
"bluetooth",
|
||||
"board",
|
||||
"bootmgr",
|
||||
"break",
|
||||
"brightness",
|
||||
"camera",
|
||||
@@ -694,6 +702,7 @@
|
||||
"icons",
|
||||
"kernel",
|
||||
"lm",
|
||||
"loadavg",
|
||||
"locale",
|
||||
"localip",
|
||||
"media",
|
||||
@@ -705,6 +714,7 @@
|
||||
"os",
|
||||
"packages",
|
||||
"physicaldisk",
|
||||
"physicalmemory",
|
||||
"player",
|
||||
"poweradapter",
|
||||
"processes",
|
||||
@@ -763,12 +773,16 @@
|
||||
"anyOf": [
|
||||
{
|
||||
"const": "bios",
|
||||
"description": "Print BIOS name, version, release date, etc"
|
||||
"description": "Print information of 1st-stage bootloader (name, version, release date, etc)"
|
||||
},
|
||||
{
|
||||
"const": "board",
|
||||
"description": "Print mather board name and other info"
|
||||
},
|
||||
{
|
||||
"const": "bootmgr",
|
||||
"description": "Print information of 2nd-stage bootloader (name, firmware, etc)"
|
||||
},
|
||||
{
|
||||
"const": "camera",
|
||||
"description": "Print available cameras"
|
||||
@@ -821,6 +835,10 @@
|
||||
"const": "os",
|
||||
"description": "Print operating system name and version"
|
||||
},
|
||||
{
|
||||
"const": "physicalmemory",
|
||||
"description": "Print system physical memory devices"
|
||||
},
|
||||
{
|
||||
"const": "player",
|
||||
"description": "Print music player name"
|
||||
@@ -893,6 +911,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -927,6 +948,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -958,6 +982,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -984,6 +1011,21 @@
|
||||
"minimum": 0,
|
||||
"maximum": 400,
|
||||
"default": 10
|
||||
},
|
||||
"key": {
|
||||
"$ref": "#/$defs/key"
|
||||
},
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1002,6 +1044,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1035,6 +1080,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1142,6 +1190,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1166,6 +1217,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1215,6 +1269,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1275,6 +1332,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1307,6 +1367,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1335,6 +1398,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1361,6 +1427,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1386,10 +1455,16 @@
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"forceVulkan": {
|
||||
"description": "Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
"detectionMethod": {
|
||||
"description": "Force using a specified method to detect GPUs",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"auto",
|
||||
"pci",
|
||||
"vulkan",
|
||||
"opengl"
|
||||
],
|
||||
"default": "auto"
|
||||
},
|
||||
"hideType": {
|
||||
"description": "Specify the type of GPUs should not be printed",
|
||||
@@ -1406,6 +1481,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1448,6 +1526,11 @@
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"showAllIps": {
|
||||
"description": "Show all IPs bound to the same interface.\nBy default only the first IP is shown",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"compact": {
|
||||
"description": "Show all IPs in one line",
|
||||
"type": "boolean",
|
||||
@@ -1468,6 +1551,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1494,6 +1580,42 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "Loadavg",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "loadavg",
|
||||
"description": "Print system load averages"
|
||||
},
|
||||
"ndigits": {
|
||||
"type": "integer",
|
||||
"description": "Set the number of digits to keep after the decimal point",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"default": 2
|
||||
},
|
||||
"key": {
|
||||
"$ref": "#/$defs/key"
|
||||
},
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1531,6 +1653,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1564,6 +1689,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1618,6 +1746,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1648,6 +1779,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1677,12 +1811,20 @@
|
||||
"minimum": 0,
|
||||
"default": "disabled (0)"
|
||||
},
|
||||
"ipv6": {
|
||||
"description": "Whether to use IPv6 for public IP detection server",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"key": {
|
||||
"$ref": "#/$defs/key"
|
||||
},
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1704,6 +1846,9 @@
|
||||
"description": "Set the string to be printed",
|
||||
"type": "string",
|
||||
"default": "-"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1735,6 +1880,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1761,6 +1909,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1808,6 +1959,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1846,6 +2000,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
@@ -1874,6 +2031,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"chassis",
|
||||
"kernel",
|
||||
"uptime",
|
||||
"loadavg",
|
||||
"processes",
|
||||
"packages",
|
||||
"shell",
|
||||
@@ -33,6 +34,7 @@
|
||||
"cpuusage",
|
||||
"gpu",
|
||||
"memory",
|
||||
"physicalmemory",
|
||||
"swap",
|
||||
"disk",
|
||||
"battery",
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"modules": [
|
||||
{
|
||||
"type": "title",
|
||||
"key": "User",
|
||||
"format": "{1}"
|
||||
},
|
||||
{
|
||||
"type": "title",
|
||||
"key": "Hostname",
|
||||
"format": "{2}"
|
||||
},
|
||||
{
|
||||
"type": "host",
|
||||
"key": "Model"
|
||||
},
|
||||
{
|
||||
"type": "os",
|
||||
"format": "{3} {9} {12}"
|
||||
},
|
||||
"kernel",
|
||||
"uptime",
|
||||
{
|
||||
"type": "loadavg",
|
||||
"key": "Load Average"
|
||||
},
|
||||
"processes",
|
||||
{
|
||||
"type": "wm",
|
||||
"key": "Window Manager"
|
||||
},
|
||||
{
|
||||
"type": "de",
|
||||
"key": "Desktop Environment"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"format": "{7}"
|
||||
},
|
||||
{
|
||||
"type": "terminal",
|
||||
"format": "{5} {6} \u001b[37m█\u001b[97m█ \u001b[36m█\u001b[96m█ \u001b[35m█\u001b[95m█ \u001b[34m█\u001b[94m█ \u001b[33m█\u001b[93m█ \u001b[32m█\u001b[92m█ \u001b[31m█\u001b[91m█ \u001b[30m█\u001b[90m█"
|
||||
},
|
||||
{
|
||||
"type": "packages",
|
||||
"format": "{1}"
|
||||
},
|
||||
{
|
||||
"type": "cpu",
|
||||
"key": "Temperature",
|
||||
"temp": true,
|
||||
"format": "{8}"
|
||||
},
|
||||
{
|
||||
"type": "cpu",
|
||||
"key": "CPU",
|
||||
"format": "{4} x {1}"
|
||||
},
|
||||
{
|
||||
"type": "gpu",
|
||||
"format": "{2}"
|
||||
},
|
||||
{
|
||||
"type": "memory",
|
||||
"key": "RAM"
|
||||
},
|
||||
{
|
||||
"type": "disk",
|
||||
"key": "Disk",
|
||||
"folders": "/"
|
||||
},
|
||||
{
|
||||
"type": "localip",
|
||||
"key": "LAN IP",
|
||||
"showIpv6": true,
|
||||
"showPrefixLen": false
|
||||
},
|
||||
{
|
||||
"type": "publicip",
|
||||
"key": "WAN IP"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"showErrors": true,
|
||||
"noBuffer": true
|
||||
},
|
||||
"logo": null,
|
||||
"modules": [
|
||||
"title",
|
||||
"separator",
|
||||
@@ -16,6 +17,7 @@
|
||||
"chassis",
|
||||
"kernel",
|
||||
"uptime",
|
||||
"loadavg",
|
||||
"processes",
|
||||
"packages",
|
||||
"shell",
|
||||
@@ -39,6 +41,7 @@
|
||||
"cpuusage",
|
||||
"gpu",
|
||||
"memory",
|
||||
"physicalmemory",
|
||||
"swap",
|
||||
"disk",
|
||||
"battery",
|
||||
|
||||
+25
-13
@@ -1,25 +1,37 @@
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"logo": {
|
||||
"type": "builtin",
|
||||
"source": "arch"
|
||||
},
|
||||
"modules": [
|
||||
"host",
|
||||
"display",
|
||||
{
|
||||
"type": "host",
|
||||
"format": "{?2}{2}{?}{?5} ({5}){?}"
|
||||
},
|
||||
"chassis",
|
||||
{
|
||||
"type": "board",
|
||||
"format": "{?1}{1}{?}{?2} ({2}){?}"
|
||||
},
|
||||
"cpu",
|
||||
"gpu",
|
||||
{
|
||||
"type": "memory",
|
||||
"format": "{?2}{2}{?}"
|
||||
},
|
||||
{
|
||||
"type": "disk",
|
||||
"format": "{?2}{2}{?}"
|
||||
},
|
||||
"physicaldisk",
|
||||
"gpu",
|
||||
"display",
|
||||
"monitor",
|
||||
{
|
||||
"type": "wifi",
|
||||
"format": "{?1}{1}{?}{?6} - {6}{?}"
|
||||
},
|
||||
{
|
||||
"type": "sound",
|
||||
"format": "{?2}{2}{?}"
|
||||
},
|
||||
"camera",
|
||||
{
|
||||
"type": "battery",
|
||||
"format": "{?1}{1} {?}{?2}{2} {?}{?3}({3}){?}"
|
||||
}
|
||||
"format": "{?1}{1}{?}{?2} {2}{?}{?3} ({3}){?}"
|
||||
},
|
||||
"poweradapter"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -79,29 +79,10 @@ static void genJsonResult(FFModuleBaseInfo* baseInfo, yyjson_mut_doc* doc)
|
||||
|
||||
static void parseStructureCommand(
|
||||
const char* line,
|
||||
FFlist* customValues,
|
||||
void (*fn)(FFModuleBaseInfo *baseInfo, yyjson_mut_doc* jsonDoc),
|
||||
yyjson_mut_doc* jsonDoc
|
||||
)
|
||||
{
|
||||
// handle `--set` and `--set-keyless`
|
||||
FF_LIST_FOR_EACH(FFCustomValue, customValue, *customValues)
|
||||
{
|
||||
if (ffStrbufEqualS(&customValue->key, line))
|
||||
{
|
||||
__attribute__((__cleanup__(ffDestroyCustomOptions))) FFCustomOptions options;
|
||||
ffInitCustomOptions(&options);
|
||||
if (customValue->printKey)
|
||||
ffStrbufAppend(&options.moduleArgs.key, &customValue->key);
|
||||
ffStrbufAppend(&options.moduleArgs.outputFormat, &customValue->value);
|
||||
if (__builtin_expect(jsonDoc != NULL, false))
|
||||
fn((FFModuleBaseInfo*) &options, jsonDoc);
|
||||
else
|
||||
ffPrintCustom(&options);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(ffCharIsEnglishAlphabet(line[0]))
|
||||
{
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(line[0]) - 'A']; *modules; ++modules)
|
||||
@@ -134,7 +115,7 @@ void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc)
|
||||
if(instance.config.display.stat)
|
||||
ms = ffTimeGetTick();
|
||||
|
||||
parseStructureCommand(data->structure.chars + startIndex, &data->customValues, genJsonResult, jsonDoc);
|
||||
parseStructureCommand(data->structure.chars + startIndex, genJsonResult, jsonDoc);
|
||||
|
||||
if(instance.config.display.stat)
|
||||
{
|
||||
@@ -177,7 +158,7 @@ void ffMigrateCommandOptionToJsonc(FFdata* data, yyjson_mut_doc* jsonDoc)
|
||||
uint32_t colonIndex = ffStrbufNextIndexC(&data->structure, startIndex, ':');
|
||||
data->structure.chars[colonIndex] = '\0';
|
||||
|
||||
parseStructureCommand(data->structure.chars + startIndex, &data->customValues, genJsonConfig, jsonDoc);
|
||||
parseStructureCommand(data->structure.chars + startIndex, genJsonConfig, jsonDoc);
|
||||
|
||||
startIndex = colonIndex + 1;
|
||||
}
|
||||
|
||||
@@ -2,18 +2,10 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFCustomValue
|
||||
{
|
||||
bool printKey;
|
||||
FFstrbuf key;
|
||||
FFstrbuf value;
|
||||
} FFCustomValue;
|
||||
|
||||
// Things only needed by fastfetch
|
||||
typedef struct FFdata
|
||||
{
|
||||
FFstrbuf structure;
|
||||
FFlist customValues; // List of FFCustomValue
|
||||
bool configLoaded;
|
||||
} FFdata;
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs*
|
||||
ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val));
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "outputColor"))
|
||||
{
|
||||
ffOptionParseColor(yyjson_get_str(val), &moduleArgs->outputColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "keyColor"))
|
||||
{
|
||||
ffOptionParseColor(yyjson_get_str(val), &moduleArgs->keyColor);
|
||||
|
||||
@@ -9,6 +9,7 @@ static FFModuleBaseInfo* B[] = {
|
||||
(void*) &instance.config.modules.bios,
|
||||
(void*) &instance.config.modules.bluetooth,
|
||||
(void*) &instance.config.modules.board,
|
||||
(void*) &instance.config.modules.bootmgr,
|
||||
(void*) &instance.config.modules.break_,
|
||||
(void*) &instance.config.modules.brightness,
|
||||
NULL,
|
||||
@@ -71,6 +72,7 @@ static FFModuleBaseInfo* K[] = {
|
||||
|
||||
static FFModuleBaseInfo* L[] = {
|
||||
(void*) &instance.config.modules.lm,
|
||||
(void*) &instance.config.modules.loadavg,
|
||||
(void*) &instance.config.modules.locale,
|
||||
(void*) &instance.config.modules.localIP,
|
||||
NULL,
|
||||
@@ -98,6 +100,7 @@ static FFModuleBaseInfo* O[] = {
|
||||
static FFModuleBaseInfo* P[] = {
|
||||
(void*) &instance.config.modules.packages,
|
||||
(void*) &instance.config.modules.physicalDisk,
|
||||
(void*) &instance.config.modules.physicalMemory,
|
||||
(void*) &instance.config.modules.player,
|
||||
(void*) &instance.config.modules.powerAdapter,
|
||||
(void*) &instance.config.modules.processes,
|
||||
|
||||
@@ -22,6 +22,7 @@ typedef struct FFNetworkingState {
|
||||
#endif
|
||||
|
||||
uint32_t timeout;
|
||||
bool ipv6;
|
||||
} FFNetworkingState;
|
||||
|
||||
const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers);
|
||||
|
||||
@@ -14,7 +14,7 @@ static const char* connectAndSend(FFNetworkingState* state)
|
||||
struct addrinfo* addr;
|
||||
|
||||
if(getaddrinfo(state->host.chars, "80", &(struct addrinfo) {
|
||||
.ai_family = AF_INET,
|
||||
.ai_family = state->ipv6 ? AF_INET6 : AF_INET,
|
||||
.ai_socktype = SOCK_STREAM,
|
||||
}, &addr) != 0)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho
|
||||
struct addrinfo* addr;
|
||||
|
||||
if(getaddrinfo(host, "80", &(struct addrinfo) {
|
||||
.ai_family = AF_INET,
|
||||
.ai_family = state->ipv6 ? AF_INET6 : AF_INET,
|
||||
.ai_socktype = SOCK_STREAM,
|
||||
}, &addr) != 0)
|
||||
return "getaddrinfo() failed";
|
||||
|
||||
@@ -39,6 +39,16 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const
|
||||
ffOptionParseString(argumentKey, value, &result->outputFormat);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "output-color"))
|
||||
{
|
||||
if(value == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error: usage: %s <str>\n", argumentKey);
|
||||
exit(477);
|
||||
}
|
||||
ffOptionParseColor(value, &result->outputColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "key-color"))
|
||||
{
|
||||
if(value == NULL)
|
||||
@@ -148,6 +158,12 @@ void ffOptionParseColor(const char* value, FFstrbuf* buffer)
|
||||
FF_APPEND_COLOR_CODE_COND(reset_, FF_COLOR_MODE_RESET)
|
||||
else FF_APPEND_COLOR_CODE_COND(bright_, FF_COLOR_MODE_BOLD)
|
||||
else FF_APPEND_COLOR_CODE_COND(dim_, FF_COLOR_MODE_DIM)
|
||||
else FF_APPEND_COLOR_CODE_COND(italic_, FF_COLOR_MODE_ITALIC)
|
||||
else FF_APPEND_COLOR_CODE_COND(underline_, FF_COLOR_MODE_UNDERLINE)
|
||||
else FF_APPEND_COLOR_CODE_COND(blink_, FF_COLOR_MODE_BLINK)
|
||||
else FF_APPEND_COLOR_CODE_COND(inverse_, FF_COLOR_MODE_INVERSE)
|
||||
else FF_APPEND_COLOR_CODE_COND(hidden_, FF_COLOR_MODE_HIDDEN)
|
||||
else FF_APPEND_COLOR_CODE_COND(strike_, FF_COLOR_MODE_STRIKETHROUGH)
|
||||
else FF_APPEND_COLOR_CODE_COND(black, FF_COLOR_FG_BLACK)
|
||||
else FF_APPEND_COLOR_CODE_COND(red, FF_COLOR_FG_RED)
|
||||
else FF_APPEND_COLOR_CODE_COND(green, FF_COLOR_FG_GREEN)
|
||||
@@ -180,6 +196,7 @@ void ffOptionInitModuleArg(FFModuleArgs* args)
|
||||
ffStrbufInit(&args->key);
|
||||
ffStrbufInit(&args->keyColor);
|
||||
ffStrbufInit(&args->outputFormat);
|
||||
ffStrbufInit(&args->outputColor);
|
||||
args->keyWidth = 0;
|
||||
}
|
||||
|
||||
@@ -188,4 +205,5 @@ void ffOptionDestroyModuleArg(FFModuleArgs* args)
|
||||
ffStrbufDestroy(&args->key);
|
||||
ffStrbufDestroy(&args->keyColor);
|
||||
ffStrbufDestroy(&args->outputFormat);
|
||||
ffStrbufDestroy(&args->outputColor);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ typedef struct FFModuleArgs
|
||||
FFstrbuf key;
|
||||
FFstrbuf keyColor;
|
||||
FFstrbuf outputFormat;
|
||||
FFstrbuf outputColor;
|
||||
uint32_t keyWidth;
|
||||
} FFModuleArgs;
|
||||
|
||||
|
||||
+15
-3
@@ -6,7 +6,15 @@
|
||||
#include "util/textModifier.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config)
|
||||
static void appendOutputColor(FFstrbuf* buffer, const FFModuleArgs* module)
|
||||
{
|
||||
if (module->outputColor.length)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", module->outputColor.chars);
|
||||
else if (instance.config.display.colorOutput.length)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", instance.config.display.colorOutput.chars);
|
||||
}
|
||||
|
||||
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config, const FFModuleArgs* module)
|
||||
{
|
||||
uint8_t green = config.green, yellow = config.yellow;
|
||||
assert(green <= 100 && yellow <= 100);
|
||||
@@ -66,16 +74,19 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig con
|
||||
if(options->barBorder)
|
||||
{
|
||||
if(!options->pipe)
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m ]");
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m ]");\
|
||||
else
|
||||
ffStrbufAppendS(buffer, " ]");
|
||||
}
|
||||
|
||||
if(!options->pipe)
|
||||
{
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
appendOutputColor(buffer, module);
|
||||
}
|
||||
}
|
||||
|
||||
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses)
|
||||
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses, const FFModuleArgs* module)
|
||||
{
|
||||
uint8_t green = config.green, yellow = config.yellow;
|
||||
assert(green <= 100 && yellow <= 100);
|
||||
@@ -120,6 +131,7 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig con
|
||||
if (colored && !options->pipe)
|
||||
{
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
appendOutputColor(buffer, module);
|
||||
}
|
||||
|
||||
if (parentheses)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "util/FFstrbuf.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/option.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -21,8 +22,8 @@ enum
|
||||
// [yellow, green): print yellow
|
||||
// [0, yellow): print red
|
||||
|
||||
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config);
|
||||
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses);
|
||||
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config, const FFModuleArgs* module);
|
||||
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses, const FFModuleArgs* module);
|
||||
|
||||
typedef struct yyjson_val yyjson_val;
|
||||
typedef struct yyjson_mut_doc yyjson_mut_doc;
|
||||
|
||||
@@ -49,8 +49,13 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
ffStrbufWriteTo(&instance.config.display.keyValueSeparator, stdout);
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
|
||||
if (moduleArgs->outputColor.length)
|
||||
ffPrintColor(&moduleArgs->outputColor);
|
||||
else if (instance.config.display.colorOutput.length)
|
||||
ffPrintColor(&instance.config.display.colorOutput);
|
||||
}
|
||||
|
||||
if (!instance.config.display.pipe && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
|
||||
{
|
||||
|
||||
+8
-2
@@ -3,7 +3,7 @@
|
||||
#include "util/textModifier.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig config)
|
||||
void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig config, const FFModuleArgs* module)
|
||||
{
|
||||
if (celsius != celsius) // ignores NaN
|
||||
return;
|
||||
@@ -37,7 +37,7 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi
|
||||
}
|
||||
}
|
||||
|
||||
switch (options->temperatureUnit)
|
||||
switch (options->tempUnit)
|
||||
{
|
||||
case FF_TEMPERATURE_UNIT_CELSIUS:
|
||||
ffStrbufAppendF(buffer, "%.*f°C", options->tempNdigits, celsius);
|
||||
@@ -51,7 +51,13 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi
|
||||
}
|
||||
|
||||
if (!options->pipe)
|
||||
{
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
if (module->outputColor.length)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", module->outputColor.chars);
|
||||
else if (instance.config.display.colorOutput.length)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", instance.config.display.colorOutput.chars);
|
||||
}
|
||||
}
|
||||
|
||||
bool ffTempsParseCommandOptions(const char* key, const char* subkey, const char* value, bool* useTemp, FFColorRangeConfig* config)
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/parsing.h"
|
||||
#include "common/option.h"
|
||||
|
||||
void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig config);
|
||||
void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig config, const FFModuleArgs* module);
|
||||
bool ffTempsParseCommandOptions(const char* key, const char* subkey, const char* value, bool* useTemp, FFColorRangeConfig* config);
|
||||
bool ffTempsParseJsonObject(const char* key, yyjson_val* value, bool* useTemp, FFColorRangeConfig* config);
|
||||
void ffTempsGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FF_MAYBE_UNUSED bool defaultTemp, FFColorRangeConfig defaultConfig, bool temp, FFColorRangeConfig config);
|
||||
|
||||
+58
-28
@@ -436,7 +436,7 @@
|
||||
{
|
||||
"long": "color-keys",
|
||||
"desc": "Set the color of the keys",
|
||||
"remark": "See `-h color` for the list of available colors",
|
||||
"remark": "Doesn't affect module Title, Separator and Colors. See `-h color` for the list of available colors",
|
||||
"arg": {
|
||||
"type": "color"
|
||||
}
|
||||
@@ -449,6 +449,14 @@
|
||||
"type": "color"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "color-output",
|
||||
"desc": "Set the color of module output",
|
||||
"remark": "See `-h color` for the list of available colors",
|
||||
"arg": {
|
||||
"type": "color"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "color",
|
||||
"desc": "Set the color of both the keys and title",
|
||||
@@ -481,22 +489,6 @@
|
||||
"default": ": "
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "set",
|
||||
"desc": "Hard set the value of a key",
|
||||
"remark": "Deprecated. Use \"Custom\" module instead",
|
||||
"arg": {
|
||||
"type": "key=value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "set-keyless",
|
||||
"desc": "Hard set the value of a key, but don't print the key or the separator",
|
||||
"remark": "Deprecated. Use \"Custom\" module instead",
|
||||
"arg": {
|
||||
"type": "key=value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "show-errors",
|
||||
"desc": "Print occurring errors",
|
||||
@@ -521,7 +513,7 @@
|
||||
"arg": {
|
||||
"type": "bool",
|
||||
"optional": true,
|
||||
"default": true
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -938,11 +930,11 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "os-file",
|
||||
"desc": "Set the additional file path which containing OS information",
|
||||
"remark": "Linux only",
|
||||
"long": "separator-output-color",
|
||||
"desc": "Set the color of the separator module",
|
||||
"arg": {
|
||||
"type": "path"
|
||||
"type": "color",
|
||||
"default": "default"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -1205,13 +1197,18 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "gpu-force-vulkan",
|
||||
"desc": "Force using vulkan to detect GPUs",
|
||||
"remark": "Vulkan supports video memory usage detection",
|
||||
"long": "gpu-detection-method",
|
||||
"desc": "Force using a specified method to detect GPUs",
|
||||
"remark": "Methods are used in this order: DRM (Linux only) -> PCI (Linux, FreeBSD and other platform specific methods) -> Vulkan -> OpenGL",
|
||||
"arg": {
|
||||
"type": "bool",
|
||||
"optional": true,
|
||||
"default": false
|
||||
"type": "enum",
|
||||
"enum": {
|
||||
"auto": "Use DRM if available, which is most feature-rich. Requires proper DRM driver installed",
|
||||
"pci": "Search PCI devices, which do not requires any driver installed",
|
||||
"vulkan": "Use Vulkan API. Slow and requires vulkan driver installed",
|
||||
"opengl": "Use OpenGL API. Slow and only detects one GPU"
|
||||
},
|
||||
"default": "auto"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -1236,6 +1233,14 @@
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "loadavg-ndigits",
|
||||
"desc": "Set the number of digits to keep after the decimal point when printing load average",
|
||||
"arg": {
|
||||
"type": "num",
|
||||
"default": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "localip-show-ipv4",
|
||||
"desc": "Show IPv4 addresses in local ip module",
|
||||
@@ -1298,6 +1303,15 @@
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "localip-show-all-ips",
|
||||
"desc": "Show all IPs bound to the same interface. By default only the first IP is shown",
|
||||
"arg": {
|
||||
"type": "bool",
|
||||
"optional": true,
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "localip-compact",
|
||||
"desc": "Show all IPs in one line",
|
||||
@@ -1348,6 +1362,14 @@
|
||||
"type": "str"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "publicip-ipv6",
|
||||
"desc": "Whether to use IPv6 for public IP detection server",
|
||||
"arg": {
|
||||
"type": "bool",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "weather-location",
|
||||
"desc": "Set the location to be used",
|
||||
@@ -1522,6 +1544,14 @@
|
||||
},
|
||||
"pseudo": true
|
||||
},
|
||||
{
|
||||
"long": "<module>-output-color",
|
||||
"desc": "Override the global \"--color-output\" option for each specific module",
|
||||
"arg": {
|
||||
"type": "color"
|
||||
},
|
||||
"pseudo": true
|
||||
},
|
||||
{
|
||||
"long": "<module>-key-width",
|
||||
"desc": "Override the global \"--key-width\" option for each specific module",
|
||||
|
||||
@@ -5,6 +5,6 @@ Infos about them can be found here: https://en.wikipedia.org/wiki/ANSI_escape_co
|
||||
Examples:
|
||||
--color 35: sets the color to magenta. `--color magenta` is also supported
|
||||
--color 38;5;38: sets the color to 38th color of ANSI 256 colors
|
||||
--color 4;92: sets the color to bright Green with underline
|
||||
--color 4;92: sets the color to bright Green with underline. `--color underline_green` is also supported
|
||||
--color 5;104: blinking text on a blue background
|
||||
If no color is set, the main color of the logo will be used.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "battery.h"
|
||||
|
||||
#include "common/io/io.h"
|
||||
#include "util/windows/nt.h"
|
||||
#include "util/windows/unicode.h"
|
||||
#include "util/mallocHelper.h"
|
||||
#include "util/smbiosHelper.h"
|
||||
@@ -12,16 +13,6 @@
|
||||
#include <devguid.h>
|
||||
#include <winternl.h>
|
||||
|
||||
NTSYSCALLAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtPowerInformation(
|
||||
IN POWER_INFORMATION_LEVEL InformationLevel,
|
||||
IN PVOID InputBuffer OPTIONAL,
|
||||
IN ULONG InputBufferLength,
|
||||
OUT PVOID OutputBuffer OPTIONAL,
|
||||
IN ULONG OutputBufferLength);
|
||||
|
||||
static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
|
||||
{
|
||||
if(*hdev)
|
||||
@@ -154,8 +145,6 @@ static const char* detectWithSetupApi(FFBatteryOptions* options, FFlist* results
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef struct FFSmbiosPortableBattery
|
||||
{
|
||||
FFSmbiosHeader Header;
|
||||
@@ -178,11 +167,18 @@ typedef struct FFSmbiosPortableBattery
|
||||
uint8_t SbdsDeviceChemistry; // string
|
||||
uint8_t DesignCapacityMultiplier; // varies
|
||||
uint16_t OEMSpecific; // varies
|
||||
} FFSmbiosPortableBattery;
|
||||
} __attribute__((__packed__)) FFSmbiosPortableBattery;
|
||||
|
||||
static_assert(offsetof(FFSmbiosPortableBattery, OEMSpecific) == 0x16,
|
||||
"FFSmbiosPortableBattery: Wrong struct alignment");
|
||||
|
||||
const char* detectBySmbios(FFBatteryResult* battery)
|
||||
{
|
||||
const FFSmbiosPortableBattery* data = (const FFSmbiosPortableBattery*) (*ffGetSmbiosHeaderTable())[FF_SMBIOS_TYPE_PORTABLE_BATTERY];
|
||||
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
|
||||
if (!smbiosTable)
|
||||
return "Failed to get SMBIOS data";
|
||||
|
||||
const FFSmbiosPortableBattery* data = (const FFSmbiosPortableBattery*) (*smbiosTable)[FF_SMBIOS_TYPE_PORTABLE_BATTERY];
|
||||
if (!data)
|
||||
return "Portable battery section is not found in SMBIOS data";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
const char* ffDetectBios(FFBiosResult* bios)
|
||||
const char *ffDetectBios(FFBiosResult *bios)
|
||||
{
|
||||
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->date);
|
||||
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->release);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "bios.h"
|
||||
#include "util/smbiosHelper.h"
|
||||
#include "util/windows/registry.h"
|
||||
|
||||
#include <ntstatus.h>
|
||||
#include <winternl.h>
|
||||
@@ -35,7 +36,7 @@ typedef struct FFSmbiosBios
|
||||
uint16_t BiosStartingAddressSegment; // varies
|
||||
uint8_t BiosReleaseDate; // string
|
||||
uint8_t BiosRomSize; // string
|
||||
uint32_t BiosCharacteristics; // bit field
|
||||
uint64_t BiosCharacteristics; // bit field
|
||||
|
||||
// 2.4+
|
||||
uint8_t BiosCharacteristicsExtensionBytes[2]; // bit field
|
||||
@@ -46,11 +47,18 @@ typedef struct FFSmbiosBios
|
||||
|
||||
// 3.1+
|
||||
uint16_t ExtendedBiosRomSize; // bit field
|
||||
} FFSmbiosBios;
|
||||
} __attribute__((__packed__)) FFSmbiosBios;
|
||||
|
||||
static_assert(offsetof(FFSmbiosBios, ExtendedBiosRomSize) == 0x18,
|
||||
"FFSmbiosBios: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectBios(FFBiosResult* bios)
|
||||
{
|
||||
const FFSmbiosBios* data = (const FFSmbiosBios*) (*ffGetSmbiosHeaderTable())[FF_SMBIOS_TYPE_BIOS];
|
||||
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
|
||||
if (!smbiosTable)
|
||||
return "Failed to get SMBIOS data";
|
||||
|
||||
const FFSmbiosBios* data = (const FFSmbiosBios*) (*smbiosTable)[FF_SMBIOS_TYPE_BIOS];
|
||||
if (!data)
|
||||
return "BIOS section is not found in SMBIOS data";
|
||||
|
||||
|
||||
@@ -14,13 +14,20 @@ typedef struct FFSmbiosBaseboard
|
||||
uint8_t LocationInChassis; // string
|
||||
uint16_t ChassisHandle; // varies
|
||||
uint8_t BoardType; // enum
|
||||
uint8_t NumberOfContainedObjectHandle; // varies
|
||||
uint16_t ContainedObjectHandle[]; // varies
|
||||
} FFSmbiosBaseboard;
|
||||
uint8_t NumberOfContainedObjectHandles; // varies
|
||||
uint16_t ContainedObjectHandles[]; // varies
|
||||
} __attribute__((__packed__)) FFSmbiosBaseboard;
|
||||
|
||||
static_assert(offsetof(FFSmbiosBaseboard, ContainedObjectHandles) == 0x0F,
|
||||
"FFSmbiosBaseboard: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectBoard(FFBoardResult* board)
|
||||
{
|
||||
const FFSmbiosBaseboard* data = (const FFSmbiosBaseboard*) (*ffGetSmbiosHeaderTable())[FF_SMBIOS_TYPE_BASEBOARD_INFO];
|
||||
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
|
||||
if (!smbiosTable)
|
||||
return "Failed to get SMBIOS data";
|
||||
|
||||
const FFSmbiosBaseboard* data = (const FFSmbiosBaseboard*) (*smbiosTable)[FF_SMBIOS_TYPE_BASEBOARD_INFO];
|
||||
if (!data)
|
||||
return "Baseboard information section is not found in SMBIOS data";
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "efi_helper.h"
|
||||
|
||||
static inline uint8_t evBits(uint16_t val, uint8_t mask, uint8_t shift)
|
||||
{
|
||||
return (uint8_t) ((val & (mask << shift)) >> shift);
|
||||
}
|
||||
|
||||
static void ffEfiUcs2ToUtf8(const uint16_t *const chars, FFstrbuf* result)
|
||||
{
|
||||
for (uint32_t i = 0; chars[i]; i++)
|
||||
{
|
||||
if (chars[i] <= 0x007f)
|
||||
ffStrbufAppendC(result, (char) chars[i]);
|
||||
else if (chars[i] > 0x007f && chars[i] <= 0x07ff)
|
||||
{
|
||||
ffStrbufAppendC(result, (char) (0xc0 | evBits(chars[i], 0x1f, 6)));
|
||||
ffStrbufAppendC(result, (char) (0x80 | evBits(chars[i], 0x3f, 0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ffStrbufAppendC(result, (char) (0xe0 | evBits(chars[i], 0xf, 12)));
|
||||
ffStrbufAppendC(result, (char) (0x80 | evBits(chars[i], 0x3f, 6)));
|
||||
ffStrbufAppendC(result, (char) (0x80 | evBits(chars[i], 0x3f, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ffEfiFillLoadOption(const FFEfiLoadOption* efiOption, FFBootmgrResult* result)
|
||||
{
|
||||
uint32_t descLen = 0;
|
||||
while (efiOption->Description[descLen]) ++descLen;
|
||||
|
||||
if (descLen)
|
||||
ffEfiUcs2ToUtf8(efiOption->Description, &result->name);
|
||||
|
||||
for (
|
||||
ffEfiDevicePathProtocol* filePathList = (void*) &efiOption->Description[descLen + 1];
|
||||
filePathList->Type != 0x7F; // End of Hardware Device Path
|
||||
filePathList = (void*) ((uint8_t*) filePathList + filePathList->Length))
|
||||
{
|
||||
if (filePathList->Type == 4 && filePathList->SubType == 4)
|
||||
{
|
||||
// https://uefi.org/specs/UEFI/2.10/10_Protocols_Device_Path_Protocol.html#file-path-media-device-path
|
||||
ffEfiUcs2ToUtf8((uint16_t*) filePathList->SpecificDevicePathData, &result->firmware);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFBootmgrResult
|
||||
{
|
||||
FFstrbuf name;
|
||||
FFstrbuf firmware;
|
||||
bool secureBoot;
|
||||
} FFBootmgrResult;
|
||||
|
||||
const char* ffDetectBootmgr(FFBootmgrResult* bios);
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "bootmgr.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
const char* ffDetectBootmgr(FFBootmgrResult* result)
|
||||
{
|
||||
if (ffPathExists("/System/Library/CoreServices/boot.efi", FF_PATHTYPE_FILE))
|
||||
ffStrbufSetStatic(&result->firmware, "/System/Library/CoreServices/boot.efi");
|
||||
|
||||
ffStrbufSetStatic(&result->name, "iBoot");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "bootmgr.h"
|
||||
#include "efi_helper.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <sys/efiio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
const char* ffDetectBootmgr(FFBootmgrResult* result)
|
||||
{
|
||||
FF_AUTO_CLOSE_FD int efifd = open("/dev/efi", O_RDWR);
|
||||
if (efifd < 0) return "open(/dev/efi) failed";
|
||||
|
||||
uint8_t buffer[2048];
|
||||
struct efi_var_ioc ioc = {
|
||||
.vendor = { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } },
|
||||
.data = buffer,
|
||||
};
|
||||
|
||||
ioc.datasize = sizeof(buffer);
|
||||
ioc.name = (efi_char[]){ 'B', 'o', 'o', 't', 'C', 'u', 'r', 'r', 'e', 'n', 't', '\0' };
|
||||
ioc.namesize = sizeof("BootCurrent") * 2;
|
||||
if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) < 0 || ioc.datasize != 2)
|
||||
return "ioctl(EFIIOC_VAR_GET, BootCurrent) failed";
|
||||
|
||||
unsigned char hex[5];
|
||||
snprintf((char*) hex, sizeof(hex), "%04X", *(uint16_t*)buffer);
|
||||
ioc.datasize = sizeof(buffer);
|
||||
ioc.name = (efi_char[]){ 'B', 'o', 'o', 't', hex[0], hex[1], hex[2], hex[3], '\0' };
|
||||
ioc.namesize = sizeof("Boot####") * 2;
|
||||
if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) < 0 || ioc.datasize == sizeof(buffer))
|
||||
return "ioctl(EFIIOC_VAR_GET, Boot####) failed";
|
||||
|
||||
ffEfiFillLoadOption((FFEfiLoadOption *)buffer, result);
|
||||
|
||||
ioc.name = (efi_char[]){ 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', '\0' };
|
||||
ioc.namesize = sizeof("SecureBoot") * 2;
|
||||
ioc.datasize = sizeof(buffer);
|
||||
if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) == 0 && ioc.datasize == 1)
|
||||
result->secureBoot = !!buffer[0];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "bootmgr.h"
|
||||
#include "common/io/io.h"
|
||||
#include "efi_helper.h"
|
||||
|
||||
#define FF_EFIVARS_PATH_PREFIX "/sys/firmware/efi/efivars/"
|
||||
|
||||
const char* ffDetectBootmgr(FFBootmgrResult* result)
|
||||
{
|
||||
uint8_t buffer[2048];
|
||||
|
||||
if (ffReadFileData(FF_EFIVARS_PATH_PREFIX "BootCurrent-" FF_EFI_GLOBAL_GUID, sizeof(buffer), buffer) != 6)
|
||||
return "Failed to read efivar: BootCurrent";
|
||||
|
||||
uint16_t value = *(uint16_t *)&buffer[4];
|
||||
snprintf((char*) buffer, sizeof(buffer), FF_EFIVARS_PATH_PREFIX "Boot%04X-" FF_EFI_GLOBAL_GUID, value);
|
||||
|
||||
ssize_t size = ffReadFileData((const char*) buffer, sizeof(buffer), buffer);
|
||||
if (size < 5 + (int) sizeof(FFEfiLoadOption) || size == (ssize_t) sizeof(buffer))
|
||||
return "Failed to read efivar: Boot####";
|
||||
|
||||
ffEfiFillLoadOption((FFEfiLoadOption *)&buffer[4], result);
|
||||
|
||||
if (ffReadFileData(FF_EFIVARS_PATH_PREFIX "SecureBoot-" FF_EFI_GLOBAL_GUID, sizeof(buffer), buffer) == 6)
|
||||
result->secureBoot = buffer[4] == 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "bootmgr.h"
|
||||
|
||||
const char* ffDetectBootmgr(FF_MAYBE_UNUSED FFBootmgrResult* result)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#include "bootmgr.h"
|
||||
#include "efi_helper.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
const char* enablePrivilege(const wchar_t* privilege)
|
||||
{
|
||||
HANDLE token;
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token))
|
||||
return "OpenProcessToken() failed";
|
||||
|
||||
TOKEN_PRIVILEGES tp = {
|
||||
.PrivilegeCount = 1,
|
||||
.Privileges = {
|
||||
(LUID_AND_ATTRIBUTES) { .Attributes = SE_PRIVILEGE_ENABLED }
|
||||
},
|
||||
};
|
||||
if (!LookupPrivilegeValueW(NULL, privilege, &tp.Privileges[0].Luid))
|
||||
return "LookupPrivilegeValue() failed";
|
||||
|
||||
if (!AdjustTokenPrivileges(token, false, &tp, sizeof(tp), NULL, NULL))
|
||||
return "AdjustTokenPrivileges() failed";
|
||||
|
||||
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
|
||||
return "The token does not have the specified privilege";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* ffDetectBootmgr(FFBootmgrResult* result)
|
||||
{
|
||||
if (enablePrivilege(L"SeSystemEnvironmentPrivilege") != NULL)
|
||||
return "Failed to enable SeSystemEnvironmentPrivilege";
|
||||
|
||||
uint16_t value;
|
||||
if (GetFirmwareEnvironmentVariableW(L"BootCurrent", L"{" FF_EFI_GLOBAL_GUID L"}", &value, sizeof(value)) != 2)
|
||||
return "GetFirmwareEnvironmentVariableW(BootCurrent) failed";
|
||||
|
||||
uint8_t buffer[2048];
|
||||
wchar_t key[16];
|
||||
wsprintfW(key, L"Boot%04X", value);
|
||||
uint32_t size = GetFirmwareEnvironmentVariableW(key, L"{" FF_EFI_GLOBAL_GUID L"}", buffer, sizeof(buffer));
|
||||
if (size < sizeof(FFEfiLoadOption) || size == sizeof(buffer))
|
||||
return "GetFirmwareEnvironmentVariableW(Boot####) failed";
|
||||
|
||||
ffEfiFillLoadOption((FFEfiLoadOption *)buffer, result);
|
||||
|
||||
DWORD uefiSecureBootEnabled = 0, bufSize = 0;
|
||||
if (RegGetValueW(HKEY_LOCAL_MACHINE, L"SYSTEM\\ControlSet001\\Control\\SecureBoot\\State", L"UEFISecureBootEnabled", RRF_RT_REG_DWORD, NULL, &uefiSecureBootEnabled, &bufSize) == ERROR_SUCCESS)
|
||||
result->secureBoot = !!uefiSecureBootEnabled;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "bootmgr.h"
|
||||
|
||||
// https://uefi.org/specs/UEFI/2.10/10_Protocols_Device_Path_Protocol.html#generic-device-path-structures
|
||||
typedef struct ffEfiDevicePathProtocol
|
||||
{
|
||||
uint8_t Type;
|
||||
uint8_t SubType;
|
||||
uint16_t Length;
|
||||
uint8_t SpecificDevicePathData[];
|
||||
} ffEfiDevicePathProtocol;
|
||||
|
||||
// https://uefi.org/specs/UEFI/2.10/03_Boot_Manager.html#load-options
|
||||
typedef struct FFEfiLoadOption
|
||||
{
|
||||
uint32_t Attributes;
|
||||
uint16_t FilePathListLength;
|
||||
uint16_t Description[];
|
||||
// ffEfiDevicePathProtocol FilePathList[];
|
||||
// uint8_t OptionalData[];
|
||||
} FFEfiLoadOption;
|
||||
|
||||
bool ffEfiFillLoadOption(const FFEfiLoadOption* efiOption, FFBootmgrResult* result);
|
||||
|
||||
#define FF_EFI_GLOBAL_GUID "8be4df61-93ca-11d2-aa0d-00e098032b8c"
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
const char* ffDetectCamera(FFlist* result)
|
||||
{
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
FF_SUPPRESS_IO(); // #822
|
||||
|
||||
AVCaptureDeviceType deviceType;
|
||||
@@ -47,6 +48,8 @@ const char* ffDetectCamera(FFlist* result)
|
||||
camera->width = size.width < 0 ? 0 : (uint32_t) size.width;
|
||||
camera->height = size.height < 0 ? 0 : (uint32_t) size.height;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#else
|
||||
return "No support for old MacOS version";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -25,11 +25,18 @@ typedef struct FFSmbiosSystemEnclosure
|
||||
uint8_t ContainedElementCount; // varies
|
||||
uint8_t ContainedRecordLength; // varies
|
||||
uint8_t ContainedElements[]; // varies
|
||||
} FFSmbiosSystemEnclosure;
|
||||
} __attribute__((__packed__)) FFSmbiosSystemEnclosure;
|
||||
|
||||
static_assert(offsetof(FFSmbiosSystemEnclosure, ContainedElements) == 0x15,
|
||||
"FFSmbiosSystemEnclosure: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectChassis(FFChassisResult* result)
|
||||
{
|
||||
const FFSmbiosSystemEnclosure* data = (const FFSmbiosSystemEnclosure*) (*ffGetSmbiosHeaderTable())[FF_SMBIOS_TYPE_SYSTEM_ENCLOSURE];
|
||||
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
|
||||
if (!smbiosTable)
|
||||
return "Failed to get SMBIOS data";
|
||||
|
||||
const FFSmbiosSystemEnclosure* data = (const FFSmbiosSystemEnclosure*) (*smbiosTable)[FF_SMBIOS_TYPE_SYSTEM_ENCLOSURE];
|
||||
if (!data)
|
||||
return "System enclosure is not found in SMBIOS data";
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
|
||||
#define FF_CPU_TEMP_UNSET (0/0.0)
|
||||
|
||||
typedef struct FFCPUCore
|
||||
{
|
||||
uint32_t freq;
|
||||
uint32_t count;
|
||||
} FFCPUCore;
|
||||
|
||||
typedef struct FFCPUResult
|
||||
{
|
||||
FFstrbuf name;
|
||||
@@ -16,10 +22,12 @@ typedef struct FFCPUResult
|
||||
double frequencyBase; // GHz
|
||||
double frequencyMax; // GHz
|
||||
double frequencyMin; // GHz
|
||||
double frequencyBiosLimit; // GHz
|
||||
|
||||
FFCPUCore coreTypes[16]; // number of P cores, E cores, etc.
|
||||
|
||||
double temperature;
|
||||
} FFCPUResult;
|
||||
|
||||
const char* ffCPUDetectByCpuid(FFCPUResult* cpu);
|
||||
const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu);
|
||||
const char* ffCPUAppleCodeToName(uint32_t code);
|
||||
|
||||
@@ -68,20 +68,37 @@ static const char* detectFrequency(FFCPUResult* cpu)
|
||||
{
|
||||
cpu->frequencyBase = ffSysctlGetInt64("hw.cpufrequency", 0) / 1000.0 / 1000.0 / 1000.0;
|
||||
cpu->frequencyMin = ffSysctlGetInt64("hw.cpufrequency_min", 0) / 1000.0 / 1000.0 / 1000.0;
|
||||
cpu->frequencyMax = ffSysctlGetInt64("hw.cpufrequency_max", 0);
|
||||
if(cpu->frequencyMax > 0.0)
|
||||
cpu->frequencyMax /= 1000.0 * 1000.0 * 1000.0;
|
||||
else
|
||||
cpu->frequencyMax = ffSysctlGetInt64("hw.cpufrequency_max", 0) / 1000.0 / 1000.0 / 1000.0;
|
||||
if(cpu->frequencyBase != cpu->frequencyBase)
|
||||
{
|
||||
unsigned current = 0;
|
||||
size_t size = sizeof(current);
|
||||
if (sysctl((int[]){ CTL_HW, HW_CPU_FREQ }, 2, ¤t, &size, NULL, 0) == 0)
|
||||
cpu->frequencyMax = (double) current / 1000.0 / 1000.0 / 1000.0;
|
||||
cpu->frequencyBase = (double) current / 1000.0 / 1000.0 / 1000.0;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char* detectCoreCount(FFCPUResult* cpu)
|
||||
{
|
||||
uint32_t nPerfLevels = (uint32_t) ffSysctlGetInt("hw.nperflevels", 0);
|
||||
if (nPerfLevels <= 0) return "sysctl(hw.nperflevels) failed";
|
||||
|
||||
char sysctlKey[] = "hw.perflevelN.logicalcpu";
|
||||
if (nPerfLevels > sizeof(cpu->coreTypes) / sizeof(cpu->coreTypes[0]))
|
||||
nPerfLevels = sizeof(cpu->coreTypes) / sizeof(cpu->coreTypes[0]);
|
||||
for (uint32_t i = 0; i < nPerfLevels; ++i)
|
||||
{
|
||||
sysctlKey[strlen("hw.perflevel")] = (char) ('0' + i);
|
||||
cpu->coreTypes[i] = (FFCPUCore) {
|
||||
.freq = nPerfLevels - i,
|
||||
.count = (uint32_t) ffSysctlGetInt(sysctlKey, 0),
|
||||
};
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
{
|
||||
if (ffSysctlGetString("machdep.cpu.brand_string", &cpu->name) != NULL)
|
||||
@@ -104,6 +121,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.activecpu", 1);
|
||||
|
||||
detectFrequency(cpu);
|
||||
detectCoreCount(cpu);
|
||||
|
||||
cpu->temperature = options->temp ? detectCpuTemp(&cpu->name) : FF_CPU_TEMP_UNSET;
|
||||
|
||||
|
||||
@@ -11,6 +11,62 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
cpu->coresLogical = cpu->coresPhysical;
|
||||
cpu->coresOnline = cpu->coresPhysical;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
if (ffSysctlGetString("kern.sched.topology_spec", &buffer) == NULL && buffer.length > 0)
|
||||
{
|
||||
// <groups>
|
||||
// <group level="1" cache-level="3">
|
||||
// <cpu count="4" mask="f,0,0,0">0, 1, 2, 3</cpu>
|
||||
// <children>
|
||||
// <group level="2" cache-level="2">
|
||||
// <cpu count="2" mask="3,0,0,0">0, 1</cpu>
|
||||
// <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags>
|
||||
// </group>
|
||||
// <group level="2" cache-level="2">
|
||||
// <cpu count="2" mask="c,0,0,0">2, 3</cpu>
|
||||
// <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags>
|
||||
// </group>
|
||||
// </children>
|
||||
// </group>
|
||||
// </groups>
|
||||
uint32_t i = 0;
|
||||
while (true)
|
||||
{
|
||||
i = ffStrbufNextIndexS(&buffer, i, "<flag name=\"THREAD\">THREAD group</flag>"); // Find physical core with hyper-threading enabled
|
||||
if (i >= buffer.length) break;
|
||||
cpu->coresPhysical--;
|
||||
i += (uint32_t) strlen("<flag name=\"THREAD\">THREAD group</flag>");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ifreq = (uint32_t) -1;
|
||||
for (uint16_t i = 0; i < cpu->coresLogical; ++i)
|
||||
{
|
||||
ffStrbufClear(&buffer);
|
||||
char key[32];
|
||||
snprintf(key, sizeof(key), "dev.cpu.%u.freq_levels", i);
|
||||
if (ffSysctlGetString(key, &buffer) == NULL && buffer.length > 0)
|
||||
{
|
||||
// MHz/Watts pairs like: 2501/32000 2187/27125 2000/24000
|
||||
uint32_t fmax = (uint32_t) strtoul(buffer.chars, NULL, 10);
|
||||
uint32_t fmin = fmax;
|
||||
uint32_t i = ffStrbufLastIndexC(&buffer, ' ');
|
||||
if (i < buffer.length)
|
||||
fmin = (uint32_t) strtoul(buffer.chars + i + 1, NULL, 10);
|
||||
if (!(cpu->frequencyMin <= fmin)) cpu->frequencyMin = fmin; // Counting for NaN
|
||||
if (!(cpu->frequencyMax >= fmax)) cpu->frequencyMax = fmax;
|
||||
|
||||
uint32_t ifreq = 0;
|
||||
while (cpu->coreTypes[ifreq].freq != fmax && cpu->coreTypes[ifreq].freq > 0)
|
||||
++ifreq;
|
||||
if (cpu->coreTypes[ifreq].freq == 0)
|
||||
cpu->coreTypes[ifreq].freq = fmax;
|
||||
cpu->coreTypes[ifreq].count++;
|
||||
}
|
||||
}
|
||||
cpu->frequencyMin /= 1000;
|
||||
cpu->frequencyMax /= 1000;
|
||||
|
||||
int clockRate = ffSysctlGetInt("hw.clockrate", 0);
|
||||
cpu->frequencyBase = clockRate <= 0 ? 0.0/0.0 : clockRate / 1000.0;
|
||||
cpu->temperature = FF_CPU_TEMP_UNSET;
|
||||
|
||||
@@ -88,14 +88,14 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static double getFrequency(FFstrbuf* basePath, const char* cpuinfoFileName, const char* scalingFileName, FFstrbuf* buffer)
|
||||
static uint32_t getFrequency(FFstrbuf* basePath, const char* cpuinfoFileName, const char* scalingFileName, FFstrbuf* buffer)
|
||||
{
|
||||
uint32_t baseLen = basePath->length;
|
||||
ffStrbufAppendS(basePath, cpuinfoFileName);
|
||||
bool ok = ffReadFileBuffer(basePath->chars, buffer);
|
||||
ffStrbufSubstrBefore(basePath, baseLen);
|
||||
if (ok)
|
||||
return ffStrbufToDouble(buffer) / 1e6;
|
||||
return (uint32_t) ffStrbufToUInt(buffer, 0);
|
||||
|
||||
if (scalingFileName)
|
||||
{
|
||||
@@ -103,10 +103,28 @@ static double getFrequency(FFstrbuf* basePath, const char* cpuinfoFileName, cons
|
||||
ok = ffReadFileBuffer(basePath->chars, buffer);
|
||||
ffStrbufSubstrBefore(basePath, baseLen);
|
||||
if (ok)
|
||||
return ffStrbufToDouble(buffer) / 1e6;
|
||||
return (uint32_t) ffStrbufToUInt(buffer, 0);
|
||||
}
|
||||
|
||||
return 0.0/0.0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t getNumCores(FFstrbuf* basePath, FFstrbuf* buffer)
|
||||
{
|
||||
uint32_t baseLen = basePath->length;
|
||||
ffStrbufAppendS(basePath, "/affected_cpus");
|
||||
bool ok = ffReadFileBuffer(basePath->chars, buffer);
|
||||
ffStrbufSubstrBefore(basePath, baseLen);
|
||||
if (ok)
|
||||
return (uint8_t) ffStrbufCountC(buffer, ' ') + 1;
|
||||
|
||||
ffStrbufAppendS(basePath, "/related_cpus");
|
||||
ok = ffReadFileBuffer(basePath->chars, buffer);
|
||||
ffStrbufSubstrBefore(basePath, baseLen);
|
||||
if (ok)
|
||||
return (uint8_t) ffStrbufCountC(buffer, ' ') + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool detectFrequency(FFCPUResult* cpu)
|
||||
@@ -119,38 +137,58 @@ static bool detectFrequency(FFCPUResult* cpu)
|
||||
uint32_t baseLen = path.length;
|
||||
|
||||
struct dirent* entry;
|
||||
while((entry = readdir(dir)) != NULL)
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if (ffStrStartsWith(entry->d_name, "policy") && isdigit(entry->d_name[strlen("policy")]))
|
||||
{
|
||||
ffStrbufAppendS(&path, entry->d_name);
|
||||
double fbase = getFrequency(&path, "/base_frequency", NULL, &buffer);
|
||||
if (fbase == fbase)
|
||||
uint32_t fbase = getFrequency(&path, "/base_frequency", NULL, &buffer);
|
||||
if (fbase > 0)
|
||||
{
|
||||
if (cpu->frequencyBase == cpu->frequencyBase)
|
||||
cpu->frequencyBase = cpu->frequencyBase > fbase ? cpu->frequencyBase : fbase;
|
||||
else
|
||||
cpu->frequencyBase = fbase;
|
||||
}
|
||||
double fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
|
||||
if (fmax == fmax)
|
||||
uint32_t fbioslimit = getFrequency(&path, "/bios_limit", NULL, &buffer);
|
||||
if (fbioslimit > 0)
|
||||
{
|
||||
if (cpu->frequencyBiosLimit == cpu->frequencyBiosLimit)
|
||||
cpu->frequencyBiosLimit = cpu->frequencyBiosLimit > fbioslimit ? cpu->frequencyBiosLimit : fbioslimit;
|
||||
else
|
||||
cpu->frequencyBiosLimit = fbioslimit;
|
||||
}
|
||||
uint32_t fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
|
||||
if (fmax > 0)
|
||||
{
|
||||
if (cpu->frequencyMax == cpu->frequencyMax)
|
||||
cpu->frequencyMax = cpu->frequencyMax > fmax ? cpu->frequencyMax : fmax;
|
||||
else
|
||||
cpu->frequencyMax = fmax;
|
||||
}
|
||||
double fmin = getFrequency(&path, "/cpuinfo_min_freq", "/scaling_min_freq", &buffer);
|
||||
if (fmin == fmin)
|
||||
uint32_t fmin = getFrequency(&path, "/cpuinfo_min_freq", "/scaling_min_freq", &buffer);
|
||||
if (fmin > 0)
|
||||
{
|
||||
if (cpu->frequencyMin == cpu->frequencyMin)
|
||||
cpu->frequencyMin = cpu->frequencyMin < fmin ? cpu->frequencyMin : fmin;
|
||||
else
|
||||
cpu->frequencyMin = fmin;
|
||||
}
|
||||
|
||||
uint32_t freq = fbase == 0 ? fmax : fbase; // seems base frequencies are more stable
|
||||
uint32_t ifreq = 0;
|
||||
while (cpu->coreTypes[ifreq].freq != freq && cpu->coreTypes[ifreq].freq > 0)
|
||||
++ifreq;
|
||||
if (cpu->coreTypes[ifreq].freq == 0)
|
||||
cpu->coreTypes[ifreq].freq = freq;
|
||||
cpu->coreTypes[ifreq].count += getNumCores(&path, &buffer);
|
||||
ffStrbufSubstrBefore(&path, baseLen);
|
||||
}
|
||||
}
|
||||
cpu->frequencyBase /= 1e6;
|
||||
cpu->frequencyMax /= 1e6;
|
||||
cpu->frequencyMin /= 1e6;
|
||||
cpu->frequencyBiosLimit /= 1e6;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "cpu.h"
|
||||
#include "detection/temps/temps_windows.h"
|
||||
#include "util/windows/registry.h"
|
||||
#include "util/windows/nt.h"
|
||||
#include "util/mallocHelper.h"
|
||||
#include "util/smbiosHelper.h"
|
||||
|
||||
@@ -48,7 +49,10 @@ typedef struct FFSmbiosProcessorInfo
|
||||
|
||||
// 3.6+
|
||||
uint16_t ThreadEnabled; // varies
|
||||
} FFSmbiosProcessorInfo;
|
||||
} __attribute__((__packed__)) FFSmbiosProcessorInfo;
|
||||
|
||||
static_assert(offsetof(FFSmbiosProcessorInfo, ThreadEnabled) == 0x30,
|
||||
"FFSmbiosProcessorInfo: Wrong struct alignment");
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
|
||||
@@ -77,7 +81,11 @@ inline static const char* detectSpeedByCpuid(FF_MAYBE_UNUSED FFCPUResult* cpu)
|
||||
|
||||
static const char* detectMaxSpeedBySmbios(FFCPUResult* cpu)
|
||||
{
|
||||
const FFSmbiosProcessorInfo* data = (const FFSmbiosProcessorInfo*) (*ffGetSmbiosHeaderTable())[FF_SMBIOS_TYPE_PROCESSOR_INFO];
|
||||
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
|
||||
if (!smbiosTable)
|
||||
return "Failed to get SMBIOS data";
|
||||
|
||||
const FFSmbiosProcessorInfo* data = (const FFSmbiosProcessorInfo*) (*smbiosTable)[FF_SMBIOS_TYPE_PROCESSOR_INFO];
|
||||
|
||||
if (!data)
|
||||
return "Processor information is not found in SMBIOS data";
|
||||
@@ -139,13 +147,6 @@ static const char* detectByRegistry(FFCPUResult* cpu)
|
||||
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL))
|
||||
return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, NULL) failed";
|
||||
|
||||
if (detectSpeedByCpuid(cpu) != NULL || cpu->frequencyBase != cpu->frequencyBase)
|
||||
{
|
||||
uint32_t mhz;
|
||||
if(ffRegReadUint(hKey, L"~MHz", &mhz, NULL))
|
||||
cpu->frequencyBase = mhz / 1000.0;
|
||||
}
|
||||
|
||||
ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL);
|
||||
ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL);
|
||||
|
||||
@@ -159,6 +160,27 @@ static const char* detectByRegistry(FFCPUResult* cpu)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char* detectCoreTypes(FFCPUResult* cpu)
|
||||
{
|
||||
FF_AUTO_FREE PROCESSOR_POWER_INFORMATION* pinfo = calloc(cpu->coresLogical, sizeof(PROCESSOR_POWER_INFORMATION));
|
||||
if (!NT_SUCCESS(NtPowerInformation(ProcessorInformation, NULL, 0, pinfo, (ULONG) sizeof(PROCESSOR_POWER_INFORMATION) * cpu->coresLogical)))
|
||||
return "NtPowerInformation(ProcessorInformation, NULL, 0, pinfo, size) failed";
|
||||
|
||||
for (uint32_t icore = 0; icore < cpu->coresLogical && pinfo[icore].MhzLimit; ++icore)
|
||||
{
|
||||
uint32_t ifreq = 0;
|
||||
while (cpu->coreTypes[ifreq].freq != pinfo[icore].MhzLimit && cpu->coreTypes[ifreq].freq > 0)
|
||||
++ifreq;
|
||||
if (cpu->coreTypes[ifreq].freq == 0)
|
||||
cpu->coreTypes[ifreq].freq = pinfo[icore].MhzLimit;
|
||||
++cpu->coreTypes[ifreq].count;
|
||||
}
|
||||
|
||||
if (cpu->frequencyBase != cpu->frequencyBase)
|
||||
cpu->frequencyBase = pinfo->MaxMhz / 1000.0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
{
|
||||
detectNCores(cpu);
|
||||
@@ -167,6 +189,9 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
detectSpeedByCpuid(cpu);
|
||||
detectCoreTypes(cpu);
|
||||
|
||||
if (cpu->frequencyMax != cpu->frequencyMax)
|
||||
detectMaxSpeedBySmbios(cpu);
|
||||
|
||||
|
||||
@@ -66,6 +66,10 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk)
|
||||
#include <sys/attr.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
#define MNT_REMOVABLE 0x00000200
|
||||
#endif
|
||||
|
||||
struct CmnAttrBuf {
|
||||
uint32_t length;
|
||||
attrreference_t nameRef;
|
||||
@@ -132,13 +136,15 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
ffStrbufInitS(&disk->filesystem, fs->f_fstypename);
|
||||
ffStrbufInit(&disk->name);
|
||||
disk->type = 0;
|
||||
disk->createTime = 0;
|
||||
|
||||
detectFsInfo(fs, disk);
|
||||
|
||||
if(fs->f_flags & MNT_RDONLY)
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
|
||||
struct stat st;
|
||||
if(stat(fs->f_mntonname, &st) == 0)
|
||||
if(stat(fs->f_mntonname, &st) == 0 && st.st_birthtimespec.tv_sec > 0)
|
||||
disk->createTime = (uint64_t)((st.st_birthtimespec.tv_sec * 1000) + (st.st_birthtimespec.tv_nsec / 1000000));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#include <CoreVideo/CVDisplayLink.h>
|
||||
|
||||
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import));
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
#import <IOKit/graphics/IOGraphicsLib.h>
|
||||
extern CFDictionaryRef CoreDisplay_IODisplayCreateInfoDictionary(io_service_t framebuffer, IOOptionBits options) __attribute__((weak_import));
|
||||
#endif
|
||||
|
||||
static void detectDisplays(FFDisplayServerResult* ds)
|
||||
{
|
||||
@@ -38,6 +42,7 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
if(CoreDisplay_DisplayCreateInfoDictionary)
|
||||
{
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen);
|
||||
@@ -48,6 +53,19 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
ffCfDictGetString(productNames, CFSTR("en_US"), &name);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if(CoreDisplay_IODisplayCreateInfoDictionary)
|
||||
{
|
||||
io_service_t servicePort = CGDisplayIOServicePort(screen);
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName);
|
||||
if(displayInfo)
|
||||
{
|
||||
CFDictionaryRef productNames;
|
||||
if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames))
|
||||
ffCfDictGetString(productNames, CFSTR("en_US"), &name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ffdsAppendDisplay(ds,
|
||||
(uint32_t)CGDisplayModeGetPixelWidth(mode),
|
||||
|
||||
@@ -25,7 +25,11 @@ const char* ffDetectFontImpl(FFFontResult* result)
|
||||
{
|
||||
ffStrbufAppendS(&result->fonts[0], [NSFont systemFontOfSize:12].familyName.UTF8String);
|
||||
ffStrbufAppendS(&result->fonts[1], [NSFont userFontOfSize:12].familyName.UTF8String);
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
ffStrbufAppendS(&result->fonts[2], [NSFont monospacedSystemFontOfSize:12 weight:400].familyName.UTF8String);
|
||||
#else
|
||||
ffStrbufAppendS(&result->fonts[2], "");
|
||||
#endif
|
||||
ffStrbufAppendS(&result->fonts[3], [NSFont userFixedPitchFontOfSize:12].familyName.UTF8String);
|
||||
generateString(result);
|
||||
|
||||
|
||||
+41
-57
@@ -14,42 +14,24 @@ const char* FF_GPU_VENDOR_NAME_MICROSOFT = "Microsoft";
|
||||
const char* FF_GPU_VENDOR_NAME_REDHAT = "RedHat";
|
||||
const char* FF_GPU_VENDOR_NAME_ORACLE = "Oracle";
|
||||
|
||||
static inline bool arrayContains(const unsigned arr[], unsigned vendorId, unsigned length)
|
||||
{
|
||||
for (unsigned i = 0; i < length; ++i)
|
||||
{
|
||||
if (arr[i] == vendorId)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* ffGetGPUVendorString(unsigned vendorId)
|
||||
{
|
||||
// https://devicehunt.com/all-pci-vendors
|
||||
if(vendorId == 0x106b)
|
||||
return FF_GPU_VENDOR_NAME_APPLE;
|
||||
if(arrayContains((const unsigned[]) {0x1002, 0x1022}, vendorId, 2))
|
||||
return FF_GPU_VENDOR_NAME_AMD;
|
||||
else if(arrayContains((const unsigned[]) {0x03e7, 0x8086, 0x8087}, vendorId, 3))
|
||||
return FF_GPU_VENDOR_NAME_INTEL;
|
||||
else if(arrayContains((const unsigned[]) {0x0955, 0x10de, 0x12d2}, vendorId, 3))
|
||||
return FF_GPU_VENDOR_NAME_NVIDIA;
|
||||
else if(arrayContains((const unsigned[]) {0x5143}, vendorId, 1))
|
||||
return FF_GPU_VENDOR_NAME_QUALCOMM;
|
||||
else if(arrayContains((const unsigned[]) {0x14c3}, vendorId, 1))
|
||||
return FF_GPU_VENDOR_NAME_MTK;
|
||||
else if(arrayContains((const unsigned[]) {0x15ad}, vendorId, 1))
|
||||
return FF_GPU_VENDOR_NAME_VMWARE;
|
||||
else if(arrayContains((const unsigned[]) {0x1af4}, vendorId, 1))
|
||||
return FF_GPU_VENDOR_NAME_REDHAT;
|
||||
else if(arrayContains((const unsigned[]) {0x1ab8}, vendorId, 1))
|
||||
return FF_GPU_VENDOR_NAME_PARALLEL;
|
||||
else if(arrayContains((const unsigned[]) {0x1414}, vendorId, 1))
|
||||
return FF_GPU_VENDOR_NAME_MICROSOFT;
|
||||
else if(arrayContains((const unsigned[]) {0x108e}, vendorId, 1))
|
||||
return FF_GPU_VENDOR_NAME_ORACLE;
|
||||
return NULL;
|
||||
switch (vendorId)
|
||||
{
|
||||
case 0x106b: return FF_GPU_VENDOR_NAME_APPLE;
|
||||
case 0x1002: case 0x1022: return FF_GPU_VENDOR_NAME_AMD;
|
||||
case 0x8086: case 0x8087: case 0x03e7: return FF_GPU_VENDOR_NAME_INTEL;
|
||||
case 0x0955: case 0x10de: case 0x12d2: return FF_GPU_VENDOR_NAME_NVIDIA;
|
||||
case 0x5143: return FF_GPU_VENDOR_NAME_QUALCOMM;
|
||||
case 0x14c3: return FF_GPU_VENDOR_NAME_MTK;
|
||||
case 0x15ad: return FF_GPU_VENDOR_NAME_VMWARE;
|
||||
case 0x1af4: return FF_GPU_VENDOR_NAME_REDHAT;
|
||||
case 0x1ab8: return FF_GPU_VENDOR_NAME_PARALLEL;
|
||||
case 0x1414: return FF_GPU_VENDOR_NAME_MICROSOFT;
|
||||
case 0x108e: return FF_GPU_VENDOR_NAME_ORACLE;
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char* detectByOpenGL(FFlist* gpus)
|
||||
@@ -64,9 +46,9 @@ const char* detectByOpenGL(FFlist* gpus)
|
||||
{
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
ffStrbufInitMove(&gpu->vendor, &result.vendor);
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
ffStrbufInitMove(&gpu->name, &result.renderer);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
ffStrbufInitMove(&gpu->driver, &result.vendor);
|
||||
ffStrbufInitF(&gpu->platformApi, "OpenGL %s", result.version.chars);
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
@@ -74,22 +56,18 @@ const char* detectByOpenGL(FFlist* gpus)
|
||||
gpu->dedicated = gpu->shared = (FFGPUMemory){0, 0};
|
||||
gpu->deviceId = 0;
|
||||
|
||||
if (ffStrbufIgnCaseEqualS(&gpu->vendor, "Mesa"))
|
||||
ffStrbufClear(&gpu->vendor);
|
||||
|
||||
if (!gpu->vendor.length)
|
||||
if (ffStrbufContainS(&gpu->name, "Apple"))
|
||||
{
|
||||
if (ffStrbufContainS(&gpu->name, "Apple"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE);
|
||||
else if (ffStrbufContainS(&gpu->name, "Intel"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
|
||||
else if (ffStrbufContainS(&gpu->name, "AMD") || ffStrbufContainS(&gpu->name, "ATI"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
|
||||
else if (ffStrbufContainS(&gpu->name, "NVIDIA"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
|
||||
}
|
||||
if (ffStrbufEqualS(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE);
|
||||
gpu->type = FF_GPU_TYPE_INTEGRATED;
|
||||
}
|
||||
else if (ffStrbufContainS(&gpu->name, "Intel"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
|
||||
else if (ffStrbufContainS(&gpu->name, "AMD") || ffStrbufContainS(&gpu->name, "ATI"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
|
||||
else if (ffStrbufContainS(&gpu->name, "NVIDIA"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
|
||||
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&result.version);
|
||||
@@ -101,20 +79,26 @@ const char* detectByOpenGL(FFlist* gpus)
|
||||
|
||||
const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result)
|
||||
{
|
||||
if (!options->forceVulkan)
|
||||
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_PCI)
|
||||
{
|
||||
const char* error = ffDetectGPUImpl(options, result);
|
||||
if (!error && result->length > 0) return NULL;
|
||||
}
|
||||
FFVulkanResult* vulkan = ffDetectVulkan();
|
||||
if (!vulkan->error && vulkan->gpus.length > 0)
|
||||
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_VULKAN)
|
||||
{
|
||||
ffListDestroy(result);
|
||||
ffListInitMove(result, &vulkan->gpus);
|
||||
return NULL;
|
||||
FFVulkanResult* vulkan = ffDetectVulkan();
|
||||
if (!vulkan->error && vulkan->gpus.length > 0)
|
||||
{
|
||||
ffListDestroy(result);
|
||||
ffListInitMove(result, &vulkan->gpus);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (options->detectionMethod <= FF_GPU_DETECTION_METHOD_OPENGL)
|
||||
{
|
||||
if (detectByOpenGL(result) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
if (detectByOpenGL(result) == NULL)
|
||||
return NULL;
|
||||
|
||||
return "GPU detection failed";
|
||||
}
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
#ifndef MAC_OS_VERSION_13_0
|
||||
#define MTLGPUFamilyMetal3 ((MTLGPUFamily) 5001)
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
#define MTLFeatureSet_macOS_GPUFamily1_v4 ((MTLFeatureSet) 10004)
|
||||
#define MTLFeatureSet_macOS_GPUFamily2_v1 ((MTLFeatureSet) 10005)
|
||||
#endif
|
||||
|
||||
const char* ffGpuDetectMetal(FFlist* gpus)
|
||||
{
|
||||
if (@available(macOS 10.15, *))
|
||||
if (@available(macOS 10.13, *))
|
||||
{
|
||||
for (id<MTLDevice> device in MTLCopyAllDevices())
|
||||
{
|
||||
@@ -23,6 +27,12 @@ const char* ffGpuDetectMetal(FFlist* gpus)
|
||||
}
|
||||
if (!gpu) continue;
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
if ([device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1])
|
||||
ffStrbufSetStatic(&gpu->platformApi, "Metal Feature Set 2");
|
||||
else if ([device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1])
|
||||
ffStrbufSetStatic(&gpu->platformApi, "Metal Feature Set 1");
|
||||
#else // MAC_OS_X_VERSION_10_15
|
||||
if ([device supportsFamily:MTLGPUFamilyMetal3])
|
||||
ffStrbufSetStatic(&gpu->platformApi, "Metal 3");
|
||||
else if ([device supportsFamily:MTLGPUFamilyCommon3])
|
||||
@@ -32,15 +42,16 @@ const char* ffGpuDetectMetal(FFlist* gpus)
|
||||
else if ([device supportsFamily:MTLGPUFamilyCommon1])
|
||||
ffStrbufSetStatic(&gpu->platformApi, "Metal Common 1");
|
||||
|
||||
if (device.hasUnifiedMemory)
|
||||
gpu->type = device.hasUnifiedMemory ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE;
|
||||
#endif
|
||||
|
||||
if (gpu->type == FF_GPU_TYPE_INTEGRATED)
|
||||
{
|
||||
gpu->type = FF_GPU_TYPE_INTEGRATED;
|
||||
gpu->shared.total = device.recommendedMaxWorkingSetSize;
|
||||
gpu->shared.used = device.currentAllocatedSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpu->type = FF_GPU_TYPE_DISCRETE;
|
||||
gpu->dedicated.total = device.recommendedMaxWorkingSetSize;
|
||||
gpu->dedicated.used = device.currentAllocatedSize;
|
||||
}
|
||||
|
||||
+143
-46
@@ -15,8 +15,68 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
static void pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer)
|
||||
#if __has_include(<drm/drm.h>)
|
||||
#include <drm/drm.h>
|
||||
#define FF_HAVE_DRM_H 1
|
||||
#elif __has_include(<libdrm/drm.h>)
|
||||
#include <libdrm/drm.h>
|
||||
#define FF_HAVE_DRM_H 1
|
||||
#endif
|
||||
|
||||
#if FF_HAVE_DRM_H
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if __aarch64__ && __has_include(<drm/asahi_drm.h>)
|
||||
#include <drm/asahi_drm.h>
|
||||
#define FF_HAVE_ASAHI_DRM_H 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if FF_HAVE_DRM_H
|
||||
static const char* drmDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer, const char* drmKey)
|
||||
{
|
||||
ffStrbufSetS(buffer, "/dev/dri/");
|
||||
ffStrbufAppendS(buffer, drmKey);
|
||||
FF_AUTO_CLOSE_FD int fd = open(buffer->chars, O_RDONLY);
|
||||
if (fd < 0) return "open(/dev/dri/drm_key) failed";
|
||||
|
||||
ffStrbufEnsureFixedLengthFree(&gpu->driver, 128);
|
||||
drm_version_t version = {
|
||||
.name = gpu->driver.chars,
|
||||
.name_len = gpu->driver.allocated,
|
||||
};
|
||||
if (ioctl(fd, DRM_IOCTL_VERSION, &version) < 0) return "ioctl(DRM_IOCTL_VERSION) failed";
|
||||
gpu->driver.length = (uint32_t) version.name_len;
|
||||
gpu->driver.chars[gpu->driver.length] = '\0';
|
||||
|
||||
if (version.version_major || version.version_minor || version.version_patchlevel)
|
||||
ffStrbufAppendF(&gpu->driver, " %d.%d.%d", version.version_major, version.version_minor, version.version_patchlevel);
|
||||
else
|
||||
{
|
||||
ffStrbufAppendS(pciDir, "/driver/module/version");
|
||||
if (ffReadFileBuffer(pciDir->chars, buffer))
|
||||
{
|
||||
ffStrbufTrimRightSpace(buffer);
|
||||
ffStrbufAppendC(&gpu->driver, ' ');
|
||||
ffStrbufAppend(&gpu->driver, buffer);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey)
|
||||
{
|
||||
#if FF_HAVE_DRM_H
|
||||
if (drmKey)
|
||||
{
|
||||
drmDetectDriver(gpu, pciDir, buffer, drmKey);
|
||||
if (gpu->driver.length > 0) return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
ffStrbufAppendS(pciDir, "/driver");
|
||||
char pathBuf[PATH_MAX];
|
||||
ssize_t resultLength = readlink(pciDir->chars, pathBuf, sizeof(pathBuf));
|
||||
@@ -35,8 +95,11 @@ static void pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer
|
||||
ffStrbufTrimRightSpace(buffer);
|
||||
ffStrbufAppendC(&gpu->driver, ' ');
|
||||
ffStrbufAppend(&gpu->driver, buffer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer)
|
||||
@@ -100,24 +163,26 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu,
|
||||
|
||||
static void pciDetectIntelSpecific(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer)
|
||||
{
|
||||
if (!ffStrbufEndsWithS(pciDir, "/device")) // Must be in `/sys/class/drm/cardN/device`
|
||||
return;
|
||||
|
||||
// Works for Intel GPUs
|
||||
// https://patchwork.kernel.org/project/intel-gfx/patch/1422039866-11572-3-git-send-email-ville.syrjala@linux.intel.com/
|
||||
ffStrbufSetNS(buffer, pciDir->length - (uint32_t) strlen("device"), pciDir->chars);
|
||||
ffStrbufAppendS(buffer, "gt_max_freq_mhz");
|
||||
char str[16];
|
||||
ssize_t len = ffReadFileData(buffer->chars, sizeof(str) - 1, str);
|
||||
if (len > 1)
|
||||
{
|
||||
str[len] = '\0';
|
||||
gpu->frequency = (double) strtoul(str, NULL, 10) / 1000.0;
|
||||
}
|
||||
|
||||
if (ffStrbufStartsWithS(&gpu->name, "Intel "))
|
||||
ffStrbufSubstrAfter(&gpu->name, (uint32_t) strlen("Intel "));
|
||||
gpu->type = ffStrbufStartsWithIgnCaseS(&gpu->name, "Arc ") ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
|
||||
|
||||
ffStrbufAppendS(pciDir, "/drm/");
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDir->chars);
|
||||
if (!dirp) return;
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dirp)) != NULL)
|
||||
{
|
||||
if (ffStrStartsWith(entry->d_name, "card")) break;
|
||||
}
|
||||
if (!entry) return;
|
||||
ffStrbufAppendS(pciDir, entry->d_name);
|
||||
ffStrbufAppendS(pciDir, "/gt_max_freq_mhz");
|
||||
if (ffReadFileBuffer(pciDir->chars, buffer))
|
||||
gpu->frequency = ffStrbufToDouble(buffer) / 1000.0;
|
||||
}
|
||||
|
||||
static bool loadPciIds(FFstrbuf* pciids)
|
||||
@@ -143,9 +208,9 @@ static bool loadPciIds(FFstrbuf* pciids)
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir)
|
||||
static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf* buffer, FFstrbuf* deviceDir, const char* drmKey)
|
||||
{
|
||||
const uint32_t drmDirPathLength = drmDir->length;
|
||||
const uint32_t drmDirPathLength = deviceDir->length;
|
||||
uint32_t vendorId, deviceId, subVendorId, subDeviceId;
|
||||
uint8_t classId, subclassId;
|
||||
if (sscanf(buffer->chars + strlen("pci:"), "v%8" SCNx32 "d%8" SCNx32 "sv%8" SCNx32 "sd%8" SCNx32 "bc%2" SCNx8 "sc%2" SCNx8, &vendorId, &deviceId, &subVendorId, &subDeviceId, &classId, &subclassId) != 6)
|
||||
@@ -155,15 +220,23 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
return "Not a GPU device";
|
||||
|
||||
char pciPath[PATH_MAX];
|
||||
ssize_t pathLength = readlink(drmDir->chars, pciPath, sizeof(pciPath) - 1);
|
||||
if (pathLength <= 0)
|
||||
return "Unable to get PCI device path";
|
||||
pciPath[pathLength] = '\0';
|
||||
const char* pPciPath = strrchr(pciPath, '/');
|
||||
if (pPciPath)
|
||||
pPciPath++;
|
||||
const char* pPciPath = NULL;
|
||||
if (drmKey)
|
||||
{
|
||||
ssize_t pathLength = readlink(deviceDir->chars, pciPath, sizeof(pciPath) - 1);
|
||||
if (pathLength <= 0)
|
||||
return "Unable to get PCI device path";
|
||||
pciPath[pathLength] = '\0';
|
||||
pPciPath = strrchr(pciPath, '/');
|
||||
if (__builtin_expect(pPciPath != NULL, true))
|
||||
pPciPath++;
|
||||
else
|
||||
pPciPath = pciPath;
|
||||
}
|
||||
else
|
||||
pPciPath = pciPath;
|
||||
{
|
||||
pPciPath = memrchr(deviceDir->chars, '/', deviceDir->length) + 1;
|
||||
}
|
||||
|
||||
uint32_t pciDomain, pciBus, pciDevice, pciFunc;
|
||||
if (sscanf(pPciPath, "%" SCNx32 ":%" SCNx32 ":%" SCNx32 ".%" SCNx32, &pciDomain, &pciBus, &pciDevice, &pciFunc) != 4)
|
||||
@@ -181,10 +254,12 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
gpu->deviceId = ((uint64_t) pciDomain << 6) | ((uint64_t) pciBus << 4) | (deviceId << 2) | pciFunc;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
|
||||
if (drmKey) ffStrbufSetF(&gpu->platformApi, "DRM (%s)", drmKey);
|
||||
|
||||
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD)
|
||||
{
|
||||
ffStrbufAppendS(drmDir, "/revision");
|
||||
if (ffReadFileBuffer(drmDir->chars, buffer))
|
||||
ffStrbufAppendS(deviceDir, "/revision");
|
||||
if (ffReadFileBuffer(deviceDir->chars, buffer))
|
||||
{
|
||||
char* pend;
|
||||
uint64_t revision = strtoul(buffer->chars, &pend, 16);
|
||||
@@ -199,7 +274,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
|
||||
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
|
||||
}
|
||||
|
||||
if (gpu->name.length == 0)
|
||||
@@ -213,18 +288,18 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu);
|
||||
}
|
||||
|
||||
pciDetectDriver(gpu, drmDir, buffer);
|
||||
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
|
||||
pciDetectDriver(gpu, deviceDir, buffer, drmKey);
|
||||
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
|
||||
|
||||
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD)
|
||||
{
|
||||
pciDetectAmdSpecific(options, gpu, drmDir, buffer);
|
||||
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
|
||||
pciDetectAmdSpecific(options, gpu, deviceDir, buffer);
|
||||
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
|
||||
}
|
||||
else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL)
|
||||
{
|
||||
pciDetectIntelSpecific(gpu, drmDir, buffer);
|
||||
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
|
||||
pciDetectIntelSpecific(gpu, deviceDir, buffer);
|
||||
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
|
||||
}
|
||||
else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA)
|
||||
{
|
||||
@@ -261,7 +336,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir)
|
||||
FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, const char* drmKey)
|
||||
{
|
||||
uint32_t index = ffStrbufFirstIndexS(buffer, "apple,agx-t");
|
||||
if (index == buffer->length) return "display-subsystem?";
|
||||
@@ -272,14 +347,34 @@ FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, F
|
||||
ffStrbufInitStatic(&gpu->name, ffCPUAppleCodeToName((uint32_t) gpu->deviceId));
|
||||
ffStrbufInitStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
ffStrbufInit(&gpu->platformApi);
|
||||
ffStrbufInitF(&gpu->platformApi, "DRM (%s)", drmKey);
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->type = FF_GPU_TYPE_INTEGRATED;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
|
||||
pciDetectDriver(gpu, drmDir, buffer);
|
||||
pciDetectDriver(gpu, drmDir, buffer, drmKey);
|
||||
|
||||
#if FF_HAVE_ASAHI_DRM_H
|
||||
ffStrbufSetS(buffer, "/dev/dri/");
|
||||
ffStrbufAppendS(buffer, drmKey);
|
||||
FF_AUTO_CLOSE_FD int fd = open(buffer->chars, O_RDONLY);
|
||||
if (fd >= 0)
|
||||
{
|
||||
struct drm_asahi_params_global paramsGlobal = {};
|
||||
if (ioctl(fd, DRM_IOCTL_ASAHI_GET_PARAMS, &(struct drm_asahi_get_params){
|
||||
.param_group = DRM_ASAHI_GET_PARAMS,
|
||||
.pointer = (uint64_t) ¶msGlobal,
|
||||
.size = sizeof(paramsGlobal),
|
||||
}) >= 0)
|
||||
{
|
||||
gpu->coreCount = (int) paramsGlobal.num_cores_total_active;
|
||||
gpu->frequency = paramsGlobal.max_frequency_khz / 1e6;
|
||||
gpu->deviceId = paramsGlobal.chip_id;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -311,10 +406,10 @@ static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
|
||||
ffStrbufSubstrBefore(&drmDir, drmDir.length - (uint32_t) strlen("/modalias"));
|
||||
|
||||
if (ffStrbufStartsWithS(&buffer, "pci:"))
|
||||
detectPci(options, gpus, &buffer, &drmDir);
|
||||
detectPci(options, gpus, &buffer, &drmDir, entry->d_name);
|
||||
#ifdef __aarch64__
|
||||
else if (ffStrbufStartsWithS(&buffer, "of:"))
|
||||
detectAsahi(gpus, &buffer, &drmDir);
|
||||
detectAsahi(gpus, &buffer, &drmDir, entry->d_name);
|
||||
#endif
|
||||
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
@@ -356,7 +451,7 @@ static const char* pciDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
|
||||
ffStrbufSubstrBefore(&pciDir, pciDevDirLength);
|
||||
assert(ffStrbufStartsWithS(&buffer, "pci:"));
|
||||
|
||||
detectPci(options, gpus, &buffer, &pciDir);
|
||||
detectPci(options, gpus, &buffer, &pciDir, NULL);
|
||||
ffStrbufSubstrBefore(&pciDir, pciBaseDirLength);
|
||||
}
|
||||
|
||||
@@ -365,14 +460,16 @@ 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)
|
||||
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;
|
||||
#endif
|
||||
|
||||
if (drmDetectGPUs(options, gpus) == NULL && gpus->length > 0)
|
||||
return NULL;
|
||||
|
||||
}
|
||||
return pciDetectGPUs(options, gpus);
|
||||
}
|
||||
|
||||
@@ -18,17 +18,24 @@ typedef struct FFSmbiosSystemInfo
|
||||
uint8_t ClockSeqHiAndReserved;
|
||||
uint8_t ClockSeqLow;
|
||||
uint8_t Node[6];
|
||||
} UUID; // varies
|
||||
} __attribute__((__packed__)) UUID; // varies
|
||||
uint8_t WakeUpType; // enum
|
||||
|
||||
// 2.4+
|
||||
uint8_t SKUNumber; // string
|
||||
uint8_t Family; // string
|
||||
} FFSmbiosSystemInfo;
|
||||
} __attribute__((__packed__)) FFSmbiosSystemInfo;
|
||||
|
||||
static_assert(offsetof(FFSmbiosSystemInfo, Family) == 0x1A,
|
||||
"FFSmbiosSystemInfo: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
const FFSmbiosSystemInfo* data = (const FFSmbiosSystemInfo*) (*ffGetSmbiosHeaderTable())[FF_SMBIOS_TYPE_SYSTEM_INFO];
|
||||
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
|
||||
if (!smbiosTable)
|
||||
return "Failed to get SMBIOS data";
|
||||
|
||||
const FFSmbiosSystemInfo* data = (const FFSmbiosSystemInfo*) (*smbiosTable)[FF_SMBIOS_TYPE_SYSTEM_INFO];
|
||||
if (!data)
|
||||
return "System information is not found in SMBIOS data";
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
const char* ffDetectLoadavg(double result[3]);
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "detection/loadavg/loadavg.h"
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/types.h>
|
||||
#include <sys/resource.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
const char* ffDetectLoadavg(double result[3])
|
||||
{
|
||||
struct loadavg load;
|
||||
size_t size = sizeof(load);
|
||||
if (sysctl((int []) { CTL_VM, VM_LOADAVG }, 2, &load, &size, NULL, 0) < 0)
|
||||
return "sysctl({CTL_VM, VM_LOADAVG}) failed";
|
||||
for (int i = 0; i < 3; i++)
|
||||
result[i] = (double) load.ldavg[i] / (double) load.fscale;
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "detection/loadavg/loadavg.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
const char* ffDetectLoadavg(double result[3])
|
||||
{
|
||||
#ifndef __ANDROID__ // cat: /proc/loadavg: Permission denied
|
||||
|
||||
// Don't use syscall for container compatibility. #620
|
||||
char buf[64];
|
||||
ssize_t nRead = ffReadFileData("/proc/uptime", sizeof(buf) - 1, buf);
|
||||
if (nRead > 0)
|
||||
{
|
||||
buf[nRead] = '\0';
|
||||
|
||||
if (sscanf(buf, "%lf %lf %lf", &result[0], &result[1], &result[2]) == 3)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// getloadavg requires higher ANDROID_API version
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "detection/loadavg/loadavg.h"
|
||||
|
||||
const char* ffDetectLoadavg(FF_MAYBE_UNUSED double result[3])
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <netpacket/packet.h>
|
||||
#endif
|
||||
|
||||
static void addNewIp(FFlist* list, const char* name, const char* addr, int type, bool defaultRoute)
|
||||
static void addNewIp(FFlist* list, const char* name, const char* addr, int type, bool defaultRoute, bool firstOnly)
|
||||
{
|
||||
FFLocalIpResult* ip = NULL;
|
||||
|
||||
@@ -40,11 +40,19 @@ static void addNewIp(FFlist* list, const char* name, const char* addr, int type,
|
||||
switch (type)
|
||||
{
|
||||
case AF_INET:
|
||||
if (ip->ipv4.length) ffStrbufAppendC(&ip->ipv4, ',');
|
||||
if (ip->ipv4.length)
|
||||
{
|
||||
if (firstOnly) return;
|
||||
ffStrbufAppendC(&ip->ipv4, ',');
|
||||
}
|
||||
ffStrbufAppendS(&ip->ipv4, addr);
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (ip->ipv6.length) ffStrbufAppendC(&ip->ipv6, ',');
|
||||
if (ip->ipv6.length)
|
||||
{
|
||||
if (firstOnly) return;
|
||||
ffStrbufAppendC(&ip->ipv6, ',');
|
||||
}
|
||||
ffStrbufAppendS(&ip->ipv6, addr);
|
||||
break;
|
||||
case -1:
|
||||
@@ -67,7 +75,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
continue;
|
||||
|
||||
bool isDefaultRoute = ffStrEquals(defaultRouteIfName, ifa->ifa_name);
|
||||
if (options->defaultRouteOnly && !isDefaultRoute)
|
||||
if ((options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) && !isDefaultRoute)
|
||||
continue;
|
||||
|
||||
if ((ifa->ifa_flags & IFF_LOOPBACK) && !(options->showType & FF_LOCALIP_TYPE_LOOP_BIT))
|
||||
@@ -96,7 +104,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
}
|
||||
}
|
||||
|
||||
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET, isDefaultRoute);
|
||||
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET, isDefaultRoute, !(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT));
|
||||
}
|
||||
else if (ifa->ifa_addr->sa_family == AF_INET6)
|
||||
{
|
||||
@@ -121,7 +129,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
}
|
||||
}
|
||||
|
||||
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET6, isDefaultRoute);
|
||||
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET6, isDefaultRoute, !(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT));
|
||||
}
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||
else if (ifa->ifa_addr->sa_family == AF_LINK)
|
||||
@@ -133,7 +141,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
uint8_t* ptr = (uint8_t*) LLADDR((struct sockaddr_dl *)ifa->ifa_addr);
|
||||
snprintf(addressBuffer, sizeof(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]);
|
||||
addNewIp(results, ifa->ifa_name, addressBuffer, -1, isDefaultRoute);
|
||||
addNewIp(results, ifa->ifa_name, addressBuffer, -1, isDefaultRoute, false);
|
||||
}
|
||||
#else
|
||||
else if (ifa->ifa_addr->sa_family == AF_PACKET)
|
||||
@@ -145,7 +153,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
uint8_t* ptr = ((struct sockaddr_ll *)ifa->ifa_addr)->sll_addr;
|
||||
snprintf(addressBuffer, sizeof(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]);
|
||||
addNewIp(results, ifa->ifa_name, addressBuffer, -1, isDefaultRoute);
|
||||
addNewIp(results, ifa->ifa_name, addressBuffer, -1, isDefaultRoute, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
for (IP_ADAPTER_ADDRESSES* adapter = adapter_addresses; adapter; adapter = adapter->Next)
|
||||
{
|
||||
bool isDefaultRoute = adapter->IfIndex == defaultRouteIfIndex;
|
||||
if (options->defaultRouteOnly && !isDefaultRoute)
|
||||
if ((options->showType & FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT) && !isDefaultRoute)
|
||||
continue;
|
||||
|
||||
bool isLoop = adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK;
|
||||
@@ -102,10 +102,14 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
newIp = false;
|
||||
}
|
||||
|
||||
uint32_t typesToAdd = options->showType & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_IPV6_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT);
|
||||
|
||||
for (IP_ADAPTER_UNICAST_ADDRESS* ifa = adapter->FirstUnicastAddress; ifa; ifa = ifa->Next)
|
||||
{
|
||||
if (ifa->Address.lpSockaddr->sa_family == AF_INET)
|
||||
{
|
||||
if (!(typesToAdd & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT))) continue;
|
||||
|
||||
SOCKADDR_IN* ipv4 = (SOCKADDR_IN*) ifa->Address.lpSockaddr;
|
||||
char addressBuffer[INET_ADDRSTRLEN + 4];
|
||||
inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN);
|
||||
@@ -118,9 +122,14 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
|
||||
addNewIp(results, name, addressBuffer, AF_INET, newIp, isDefaultRoute);
|
||||
newIp = false;
|
||||
|
||||
typesToAdd &= ~(unsigned) FF_LOCALIP_TYPE_IPV4_BIT;
|
||||
if (typesToAdd == 0) break;
|
||||
}
|
||||
else if (ifa->Address.lpSockaddr->sa_family == AF_INET6)
|
||||
{
|
||||
if (!(typesToAdd & (FF_LOCALIP_TYPE_IPV6_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT))) continue;
|
||||
|
||||
SOCKADDR_IN6* ipv6 = (SOCKADDR_IN6*) ifa->Address.lpSockaddr;
|
||||
char addressBuffer[INET6_ADDRSTRLEN + 4];
|
||||
inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN);
|
||||
@@ -133,6 +142,9 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
|
||||
addNewIp(results, name, addressBuffer, AF_INET6, newIp, isDefaultRoute);
|
||||
newIp = false;
|
||||
|
||||
typesToAdd &= ~(unsigned) FF_LOCALIP_TYPE_IPV6_BIT;
|
||||
if (typesToAdd == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,22 @@
|
||||
|
||||
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import));
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
#import <IOKit/graphics/IOGraphicsLib.h>
|
||||
extern CFDictionaryRef CoreDisplay_IODisplayCreateInfoDictionary(io_service_t framebuffer, IOOptionBits options) __attribute__((weak_import));
|
||||
#endif
|
||||
|
||||
static bool detectHdrSupportWithNSScreen(FFDisplayResult* display)
|
||||
{
|
||||
NSScreen* mainScreen = NSScreen.mainScreen;
|
||||
if (display->primary)
|
||||
{
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
return mainScreen.maximumPotentialExtendedDynamicRangeColorComponentValue > 1;
|
||||
#else
|
||||
return mainScreen.maximumExtendedDynamicRangeColorComponentValue > 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
for (NSScreen* screen in NSScreen.screens)
|
||||
@@ -22,7 +33,11 @@ static bool detectHdrSupportWithNSScreen(FFDisplayResult* display)
|
||||
NSNumber* screenNumber = [screen.deviceDescription valueForKey:@"NSScreenNumber"];
|
||||
if (screenNumber && screenNumber.longValue == (long) display->id)
|
||||
{
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
return screen.maximumPotentialExtendedDynamicRangeColorComponentValue > 1;
|
||||
#else
|
||||
return screen.maximumExtendedDynamicRangeColorComponentValue > 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,13 +46,19 @@ static bool detectHdrSupportWithNSScreen(FFDisplayResult* display)
|
||||
|
||||
const char* ffDetectMonitor(FFlist* results)
|
||||
{
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
if(!CoreDisplay_DisplayCreateInfoDictionary) return "CoreDisplay_DisplayCreateInfoDictionary is not available";
|
||||
|
||||
#endif
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
|
||||
FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays)
|
||||
{
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary((CGDirectDisplayID) display->id);
|
||||
#else
|
||||
io_service_t servicePort = CGDisplayIOServicePort((CGDirectDisplayID) display->id);
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName);
|
||||
#endif
|
||||
if(!displayInfo) continue;
|
||||
|
||||
bool isVirtual = false;
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
#include "detection/opencl/opencl.h"
|
||||
|
||||
#if defined(FF_HAVE_OPENCL) || defined(__APPLE__)
|
||||
#ifdef __APPLE__
|
||||
#include <AvailabilityMacros.h>
|
||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED > 1050) && !defined(__ppc__)
|
||||
#define MACOS_HAS_OPENCL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(FF_HAVE_OPENCL) || defined(MACOS_HAS_OPENCL)
|
||||
|
||||
#include "common/library.h"
|
||||
#include "common/parsing.h"
|
||||
@@ -64,7 +71,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // defined(FF_HAVE_OPENCL) || defined(__APPLE__)
|
||||
#endif // defined(FF_HAVE_OPENCL) || defined(MACOS_HAS_OPENCL)
|
||||
|
||||
const char* ffDetectOpenCL(FFOpenCLResult* result)
|
||||
{
|
||||
@@ -84,7 +91,7 @@ const char* ffDetectOpenCL(FFOpenCLResult* result)
|
||||
|
||||
return openCLHandleData(&data, result);
|
||||
|
||||
#elif defined(__APPLE__) // FF_HAVE_OPENCL
|
||||
#elif defined(MACOS_HAS_OPENCL) // FF_HAVE_OPENCL
|
||||
|
||||
OpenCLData data;
|
||||
data.ffclGetPlatformIDs = clGetPlatformIDs;
|
||||
|
||||
@@ -97,8 +97,7 @@ void ffDetectOSImpl(FFOSResult* os)
|
||||
{
|
||||
parseSystemVersion(os);
|
||||
|
||||
if(ffStrbufStartsWithIgnCaseS(&os->name, "MacOS"))
|
||||
ffStrbufSetStatic(&os->id, "macos");
|
||||
ffStrbufSetStatic(&os->id, "macos");
|
||||
|
||||
if(os->version.length == 0)
|
||||
ffSysctlGetString("kern.osproductversion", &os->version);
|
||||
|
||||
@@ -31,7 +31,7 @@ static bool parseLsbRelease(const char* fileName, FFOSResult* result)
|
||||
|
||||
static bool parseOsRelease(const char* fileName, FFOSResult* result)
|
||||
{
|
||||
return ffParsePropFileValues(fileName, 10, (FFpropquery[]) {
|
||||
return ffParsePropFileValues(fileName, 11, (FFpropquery[]) {
|
||||
{"PRETTY_NAME =", &result->prettyName},
|
||||
{"NAME =", &result->name},
|
||||
{"ID =", &result->id},
|
||||
@@ -41,7 +41,8 @@ static bool parseOsRelease(const char* fileName, FFOSResult* result)
|
||||
{"VERSION =", &result->version},
|
||||
{"VERSION_ID =", &result->versionID},
|
||||
{"VERSION_CODENAME =", &result->codename},
|
||||
{"BUILD_ID =", &result->buildID}
|
||||
{"CODENAME =", &result->codename},
|
||||
{"BUILD_ID =", &result->buildID},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -156,6 +157,12 @@ static bool detectDebianDerived(FFOSResult* result)
|
||||
ffStrbufSetNS(&result->versionID, versionEnd - versionStart, result->prettyName.chars + versionStart);
|
||||
return true;
|
||||
}
|
||||
else if (ffStrbufStartsWithS(&result->name, "Loc-OS"))
|
||||
{
|
||||
ffStrbufSetS(&result->id, "locos");
|
||||
ffStrbufSetS(&result->idLike, "debian");
|
||||
return true;
|
||||
}
|
||||
else if (ffPathExists("/usr/bin/pveversion", FF_PATHTYPE_FILE))
|
||||
{
|
||||
ffStrbufSetS(&result->id, "pve");
|
||||
|
||||
@@ -14,6 +14,8 @@ typedef struct FFPackagesResult
|
||||
uint32_t eopkg;
|
||||
uint32_t flatpakSystem;
|
||||
uint32_t flatpakUser;
|
||||
uint32_t lpkg;
|
||||
uint32_t lpkgbuild;
|
||||
uint32_t nixDefault;
|
||||
uint32_t nixSystem;
|
||||
uint32_t nixUser;
|
||||
|
||||
@@ -412,6 +412,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts,
|
||||
{
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_APK_BIT)) packageCounts->apk += getNumStrings(baseDir, "/lib/apk/db/installed", "C:Q");
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_DPKG_BIT)) packageCounts->dpkg += getNumStrings(baseDir, "/var/lib/dpkg/status", "Status: install ok installed");
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_LPKG_BIT)) packageCounts->lpkg += getNumStrings(baseDir, "/opt/Loc-OS-LPKG/installed-lpkg/Listinstalled-lpkg.list", "\n");
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_EMERGE_BIT)) packageCounts->emerge += countFilesRecursive(baseDir, "/var/db/pkg", "SIZE");
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_EOPKG_BIT)) packageCounts->eopkg += getNumElements(baseDir, "/var/lib/eopkg/package", DT_DIR);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_FLATPAK_BIT)) packageCounts->flatpakSystem += getFlatpak(baseDir, "/var/lib/flatpak");
|
||||
@@ -421,6 +422,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts,
|
||||
packageCounts->nixSystem += getNixPackages(baseDir, "/run/current-system");
|
||||
}
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_PACMAN_BIT)) packageCounts->pacman += getNumElements(baseDir, "/var/lib/pacman/local", DT_DIR);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_LPKGBUILD_BIT)) packageCounts->lpkgbuild += getNumElements(baseDir, "/opt/Loc-OS-LPKG/lpkgbuild/remove", DT_REG);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_PKGTOOL_BIT)) packageCounts->pkgtool += getNumElements(baseDir, "/var/log/packages", DT_REG);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_RPM_BIT)) packageCounts->rpm += getSQLite3Int(baseDir, "/var/lib/rpm/rpmdb.sqlite", "SELECT count(*) FROM Packages");
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_SNAP_BIT)) packageCounts->snap += getSnap(baseDir);
|
||||
@@ -508,30 +510,28 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
|
||||
ffStrbufAppendS(&profilePath, ".nix-profile");
|
||||
if (ffPathExists(profilePath.chars, FF_PATHTYPE_DIRECTORY))
|
||||
{
|
||||
result->nixUser = getNixPackages(&baseDir, ".nix-profile");
|
||||
result->nixUser += getNixPackages(&baseDir, ".nix-profile");
|
||||
}
|
||||
|
||||
// check if $XDG_STATE_HOME/nix/profile exists
|
||||
FF_STRBUF_AUTO_DESTROY stateDir = ffStrbufCreate();
|
||||
const char* stateHome = getenv("XDG_STATE_HOME");
|
||||
if(ffStrSet(stateHome))
|
||||
{
|
||||
ffStrbufSetS(&stateDir, stateHome);
|
||||
ffStrbufEnsureEndsWithC(&stateDir, '/');
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY stateDir = ffStrbufCreate();
|
||||
const char* stateHome = getenv("XDG_STATE_HOME");
|
||||
if(ffStrSet(stateHome))
|
||||
{
|
||||
ffStrbufSetS(&stateDir, stateHome);
|
||||
ffStrbufEnsureEndsWithC(&stateDir, '/');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffStrbufSet(&stateDir, &instance.state.platform.homeDir);
|
||||
ffStrbufAppendS(&stateDir, ".local/state/");
|
||||
}
|
||||
|
||||
ffStrbufSet(&profilePath, &stateDir);
|
||||
ffStrbufAppendS(&profilePath, "nix/profile");
|
||||
result->nixUser = getNixPackages(&stateDir, "nix/profile");
|
||||
ffStrbufSet(&stateDir, &instance.state.platform.homeDir);
|
||||
ffStrbufAppendS(&stateDir, ".local/state/");
|
||||
}
|
||||
|
||||
ffStrbufSet(&profilePath, &stateDir);
|
||||
ffStrbufAppendS(&profilePath, "nix/profile");
|
||||
result->nixUser += getNixPackages(&stateDir, "nix/profile");
|
||||
}
|
||||
|
||||
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_FLATPAK_BIT))
|
||||
result->flatpakUser = getFlatpak(&baseDir, "/.local/share/flatpak");
|
||||
}
|
||||
|
||||
@@ -7,17 +7,22 @@
|
||||
#include <IOKit/storage/IOBlockStorageDriver.h>
|
||||
#include <IOKit/storage/IOStorageDeviceCharacteristics.h>
|
||||
#include <IOKit/storage/IOStorageProtocolCharacteristics.h>
|
||||
#include <IOKit/storage/nvme/NVMeSMARTLibExternal.h>
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
#include <IOKit/storage/nvme/NVMeSMARTLibExternal.h>
|
||||
#endif
|
||||
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
static inline void wrapIoDestroyPlugInInterface(IOCFPlugInInterface*** pluginInf)
|
||||
{
|
||||
assert(pluginInf);
|
||||
if (*pluginInf)
|
||||
IODestroyPlugInInterface(*pluginInf);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char* detectSsdTemp(io_service_t entryPhysical, double* temp)
|
||||
{
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
__attribute__((__cleanup__(wrapIoDestroyPlugInInterface))) IOCFPlugInInterface** pluginInf = NULL;
|
||||
int32_t score;
|
||||
if (IOCreatePlugInInterfaceForService(entryPhysical, kIONVMeSMARTUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInf, &score) != kIOReturnSuccess)
|
||||
@@ -36,6 +41,9 @@ static const char* detectSsdTemp(io_service_t entryPhysical, double* temp)
|
||||
|
||||
(*pluginInf)->Release(smartInf);
|
||||
return error;
|
||||
#else
|
||||
return "No support for old MacOS version";
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
@@ -117,12 +125,14 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
if (options->temp)
|
||||
{
|
||||
FF_CFTYPE_AUTO_RELEASE CFBooleanRef nvmeSMARTCapable = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyNVMeSMARTCapableKey), kCFAllocatorDefault, kNilOptions);
|
||||
if (nvmeSMARTCapable && CFBooleanGetValue(nvmeSMARTCapable))
|
||||
detectSsdTemp(entryPhysical, &device->temperature);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "physicalmemory.h"
|
||||
|
||||
static inline const char* getVendorString(unsigned vendorId)
|
||||
{
|
||||
switch (vendorId)
|
||||
{
|
||||
case 0x017A: return "Apacer";
|
||||
case 0x0198: return "Kingston";
|
||||
case 0x029E: return "Corsair";
|
||||
case 0x04CB: return "A-DATA";
|
||||
case 0x04CD: return "G-Skill";
|
||||
case 0x059B: case 0x859B: return "Crucial";
|
||||
case 0x00CE: case 0x80CE: case 0xCE00: return "Samsung";
|
||||
case 0x014F: return "Transcend";
|
||||
case 0x2C00: case 0x802C: return "Micron";
|
||||
case 0xAD00: case 0x80AD: return "SK Hynix";
|
||||
case 0x5105: case 0x8551: return "Qimonda";
|
||||
case 0x02FE: return "Elpida";
|
||||
case 0x0467: return "Ramaxel";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void FFPhysicalMemoryUpdateVendorString(FFPhysicalMemoryResult* device)
|
||||
{
|
||||
char vendorIdStr[5];
|
||||
if (ffStrbufStartsWithS(&device->vendor, "0x"))
|
||||
{
|
||||
if (device->vendor.length < 6) return;
|
||||
memcpy(vendorIdStr, device->vendor.chars + 2, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (device->vendor.length < 4) return;
|
||||
memcpy(vendorIdStr, device->vendor.chars, 4);
|
||||
}
|
||||
vendorIdStr[4] = '\0';
|
||||
char* pEnd = NULL;
|
||||
uint32_t vendorId = (uint32_t) strtoul(vendorIdStr, &pEnd, 16);
|
||||
if (*pEnd != '\0') return;
|
||||
const char* vendorStr = getVendorString(vendorId);
|
||||
if (vendorStr) ffStrbufSetStatic(&device->vendor, vendorStr);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFPhysicalMemoryResult
|
||||
{
|
||||
uint64_t size; // B
|
||||
uint32_t maxSpeed; // MT/s
|
||||
uint32_t runningSpeed; // MT/s
|
||||
FFstrbuf type;
|
||||
FFstrbuf formFactor;
|
||||
FFstrbuf locator;
|
||||
FFstrbuf partNumber;
|
||||
FFstrbuf vendor;
|
||||
FFstrbuf serial;
|
||||
bool ecc;
|
||||
} FFPhysicalMemoryResult;
|
||||
|
||||
const char* ffDetectPhysicalMemory(FFlist* result); // list of FFPhysicalMemoryResult
|
||||
|
||||
void FFPhysicalMemoryUpdateVendorString(FFPhysicalMemoryResult* device);
|
||||
@@ -0,0 +1,121 @@
|
||||
#include "physicalmemory.h"
|
||||
#include "common/processing.h"
|
||||
#include "util/smbiosHelper.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
static void appendDevice(
|
||||
FFlist* result,
|
||||
NSString* type,
|
||||
NSString* vendor,
|
||||
NSString* size,
|
||||
|
||||
// Intel only
|
||||
NSString* locator,
|
||||
NSString* serial,
|
||||
NSString* partNumber,
|
||||
NSString* speed,
|
||||
bool ecc)
|
||||
{
|
||||
FFPhysicalMemoryResult* device = ffListAdd(result);
|
||||
ffStrbufInitS(&device->type, type.UTF8String);
|
||||
ffStrbufInit(&device->formFactor);
|
||||
ffStrbufInitS(&device->locator, locator.UTF8String);
|
||||
ffStrbufInitS(&device->vendor, vendor.UTF8String);
|
||||
FFPhysicalMemoryUpdateVendorString(device);
|
||||
ffStrbufInitS(&device->serial, serial.UTF8String);
|
||||
ffCleanUpSmbiosValue(&device->serial);
|
||||
ffStrbufInitS(&device->partNumber, partNumber.UTF8String);
|
||||
ffCleanUpSmbiosValue(&device->partNumber);
|
||||
device->size = 0;
|
||||
device->maxSpeed = 0;
|
||||
device->runningSpeed = 0;
|
||||
device->ecc = ecc;
|
||||
|
||||
if (size)
|
||||
{
|
||||
char* unit = NULL;
|
||||
device->size = strtoul(size.UTF8String, &unit, 10);
|
||||
if (*unit == ' ') ++unit;
|
||||
|
||||
switch (*unit)
|
||||
{
|
||||
case 'G': device->size *= 1024ULL * 1024 * 1024; break;
|
||||
case 'M': device->size *= 1024ULL * 1024; break;
|
||||
case 'K': device->size *= 1024ULL; break;
|
||||
case 'T': device->size *= 1024ULL * 1024 * 1024 * 1024; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (speed)
|
||||
{
|
||||
char* unit = NULL;
|
||||
device->maxSpeed = (uint32_t) strtoul(speed.UTF8String, &unit, 10);
|
||||
if (*unit == ' ') ++unit;
|
||||
|
||||
switch (*unit)
|
||||
{
|
||||
case 'T': device->maxSpeed *= 1000 * 1000; break;
|
||||
case 'G': device->maxSpeed *= 1000; break;
|
||||
case 'K': device->maxSpeed /= 1000; break;
|
||||
}
|
||||
device->runningSpeed = device->maxSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
const char* ffDetectPhysicalMemory(FFlist* result)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) {
|
||||
"system_profiler",
|
||||
"SPMemoryDataType",
|
||||
"-xml",
|
||||
"-detailLevel",
|
||||
"full",
|
||||
NULL
|
||||
}) != NULL)
|
||||
return "Starting `system_profiler SPMemoryDataType -xml -detailLevel full` failed";
|
||||
|
||||
NSArray* arr = [NSPropertyListSerialization propertyListWithData:[NSData dataWithBytes:buffer.chars length:buffer.length]
|
||||
options:NSPropertyListImmutable
|
||||
format:nil
|
||||
error:nil];
|
||||
if (!arr || !arr.count)
|
||||
return "system_profiler SPMemoryDataType returned an empty array";
|
||||
|
||||
for (NSDictionary* data in arr[0][@"_items"])
|
||||
{
|
||||
if (data[@"_items"])
|
||||
{
|
||||
// for Intel
|
||||
for (NSDictionary* item in data[@"_items"])
|
||||
{
|
||||
appendDevice(result,
|
||||
item[@"dimm_type"],
|
||||
item[@"dimm_manufacturer"],
|
||||
item[@"dimm_size"],
|
||||
item[@"_name"],
|
||||
item[@"dimm_serial_number"],
|
||||
item[@"dimm_part_number"],
|
||||
item[@"dimm_speed"],
|
||||
!![data[@"global_ecc_state"] isEqualToString:@"ecc_enabled"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// for Apple Silicon
|
||||
appendDevice(result,
|
||||
data[@"dimm_type"],
|
||||
data[@"dimm_manufacturer"],
|
||||
data[@"SPMemoryDataType"],
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
#include "physicalmemory.h"
|
||||
#include "util/smbiosHelper.h"
|
||||
|
||||
// 7.18
|
||||
typedef struct FFSmbiosMemoryDevice
|
||||
{
|
||||
FFSmbiosHeader Header;
|
||||
|
||||
// 2.1+
|
||||
uint16_t PhysicalMemoryArrayHandle; // varies
|
||||
uint16_t MemoryErrorInformationHandle; //varies
|
||||
uint16_t TotalWidth; // varies
|
||||
uint16_t DataWidth; // varies
|
||||
uint16_t Size; // varies
|
||||
uint8_t FormFactor; // enum
|
||||
uint8_t DeviceSet; // varies
|
||||
uint8_t DeviceLocator; // string
|
||||
uint8_t BankLocator; // string
|
||||
uint8_t MemoryType; // enum
|
||||
uint16_t TypeDetail; // bit field
|
||||
|
||||
// 2.3+
|
||||
uint16_t Speed; // varies
|
||||
uint8_t Manufacturer; // string
|
||||
uint8_t SerialNumber; // string
|
||||
uint8_t AssetTag; // string
|
||||
uint8_t PartNumber; // string
|
||||
|
||||
// 2.6+
|
||||
uint8_t Attributes; // varies
|
||||
|
||||
// 2.7+
|
||||
uint32_t ExtendedSize; // varies
|
||||
uint16_t ConfiguredMemorySpeed; // varies
|
||||
|
||||
// 2.8+
|
||||
uint16_t MinimumVoltage; // varies
|
||||
uint16_t MaximumVoltage; // varies
|
||||
uint16_t ConfiguredVoltage; // varies
|
||||
|
||||
// 3.2+
|
||||
uint8_t MemoryTechnology; // varies
|
||||
uint16_t MemoryOperatingMode; // bit field
|
||||
uint8_t FirmwareVersion; // string
|
||||
uint16_t ModuleManufacturerID; // varies
|
||||
uint16_t ModuleProductID; // varies
|
||||
uint16_t MemorySubsystemControllerManufacturerID; // vaies
|
||||
uint16_t MemorySubsystemControllerProductID; // varies
|
||||
uint64_t NonVolatileSize; // varies
|
||||
uint64_t VolatileSize; // varies
|
||||
uint64_t CacheSize; // varies
|
||||
uint64_t LogicalSize; // varies
|
||||
|
||||
// 3.3+
|
||||
uint32_t ExtendedSpeed; // varies
|
||||
uint32_t ExtendedConfiguredSpeed; // varies
|
||||
|
||||
// 3.7+
|
||||
uint16_t Pmic0ManufacturerID; // varies
|
||||
uint16_t Pmic0RevisionNumber; // varies
|
||||
uint16_t RcdManufacturerID; // varies
|
||||
uint16_t RcdRevisionNumber; // varies
|
||||
} __attribute__((__packed__)) FFSmbiosMemoryDevice;
|
||||
|
||||
static_assert(offsetof(FFSmbiosMemoryDevice, RcdRevisionNumber) == 0x62,
|
||||
"FFSmbiosMemoryDevice: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectPhysicalMemory(FFlist* result)
|
||||
{
|
||||
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
|
||||
if (!smbiosTable)
|
||||
return "Failed to get SMBIOS data";
|
||||
|
||||
const FFSmbiosMemoryDevice* data = (const FFSmbiosMemoryDevice*) (*smbiosTable)[FF_SMBIOS_TYPE_MEMORY_DEVICE];
|
||||
if (!data)
|
||||
return "Memory device is not found in SMBIOS data";
|
||||
|
||||
for (; data->Header.Type == FF_SMBIOS_TYPE_MEMORY_DEVICE;
|
||||
data = (const FFSmbiosMemoryDevice*) ffSmbiosNextEntry(&data->Header))
|
||||
{
|
||||
if (data->Size == 0) continue;
|
||||
|
||||
const char* strings = (const char*) data + data->Header.Length;
|
||||
|
||||
FFPhysicalMemoryResult* device = ffListAdd(result);
|
||||
ffStrbufInit(&device->type);
|
||||
ffStrbufInit(&device->formFactor);
|
||||
ffStrbufInit(&device->locator);
|
||||
ffStrbufInit(&device->vendor);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->partNumber);
|
||||
device->size = 0;
|
||||
device->maxSpeed = 0;
|
||||
device->runningSpeed = 0;
|
||||
device->ecc = false;
|
||||
|
||||
if (data->TotalWidth != 0xFFFF && data->DataWidth != 0xFFFF)
|
||||
device->ecc = data->TotalWidth > data->DataWidth;
|
||||
|
||||
if (data->Size != 0xFFFF)
|
||||
{
|
||||
if (data->Size == 0x7FFF)
|
||||
device->size = (data->ExtendedSize & ~(1 << 31)) * 1024 * 1024;
|
||||
else if (data->Size & (1 << 15))
|
||||
{
|
||||
// in kB
|
||||
device->size = (data->Size & ~(1u << 15)) * 1024ULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// in MB
|
||||
device->size = data->Size * 1024ULL * 1024ULL;
|
||||
}
|
||||
}
|
||||
|
||||
ffStrbufSetF(&device->locator, "%s/%s", ffSmbiosLocateString(strings, data->BankLocator), ffSmbiosLocateString(strings, data->DeviceLocator));
|
||||
|
||||
switch (data->FormFactor)
|
||||
{
|
||||
case 0x01: ffStrbufSetStatic(&device->formFactor, "Other"); break;
|
||||
case 0x02: ffStrbufSetStatic(&device->formFactor, "Unknown"); break;
|
||||
case 0x03: ffStrbufSetStatic(&device->formFactor, "SIMM"); break;
|
||||
case 0x04: ffStrbufSetStatic(&device->formFactor, "SIP"); break;
|
||||
case 0x05: ffStrbufSetStatic(&device->formFactor, "Chip"); break;
|
||||
case 0x06: ffStrbufSetStatic(&device->formFactor, "DIP"); break;
|
||||
case 0x07: ffStrbufSetStatic(&device->formFactor, "ZIP"); break;
|
||||
case 0x08: ffStrbufSetStatic(&device->formFactor, "Proprietary Card"); break;
|
||||
case 0x09: ffStrbufSetStatic(&device->formFactor, "DIMM"); break;
|
||||
case 0x0A: ffStrbufSetStatic(&device->formFactor, "TSOP"); break;
|
||||
case 0x0B: ffStrbufSetStatic(&device->formFactor, "Row of chips"); break;
|
||||
case 0x0C: ffStrbufSetStatic(&device->formFactor, "RIMM"); break;
|
||||
case 0x0D: ffStrbufSetStatic(&device->formFactor, "SODIMM"); break;
|
||||
case 0x0E: ffStrbufSetStatic(&device->formFactor, "SRIMM"); break;
|
||||
case 0x0F: ffStrbufSetStatic(&device->formFactor, "FBDIMM"); break;
|
||||
case 0x10: ffStrbufSetStatic(&device->formFactor, "Die"); break;
|
||||
default: ffStrbufSetF(&device->formFactor, "Unknown (%d)", (int) data->FormFactor); break;
|
||||
}
|
||||
|
||||
switch (data->MemoryType)
|
||||
{
|
||||
case 0x01: ffStrbufSetStatic(&device->type, "Other"); break;
|
||||
case 0x02: ffStrbufSetStatic(&device->type, "Unknown"); break;
|
||||
case 0x03: ffStrbufSetStatic(&device->type, "DRAM"); break;
|
||||
case 0x04: ffStrbufSetStatic(&device->type, "EDRAM"); break;
|
||||
case 0x05: ffStrbufSetStatic(&device->type, "VRAM"); break;
|
||||
case 0x06: ffStrbufSetStatic(&device->type, "SRAM"); break;
|
||||
case 0x07: ffStrbufSetStatic(&device->type, "RAM"); break;
|
||||
case 0x08: ffStrbufSetStatic(&device->type, "ROM"); break;
|
||||
case 0x09: ffStrbufSetStatic(&device->type, "FLASH"); break;
|
||||
case 0x0A: ffStrbufSetStatic(&device->type, "EEPROM"); break;
|
||||
case 0x0B: ffStrbufSetStatic(&device->type, "FEPROM"); break;
|
||||
case 0x0C: ffStrbufSetStatic(&device->type, "EPROM"); break;
|
||||
case 0x0D: ffStrbufSetStatic(&device->type, "CDRAM"); break;
|
||||
case 0x0E: ffStrbufSetStatic(&device->type, "3DRAM"); break;
|
||||
case 0x0F: ffStrbufSetStatic(&device->type, "SDRAM"); break;
|
||||
case 0x10: ffStrbufSetStatic(&device->type, "SGRAM"); break;
|
||||
case 0x11: ffStrbufSetStatic(&device->type, "RDRAM"); break;
|
||||
case 0x12: ffStrbufSetStatic(&device->type, "DDR"); break;
|
||||
case 0x13: ffStrbufSetStatic(&device->type, "DDR2"); break;
|
||||
case 0x14: ffStrbufSetStatic(&device->type, "DDR2 FB-DIMM"); break;
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
case 0x17: ffStrbufSetStatic(&device->type, "Reserved"); break;
|
||||
case 0x18: ffStrbufSetStatic(&device->type, "DDR3"); break;
|
||||
case 0x19: ffStrbufSetStatic(&device->type, "FBD2"); break;
|
||||
case 0x1A: ffStrbufSetStatic(&device->type, "DDR4"); break;
|
||||
case 0x1B: ffStrbufSetStatic(&device->type, "LPDDR"); break;
|
||||
case 0x1C: ffStrbufSetStatic(&device->type, "LPDDR2"); break;
|
||||
case 0x1D: ffStrbufSetStatic(&device->type, "LPDDR3"); break;
|
||||
case 0x1E: ffStrbufSetStatic(&device->type, "LPDDR4"); break;
|
||||
case 0x1F: ffStrbufSetStatic(&device->type, "Logical non-volatile device"); break;
|
||||
case 0x20: ffStrbufSetStatic(&device->type, "HBM"); break;
|
||||
case 0x21: ffStrbufSetStatic(&device->type, "HBM2"); break;
|
||||
case 0x22: ffStrbufSetStatic(&device->type, "DDR5"); break;
|
||||
case 0x23: ffStrbufSetStatic(&device->type, "LPDDR5"); break;
|
||||
case 0x24: ffStrbufSetStatic(&device->type, "HBM3"); break;
|
||||
default: ffStrbufSetF(&device->type, "Unknown (%d)", (int) data->MemoryType); break;
|
||||
}
|
||||
|
||||
if (data->Header.Length > offsetof(FFSmbiosMemoryDevice, Speed)) // 2.3+
|
||||
{
|
||||
if (data->Speed)
|
||||
device->maxSpeed = data->Speed == 0xFFFF ? data->ExtendedSpeed : data->Speed;
|
||||
|
||||
ffStrbufSetStatic(&device->vendor, ffSmbiosLocateString(strings, data->Manufacturer));
|
||||
FFPhysicalMemoryUpdateVendorString(device);
|
||||
|
||||
ffStrbufSetStatic(&device->serial, ffSmbiosLocateString(strings, data->SerialNumber));
|
||||
ffCleanUpSmbiosValue(&device->serial);
|
||||
|
||||
ffStrbufSetStatic(&device->partNumber, ffSmbiosLocateString(strings, data->PartNumber));
|
||||
ffCleanUpSmbiosValue(&device->partNumber);
|
||||
}
|
||||
|
||||
if (data->Header.Length > offsetof(FFSmbiosMemoryDevice, ConfiguredMemorySpeed)) // 2.7+
|
||||
{
|
||||
if (data->ConfiguredMemorySpeed)
|
||||
device->runningSpeed = data->ConfiguredMemorySpeed == 0xFFFF
|
||||
? data->ExtendedConfiguredSpeed : data->ConfiguredMemorySpeed;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "physicalmemory.h"
|
||||
|
||||
const char* ffDetectPhysicalMemory(FF_MAYBE_UNUSED FFlist* result)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -2,21 +2,24 @@
|
||||
#include "common/networking.h"
|
||||
|
||||
#define FF_UNITIALIZED ((const char*)(uintptr_t) -1)
|
||||
static FFNetworkingState state;
|
||||
static const char* status = FF_UNITIALIZED;
|
||||
static FFNetworkingState states[2];
|
||||
static const char* statuses[2] = { FF_UNITIALIZED, FF_UNITIALIZED };
|
||||
|
||||
void ffPreparePublicIp(FFPublicIpOptions* options)
|
||||
{
|
||||
if (status != FF_UNITIALIZED)
|
||||
FFNetworkingState* state = &states[options->ipv6];
|
||||
const char** status = &statuses[options->ipv6];
|
||||
if (*status != FF_UNITIALIZED)
|
||||
{
|
||||
fputs("Error: this module can only be used once due to internal limitations\n", stderr);
|
||||
fputs("Error: PublicIp module can only be used once due to internal limitations\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
state.timeout = options->timeout;
|
||||
state->timeout = options->timeout;
|
||||
state->ipv6 = options->ipv6;
|
||||
|
||||
if (options->url.length == 0)
|
||||
status = ffNetworkingSendHttpRequest(&state, "ipinfo.io", "/json", NULL);
|
||||
*status = ffNetworkingSendHttpRequest(state, options->ipv6 ? "v6.ipinfo.io" : "ipinfo.io", "/json", NULL);
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY host = ffStrbufCreateCopy(&options->url);
|
||||
@@ -40,7 +43,7 @@ void ffPreparePublicIp(FFPublicIpOptions* options)
|
||||
host.chars[pathStartIndex] = '\0';
|
||||
}
|
||||
|
||||
status = ffNetworkingSendHttpRequest(&state, host.chars, path.length == 0 ? "/" : path.chars, NULL);
|
||||
*status = ffNetworkingSendHttpRequest(state, host.chars, path.length == 0 ? "/" : path.chars, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,14 +56,16 @@ static inline void wrapYyjsonFree(yyjson_doc** doc)
|
||||
|
||||
const char* ffDetectPublicIp(FFPublicIpOptions* options, FFPublicIpResult* result)
|
||||
{
|
||||
if (status == FF_UNITIALIZED)
|
||||
FFNetworkingState* state = &states[options->ipv6];
|
||||
const char** status = &statuses[options->ipv6];
|
||||
if (*status == FF_UNITIALIZED)
|
||||
ffPreparePublicIp(options);
|
||||
|
||||
if (status != NULL)
|
||||
return status;
|
||||
if (*status != NULL)
|
||||
return *status;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY response = ffStrbufCreateA(4096);
|
||||
const char* error = ffNetworkingRecvHttpResponse(&state, &response);
|
||||
const char* error = ffNetworkingRecvHttpResponse(state, &response);
|
||||
if (error == NULL)
|
||||
ffStrbufSubstrAfterFirstS(&response, "\r\n\r\n");
|
||||
else
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "common/properties.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/processing.h"
|
||||
#include "detection/terminalshell/terminalshell.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "util/mallocHelper.h"
|
||||
@@ -265,9 +266,9 @@ static void detectXterm(FFTerminalFontResult* terminalFont)
|
||||
ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars);
|
||||
}
|
||||
|
||||
static void detectSt(FFTerminalFontResult* terminalFont, uint32_t pid)
|
||||
static void detectSt(FFTerminalFontResult* terminalFont, const FFTerminalResult* terminal)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY size = ffStrbufCreateF("/proc/%u/cmdline", pid);
|
||||
FF_STRBUF_AUTO_DESTROY size = ffStrbufCreateF("/proc/%u/cmdline", terminal->pid);
|
||||
FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate();
|
||||
if (!ffAppendFileBuffer(size.chars, &font))
|
||||
{
|
||||
@@ -276,20 +277,53 @@ static void detectSt(FFTerminalFontResult* terminalFont, uint32_t pid)
|
||||
}
|
||||
|
||||
const char* p = memmem(font.chars, font.length, "\0-f", sizeof("\0-f")); // find parameter of `-f`
|
||||
if (!p)
|
||||
if (p)
|
||||
{
|
||||
ffStrbufAppendF(&terminalFont->error, "st was not executed with `-f` parameter");
|
||||
return;
|
||||
// st was executed with `-f` parameter
|
||||
ffStrbufSubstrAfter(&font, (uint32_t) (p + (sizeof("\0-f") - 1) - font.chars));
|
||||
ffStrbufRecalculateLength(&font);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&font);
|
||||
if (ffProcessAppendStdOut(&font, (char* const[]) {
|
||||
"strings",
|
||||
terminal->exePath.chars,
|
||||
NULL,
|
||||
}) != NULL || font.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "Failed to run `strings st`");
|
||||
return;
|
||||
}
|
||||
|
||||
// Search font config string in st binary
|
||||
uint32_t middleIndex = ffStrbufFirstIndexS(&font, "size=");
|
||||
if (middleIndex == font.length)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
ffStrbufSubstrAfter(&font, (uint32_t) (p + (sizeof("\0-f") - 1) - font.chars));
|
||||
ffStrbufRecalculateLength(&font);
|
||||
// JetBrainsMono Nerd Font Mono:pixelsize=12:antialias=true:autohint=true
|
||||
|
||||
// `monospace:size=15` || `monospace` || `:size=15`
|
||||
uint32_t index = ffStrbufFirstIndexS(&font, ":size=");
|
||||
uint32_t index = ffStrbufFirstIndexC(&font, ':');
|
||||
if (index != font.length)
|
||||
{
|
||||
ffStrbufSetS(&size, font.chars + index + strlen(":size="));
|
||||
uint32_t sIndex = ffStrbufNextIndexS(&font, index + 1, "size=");
|
||||
if (sIndex != font.length)
|
||||
{
|
||||
sIndex += strlen("size=");
|
||||
uint32_t sIndexEnd = ffStrbufNextIndexC(&font, sIndex, ':');
|
||||
ffStrbufSetNS(&size, sIndexEnd - sIndex, font.chars + sIndex);
|
||||
}
|
||||
ffStrbufSubstrBefore(&font, index);
|
||||
}
|
||||
else
|
||||
@@ -365,7 +399,7 @@ void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFo
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "xterm"))
|
||||
detectXterm(terminalFont);
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "st"))
|
||||
detectSt(terminalFont, terminal->pid);
|
||||
detectSt(terminalFont, terminal);
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "warp"))
|
||||
detectWarp(terminalFont);
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "weston-terminal"))
|
||||
|
||||
@@ -46,7 +46,7 @@ static void getProcessInformation(pid_t pid, FFstrbuf* processName, FFstrbuf* ex
|
||||
ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1);
|
||||
if (length > 0) // doesn't contain trailing NUL
|
||||
{
|
||||
exePath->chars[length + 1] = '\0';
|
||||
exePath->chars[length] = '\0';
|
||||
exePath->length = (uint32_t) length;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,10 @@ static void getProcessInformation(pid_t pid, FFstrbuf* processName, FFstrbuf* ex
|
||||
int mibs[] = { CTL_KERN, KERN_PROCARGS2, pid };
|
||||
if (sysctl(mibs, sizeof(mibs) / sizeof(*mibs), NULL, &len, NULL, 0) == 0)
|
||||
{
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
//don't know why if don't let len longer, proArgs2 and len will change during the following sysctl() in old MacOS version.
|
||||
len++;
|
||||
#endif
|
||||
FF_AUTO_FREE char* const procArgs2 = malloc(len);
|
||||
if (sysctl(mibs, sizeof(mibs) / sizeof(*mibs), procArgs2, &len, NULL, 0) == 0)
|
||||
{
|
||||
@@ -244,6 +248,8 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
|
||||
ffStrEquals(name, "guake-wrapped") ||
|
||||
ffStrEquals(name, "time") ||
|
||||
ffStrEquals(name, "hyfetch") || //when hyfetch uses fastfetch as backend
|
||||
ffStrEquals(name, "clifm") || //https://github.com/leo-arch/clifm/issues/289
|
||||
ffStrEquals(name, "valgrind") ||
|
||||
ffStrContainsIgnCase(name, "debug") ||
|
||||
ffStrContainsIgnCase(name, "not-found") ||
|
||||
ffStrEndsWith(name, ".sh")
|
||||
@@ -294,6 +300,7 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
|
||||
ffStrEquals(name, "xonsh") || // works in Linux but not in macOS because kernel returns `Python` in this case
|
||||
ffStrEquals(name, "login") ||
|
||||
ffStrEquals(name, "sshd") ||
|
||||
ffStrEquals(name, "clifm") || // https://github.com/leo-arch/clifm/issues/289
|
||||
ffStrEquals(name, "chezmoi") || // #762
|
||||
#ifdef __linux__
|
||||
ffStrStartsWith(name, "flatpak-") || // #707
|
||||
@@ -307,10 +314,19 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
|
||||
|
||||
#ifdef __APPLE__
|
||||
// https://github.com/fastfetch-cli/fastfetch/discussions/501
|
||||
if (ffStrEndsWith(name, " (figterm)") || ffStrEndsWith(name, " (cwterm)"))
|
||||
const char* pLeft = strstr(name, " (");
|
||||
if (pLeft)
|
||||
{
|
||||
if (__builtin_expect(getProcessNameAndPpid(ppid, name, &ppid, NULL) != NULL, false))
|
||||
return 0;
|
||||
pLeft += 2;
|
||||
const char* pRight = strstr(pLeft, "term)");
|
||||
if (pRight && pRight[5] == '\0')
|
||||
{
|
||||
for (; pLeft < pRight; ++pLeft)
|
||||
if (*pLeft < 'a' || *pLeft > 'z')
|
||||
break;
|
||||
if (pLeft == pRight && getProcessNameAndPpid(ppid, name, &ppid, NULL) != NULL)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ void ffPrepareWeather(FFWeatherOptions* options)
|
||||
{
|
||||
if (status != FF_UNITIALIZED)
|
||||
{
|
||||
fputs("Error: this module can only be used once due to internal limitations\n", stderr);
|
||||
fputs("Error: Weather module can only be used once due to internal limitations\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,13 +135,13 @@ const char* ffDetectWifi(FFlist* result)
|
||||
case kCWSecurityEnterprise:
|
||||
ffStrbufSetStatic(&item->conn.security, "Enterprise");
|
||||
break;
|
||||
case kCWSecurityWPA3Personal:
|
||||
case 11 /*kCWSecurityWPA3Personal*/:
|
||||
ffStrbufSetStatic(&item->conn.security, "WPA3 Personal");
|
||||
break;
|
||||
case kCWSecurityWPA3Enterprise:
|
||||
case 12 /*kCWSecurityWPA3Enterprise*/:
|
||||
ffStrbufSetStatic(&item->conn.security, "WPA3 Enterprise");
|
||||
break;
|
||||
case kCWSecurityWPA3Transition:
|
||||
case 13 /*kCWSecurityWPA3Transition*/:
|
||||
ffStrbufSetStatic(&item->conn.security, "WPA3 Transition");
|
||||
break;
|
||||
case 14 /*kCWSecurityOWE*/:
|
||||
|
||||
@@ -36,9 +36,17 @@ const char* ffDetectWifi(FFlist* result)
|
||||
item->conn.txRate = 0.0/0.0;
|
||||
|
||||
ffParsePropLines(ifconfig.chars, "ssid ", &item->conn.ssid);
|
||||
if (item->conn.ssid.length) ffStrbufSubstrBeforeFirstC(&item->conn.ssid, ' ');
|
||||
if (item->conn.ssid.length)
|
||||
{
|
||||
uint32_t ibssid = ffStrbufFirstIndexS(&item->conn.ssid, " bssid ");
|
||||
if (ibssid < item->conn.ssid.length)
|
||||
{
|
||||
ibssid += (uint32_t) strlen(" bssid ");
|
||||
ffStrbufSetS(&item->conn.macAddress, item->conn.ssid.chars + ibssid);
|
||||
}
|
||||
|
||||
ffParsePropLines(ifconfig.chars, "ether ", &item->conn.macAddress);
|
||||
ffStrbufSubstrBeforeFirstC(&item->conn.ssid, ' ');
|
||||
}
|
||||
|
||||
ffParsePropLines(ifconfig.chars, "media: ", &item->conn.protocol);
|
||||
if (item->conn.protocol.length)
|
||||
@@ -53,7 +61,7 @@ const char* ffDetectWifi(FFlist* result)
|
||||
}
|
||||
}
|
||||
|
||||
ffParsePropLines(ifconfig.chars, "status: ", &item->conn.macAddress);
|
||||
ffParsePropLines(ifconfig.chars, "status: ", &item->conn.status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+59
-172
@@ -234,10 +234,13 @@ static bool printSpecificCommandHelp(const char* command)
|
||||
}
|
||||
}
|
||||
|
||||
yyjson_doc_free(doc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yyjson_doc_free(doc);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -317,7 +320,43 @@ static void listModules(bool pretty)
|
||||
}
|
||||
}
|
||||
|
||||
static void parseOption(FFdata* data, const char* key, const char* value);
|
||||
// Temporary copy before new release of yyjson
|
||||
static bool ffyyjson_locate_pos(const char *str, size_t len, size_t pos,
|
||||
size_t *line, size_t *col, size_t *chr) {
|
||||
size_t line_sum = 0, line_pos = 0, chr_sum = 0;
|
||||
const uint8_t *cur = (const uint8_t *)str;
|
||||
const uint8_t *end = cur + pos;
|
||||
|
||||
if (!str || pos > len) {
|
||||
if (line) *line = 0;
|
||||
if (col) *col = 0;
|
||||
if (chr) *chr = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
while (cur < end) {
|
||||
uint8_t c = *cur;
|
||||
chr_sum += 1;
|
||||
if (__builtin_expect(c < 0x80, true)) { /* 0xxxxxxx (0x00-0x7F) ASCII */
|
||||
if (c == '\n') {
|
||||
line_sum += 1;
|
||||
line_pos = chr_sum;
|
||||
}
|
||||
cur += 1;
|
||||
}
|
||||
else if (c < 0xC0) cur += 1; /* 10xxxxxx (0x80-0xBF) Invalid */
|
||||
else if (c < 0xE0) cur += 2; /* 110xxxxx (0xC0-0xDF) 2-byte UTF-8 */
|
||||
else if (c < 0xF0) cur += 3; /* 1110xxxx (0xE0-0xEF) 3-byte UTF-8 */
|
||||
else if (c < 0xF8) cur += 4; /* 11110xxx (0xF0-0xF7) 4-byte UTF-8 */
|
||||
else cur += 1; /* 11111xxx (0xF8-0xFF) Invalid */
|
||||
}
|
||||
|
||||
if (line) *line = line_sum + 1;
|
||||
if (col) *col = chr_sum - line_pos + 1;
|
||||
if (chr) *chr = chr_sum;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool parseJsoncFile(const char* path)
|
||||
{
|
||||
@@ -325,12 +364,16 @@ static bool parseJsoncFile(const char* path)
|
||||
|
||||
{
|
||||
yyjson_read_err error;
|
||||
instance.state.configDoc = yyjson_read_file(path, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, &error);
|
||||
instance.state.configDoc = yyjson_read_file(path, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, NULL, &error);
|
||||
if (!instance.state.configDoc)
|
||||
{
|
||||
if (error.code != YYJSON_READ_ERROR_FILE_OPEN)
|
||||
{
|
||||
fprintf(stderr, "Error: failed to parse JSON config file `%s` at pos %zu: %s\n", path, error.pos, error.msg);
|
||||
size_t row = 0, col = error.pos;
|
||||
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
|
||||
if (ffAppendFileBuffer(path, &content))
|
||||
ffyyjson_locate_pos(content.chars, content.length, error.pos, &row, &col, NULL);
|
||||
fprintf(stderr, "Error: failed to parse JSON config file `%s` at (%zu, %zu): %s\n", path, row, col, error.msg);
|
||||
exit(477);
|
||||
}
|
||||
return false;
|
||||
@@ -360,104 +403,6 @@ static bool parseJsoncFile(const char* path)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool parseConfigFile(FFdata* data, const char* path)
|
||||
{
|
||||
FF_AUTO_CLOSE_FILE FILE* file = fopen(path, "r");
|
||||
if(file == NULL)
|
||||
return false;
|
||||
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
FF_STRBUF_AUTO_DESTROY unescaped = ffStrbufCreate();
|
||||
|
||||
while ((read = getline(&line, &len, file)) != -1)
|
||||
{
|
||||
char* lineStart = line;
|
||||
char* lineEnd = line + read - 1;
|
||||
|
||||
//Trim line left
|
||||
while(isspace(*lineStart))
|
||||
++lineStart;
|
||||
|
||||
//Continue if line is empty or a comment
|
||||
if(*lineStart == '\0' || *lineStart == '#')
|
||||
continue;
|
||||
|
||||
//Trim line right
|
||||
while(lineEnd > lineStart && isspace(*lineEnd))
|
||||
--lineEnd;
|
||||
*(lineEnd + 1) = '\0';
|
||||
|
||||
char* valueStart = strchr(lineStart, ' ');
|
||||
|
||||
//If the line has no white space, it is only a key
|
||||
if(valueStart == NULL)
|
||||
{
|
||||
parseOption(data, lineStart, NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
//separate the key from the value
|
||||
*valueStart = '\0';
|
||||
++valueStart;
|
||||
|
||||
//Trim space of value left
|
||||
while(isspace(*valueStart))
|
||||
++valueStart;
|
||||
|
||||
//If we want whitespace in values, we need to quote it. This is done to keep consistency with shell.
|
||||
if((*valueStart == '"' || *valueStart == '\'') && *valueStart == *lineEnd && lineEnd > valueStart)
|
||||
{
|
||||
++valueStart;
|
||||
*lineEnd = '\0';
|
||||
--lineEnd;
|
||||
}
|
||||
|
||||
if (strchr(valueStart, '\\'))
|
||||
{
|
||||
// Unescape all `\x`s
|
||||
const char* value = valueStart;
|
||||
while(*value != '\0')
|
||||
{
|
||||
if(*value != '\\')
|
||||
{
|
||||
ffStrbufAppendC(&unescaped, *value);
|
||||
++value;
|
||||
continue;
|
||||
}
|
||||
|
||||
++value;
|
||||
|
||||
switch(*value)
|
||||
{
|
||||
case 'n': ffStrbufAppendC(&unescaped, '\n'); break;
|
||||
case 't': ffStrbufAppendC(&unescaped, '\t'); break;
|
||||
case 'e': ffStrbufAppendC(&unescaped, '\e'); break;
|
||||
case '\\': ffStrbufAppendC(&unescaped, '\\'); break;
|
||||
default:
|
||||
ffStrbufAppendC(&unescaped, '\\');
|
||||
ffStrbufAppendC(&unescaped, *value);
|
||||
break;
|
||||
}
|
||||
|
||||
++value;
|
||||
}
|
||||
parseOption(data, lineStart, unescaped.chars);
|
||||
ffStrbufClear(&unescaped);
|
||||
}
|
||||
else
|
||||
{
|
||||
parseOption(data, lineStart, valueStart);
|
||||
}
|
||||
}
|
||||
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void generateConfigFile(bool force, const char* filePath)
|
||||
{
|
||||
if (!filePath)
|
||||
@@ -467,11 +412,6 @@ static void generateConfigFile(bool force, const char* filePath)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ffStrEqualsIgnCase(filePath, "conf") || ffStrEqualsIgnCase(filePath, "jsonc"))
|
||||
{
|
||||
fputs("Error: specifying file type is no longer supported\n", stderr);
|
||||
exit(477);
|
||||
}
|
||||
ffStrbufSetS(&instance.state.genConfigPath, filePath);
|
||||
}
|
||||
|
||||
@@ -507,19 +447,15 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
|
||||
if (ffStrEqualsIgnCase(value, "none"))
|
||||
return;
|
||||
|
||||
bool isJsonConfig = fileNameLen > strlen(".jsonc") && strcasecmp(value + fileNameLen - strlen(".jsonc"), ".jsonc") == 0;
|
||||
if (ffStrEndsWithIgnCase(value, ".conf"))
|
||||
{
|
||||
fprintf(stderr, "Error: flag based config files are no longer not supported: %s\n", value);
|
||||
exit(414);
|
||||
}
|
||||
|
||||
//Try to load as an absolute path
|
||||
|
||||
if(isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, value))
|
||||
return;
|
||||
|
||||
{
|
||||
bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, value);
|
||||
|
||||
if(success)
|
||||
return;
|
||||
}
|
||||
if (parseJsoncFile(value)) return;
|
||||
|
||||
//Try to load as a relative path
|
||||
|
||||
@@ -531,15 +467,14 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
|
||||
ffStrbufAppendS(&absolutePath, "fastfetch/presets/");
|
||||
ffStrbufAppendS(&absolutePath, value);
|
||||
|
||||
bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars);
|
||||
bool success = parseJsoncFile(absolutePath.chars);
|
||||
if (!success)
|
||||
{
|
||||
ffStrbufAppendS(&absolutePath, ".jsonc");
|
||||
success = parseJsoncFile(absolutePath.chars);
|
||||
}
|
||||
|
||||
if(success)
|
||||
return;
|
||||
if (success) return;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -549,15 +484,14 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
|
||||
ffStrbufAppendS(&absolutePath, "/presets/");
|
||||
ffStrbufAppendS(&absolutePath, value);
|
||||
|
||||
bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars);
|
||||
bool success = parseJsoncFile(absolutePath.chars);
|
||||
if (!success)
|
||||
{
|
||||
ffStrbufAppendS(&absolutePath, ".jsonc");
|
||||
success = parseJsoncFile(absolutePath.chars);
|
||||
}
|
||||
|
||||
if(success)
|
||||
return;
|
||||
if (success) return;
|
||||
}
|
||||
|
||||
//File not found
|
||||
@@ -695,38 +629,7 @@ static void parseCommand(FFdata* data, char* key, char* value)
|
||||
|
||||
static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
{
|
||||
if(ffStrEqualsIgnCase(key, "--set") || ffStrEqualsIgnCase(key, "--set-keyless"))
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY customValueStr = ffStrbufCreate();
|
||||
ffOptionParseString(key, value, &customValueStr);
|
||||
uint32_t index = ffStrbufFirstIndexC(&customValueStr, '=');
|
||||
if(index == 0 || index == customValueStr.length)
|
||||
{
|
||||
fprintf(stderr, "Error: usage: %s <key>=<str>\n", key);
|
||||
exit(477);
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY customKey = ffStrbufCreateNS(index, customValueStr.chars);
|
||||
|
||||
FFCustomValue* customValue = NULL;
|
||||
FF_LIST_FOR_EACH(FFCustomValue, x, data->customValues)
|
||||
{
|
||||
if(ffStrbufEqual(&x->key, &customKey))
|
||||
{
|
||||
ffStrbufDestroy(&x->key);
|
||||
ffStrbufDestroy(&x->value);
|
||||
customValue = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!customValue) customValue = (FFCustomValue*) ffListAdd(&data->customValues);
|
||||
ffStrbufInitMove(&customValue->key, &customKey);
|
||||
ffStrbufSubstrAfter(&customValueStr, index);
|
||||
ffStrbufInitMove(&customValue->value, &customValueStr);
|
||||
customValue->printKey = key[5] == '\0';
|
||||
}
|
||||
|
||||
else if(ffStrEqualsIgnCase(key, "-s") || ffStrEqualsIgnCase(key, "--structure"))
|
||||
if(ffStrEqualsIgnCase(key, "-s") || ffStrEqualsIgnCase(key, "--structure"))
|
||||
ffOptionParseString(key, value, &data->structure);
|
||||
|
||||
else if(
|
||||
@@ -744,7 +647,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
}
|
||||
}
|
||||
|
||||
static void parseConfigFiles(FFdata* data)
|
||||
static void parseConfigFiles(void)
|
||||
{
|
||||
if (__builtin_expect(instance.state.genConfigPath.length == 0, true))
|
||||
{
|
||||
@@ -758,15 +661,6 @@ static void parseConfigFiles(FFdata* data)
|
||||
if (success) return;
|
||||
}
|
||||
}
|
||||
FF_LIST_FOR_EACH(FFstrbuf, dir, instance.state.platform.configDirs)
|
||||
{
|
||||
uint32_t dirLength = dir->length;
|
||||
|
||||
ffStrbufAppendS(dir, "fastfetch/config.conf");
|
||||
bool success = parseConfigFile(data, dir->chars);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
if (success) return;
|
||||
}
|
||||
}
|
||||
|
||||
static void parseArguments(FFdata* data, int argc, char** argv, void (*parser)(FFdata* data, char* key, char* value))
|
||||
@@ -868,13 +762,12 @@ int main(int argc, char** argv)
|
||||
//Data stores things only needed for the configuration of fastfetch
|
||||
FFdata data = {
|
||||
.structure = ffStrbufCreate(),
|
||||
.customValues = ffListCreate(sizeof(FFCustomValue)),
|
||||
.configLoaded = false,
|
||||
};
|
||||
|
||||
parseArguments(&data, argc, argv, parseCommand);
|
||||
if(!data.configLoaded && !getenv("NO_CONFIG"))
|
||||
parseConfigFiles(&data);
|
||||
parseConfigFiles();
|
||||
parseArguments(&data, argc, argv, (void*) parseOption);
|
||||
|
||||
if (__builtin_expect(instance.state.genConfigPath.length == 0, true))
|
||||
@@ -883,10 +776,4 @@ int main(int argc, char** argv)
|
||||
writeConfigFile(&data, &instance.state.genConfigPath);
|
||||
|
||||
ffStrbufDestroy(&data.structure);
|
||||
FF_LIST_FOR_EACH(FFCustomValue, customValue, data.customValues)
|
||||
{
|
||||
ffStrbufDestroy(&customValue->key);
|
||||
ffStrbufDestroy(&customValue->value);
|
||||
}
|
||||
ffListDestroy(&data.customValues);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
.$2xOOko $1.$2odd,
|
||||
oX$1WW$2KOOOO. 'ON$1WW$20kkk.
|
||||
$1.$2k0XKOOOOOOcOON$1W$2NOOOOO.
|
||||
xOOOOOOOOOkkOOOOOOOOO;
|
||||
$1.$2O0OkkocxO000000kcdk0OO0OOkx
|
||||
k$1W$1M$2Xkkkkloxkkkx; :dxxxxddc...
|
||||
'kO0OOOOOkc .cl:..kk0KK0Okc
|
||||
;kOOO0000xd. dO00000Oo .xkO$1NMM$2XOOOO
|
||||
.dddxkOOOkddc.kKN$1WW$2N000000l.ddk0000OOOO.
|
||||
'dd:;ddddd;.dK$1MMMW$2K00KKK0O::ddxkO00Oko
|
||||
.okxkOKK0kkOO00KKOxxlodddddddl
|
||||
.00OOkkkkkkkkOOO00OOOO0O; .dddl
|
||||
'kkkkkxxkkkkkkkOOkxdxkxxddd.
|
||||
cddddddddxxkkkkkxddddddddddo
|
||||
'ddddddodddddddddddddddddddc
|
||||
$1.$2ddddddodddddddddodddddddc
|
||||
.odddo.
|
||||
|
||||
$1.$2kOOkkk;
|
||||
lkK$1WN$2kkkxc
|
||||
kkxkkkkkkx.
|
||||
,,..xxx.
|
||||
@@ -0,0 +1,18 @@
|
||||
$3..;:::::::;.
|
||||
.0X'$1''''''''''''$3'N:
|
||||
:Xd$1,.'''''''''''''''$3lKx
|
||||
.0o$1'.'''''''''''''''''''$3:K;
|
||||
.O$1;.'$3okOx:$1'''''''''$3,dOOx:$1''$3O;
|
||||
xc$1.'$3xXl$1 $3kX;$1''$2:cc;$1''$3kXl$1 $3OX;$1''$3k.
|
||||
'x$1..'$3:0X0Xx$1',$2OOOOOd$1,:$30X0Xx$1'''$3o:
|
||||
::$1..'$2,clollxOOOOOOOOdlddlc$1''''$3d
|
||||
l'$1..$2':kkkkOOOOOOOOOOOOkkkx,$1'''$3x
|
||||
o$1...''''',$2codxkkxxxdl$1:''''''''$3d.
|
||||
d$1...''''''''''''''''''''''''''$3o.
|
||||
d$1..''''$3,loc,$1''''''''$3;os:,$1'''''$3d'
|
||||
:d$1..'$3,dKXXXXX0kxxxk0XXXXXX0l$1'''$3,O.
|
||||
'0$1..'$3cKXXXXXXXXXXXXXXXXXXXXXXk$1'''$3ck
|
||||
'0$1'.'$3cXXXXXXXXXXXXXXXXXXXXXXXXXO$1'''$3od
|
||||
.0$1,.''$30XXXXXXXXXXXXXXXXXXXXXXXXXXo$1'''$3k;
|
||||
cc$1..''$3XXXXXXXXXXXXXXXXXXXXXXXXXXXk$1''''$3k
|
||||
l$1...',$3XXXXXXXXXXXXXXXXXXXXXXXXXXXO$1''''$3d.
|
||||
@@ -0,0 +1,16 @@
|
||||
${c1} -:+:.
|
||||
${c1} :++++.
|
||||
${c1} /+++/.
|
||||
${c1} .:-::- .+/:-\`\`.::-
|
||||
${c1} .:/++++++/::::/++++++/::`
|
||||
${c2} .:///////////////////////::`
|
||||
${c2} /////////////////////////`
|
||||
${c3}+++++++++++++++++++++++++`
|
||||
${c3}++++++++++++++++++++++++
|
||||
${c4}ssssssssssssssssssssssss.
|
||||
${c4}:ssssssssssssssssssssssss-
|
||||
${c5} osssssssssssssssssssssssss`
|
||||
${c5} `syyyyyyyyyyyyyyyyyyyyyyyyys`
|
||||
${c6} `ossssssssssssssssssssssss
|
||||
${c6} :ooooooooooooooooooo+.
|
||||
${c6} `:++oo+/:- -:/+o+/-
|
||||
@@ -0,0 +1,20 @@
|
||||
_,......,_
|
||||
_aaQQQQQQWQQQQQQQaa.
|
||||
ajQQQ??^' '^??QQQw.
|
||||
,aQQP^ ?4QQa
|
||||
wQQP ^4QQa
|
||||
,QQP' ,aaaaa. ^$Q6,
|
||||
,QQP ajQQQWWWWQQQw. 4QQ
|
||||
QQP aQQP? ?$QQ. 4Q6
|
||||
jQQ jQQ' ?WQr 'QQb
|
||||
QQf ]QQ' ]QQ QQ6
|
||||
QQf ]QQ ]QQ) QQQ
|
||||
QQ6 'QQ6 ]QQ QQf
|
||||
]QQ. ^4QQaa .QQP ,QQ'
|
||||
$QQ. ^?QQQQf _yQP ,QQP
|
||||
^WQQ6. aQQ? _QQP
|
||||
^4QQQ6a. ajQQP' aQQP
|
||||
?QQQQQWQaaaaaaajQWQP? aQQP'
|
||||
?QQQQP????????^' saWQP?
|
||||
^?QQQgaaa._ __aaaQQQP?'
|
||||
'^?QWQQQQQQQQ@??^'
|
||||
@@ -0,0 +1,17 @@
|
||||
$2 @=++++++++++=@
|
||||
$2 =++++++++++++++++++=
|
||||
$2 *++++++++++++++++++++++*
|
||||
$2 =++++++++++++++++++++++++++=
|
||||
$2 *++++++++$1-..........-$2++++++++*
|
||||
$2 =++++++++$1..............$2++++++++=
|
||||
$2@++++++++$1:.....$2:++$1:.....:$2++++++++@
|
||||
$2=++++++++$1:.....$2++++$1.....:$2++++++++=
|
||||
$2=++++++++$1:.....$2++++$1.....:$2++++++++=
|
||||
$2#++++++++$1:.....$2++++$1.....:$2++++++++#
|
||||
$2 +++++++++$1......$2--$1......$2+++++++++
|
||||
$2 @++++++++$1:............:$2++++++++@
|
||||
$2 @+++++++++++$1-....-$2+++++++++++@
|
||||
$2 *++++++++++$1::::$2++++++++++*
|
||||
$2 *++++++++++++++++++++*
|
||||
$2 @*++++++++++++++*@
|
||||
$2 @#====#@
|
||||
@@ -0,0 +1,5 @@
|
||||
@..@
|
||||
(----)
|
||||
( >__< )
|
||||
^^ ~~ ^^
|
||||
| Spoink! |
|
||||
+72
-22
@@ -1115,9 +1115,9 @@ static const FFlogo C[] = {
|
||||
};
|
||||
|
||||
static const FFlogo D[] = {
|
||||
// Dahlia
|
||||
// DahliaOS
|
||||
{
|
||||
.names = {"dahlia"},
|
||||
.names = {"dahliaOS"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_DAHLIA,
|
||||
.colors = {
|
||||
FF_COLOR_FG_RED,
|
||||
@@ -1558,18 +1558,6 @@ static const FFlogo F[] = {
|
||||
.colorKeys = FF_COLOR_FG_BLUE,
|
||||
.colorTitle = FF_COLOR_FG_BLUE,
|
||||
},
|
||||
// FedoraOnyx placeholder - Currently does not have a logo
|
||||
//{
|
||||
//.names = {"Fedora_onyx", "fedora-onyx", "fedora-linux-onyx", "fedora-linux_onyx"},
|
||||
//.type = FF_LOGO_LINE_TYPE_ALTER_BIT,
|
||||
//.lines = FASTFETCH_DATATEXT_LOGO_FEDORA_ONYX,
|
||||
//.colors = {
|
||||
//FF_COLOR_FG_BLUE,
|
||||
//FF_COLOR_FG_WHITE,
|
||||
//},
|
||||
//.colorKeys = FF_COLOR_FG_BLUE,
|
||||
//.colorTitle = FF_COLOR_FG_BLUE,
|
||||
//},
|
||||
// FedoraCoreOS
|
||||
{
|
||||
.names = {"Fedora_coreos", "fedora-coreos", "fedora-linux-coreos", "fedora-linux_coreos"},
|
||||
@@ -1678,6 +1666,17 @@ static const FFlogo F[] = {
|
||||
.colorKeys = FF_COLOR_FG_MAGENTA,
|
||||
.colorTitle = FF_COLOR_FG_WHITE,
|
||||
},
|
||||
// Furreto
|
||||
{
|
||||
.names = {"Furreto"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_FURRETO,
|
||||
.colors = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
FF_COLOR_FG_LIGHT_MAGENTA,
|
||||
},
|
||||
.colorKeys = FF_COLOR_FG_CYAN,
|
||||
.colorTitle = FF_COLOR_FG_CYAN,
|
||||
},
|
||||
// LAST
|
||||
{},
|
||||
};
|
||||
@@ -2121,13 +2120,11 @@ static const FFlogo K[] = {
|
||||
},
|
||||
// KDENeon
|
||||
{
|
||||
.names = {"KDE", "kde-neon"},
|
||||
.names = {"KDE", "kde-neon", "kde neon"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_KDE,
|
||||
.colors = {
|
||||
FF_COLOR_FG_GREEN,
|
||||
},
|
||||
.colorKeys = FF_COLOR_FG_GREEN,
|
||||
.colorTitle = FF_COLOR_FG_GREEN,
|
||||
},
|
||||
// Kibojoe
|
||||
{
|
||||
@@ -2385,6 +2382,18 @@ static const FFlogo L[] = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
},
|
||||
// Loc-OS
|
||||
{
|
||||
.names = {"loc-os", "Loc-OS Linux"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_LOCOS,
|
||||
.colors = {
|
||||
FF_COLOR_FG_BLACK,
|
||||
FF_COLOR_FG_YELLOW,
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
.colorKeys = FF_COLOR_FG_YELLOW,
|
||||
.colorTitle = FF_COLOR_FG_RED,
|
||||
},
|
||||
// Lunar
|
||||
{
|
||||
.names = {"Lunar"},
|
||||
@@ -2461,6 +2470,21 @@ static const FFlogo M[] = {
|
||||
.colorKeys = FF_COLOR_FG_YELLOW,
|
||||
.colorTitle = FF_COLOR_FG_GREEN,
|
||||
},
|
||||
// MacOS3
|
||||
{
|
||||
.names = {"macos3", "mac3"},
|
||||
.type = FF_LOGO_LINE_TYPE_ALTER_BIT,
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_MACOS3,
|
||||
.colors = {
|
||||
FF_COLOR_FG_GREEN,
|
||||
FF_COLOR_FG_YELLOW,
|
||||
FF_COLOR_FG_RED,
|
||||
FF_COLOR_FG_MAGENTA,
|
||||
FF_COLOR_FG_BLUE,
|
||||
},
|
||||
.colorKeys = FF_COLOR_FG_YELLOW,
|
||||
.colorTitle = FF_COLOR_FG_GREEN,
|
||||
},
|
||||
// MainsailOS
|
||||
{
|
||||
.names = {"MainsailOS"},
|
||||
@@ -2527,7 +2551,7 @@ static const FFlogo M[] = {
|
||||
},
|
||||
// Manjaro
|
||||
{
|
||||
.names = {"manjaro", "manjaro-linux"},
|
||||
.names = {"manjaro", "manjaro-linux", "manjarolinux"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_MANJARO,
|
||||
.colors = {
|
||||
FF_COLOR_FG_GREEN,
|
||||
@@ -3004,9 +3028,19 @@ static const FFlogo O[] = {
|
||||
.colorKeys = FF_COLOR_FG_GREEN,
|
||||
.colorTitle = FF_COLOR_FG_GREEN,
|
||||
},
|
||||
// openSUSESlowroll
|
||||
{
|
||||
.names = {"opensuse_slowroll", "opensuse-slowroll", "opensuse-tumbleweed-slowroll"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SLOWROLL,
|
||||
.colors = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
.colorKeys = FF_COLOR_FG_GREEN,
|
||||
.colorTitle = FF_COLOR_FG_GREEN,
|
||||
},
|
||||
// OpenMandriva
|
||||
{
|
||||
.names = {"openmandriva", "open-mandriva", "open_mandriva"},
|
||||
.names = {"openmandriva", "open-mandriva", "open_mandriva", "openmandriva lx"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_OPENMANDRIVA,
|
||||
.colors = {
|
||||
FF_COLOR_FG_BLUE,
|
||||
@@ -3442,6 +3476,15 @@ static const FFlogo Q[] = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
},
|
||||
},
|
||||
// Quirinux
|
||||
{
|
||||
.names = {"Quirinux"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_QUIRINUX,
|
||||
.colors = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
FF_COLOR_FG_MAGENTA,
|
||||
},
|
||||
},
|
||||
// LAST
|
||||
{},
|
||||
};
|
||||
@@ -3787,6 +3830,14 @@ static const FFlogo S[] = {
|
||||
FF_COLOR_FG_YELLOW,
|
||||
},
|
||||
},
|
||||
// SpoinkOS
|
||||
{
|
||||
.names = {"SpoinkOS", "spoink-os"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_SPOINKOS,
|
||||
.colors = {
|
||||
FF_COLOR_FG_GREEN,
|
||||
},
|
||||
},
|
||||
// Slackel
|
||||
{
|
||||
.names = {"Slackel"},
|
||||
@@ -4010,10 +4061,9 @@ static const FFlogo T[] = {
|
||||
.names = {"TorizonCore"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_TORIZONCORE,
|
||||
.colors = {
|
||||
FF_COLOR_FG_LIGHT_WHITE,
|
||||
FF_COLOR_FG_YELLOW,
|
||||
FF_COLOR_FG_BLUE,
|
||||
FF_COLOR_FG_LIGHT_BLACK,
|
||||
FF_COLOR_FG_MAGENTA,
|
||||
FF_COLOR_FG_BLUE
|
||||
},
|
||||
},
|
||||
// Trisquel
|
||||
|
||||
@@ -84,9 +84,10 @@ static bool printImageIterm(bool printError)
|
||||
ffStrbufAppendNC(&buf, options->paddingTop, '\n');
|
||||
ffStrbufAppendNC(&buf, options->paddingLeft, ' ');
|
||||
}
|
||||
ffStrbufAppendF(&buf, "\e]1337;File=inline=1:%s\a",
|
||||
base64.chars
|
||||
);
|
||||
if (options->width)
|
||||
ffStrbufAppendF(&buf, "\e]1337;File=inline=1;width=%u:%s\a", (unsigned) options->width, base64.chars);
|
||||
else
|
||||
ffStrbufAppendF(&buf, "\e]1337;File=inline=1:%s\a", base64.chars);
|
||||
ffWriteFDBuffer(FFUnixFD2NativeFD(STDOUT_FILENO), &buf);
|
||||
|
||||
if (!options->separate)
|
||||
@@ -164,7 +165,11 @@ static bool printImageKittyDirect(bool printError)
|
||||
ffPrintCharTimes('\n', options->paddingTop);
|
||||
ffPrintCharTimes(' ', options->paddingLeft);
|
||||
}
|
||||
printf("\e_Ga=T,f=100,t=f;%s\e\\", base64.chars);
|
||||
|
||||
if (options->width)
|
||||
printf("\e_Ga=T,f=100,t=f,c=%u;%s\e\\", (unsigned) options->width, base64.chars);
|
||||
else
|
||||
printf("\e_Ga=T,f=100,t=f;%s\e\\", base64.chars);
|
||||
fflush(stdout);
|
||||
if (!options->separate)
|
||||
{
|
||||
|
||||
+12
-8
@@ -436,7 +436,7 @@ static bool logoTryKnownType(void)
|
||||
}
|
||||
|
||||
if(options->type == FF_LOGO_TYPE_BUILTIN)
|
||||
return logoPrintBuiltinIfExists(&options->source, FF_LOGO_SIZE_NORMAL);
|
||||
return logoPrintBuiltinIfExists(&options->source, FF_LOGO_SIZE_UNKNOWN);
|
||||
|
||||
if(options->type == FF_LOGO_TYPE_SMALL)
|
||||
return logoPrintBuiltinIfExists(&options->source, FF_LOGO_SIZE_SMALL);
|
||||
@@ -461,12 +461,6 @@ static bool logoTryKnownType(void)
|
||||
return logoPrintImageIfExists(options->type, instance.config.display.showErrors);
|
||||
}
|
||||
|
||||
static void logoPrintKnownType(void)
|
||||
{
|
||||
if(!logoTryKnownType())
|
||||
logoPrintDetected(FF_LOGO_SIZE_UNKNOWN);
|
||||
}
|
||||
|
||||
void ffLogoPrint(void)
|
||||
{
|
||||
//When generate JSON result, we don't have a logo or padding.
|
||||
@@ -497,7 +491,17 @@ void ffLogoPrint(void)
|
||||
//If the source and source type is set to something else than auto, always print with the set type.
|
||||
if(options->source.length > 0 && options->type != FF_LOGO_TYPE_AUTO)
|
||||
{
|
||||
logoPrintKnownType();
|
||||
if(!logoTryKnownType())
|
||||
{
|
||||
if (instance.config.display.showErrors)
|
||||
{
|
||||
// Image logo should have been handled
|
||||
if(options->type == FF_LOGO_TYPE_BUILTIN || options->type == FF_LOGO_TYPE_SMALL)
|
||||
fprintf(stderr, "Logo: Failed to load %s logo: %s \n", options->type == FF_LOGO_TYPE_BUILTIN ? "builtin" : "builtin small", options->source.chars);
|
||||
}
|
||||
|
||||
logoPrintDetected(FF_LOGO_SIZE_UNKNOWN);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
{
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, result->capacity, options->percent);
|
||||
ffPercentAppendBar(&str, result->capacity, options->percent, &options->moduleArgs);
|
||||
}
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -33,7 +33,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffPercentAppendNum(&str, result->capacity, options->percent, str.length > 0);
|
||||
ffPercentAppendNum(&str, result->capacity, options->percent, str.length > 0, &options->moduleArgs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendS(&str, " - ");
|
||||
|
||||
ffTempsAppendNum(result->temperature, &str, options->tempConfig);
|
||||
ffTempsAppendNum(result->temperature, &str, options->tempConfig, &options->moduleArgs);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
@@ -58,9 +58,9 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY capacityStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&capacityStr, result->capacity, options->percent, false);
|
||||
ffPercentAppendNum(&capacityStr, result->capacity, options->percent, false, &options->moduleArgs);
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig);
|
||||
ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BATTERY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
|
||||
|
||||
@@ -128,12 +128,6 @@ void ffGenerateBiosJsonResult(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (bios.version.length == 0)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "bios_version is not set.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "date", &bios.date);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "release", &bios.release);
|
||||
@@ -165,7 +159,7 @@ void ffInitBiosOptions(FFBiosOptions* options)
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BIOS_MODULE_NAME,
|
||||
"Print BIOS name, version, release date, etc",
|
||||
"Print information of 1st-stage bootloader (name, version, release date, etc)",
|
||||
ffParseBiosCommandOptions,
|
||||
ffParseBiosJsonObject,
|
||||
ffPrintBios,
|
||||
|
||||
@@ -19,7 +19,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
|
||||
{
|
||||
if (buffer.length)
|
||||
ffStrbufAppendC(&buffer, ' ');
|
||||
ffPercentAppendNum(&buffer, device->battery, options->percent, buffer.length > 0);
|
||||
ffPercentAppendNum(&buffer, device->battery, options->percent, buffer.length > 0, &options->moduleArgs);
|
||||
}
|
||||
|
||||
if (!device->connected)
|
||||
@@ -30,7 +30,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false);
|
||||
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/bootmgr/bootmgr.h"
|
||||
#include "modules/bootmgr/bootmgr.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BOOTMGR_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintBootmgr(FFBootmgrOptions* options)
|
||||
{
|
||||
FFBootmgrResult bootmgr = {
|
||||
.name = ffStrbufCreate(),
|
||||
.firmware = ffStrbufCreate(),
|
||||
};
|
||||
|
||||
const char* error = ffDetectBootmgr(&bootmgr);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY firmwareName = ffStrbufCreateCopy(&bootmgr.firmware);
|
||||
#ifndef __APPLE__
|
||||
ffStrbufSubstrAfterLastC(&firmwareName, '\\');
|
||||
#else
|
||||
ffStrbufSubstrAfterLastC(&firmwareName, '/');
|
||||
#endif
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&bootmgr.name, stdout);
|
||||
if (firmwareName.length > 0)
|
||||
printf(" - %s\n", firmwareName.chars);
|
||||
else
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOOTMGR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bootmgr.name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bootmgr.firmware},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &firmwareName},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &bootmgr.secureBoot},
|
||||
}));
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&bootmgr.name);
|
||||
ffStrbufDestroy(&bootmgr.firmware);
|
||||
}
|
||||
|
||||
bool ffParseBootmgrCommandOptions(FFBootmgrOptions* options, const char* key, const char* value)
|
||||
{
|
||||
const char* subKey = ffOptionTestPrefix(key, FF_BOOTMGR_MODULE_NAME);
|
||||
if (!subKey) return false;
|
||||
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffParseBootmgrJsonObject(FFBootmgrOptions* options, yyjson_val* module)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateBootmgrJsonConfig(FFBootmgrOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
__attribute__((__cleanup__(ffDestroyBootmgrOptions))) FFBootmgrOptions defaultOptions;
|
||||
ffInitBootmgrOptions(&defaultOptions);
|
||||
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffGenerateBootmgrJsonResult(FF_MAYBE_UNUSED FFBootmgrOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
FFBootmgrResult bootmgr = {
|
||||
.name = ffStrbufCreate(),
|
||||
.firmware = ffStrbufCreate(),
|
||||
};
|
||||
|
||||
const char* error = ffDetectBootmgr(&bootmgr);
|
||||
|
||||
if (error)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "name", &bootmgr.name);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "firmware", &bootmgr.firmware);
|
||||
yyjson_mut_obj_add_bool(doc, obj, "secureBoot", bootmgr.secureBoot);
|
||||
|
||||
exit:
|
||||
ffStrbufDestroy(&bootmgr.name);
|
||||
ffStrbufDestroy(&bootmgr.firmware);
|
||||
}
|
||||
|
||||
void ffPrintBootmgrHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOOTMGR_MODULE_NAME, "{4} ({2})", FF_BOOTMGR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name / description",
|
||||
"Firmware file path",
|
||||
"Firmware file name",
|
||||
"Is secure boot enabled",
|
||||
}));
|
||||
}
|
||||
|
||||
void ffInitBootmgrOptions(FFBootmgrOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BOOTMGR_MODULE_NAME,
|
||||
"Print information of 2nd-stage bootloader (name, firmware, etc)",
|
||||
ffParseBootmgrCommandOptions,
|
||||
ffParseBootmgrJsonObject,
|
||||
ffPrintBootmgr,
|
||||
ffGenerateBootmgrJsonResult,
|
||||
ffPrintBootmgrHelpFormat,
|
||||
ffGenerateBootmgrJsonConfig
|
||||
);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffDestroyBootmgrOptions(FFBootmgrOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_BOOTMGR_MODULE_NAME "Bootmgr"
|
||||
|
||||
void ffPrintBootmgr(FFBootmgrOptions* options);
|
||||
void ffInitBootmgrOptions(FFBootmgrOptions* options);
|
||||
void ffDestroyBootmgrOptions(FFBootmgrOptions* options);
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef struct FFBootmgrOptions
|
||||
{
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFBootmgrOptions;
|
||||
@@ -52,7 +52,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
|
||||
if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, percent, options->percent);
|
||||
ffPercentAppendBar(&str, percent, options->percent, &options->moduleArgs);
|
||||
}
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -60,7 +60,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffPercentAppendNum(&str, percent, options->percent, str.length > 0);
|
||||
ffPercentAppendNum(&str, percent, options->percent, str.length > 0, &options->moduleArgs);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
@@ -68,7 +68,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY valueStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&valueStr, percent, options->percent, false);
|
||||
ffPercentAppendNum(&valueStr, percent, options->percent, false, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &valueStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name},
|
||||
|
||||
+75
-22
@@ -6,16 +6,24 @@
|
||||
#include "modules/cpu/cpu.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 8
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 10
|
||||
|
||||
static int sortCores(const FFCPUCore* a, const FFCPUCore* b)
|
||||
{
|
||||
return (int)b->freq - (int)a->freq;
|
||||
}
|
||||
|
||||
void ffPrintCPU(FFCPUOptions* options)
|
||||
{
|
||||
FFCPUResult cpu;
|
||||
cpu.temperature = FF_CPU_TEMP_UNSET;
|
||||
cpu.coresPhysical = cpu.coresLogical = cpu.coresOnline = 0;
|
||||
cpu.frequencyMin = cpu.frequencyMax = cpu.frequencyBase = 0.0/0.0;
|
||||
ffStrbufInit(&cpu.name);
|
||||
ffStrbufInit(&cpu.vendor);
|
||||
FFCPUResult cpu = {
|
||||
.temperature = FF_CPU_TEMP_UNSET,
|
||||
.frequencyMin = 0.0/0.0,
|
||||
.frequencyMax = 0.0/0.0,
|
||||
.frequencyBase = 0.0/0.0,
|
||||
.frequencyBiosLimit = 0.0/0.0,
|
||||
.name = ffStrbufCreate(),
|
||||
.vendor = ffStrbufCreate()
|
||||
};
|
||||
|
||||
const char* error = ffDetectCPU(options, &cpu);
|
||||
|
||||
@@ -48,33 +56,64 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
if(cpu.coresOnline > 1)
|
||||
ffStrbufAppendF(&str, " (%u)", cpu.coresOnline);
|
||||
|
||||
double freq = cpu.frequencyMax;
|
||||
if(freq != freq)
|
||||
double freq = cpu.frequencyBiosLimit;
|
||||
if(freq <= 0.0000001)
|
||||
freq = cpu.frequencyMax;
|
||||
if(freq <= 0.0000001)
|
||||
freq = cpu.frequencyBase;
|
||||
if(freq == freq)
|
||||
if(freq > 0.0000001)
|
||||
ffStrbufAppendF(&str, " @ %.*f GHz", options->freqNdigits, freq);
|
||||
|
||||
if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET
|
||||
{
|
||||
ffStrbufAppendS(&str, " - ");
|
||||
ffTempsAppendNum(cpu.temperature, &str, options->tempConfig);
|
||||
ffTempsAppendNum(cpu.temperature, &str, options->tempConfig, &options->moduleArgs);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY coreTypes = ffStrbufCreate();
|
||||
uint32_t typeCount = 0;
|
||||
while (cpu.coreTypes[typeCount].count != 0 && typeCount < sizeof(cpu.coreTypes) / sizeof(cpu.coreTypes[0])) typeCount++;
|
||||
if (typeCount > 0)
|
||||
{
|
||||
qsort(cpu.coreTypes, typeCount, sizeof(cpu.coreTypes[0]), (void*) sortCores);
|
||||
|
||||
for (uint32_t i = 0; i < typeCount; i++)
|
||||
ffStrbufAppendF(&coreTypes, "%s%u", i == 0 ? "" : "+", cpu.coreTypes[i].count);
|
||||
}
|
||||
else
|
||||
ffStrbufAppendF(&coreTypes, "%u", cpu.coresOnline);
|
||||
|
||||
char freqBase[32], freqMax[32], freqBioslimit[32];
|
||||
if (cpu.frequencyBase > 0)
|
||||
snprintf(freqBase, sizeof(freqBase), "%.*f", options->freqNdigits, cpu.frequencyBase);
|
||||
else
|
||||
freqBase[0] = 0;
|
||||
if (cpu.frequencyMax > 0)
|
||||
snprintf(freqMax, sizeof(freqMax), "%.*f", options->freqNdigits, cpu.frequencyMax);
|
||||
else
|
||||
freqMax[0] = 0;
|
||||
if (cpu.frequencyBiosLimit > 0)
|
||||
snprintf(freqBioslimit, sizeof(freqBioslimit), "%.*f", options->freqNdigits, cpu.frequencyBiosLimit);
|
||||
else
|
||||
freqBioslimit[0] = 0;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig);
|
||||
ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPU_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyBase},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr}
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqBase},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqMax},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &coreTypes},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqBioslimit},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -143,12 +182,15 @@ void ffGenerateCPUJsonConfig(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
|
||||
void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
FFCPUResult cpu;
|
||||
cpu.temperature = FF_CPU_TEMP_UNSET;
|
||||
cpu.coresPhysical = cpu.coresLogical = cpu.coresOnline = 0;
|
||||
cpu.frequencyMin = cpu.frequencyMax = cpu.frequencyBase = 0.0/0.0;
|
||||
ffStrbufInit(&cpu.name);
|
||||
ffStrbufInit(&cpu.vendor);
|
||||
FFCPUResult cpu = {
|
||||
.temperature = FF_CPU_TEMP_UNSET,
|
||||
.frequencyMin = 0.0/0.0,
|
||||
.frequencyMax = 0.0/0.0,
|
||||
.frequencyBase = 0.0/0.0,
|
||||
.frequencyBiosLimit = 0.0/0.0,
|
||||
.name = ffStrbufCreate(),
|
||||
.vendor = ffStrbufCreate()
|
||||
};
|
||||
|
||||
const char* error = ffDetectCPU(options, &cpu);
|
||||
|
||||
@@ -175,6 +217,15 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
yyjson_mut_obj_add_real(doc, frequency, "base", cpu.frequencyBase);
|
||||
yyjson_mut_obj_add_real(doc, frequency, "max", cpu.frequencyMax);
|
||||
yyjson_mut_obj_add_real(doc, frequency, "min", cpu.frequencyMin);
|
||||
yyjson_mut_obj_add_real(doc, frequency, "biosLimit", cpu.frequencyBiosLimit);
|
||||
|
||||
yyjson_mut_val* coreTypes = yyjson_mut_obj_add_arr(doc, obj, "coreTypes");
|
||||
for (uint32_t i = 0; i < sizeof (cpu.coreTypes) / sizeof (cpu.coreTypes[0]) && cpu.coreTypes[i].count > 0; i++)
|
||||
{
|
||||
yyjson_mut_val* core = yyjson_mut_arr_add_obj(doc, coreTypes);
|
||||
yyjson_mut_obj_add_uint(doc, core, "count", cpu.coreTypes[i].count);
|
||||
yyjson_mut_obj_add_uint(doc, core, "freq", cpu.coreTypes[i].freq);
|
||||
}
|
||||
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", cpu.temperature);
|
||||
}
|
||||
@@ -193,7 +244,9 @@ void ffPrintCPUHelpFormat(void)
|
||||
"Online core count",
|
||||
"Base frequency",
|
||||
"Max frequency",
|
||||
"Temperature (formatted)"
|
||||
"Temperature (formatted)",
|
||||
"Logical core count grouped by frequency",
|
||||
"Bios limited frequency",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
if (!options->separate)
|
||||
{
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&str, avgValue, options->percent);
|
||||
ffPercentAppendBar(&str, avgValue, options->percent, &options->moduleArgs);
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffPercentAppendNum(&str, avgValue, options->percent, str.length > 0);
|
||||
ffPercentAppendNum(&str, avgValue, options->percent, str.length > 0, &options->moduleArgs);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -66,7 +66,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffPercentAppendNum(&str, *percent, options->percent, false);
|
||||
ffPercentAppendNum(&str, *percent, options->percent, false, &options->moduleArgs);
|
||||
}
|
||||
}
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
@@ -74,11 +74,11 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY avgStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&avgStr, avgValue, options->percent, false);
|
||||
ffPercentAppendNum(&avgStr, avgValue, options->percent, false, &options->moduleArgs);
|
||||
FF_STRBUF_AUTO_DESTROY minStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&minStr, minValue, options->percent, false);
|
||||
ffPercentAppendNum(&minStr, minValue, options->percent, false, &options->moduleArgs);
|
||||
FF_STRBUF_AUTO_DESTROY maxStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&maxStr, maxValue, options->percent, false);
|
||||
ffPercentAppendNum(&maxStr, maxValue, options->percent, false, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUUSAGE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &avgStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &maxStr},
|
||||
|
||||
@@ -60,7 +60,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
{
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, bytesPercentage, options->percent);
|
||||
ffPercentAppendBar(&str, bytesPercentage, options->percent, &options->moduleArgs);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
ffPercentAppendNum(&str, bytesPercentage, options->percent, str.length > 0);
|
||||
ffPercentAppendNum(&str, bytesPercentage, options->percent, str.length > 0, &options->moduleArgs);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
}
|
||||
@@ -105,10 +105,10 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY bytesPercentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&bytesPercentageStr, bytesPercentage, options->percent, false);
|
||||
ffPercentAppendNum(&bytesPercentageStr, bytesPercentage, options->percent, false, &options->moduleArgs);
|
||||
FF_STRBUF_AUTO_DESTROY filesPercentageStr = ffStrbufCreate();
|
||||
double filesPercentage = disk->filesTotal > 0 ? ((double) disk->filesUsed / (double) disk->filesTotal) * 100.0 : 0;
|
||||
ffPercentAppendNum(&filesPercentageStr, filesPercentage, options->percent, false);
|
||||
ffPercentAppendNum(&filesPercentageStr, filesPercentage, options->percent, false, &options->moduleArgs);
|
||||
|
||||
bool isExternal = !!(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT);
|
||||
bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
|
||||
|
||||
@@ -19,14 +19,14 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device
|
||||
{
|
||||
if (buffer.length)
|
||||
ffStrbufAppendC(&buffer, ' ');
|
||||
ffPercentAppendNum(&buffer, device->battery, options->percent, buffer.length > 0);
|
||||
ffPercentAppendNum(&buffer, device->battery, options->percent, buffer.length > 0, &options->moduleArgs);
|
||||
}
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false);
|
||||
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GAMEPAD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
|
||||
+45
-10
@@ -45,7 +45,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
|
||||
{
|
||||
ffStrbufAppendS(&output, " - ");
|
||||
ffTempsAppendNum(gpu->temperature, &output, options->tempConfig);
|
||||
ffTempsAppendNum(gpu->temperature, &output, options->tempConfig, &options->moduleArgs);
|
||||
}
|
||||
|
||||
if(gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET && gpu->dedicated.total != 0)
|
||||
@@ -61,7 +61,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffStrbufAppendS(&output, ", ");
|
||||
ffPercentAppendNum(&output, (double) gpu->dedicated.used / (double) gpu->dedicated.total * 100.0, options->percent, false);
|
||||
ffPercentAppendNum(&output, (double) gpu->dedicated.used / (double) gpu->dedicated.total * 100.0, options->percent, false, &options->moduleArgs);
|
||||
}
|
||||
ffStrbufAppendC(&output, ')');
|
||||
}
|
||||
@@ -74,7 +74,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(gpu->temperature, &tempStr, options->tempConfig);
|
||||
ffTempsAppendNum(gpu->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GPU_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name},
|
||||
@@ -127,6 +127,7 @@ void ffPrintGPU(FFGPUOptions* options)
|
||||
ffStrbufDestroy(&gpu->vendor);
|
||||
ffStrbufDestroy(&gpu->name);
|
||||
ffStrbufDestroy(&gpu->driver);
|
||||
ffStrbufDestroy(&gpu->platformApi);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,9 +144,15 @@ bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "force-vulkan"))
|
||||
if (ffStrEqualsIgnCase(subKey, "detection-method"))
|
||||
{
|
||||
options->forceVulkan = ffOptionParseBoolean(value);
|
||||
options->detectionMethod = (FFGPUDetectionMethod) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
|
||||
{ "auto", FF_GPU_DETECTION_METHOD_AUTO },
|
||||
{ "pci", FF_GPU_DETECTION_METHOD_PCI },
|
||||
{ "vulkan", FF_GPU_DETECTION_METHOD_VULKAN },
|
||||
{ "opengl", FF_GPU_DETECTION_METHOD_OPENGL },
|
||||
{},
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -190,9 +197,20 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "forceVulkan"))
|
||||
if (ffStrEqualsIgnCase(key, "detectionMethod"))
|
||||
{
|
||||
options->forceVulkan = yyjson_get_bool(val);
|
||||
int value;
|
||||
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
|
||||
{ "auto", FF_GPU_DETECTION_METHOD_AUTO },
|
||||
{ "pci", FF_GPU_DETECTION_METHOD_PCI },
|
||||
{ "vulkan", FF_GPU_DETECTION_METHOD_VULKAN },
|
||||
{ "opengl", FF_GPU_DETECTION_METHOD_OPENGL },
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options->detectionMethod = (FFGPUDetectionMethod) value;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -229,8 +247,24 @@ void ffGenerateGPUJsonConfig(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
if (options->driverSpecific != defaultOptions.driverSpecific)
|
||||
yyjson_mut_obj_add_bool(doc, module, "driverSpecific", options->driverSpecific);
|
||||
|
||||
if (options->forceVulkan != defaultOptions.forceVulkan)
|
||||
yyjson_mut_obj_add_bool(doc, module, "forceVulkan", options->forceVulkan);
|
||||
if (options->detectionMethod != defaultOptions.detectionMethod)
|
||||
{
|
||||
switch (options->detectionMethod)
|
||||
{
|
||||
case FF_GPU_DETECTION_METHOD_AUTO:
|
||||
yyjson_mut_obj_add_str(doc, module, "detectionMethod", "auto");
|
||||
break;
|
||||
case FF_GPU_DETECTION_METHOD_PCI:
|
||||
yyjson_mut_obj_add_str(doc, module, "detectionMethod", "pci");
|
||||
break;
|
||||
case FF_GPU_DETECTION_METHOD_VULKAN:
|
||||
yyjson_mut_obj_add_str(doc, module, "detectionMethod", "vulkan");
|
||||
break;
|
||||
case FF_GPU_DETECTION_METHOD_OPENGL:
|
||||
yyjson_mut_obj_add_str(doc, module, "detectionMethod", "opengl");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ffTempsGenerateJsonConfig(doc, module, defaultOptions.temp, defaultOptions.tempConfig, options->temp, options->tempConfig);
|
||||
|
||||
@@ -327,6 +361,7 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
ffStrbufDestroy(&gpu->vendor);
|
||||
ffStrbufDestroy(&gpu->name);
|
||||
ffStrbufDestroy(&gpu->driver);
|
||||
ffStrbufDestroy(&gpu->platformApi);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,7 +399,7 @@ void ffInitGPUOptions(FFGPUOptions* options)
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
|
||||
options->driverSpecific = false;
|
||||
options->forceVulkan = false;
|
||||
options->detectionMethod = FF_GPU_DETECTION_METHOD_AUTO;
|
||||
options->temp = false;
|
||||
options->hideType = FF_GPU_TYPE_UNKNOWN;
|
||||
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user