Compare commits

..

278 Commits

Author SHA1 Message Date
李通洲 4fd65ad0b8 CI: try fixing musl build 2024-05-23 13:31:53 +08:00
李通洲 6ecb383a6a Editor: remove unused functions 2024-05-23 09:00:16 +08:00
Carter Li 1b3977fc47 Merge pull request #958 from fastfetch-cli/dev
Release v2.13.2
2024-05-22 12:12:15 +00:00
李通洲 f00969cb81 Editor: fix path detection not working on Android 2024-05-22 18:38:25 +08:00
李通洲 b3e79477a6 EDITOR: always print exe in JSON results 2024-05-22 16:40:37 +08:00
李通洲 82c7f27ae7 Release: v2.13.2 2024-05-22 16:32:35 +08:00
李通洲 624a4956fc CI: test more functions 2024-05-22 16:32:35 +08:00
李通洲 30a5dd52b1 Editor: add new module
Fix #430
2024-05-22 16:32:27 +08:00
李通洲 92136370bb CI: add bootmgr 2024-05-22 16:09:09 +08:00
李通洲 d196b8079e GPU (Linux): don't query DRM drivers for driver version
Fix #956
2024-05-22 13:37:50 +08:00
李通洲 a3dbac7dfc Completion (Fish): fix compatibility for old python versions 2024-05-22 10:34:07 +08:00
李通洲 59c853fb01 GPU: write & use our own simplified nvml header 2024-05-21 22:31:36 +08:00
李通洲 5ec272acff OS (Linux): remove special handling of Loc-OS
Unless a proper reason is provided
2024-05-21 18:53:31 +08:00
CuerdOS c72fdab301 Logo (Builtin): Added CuerdOS support (#954)
* Added CuerdOS support

* Update os_linux.c

* Update os_linux.c

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2024-05-21 18:51:48 +08:00
李通洲 183f12d8b5 Presets: fix bad nerd icons 2024-05-21 15:47:37 +08:00
Carter Li 395810cd79 DisplayServer (Wayland): don't display eDP-1-unknown 2024-05-21 14:25:09 +08:00
Carter Li 36cf5856b5 Merge pull request #952 from fastfetch-cli/dev
Release: v2.13.1
2024-05-21 01:42:10 +00:00
李通洲 01d1336cf0 CPU (FreeBSD): remove unused variables 2024-05-21 09:28:21 +08:00
李通洲 28f2e9ea96 Release: v2.13.1 2024-05-21 09:24:53 +08:00
Carter Li 2d4e7f10c4 CPU: add option --show-pe-core-count 2024-05-21 09:21:03 +08:00
Carter Li aa1a5b8c36 CPU: fix CPU frequency not displayed if bios_limit doesn't exist
Regression of 264b6794f3
2024-05-21 08:44:49 +08:00
Carter Li 43bdb68cbf Merge pull request #949 from fastfetch-cli/dev
Release: v2.13.0
2024-05-20 13:28:45 +00:00
李通洲 8b43e331e3 GPU (Linux): silence compiler warnings 2024-05-20 21:07:28 +08:00
李通洲 302716fa61 GPU: silence compiler warnings 2024-05-20 20:43:24 +08:00
李通洲 188b6aba10 Release: v2.13.0 2024-05-20 20:40:25 +08:00
李通洲 7af9cab688 CI: try fixing Win32 build 2024-05-20 19:37:14 +08:00
李通洲 714b88c638 Packages (Linux): try fixing nix-user detection
Fix #937
2024-05-20 19:14:32 +08:00
李通洲 d9f1db10aa Completions (Fish): disable enum value suggestion 2024-05-20 19:05:38 +08:00
李通洲 bb10e1c9a3 Doc: update help message of --gpu-detection-method 2024-05-20 19:04:57 +08:00
李通洲 264b6794f3 CPU (Linux): detect bios limited frequency and print it by default
To match neofetch's behavior

Fix #947
2024-05-20 18:35:10 +08:00
Carter Li a8b734c877 GPU: change option --gpu-force-vulkan to --gpu-detection-method 2024-05-20 16:46:04 +08:00
Carter Li 10ca77610e GPU (Linux): detect GPU core count and freq for asahi linux 2024-05-20 15:32:13 +08:00
Carter Li c2eaea3665 Logo (Builtin): fix KDE neon
Fix #948
2024-05-20 15:31:18 +08:00
Carter Li 1619f0ab6c GPU (Linux): fix memory leaks 2024-05-20 11:00:51 +08:00
李通洲 aba211221b Doc: update README [ci skip] 2024-05-19 23:07:10 +08:00
李通洲 81485baadb CPU: better compatibility for Intel CPUs 2024-05-19 22:18:07 +08:00
李通洲 1b4fc38330 GPU (Linux): detect drm driver version 2024-05-19 22:18:06 +08:00
李通洲 3571d9277d CPU (Linux): take --cpu-freq-ndigits into account in --cpu-format 2024-05-19 22:18:06 +08:00
李通洲 e9b535d277 GPU (Linux): improve perf 2024-05-19 22:18:06 +08:00
李通洲 09ffd32144 GPU (Linux): improve Intel GPU detection code 2024-05-19 22:18:06 +08:00
Sergey Fedorov 27aa5c0343 opencl.c: unbreak build on macOS with no OpenCL support (#940)
Fixes: https://github.com/fastfetch-cli/fastfetch/issues/939
2024-05-19 21:51:46 +08:00
Sergey Fedorov 1d95f9b224 CMakeLists: unbreak build with GCC on macOS (#941) 2024-05-19 21:46:34 +08:00
李通洲 4f1cb779ab OS (Linux): fix BUILD_ID not parsed 2024-05-19 11:12:38 +08:00
Shu Niu 758ddae344 macOS: Add support for old MacOS version (#936)
* Add support for old MacOS version,  fix-1.

* Add support for old MacOS version,  fix-2.

* Add support for old MacOS version with fixing metal gpu api.

* Update disk_bsd.c

* Update disk_bsd.c

* Update gpu_apple.m

* Update monitor_apple.m

* Update os_apple.m

* Update wifi_apple.m

* Update camera_apple.m

* Update camera_apple.m

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2024-05-19 09:31:08 +08:00
李通洲 14969b31d0 CPU (Windows): fix silly mistake 2024-05-18 20:53:11 +08:00
李通洲 d88e2eeb36 CPU (macOS): fix compiling 2024-05-18 19:57:24 +08:00
李通洲 7946e69a66 CPU: print core count for different core types 2024-05-18 18:08:38 +08:00
Carter Li 15766f5266 Disk (BSD): dont set createTime if stat fails to detect it 2024-05-18 13:38:07 +08:00
Carter Li ed02845c40 OS (Linux): better code name detection 2024-05-18 13:11:22 +08:00
Carter Li 4ffa0ffcb7 Disk (FreeBSD): ensure createTime is inited 2024-05-18 13:09:37 +08:00
Carter Li c04c040713 Wifi (FreeBSD): fix bssid & status detection 2024-05-18 11:58:35 +08:00
Matheus Castello c763896b49 Logo (builtin): Fix TorizonCore logo colors (#934)
You can verify the colors of the logo from https://www.torizon.io/

Signed-off-by: Matheus Castello <matheus.castello@toradex.com>
2024-05-18 11:57:21 +08:00
李通洲 e9a44f71b2 Bootmgr (Android): fix compiling 2024-05-18 11:08:21 +08:00
李通洲 5078c8d910 Revert "GPU (Windows): try removing limitation"
This reverts commit eda9496479.
2024-05-18 10:39:51 +08:00
李通洲 f9e0efb7ee Smbios: improve SMBIOS data reading code 2024-05-18 10:35:17 +08:00
Carter Li 926390508e CPU (FreeBSD): fix core count detection 2024-05-18 16:43:33 +08:00
Carter Li 45446c1c1d Bootmgr (FreeBSD): silence compiler warnings 2024-05-18 16:41:30 +08:00
Carter Li b79c47cac9 CPU (BSD): fix max freq detection 2024-05-18 01:50:21 +08:00
Carter Li fd16e69464 CPU (macOS): fix core count detection 2024-05-18 01:46:56 +08:00
李通洲 92abf3e063 TerminalShell (Linux): ignore valgrind 2024-05-18 00:34:08 +08:00
Carter Li 90a242a4aa CPU (BSD): detect max / min frequency; detect core count of different core types 2024-05-18 00:34:08 +08:00
furretpaws 1118c57d8f Logo (Builtin): Added "Furreto Linux" support (#927)
* added furreto

* fixed

* fix i think

* Update furreto.txt

Remove left padding and empty lines. Replace `${cN}` with `$N`

* Update builtin.c

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2024-05-18 00:28:34 +08:00
李通洲 eda9496479 GPU (Windows): try removing limitation 2024-05-17 21:42:11 +08:00
李通洲 0b94ff5adb CPU (Windows): detect core count of different core types 2024-05-17 21:31:24 +08:00
李通洲 62bf3ec021 Util (Windows): add nt.h and use it 2024-05-17 21:30:47 +08:00
李通洲 ab2268a927 CPU (macOS): detect core count for different core types 2024-05-17 16:47:26 +08:00
Carter Li 1421627a47 CPU (Linux): detect core count for different core types 2024-05-17 08:35:22 +00:00
李通洲 02e5232bda TerminalShell: ignore clifm
Ref: https://github.com/leo-arch/clifm/issues/289
2024-05-17 13:57:07 +08:00
李通洲 289d03cfb2 Kernel (Windows): detect old release code name for Windows 10 2024-05-17 10:34:04 +08:00
李通洲 965ab1abc4 Packages: don't break existing config 2024-05-17 09:28:17 +08:00
Anonyzard 06b2ff9a08 Add Loc-OS Linux support (#926)
* Logo (Builtin): add Loc-OS

* Packages (Linux): add lpkg and lpkgbuild detection
2024-05-17 09:19:26 +08:00
李通洲 b4a6606faf Doc: update FAQ [ci skip] 2024-05-16 23:47:25 +08:00
李通洲 def758580f Doc: update FAQ [ci skip] 2024-05-16 23:34:40 +08:00
李通洲 5ea2b2ecc9 Doc: update FAQ [ci skip] 2024-05-16 23:26:07 +08:00
李通洲 b3886c6c47 Doc: update FAQ section [ci skip] 2024-05-16 21:58:43 +08:00
李通洲 bc76220a5b Doc: update JSON schema [ci skip] 2024-05-16 18:48:27 +08:00
李通洲 60fa7946f5 Logo (Builtin): fix build 2024-05-16 18:30:40 +08:00
SpoinkOSDevs b6a703bd56 Logo (builtin): Add SpoinkOS Logo [FIXED!] (#925)
* Update builtin.c

* Create spoinkos.txt

* Fix coding style

* Remove left padding

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2024-05-16 16:44:01 +08:00
李通洲 462c3b0e06 Bios / Bootmgr: update descriptions 2024-05-16 16:37:57 +08:00
李通洲 72138dbde5 Bootmgr (macOS): add support 2024-05-16 16:27:37 +08:00
李通洲 b2ea5d8f3e Bootmgr: reuse shared code 2024-05-16 13:24:34 +08:00
Carter Li 49080c5361 Bootmgr (FreeBSD): add support
Requires root permission
2024-05-16 11:01:11 +08:00
李通洲 445dd94b53 Bootmgr: add new module 2024-05-15 21:49:15 +08:00
李通洲 7c03fc1550 Bios: move bootmgr detection to a new module 2024-05-15 21:40:18 +08:00
李通洲 06a8f12d6a Bios (Windows): detect secure boot state & boot manager
Boot manager detection requires Administrator privilege to work
2024-05-15 20:39:22 +08:00
Carter Li 8c7edf4d2d Bios (Linux): detect boot manager & secure boot 2024-05-15 19:00:26 +08:00
李通洲 85b4679373 Logo: fix Manjaro Linux
Fix #921
2024-05-14 22:04:37 +08:00
Carter Li 215029ea27 Merge pull request #919 from fastfetch-cli/dev
Release: v2.12.0
2024-05-14 15:53:45 +08:00
李通洲 533f54fb73 Doc: update changelog [ci skip] 2024-05-14 15:20:22 +08:00
李通洲 a6212c5b01 PhysicalMemory: add Ramaxel vendor id support 2024-05-14 14:11:12 +08:00
李通洲 ba76b18367 Fastfetch: remove support of flag based config 2024-05-14 14:08:54 +08:00
李通洲 4290efb49d Release: v2.12.0 2024-05-14 10:48:21 +08:00
李通洲 30b85fc169 JsonConfig: report row and column on JSON parsing errors 2024-05-14 10:47:20 +08:00
李通洲 dc94ac8d0c Doc: update json_schema 2024-05-14 10:25:29 +08:00
李通洲 1d9e612262 Presets: update [ci skip] 2024-05-14 09:11:27 +08:00
李通洲 be1791e386 LocalIP: add option --localip-show-all-ips 2024-05-13 23:33:06 +08:00
李通洲 3b8c2d6ee6 Logo (Builtin): add Quirinux 2024-05-13 22:27:35 +08:00
Null-Ping c661e55053 PhysicalMemory: Fix ram vendor names from ids. (#917)
Change 0x0198 from HyperX to Kingston to match https://www.jedec.org/standards-documents/docs/jep-106ab. (The standard does not contain an entry for HyperX at all).
Remove the ambiguous 0x1315 - according to the standard, it belongs to Tioga Technologies and not Crucial.
Rename Hynix to SK Hynix to match the standard.
2024-05-13 22:20:27 +08:00
李通洲 56403bab5c PhysicalMemory: try converting vendor ID to name 2024-05-13 20:29:46 +08:00
李通洲 caef317ade GPU: a tiny optimization 2024-05-13 19:33:31 +08:00
李通洲 131e01f35b Presets: add archey
Ref: https://github.com/HorlogeSkynet/archey4
2024-05-13 16:45:14 +08:00
李通洲 c8e3c6882a Kernel: print kernel name in default format 2024-05-13 16:41:00 +08:00
李通洲 c985bdbbfd Logo: add macOS3 2024-05-13 15:50:10 +08:00
李通洲 b80eb47ecd PhysicalMemory: better Linux compatibility 2024-05-13 15:08:27 +08:00
Carter Li 68942c1d3f PhysicalMemory (FreeBSD): fix EFAULT errors 2024-05-13 11:06:05 +08:00
李通洲 b36b74448f Doc: update changelog 2024-05-12 20:24:56 +08:00
李通洲 217bb6657e PhysicalMemory: fix output format 2024-05-12 20:17:57 +08:00
李通洲 df2862996b PhysicalMemory: detect ecc & bank locator 2024-05-12 19:55:04 +08:00
李通洲 df6ab6427e PhysicalMemory: improve default output format; detect part number 2024-05-12 19:15:03 +08:00
李通洲 82d848727c Logo (Builtin): fix alternate logo doesn't work with type builtin
Fix #914
2024-05-12 18:32:05 +08:00
李通洲 d0d6323b1f PhysicalMemory (FreeBSD): add support 2024-05-12 18:32:05 +08:00
李通洲 6439921f85 Smbios (Windows): check if getting SMBIOS data succeeds 2024-05-11 18:07:56 +08:00
李通洲 d28907ee9d PhysicalMemory (Linux): add support
Note: this module requires root permission to work in Linux
2024-05-11 18:05:30 +08:00
李通洲 41f0971570 PhysicalMemory: ignore trash values 2024-05-11 15:12:28 +08:00
李通洲 ab0bd79bb8 PhysicalMemory: add module to ci.jsonc and all.jsonc 2024-05-11 15:05:43 +08:00
李通洲 07747aa819 PhysicalMemory (macOS): add support 2024-05-11 15:05:43 +08:00
李通洲 68efcdd0dd PhysicalMemory: add new module 2024-05-11 15:05:43 +08:00
李通洲 fef3100fd7 Smbios: add struct layout check 2024-05-11 15:05:43 +08:00
Bernhard M. Wiedemann 08a940bfd4 Logo: Add the openSUSE Slowroll distribution (#913) 2024-05-11 15:03:13 +08:00
李通洲 d6a99c631e Image: support specifying --logo-width only for --kitty-direct and --iterm
Fix: #836

Ref: https://github.com/kovidgoyal/kitty/issues/7424
2024-05-10 14:30:00 +08:00
李通洲 3d4077c2d0 Config: support more color prefixes 2024-05-10 13:39:06 +08:00
djinnalexio ce6b595421 🔧 JsonConfig: add missing brightness properties 2024-05-10 11:13:47 +08:00
djinnalexio 7d8c085254 🔧 JsonConfig: add dim colors to validation 2024-05-10 11:13:47 +08:00
Souma ec0af17fb5 Terminal (macOS): fix compatibility with (*term) (#909)
Ignore <shell> (<char>term).
This is because Fig(<shell> (figterm)) migrated to CodeWhisperer(<shell> (cwterm)) and CodeWhisperer renamed to Q(<shell> (qterm)).
Future changes will all be ignored by this change.
Related: #676
2024-05-09 19:39:17 +08:00
李通洲 2accfbc894 Networking (Windows): fix compiling 2024-05-09 16:35:51 +08:00
李通洲 01d2fa1228 Doc: update changelog (ci skip) 2024-05-09 16:32:10 +08:00
李通洲 f16843d60f Doc: update changelog 2024-05-09 16:27:24 +08:00
李通洲 acc77ebddd PublicIP: add option --publicip-ipv6 2024-05-09 15:54:49 +08:00
李通洲 7eb145fb7f Presets: add loadavg to all.jsonc and ci.jsonc 2024-05-09 09:56:34 +08:00
Carter Li 34a6eb13c6 Loadavg (BSD): add missing headers 2024-05-09 09:51:41 +08:00
李通洲 0f5e746fe2 Loadavg: add option --loadavg-ndigits 2024-05-09 09:40:53 +08:00
李通洲 b62ad16aa6 Loadavg (BSD): use sysctl 2024-05-09 09:20:18 +08:00
李通洲 f79498e4b5 PublicIP / Weather: clarify error messages
Fix #907
2024-05-09 08:49:25 +08:00
李通洲 31c433b353 Display: rename --temperature-* to --temp-* as stated in help messages
Fix #908
2024-05-09 08:46:59 +08:00
李通洲 852c6abf2e Loadavg (Android): fix compiling 2024-05-08 21:54:13 +08:00
Quinten Van Damme df3fa6f8a8 Logo: Fix dahliaOS detection (#906) 2024-05-08 19:30:25 +08:00
李通洲 738daa1c77 Loadavg: new module 2024-05-08 18:34:34 +08:00
李通洲 4204cfc500 Doc: update help message for --module-output-color 2024-05-08 16:17:05 +08:00
李通洲 9cb08d115a Separator: add --separator-output-color 2024-05-08 16:11:16 +08:00
李通洲 459f159b1b Fastfetch: revert to module color after printing custom colors 2024-05-08 15:25:59 +08:00
李通洲 2880536513 Fastfetch: support --module-ouput-color (WIP) 2024-05-08 15:01:57 +08:00
李通洲 64cb1bfdfd Doc: remove duplicated entry 2024-05-08 14:33:00 +08:00
李通洲 b80c30ace3 Doc: default --hide-cursor to false 2024-05-08 11:06:38 +08:00
李通洲 19b8849bfc Fastfetch: remove the long deprecated flag --set & `-set-keyless 2024-05-08 11:06:03 +08:00
Carter Li 8f457f047c TerminalFont (Linux): searching for font config in st binary 2024-05-08 09:54:33 +08:00
Carter Li 299bc7468f Terminal (Linux): fix exePath detection 2024-05-08 09:54:33 +08:00
Carter Li c213b0769b Merge remote-tracking branch 'origin/master' into dev 2024-05-07 09:34:02 +08:00
AcatXIo 260c883d07 Presets: Update hardware.jsonc (#899)
Update hardware.jsonc preset, fix logo being forced to arch, add more hardware information.
2024-05-07 08:54:36 +08:00
Carter Li da0db042fa Merge pull request #897 from fastfetch-cli/dev
Release: 2.11.5
2024-05-07 00:41:44 +08:00
李通洲 ae5732e2a8 Release: v2.11.5 2024-05-07 00:38:08 +08:00
李通洲 1f05a33807 Logo (Builtin): temp fix for openmandriva logo detection
Fix #896
2024-05-07 00:19:07 +08:00
李通洲 f090951abc Doc: remove --os-file completely 2024-05-06 22:48:46 +08:00
Carter Li 855fd6edee Merge pull request #890 from fastfetch-cli/dev
Release v2.11.4
2024-05-06 20:06:58 +08:00
李通洲 d4bd4401a8 Release: v2.11.4 2024-05-06 19:45:45 +08:00
李通洲 689feb39a4 OS (Linux): don't detect debian version on debian derived distros 2024-05-06 18:42:19 +08:00
Carter Li 0f64e2830a OS (Linux): detect pve & armbian 2024-05-06 16:46:27 +08:00
Carter Li 3e24cdc752 CMake: add option CUSTOM_OS_RELEASE_PATH
And remove `--os-file`
2024-05-06 16:25:08 +08:00
李通洲 dc9c285a0b Doc: update README
Who cares how people install a package...

Close #883
2024-05-06 15:56:46 +08:00
李通洲 1d03c9c85e Logo (Builtin): add armbian
Fix #842
2024-05-06 15:22:43 +08:00
李通洲 4eae11df64 Presets: fix neofetch 2024-05-06 15:09:12 +08:00
李通洲 eba13d5485 JsonConfig: fix setting size.ndigits doesn't work
Silly copy & paste error
2024-05-06 15:08:58 +08:00
apocelipes 16b875ef5a Fastfetch: fix memory leaks when passing informative options
Informative options (e.g. "--help", "--list-module") make fastfetch
exit before calling ffDestroyInstance. Using "atexit" to avoid this
kind of leak.
2024-05-06 14:40:27 +08:00
李通洲 366138e1bd CI: try fixing Linux armv7 2024-05-06 14:08:29 +08:00
李通洲 7fe18a5b7c CI: build armv7 package using ubuntu22.04
Hopefully make it usable on RaspberryPi

Fix #884
2024-05-06 09:33:58 +08:00
李通洲 39cd8cfb4c Camera: fix deprecation warning for macOS 14.0 hopefully
Fix #860
2024-05-06 09:25:06 +08:00
李通洲 8b441c85e5 Logo (Builtin): update ubuntu 2024-05-05 23:31:23 +08:00
李通洲 f66e901c44 Presets: remove unsupported format placeholders 2024-05-05 22:12:33 +08:00
李通洲 3815823a20 CMake: enforce glibc version 2024-05-05 21:29:49 +08:00
李通洲 33ff4870dc Fastfetch: enable pipe mode if $NO_COLOR is set 2024-05-05 20:16:43 +08:00
李通洲 479731f076 Custom: don't print ANSI escape code in pipe mode 2024-05-05 20:14:24 +08:00
李通洲 d2f3f47457 Colors: print non-colored blocks in pipe mode 2024-05-05 20:14:24 +08:00
李通洲 5ea89ecba5 Fastfetch: print non-colored logo in pipe mode 2024-05-05 20:14:23 +08:00
Carter Li 865f57bd76 Revert "FFstrbuf: avoid redundant checks (#881)" (#882)
This reverts commit e98e2a3d52.
2024-05-05 18:46:22 +08:00
Nour1248 e98e2a3d52 FFstrbuf: avoid redundant checks (#881) 2024-05-05 18:40:59 +08:00
Carter Li 6bb748869e Terminal (macOS): fix Apple Terminal detection
Fix #878
2024-05-05 13:36:14 +08:00
李通洲 654721b8c5 Doc: remove (kind of) outdated information
Fix #867
2024-05-05 08:39:51 +08:00
Carter Li 0542eac1b9 Doc: metion ANSI 256 colors
Fix #869
2024-05-05 07:33:32 +08:00
apocelipes b9faf8d77f fastfetch: fix #868 (#871)
Fix #868.
2024-05-05 07:10:51 +08:00
Carter Li 61f848146a Merge pull request #862 from fastfetch-cli/dev
Release: v2.11.3
2024-05-04 20:47:54 +08:00
李通洲 4175dfdc3a Doc: update changelog (ci skip) 2024-05-04 20:27:26 +08:00
李通洲 861d9006d7 Release: v2.11.3 2024-05-04 20:11:30 +08:00
李通洲 7ba07bd2e0 Logo (Image): partially revert 71cba24
Images in SSH session and tmux do work for me

Fix #861
2024-05-04 19:43:41 +08:00
李通洲 9fee36a286 Logo (Image): ensure line ending is printed when printing errors 2024-05-04 19:14:45 +08:00
李通洲 2fc9230b29 Disk (Windows): use sub thread to check accessiblity of remote volumes. 2024-05-04 15:15:00 +08:00
李通洲 5fb1286e15 Battery (Windows): simplify code 2024-05-04 12:11:42 +08:00
李通洲 a4cace4765 CMake: add CUSTOM_AMDGPU_IDS_PATH 2024-05-04 10:06:49 +08:00
李通洲 c6d2467a83 Merge remote-tracking branch 'upstream/master' into dev 2024-05-04 10:06:40 +08:00
AxeldeWater db0d38202e Update README.md again for same reason different location (#857)
Oversaw a place where it wasn't updated either
2024-05-04 07:13:38 +08:00
AxeldeWater 9fbb23b135 Update README.md about installing fastfetch on Debian/Ubuntu (#856)
Apparently the file naming standard was changed over time but this was not updated in the README
2024-05-04 00:00:44 +08:00
李通洲 3a990e495b PhysicalDisk: fix temp output in custom formation
I hate `void *`
2024-05-03 20:48:51 +08:00
李通洲 648530ee8f PhysicalDisk: fix doubled output in custom formation
Fix #852
2024-05-03 20:42:39 +08:00
Carter Li b12a59cdaf Merge pull request #851 from fastfetch-cli/dev
Release: v2.11.2
2024-05-03 14:36:04 +08:00
李通洲 83c1fe26e6 Doc: update changelog 2024-05-03 14:14:13 +08:00
李通洲 217f98a36c Global: tidy json result formats 2024-05-03 13:56:19 +08:00
李通洲 1011e21ba8 Processing: trim \r on Windows 2024-05-03 13:46:28 +08:00
李通洲 08c6a6e4cb OS (macOS): don't print build id
Remove special handling
2024-05-03 13:20:23 +08:00
李通洲 5e9fcaf7ca OS (Linux): don't use rolling as os version 2024-05-03 13:09:14 +08:00
李通洲 8b838cef61 OS (Linux): fix name detection for MX
Fix #847
2024-05-03 12:57:51 +08:00
李通洲 22d9d8e196 OS (Linux): fix OS detection for MX Linux (2nd attempt)
Ref: #847
2024-05-03 11:28:59 +08:00
李通洲 a789b8330a Doc: update logo_request.md 2024-05-03 10:10:13 +08:00
李通洲 903ecf37f7 Chore: silience some warnings 2024-05-03 10:07:16 +08:00
李通洲 c4a876f6aa OS (Linux): Prioritize lsb-release over os-release
Fix #847
2024-05-03 10:00:18 +08:00
李通洲 82285ebeb4 Release: 2.11.2 2024-05-03 10:00:18 +08:00
李通洲 36dadcdc7f Logo (Builtin): add MX2 & fix mx distro detection
Fix: #847
2024-05-03 09:11:59 +08:00
李通洲 030c05429a Logo (Builtin): add missing FF_LOGO_LINE_TYPE_SMALL_BIT flags 2024-05-03 09:11:59 +08:00
李通洲 a462a12370 Logo (Builtin): fix distro name of DraugerOS 2024-05-03 09:11:59 +08:00
李通洲 b386365d95 Logo (Builtin): fix ascii file name 2024-05-03 09:11:59 +08:00
李通洲 158db9d7c7 Logo (Builtin): add KernelOS
Fix #848
2024-05-03 09:11:59 +08:00
李通洲 407bfa8c95 Shell: don't try detecting version of raw sh shell
Fix #849
2024-05-03 09:11:59 +08:00
李通洲 1449290e9e GPU (Linux): check NULL returned by opendir
Fix #845
2024-05-03 09:11:59 +08:00
李通洲 4c0ea7354d Logo (Image): only print error if --show-error is specified 2024-05-03 09:11:59 +08:00
李通洲 71cba2451a Logo: disable image logos in ssh and tmux sessions 2024-05-03 01:10:04 +08:00
李通洲 ef3b5df048 Doc: update man page 2024-05-03 01:10:04 +08:00
Juan 3e98034e55 Packages (Linux): check xdg state home for nix user packages (#844)
Check $XDG_STATE_HOME/nix/profile if ~/.nix-profile is not found as addressed in #837.

Fix #837
2024-05-02 22:55:50 +08:00
李通洲 1c89101522 Doc: update changelog 2024-05-02 20:45:46 +08:00
Carter Li 757e6271ff Merge pull request #840 from fastfetch-cli/dev
Release: v2.11.1
2024-05-02 20:23:35 +08:00
李通洲 c5c846aa22 CI: try build for Linux armv7 2024-05-02 20:03:40 +08:00
李通洲 23a59a15ec Release: v2.11.1 2024-05-02 19:48:17 +08:00
李通洲 4798c619d0 Battery (Android): fix uninitialized variables
Fix #760 and #838
2024-05-02 19:29:13 +08:00
李通洲 023e767237 Shell (Windows): ignore hyfetch 2024-05-02 16:27:13 +08:00
李通洲 688d9b00ab Shell (Linux): don't detect hyfetch as shell 2024-05-02 15:19:43 +08:00
李通洲 c2fe2f70dc DisplayServer (Linux): silence compiler warnings 2024-05-02 15:19:43 +08:00
李通洲 3430c10ec2 Doc: clarify --disk-folders overrides other disk options 2024-05-02 14:09:56 +08:00
李通洲 9afcc00201 Disk (Windows): don't rely on env vars 2024-05-01 19:32:15 +08:00
李通洲 cd783d1267 Presets: add a new example 2024-05-01 16:00:31 +08:00
李通洲 81480532e2 Custom: make --custom-format optional 2024-05-01 15:54:30 +08:00
李通洲 982e8a0117 Disk (Windows): make / an alias of C:\ for --disk-folders 2024-05-01 15:52:38 +08:00
李通洲 8af88a3376 Doc: fix incorrect man page
Fix #828
2024-05-01 11:55:26 +08:00
Val V 9ed2f13c78 Packages (Linux): Extended Source Mage support (#825)
* Extended Source Mage support

* Fix packages format args num

* Correct spelling
2024-05-01 11:25:04 +08:00
李通洲 d7ea774d71 CI: fix release script 2024-04-30 21:42:31 +08:00
Carter Li a4b9784c48 Merge pull request #823 from fastfetch-cli/dev
Release v2.11.0
2024-04-30 20:40:40 +08:00
Carter Li 3fe2d8091a Release: v2.11.0 2024-04-30 19:43:26 +08:00
Carter Li 78c903c403 Camera (macOS): fix building on old xcode 2024-04-30 19:22:45 +08:00
Carter Li c42711ee26 Camera (macOS): try silence system deprecation warnings 2024-04-30 18:56:45 +08:00
李通洲 367264e549 Disk: only detect folders that specified by --disk-folders
Can be used to improve performance by ignoring network disks
2024-04-30 15:42:44 +08:00
李通洲 36a0c273f9 Processing: suggest increasing --processing-timeout when child process timeouts 2024-04-30 14:52:47 +08:00
李通洲 418106c485 Revert "Disk: init variables"
This reverts commit 0576d4ca26.
2024-04-30 14:46:54 +08:00
李通洲 1058e876a7 Revert "Disk (Windows): add --disk-ignore-remote"
This reverts commit c71b04ba93.
2024-04-30 14:46:26 +08:00
李通洲 8721cc1ab5 CPU (Windows): silence compiler warnings 2024-04-30 14:43:12 +08:00
李通洲 e12642e0b9 Fastfetch: make config in jsonc overridable
Fix #821
2024-04-30 09:16:59 +08:00
李通洲 315bbb3020 GPU (Linux): constantly use *_vis_* 2024-04-30 09:16:59 +08:00
李通洲 0576d4ca26 Disk: init variables 2024-04-29 23:33:18 +08:00
李通洲 c309dbb844 Doc: update bug report template 2024-04-29 23:30:55 +08:00
李通洲 c71b04ba93 Disk (Windows): add --disk-ignore-remote 2024-04-29 23:28:20 +08:00
Carter Li f3417b1b05 Merge pull request #818 from fastfetch-cli/dev
Release: v2.10.3
2024-04-29 22:49:37 +08:00
李通洲 c597b7ec3a Release: v2.10.3 2024-04-29 21:47:39 +08:00
李通洲 8b4586b914 Packages: update help messages 2024-04-29 21:47:39 +08:00
李通洲 b65a0e2543 GPU (Linux): fix copy & paste error 2024-04-29 20:43:19 +08:00
李通洲 6e15a44168 GPU (Linux): ignore . when enumerating directories 2024-04-29 20:28:50 +08:00
李通洲 6bd3d2c434 GPU (Linux): greatly improve detection for AMD cards
Completely untested
2024-04-29 20:05:50 +08:00
李通洲 29644ef904 GPU (Linux): disable vmem detection
Ref #816
2024-04-29 13:27:57 +08:00
李通洲 39dfcb6f10 Packages (Linux): optimise nix detection code 2024-04-29 10:04:20 +08:00
Juan Llamas 882b17834c Packages (nix): use hash to cache count and process count manually (#817) 2024-04-29 09:59:05 +08:00
李通洲 bdd2908e6a Doc: update changelog 2024-04-28 10:46:08 +08:00
李通洲 d4a402f4dd Common: slience compiler warnings 2024-04-28 10:34:28 +08:00
李通洲 115b293ff5 CPU (Windows): fix silly bug... 2024-04-27 23:27:16 +08:00
李通洲 6831c095ec TerminalShell (Linux): actually fix #814 2024-04-27 23:12:45 +08:00
李通洲 81fb146869 CPU (Windows): detect max CPU freq with CPUID instruction
Note this only works when Hyper-V is not enabled

Ultimately fixes #800 #812 #815
2024-04-27 23:07:12 +08:00
李通洲 35b54fd064 Separator: add fast path for ascii strings 2024-04-27 17:30:42 +08:00
李通洲 866e65749e Init: tweaks 2024-04-27 16:36:33 +08:00
李通洲 e157b9a51f TerminalShell (Linux): fix nixos wrapped process name
Fix #814
2024-04-27 16:31:39 +08:00
李通洲 74c89cc03f Wifi (Linux): try fixing #811 2024-04-26 19:26:58 +08:00
李通洲 229c6674a4 CMake: fix #810 2024-04-25 15:48:39 +08:00
李通洲 ab8ad7ffc0 Fastfetch: default hideCursor to false
It doesn't make much difference but make user's terminal unusable if fastfetch is not exited correctly
2024-04-25 14:18:25 +08:00
Carter Li 6805cb16fb Packages: support printing total number of nix / flatpak / brew packages
Ref: https://github.com/fastfetch-cli/fastfetch/issues/436#issuecomment-2075469683
2024-04-25 09:16:12 +08:00
Carter Li e596d76430 Display (Linux): don't use *-unknown as name 2024-04-25 09:08:21 +08:00
李通洲 de4afb6507 CI: test with no dependencies installed 2024-04-24 19:40:31 +08:00
李通洲 beb5f479d9 CI: build Linux binaries with Ubuntu 20.04 again...
Ref: #808
2024-04-24 19:03:44 +08:00
李通洲 e660e61027 Swap (Windows): fix x86-32 (v2) 2024-04-24 11:04:03 +08:00
halperyon e3cdecdb14 bedrock version (#809) 2024-04-24 07:45:45 +08:00
李通洲 40320e5efa Swap (Windows): fix detection in i686 build 2024-04-23 23:29:26 +08:00
李通洲 c2fd057126 CI (macOS): revert back to macos 12 before we know what was happening 2024-04-23 22:51:22 +08:00
李通洲 ea1ef0f347 JsonSchema: add missing modules 2024-04-23 22:51:22 +08:00
Guiorgy 04456d9807 allow generation of either deb or rpm package only (#807) 2024-04-23 19:05:55 +08:00
李通洲 18240524dc DisplayServer (Linux): basic support for ukui 2024-04-23 15:32:49 +08:00
Carter Li 42b7d567a1 Merge pull request #806 from fastfetch-cli/dev
Release: v2.10.2
2024-04-23 13:46:23 +08:00
李通洲 2790493cba Release: v2.10.2 2024-04-23 13:43:16 +08:00
李通洲 8eabc49e12 DisplayServer (Linux): fix silly bug that detect x11 as wayland
Fix #805
2024-04-23 13:39:49 +08:00
192 changed files with 4917 additions and 12353 deletions
+6 -5
View File
@@ -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:
@@ -59,6 +61,10 @@ strace /path/to/fastfetch --multithreading false -s {MODULE} --pipe
If you cannot do the instructions above, please upload the core dump file:
## If fastfetch is slow
Use `time fastfetch --stat` to show time usage for each module.
## If my image logo didn't show / work
<!-- Please make sure the terminal does support the image protocol you used. Note Gnome terminal doesn't support any image protocols -->
@@ -70,10 +76,5 @@ If you cannot do the instructions above, please upload the core dump file:
## 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?
+1 -1
View File
@@ -11,7 +11,7 @@ Tip: A logo can be displayed by fastfetch without getting into fastfetch's offic
# OS
```
Paste content of /etc/os-release here. If this file doesn't exist, describe a way to identify the distro.
Paste content of /etc/os-release and /etc/lsb-release here. If none of these files exist, describe a way to identify the distro
```
# Ascii
+55 -37
View File
@@ -14,14 +14,16 @@ jobs:
- name: Install codespell
shell: bash
run: sudo apt update && sudo apt install -y codespell
run: |
sudo apt-get update || true
sudo apt-get install -y codespell
- name: Run Spellchecker
run: codespell
Linux-old-amd64:
name: Linux-old-amd64
runs-on: ubuntu-20.04
no-features-test:
name: No-features-test
runs-on: ubuntu-latest
permissions:
security-events: write
contents: read
@@ -32,28 +34,12 @@ jobs:
- name: uname -a
run: uname -a
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev directx-headers-dev
- name: install linuxbrew packages
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/home/linuxbrew/.linuxbrew/bin/brew install imagemagick chafa ddcutil --ignore-dependencies
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: c
- name: configure project
run: PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_XFCONF=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OSMESA=OFF -DENABLE_OPENCL=OFF -DENABLE_LIBNM=OFF -DENABLE_FREETYPE=OFF -DENABLE_PULSE=OFF -DENABLE_DDCUTIL=OFF -DENABLE_DIRECTX_HEADERS=OFF -DENABLE_THREADS=OFF
- name: build project
run: cmake --build . --target package --verbose -j4
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v3
- name: list features
run: ./fastfetch --list-features
@@ -72,15 +58,9 @@ jobs:
- name: run tests
run: ctest
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: fastfetch-linux-old-amd64
path: ./fastfetch-*.*
linux-amd64:
name: Linux-amd64
runs-on: ubuntu-22.04 # Ubuntu 22.04 uses Glibc 2.35. Should be fine with Debian 12, which uses Glibc 2.36 (https://packages.debian.org/source/bookworm/glibc)
runs-on: ubuntu-20.04
permissions:
security-events: write
contents: read
@@ -94,12 +74,12 @@ jobs:
run: uname -a
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev libddcutil-dev libchafa-dev directx-headers-dev
run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev directx-headers-dev
- name: install linuxbrew packages
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/home/linuxbrew/.linuxbrew/bin/brew install imagemagick --ignore-dependencies
/home/linuxbrew/.linuxbrew/bin/brew install imagemagick chafa ddcutil --ignore-dependencies
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
@@ -178,6 +158,45 @@ jobs:
name: fastfetch-linux-aarch64
path: ./fastfetch-*.*
linux-armv7:
name: Linux-armv7
runs-on: ubuntu-22.04
permissions:
security-events: write
contents: read
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: run VM
uses: uraimo/run-on-arch-action@v2
id: runcmd
with:
arch: armv7
distro: ubuntu20.04
githubToken: ${{ github.token }}
run: |
uname -a
apt-get update && apt-get install -y wget
# CMake installed by apt has bug `list sub-command REMOVE_ITEM requires two or more arguments`
wget --no-check-certificate https://apt.kitware.com/ubuntu/pool/main/c/cmake/{cmake_3.29.2-0kitware1ubuntu20.04.1_armhf.deb,cmake-data_3.29.2-0kitware1ubuntu20.04.1_all.deb}
dpkg -i *.deb
apt-get install -y make g++ libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev directx-headers-dev rpm
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: fastfetch-linux-armv7
path: ./fastfetch-*.*
musl-amd64:
name: Musl-amd64
runs-on: ubuntu-latest
@@ -186,6 +205,8 @@ jobs:
- name: setup alpine linux
uses: jirutka/setup-alpine@master
with:
branch: v3.19
- name: install dependencies
run: |
@@ -225,6 +246,7 @@ jobs:
- name: setup alpine linux
uses: jirutka/setup-alpine@master
with:
branch: v3.19
arch: aarch64
- name: install dependencies
@@ -258,7 +280,7 @@ jobs:
macos-universal:
name: macOS-universal
runs-on: macos-latest
runs-on: macos-12
permissions:
security-events: write
contents: read
@@ -465,7 +487,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
@@ -521,6 +543,7 @@ jobs:
needs:
- linux-amd64
- linux-aarch64
- linux-armv7
- musl-amd64
- musl-aarch64
- macos-universal
@@ -541,11 +564,6 @@ jobs:
if: needs.linux-amd64.outputs.ffversion != steps.get_version_release.outputs.release
uses: actions/download-artifact@v4
- name: rm old artifacts
if: needs.linux-amd64.outputs.ffversion != steps.get_version_release.outputs.release
run: |
rm -rf fastfetch-*-old-*
- name: create release
if: needs.linux-amd64.outputs.ffversion != steps.get_version_release.outputs.release
uses: ncipollo/release-action@v1
+213 -1
View File
@@ -1,7 +1,219 @@
# 2.13.2
Another hotfix release :(
Bugfixes:
* Remove DRM driver version detection feature, which caused a performance regression for nouveau drivers (#956, Display, Linux)
* Fix compatibility for old python versions. Regression of `2.13.0`
* Don't use `*-unknown` as display name for Wayland protocol (Display, Linux)
Features:
* Add new module `Editor` which prints information of the default editor, i.e. $VISUAL or $EDITOR (#430, Editor)
Logos:
* Added CuerdOS
* Remove special handling of Loc-OS
# 2.13.1
Fix a regression introduced in v2.13.0
Bugfixes:
* Fix CPU frequency not displayed if `bios_limit` is not available (CPU, Linux)
Features:
* Add `--cpu-show-pe-core-count` to detect and display core count for performance / efficiency cores (CPU, FreeBSD)
# 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.
* 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 (#878, macOS, Terminal)
* Fix deprecation warning for macOS 14.0 hopefully (#860, macOS, Camera)
* 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
Hotfix for nix (https://github.com/NixOS/nixpkgs/issues/308849#issuecomment-2093962376)
Features:
* Add cmake option `CUSTOM_AMDGPU_IDS_PATH` for specifying custom path of `amdgpu.ids`
Bugfixes:
* Fix hanging when detecting disconnected network drive (Disk, Windows)
* Ensure line ending is printed when printing image logo errors (Logo)
* Revert image logo limitation change in 2.11.2; allow image logo in SSH session and tmux again (#861, Logo)
* Fix doubled output in custom formation (PhysicalDisk, Windows)
# 2.11.2
Hotfix for Debian 11
Changes:
* Error messages when trying to print image logo will only be printed with `--show-errors`
* When generating JSON output, fastfetch will generate an empty array when no result is detected, instead of an error.
Bugfixes:
* Fix segfault in Debian 11 and some old kernels. Regression introduced in 2.11.0 (#845, GPU, Linux)
* Don't try detecting version of raw `sh` shell (#849, Shell, Linux)
* Trim `\r` on Windows
Features:
* Check xdg state home for nix user packages (#837, Packages, Linux)
* Disable image logos in ssh and tmux sessions (#839)
* Support MX Linux distro detection (#847, OS, Linux)
Logo:
* Add KernelOS
* Fix name of DraugerOS
* Add missing `FF_LOGO_LINE_TYPE_SMALL_BIT` flags
* Add MX2
# 2.11.1
Hotfix for Android
Bugfixes:
* Fix uninitialized variables which can cause crashes (#760 #838, Battery, Android)
* Don't detect hyfetch as shell when used as backend of [hyfetch](https://github.com/hykilpikonna/hyfetch)
* Fix incorrect information in man page (#828)
Features:
* Support sorcery package manager detection (Packages, Linux)
* Make `--custom-format` optional (Custom)
* Make `/` an alias of `C:\` for `--disk-folders` (Disk, Windows)
* Build for Linux armv7
Logo:
* Fix colors of Source Mage logo
# 2.11.0
Changes:
* Default `hideCursor` to false. It doesn't make much difference but makes user's terminal unusable if fastfetch is not exited correctly.
* Linux amd64 binaries are built with Ubuntu 20.04 again (#808)
Bugfixes:
* Fix swap usage detection in x86-32 build (Windows, Swap)
* Fix minimum cmake version support (#810)
* Fix wifi detection on platforms that don't use NetworkManager (#811, Wifi, Linux)
* Fix NixOS wrapped process name (#814, Terminal, Linux)
* Fix GPU type detection for AMD cards (#816, GPU, Linux)
* Silence system deprecation warnings (#822, Camera, macOS)
Features:
* Add basic support DE detection support for UKUI (DE, Linux)
* Support printing total number of nix / flatpak / brew packages (Packages)
* See `fastfetch -h packages-format` for detail
* Better max CPU frequency detection support with `CPUID / 16H` instruction (CPU, Windows)
* This requires Intel Core I Gen 6 or newer, and with `Virtual Machine Platform` Windows feature disabled. X86 only.
* Improve performance of nix packages detection (Packages, Linux)
* Make config specified in JSONC overridable by command line flags
* Note this change only make global config overridable; module configs are still not
* Suggest increasing `--processing-timeout` when child process timeouts
* Only detect folders that specified by `--disk-folders`
* Previously `--disk-folders` only omits unmatched disks from output
* This option can be used to improve detection performance by ignoring slow network drives
# 2.10.2
Bugfixes:
* Fix a regression that detect x11 as wayland (#805, WM, Linux)
# 2.10.1
Bugfixes:
* fix build with `-DENABLE_DBUS=OFF`
* Fix build with `-DENABLE_DBUS=OFF` (Linux)
# 2.10.0
+56 -16
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 2.10.1
VERSION 2.13.2
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
@@ -79,6 +79,8 @@ option(IS_MUSL "Build with musl libc" OFF) # Used by Github Actions
if (LINUX)
set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`")
set(CUSTOM_AMDGPU_IDS_PATH "" CACHE STRING "Custom path to file amdgpu.ids, defaults to `/usr/share/libdrm/amdgpu.ids`")
set(CUSTOM_OS_RELEASE_PATH "" CACHE STRING "Custom path to file os-release, defaults to `/etc/os-release`")
endif()
####################
@@ -113,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()
@@ -255,7 +257,7 @@ file(GLOB LOGO_FILES "src/logo/ascii/*.txt")
set(LOGO_BUILTIN_H "#pragma once\n#pragma GCC diagnostic ignored \"-Wtrigraphs\"\n\n")
foreach(file ${LOGO_FILES})
fastfetch_load_text("${file}" content)
get_filename_component(file "${file}" NAME_WLE)
get_filename_component(file "${file}" NAME_WE)
string(TOUPPER "${file}" file)
string(REGEX REPLACE "\\$\\{c([0-9]+)\\}" "$\\1" content "${content}")
set(LOGO_BUILTIN_H "${LOGO_BUILTIN_H}#define FASTFETCH_DATATEXT_LOGO_${file} ${content}\n")
@@ -282,12 +284,14 @@ 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
src/detection/disk/disk.c
src/detection/diskio/diskio.c
src/detection/displayserver/displayserver.c
src/detection/editor/editor.c
src/detection/font/font.c
src/detection/gpu/gpu.c
src/detection/media/media.c
@@ -295,6 +299,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
@@ -311,6 +316,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
@@ -325,6 +331,7 @@ set(LIBFASTFETCH_SRC
src/modules/de/de.c
src/modules/disk/disk.c
src/modules/diskio/diskio.c
src/modules/editor/editor.c
src/modules/font/font.c
src/modules/gpu/gpu.c
src/modules/host/host.c
@@ -332,6 +339,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
@@ -342,6 +350,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
@@ -389,6 +398,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
@@ -397,6 +407,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
@@ -415,6 +426,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
@@ -455,6 +467,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
@@ -462,6 +475,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
@@ -470,6 +484,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
@@ -511,6 +526,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
@@ -518,6 +534,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
@@ -536,6 +553,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
@@ -577,6 +595,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
@@ -584,14 +603,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
@@ -634,6 +655,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
@@ -649,11 +671,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
@@ -765,7 +789,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)
@@ -784,6 +808,14 @@ if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "")
message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})
endif()
if(NOT "${CUSTOM_AMDGPU_IDS_PATH}" STREQUAL "")
message(STATUS "Custom file path of amdgpu.ids: ${CUSTOM_AMDGPU_IDS_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH})
endif()
if(NOT "${CUSTOM_OS_RELEASE_PATH}" STREQUAL "")
message(STATUS "Custom file path of os_release: ${CUSTOM_OS_RELEASE_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_OS_RELEASE_PATH=${CUSTOM_OS_RELEASE_PATH})
endif()
function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
if(NOT ENABLE_${VARNAME})
@@ -933,10 +965,6 @@ if(ENABLE_THREADS)
endif()
endif()
if(ENABLE_PCI_MEMORY)
target_compile_definitions(libfastfetch PRIVATE FF_USE_PCI_MEMORY)
endif()
if(LINUX)
target_link_libraries(libfastfetch
PRIVATE "m"
@@ -1147,16 +1175,28 @@ endif()
if(LINUX)
find_program(HAVE_DPKG "dpkg")
find_program(HAVE_RPMBUILD "rpmbuild")
if(HAVE_DPKG AND HAVE_RPMBUILD)
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB;RPM")
if(HAVE_DPKG)
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
set(CPACK_DEBIAN_PACKAGE_SECTION, "utils")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
if(NOT IS_MUSL)
EXECUTE_PROCESS (
COMMAND getconf GNU_LIBC_VERSION
OUTPUT_VARIABLE GLIBC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING (REPLACE "glibc " "" GLIBC_VERSION ${GLIBC_VERSION})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= ${GLIBC_VERSION})")
endif()
endif()
set(CPACK_DEBIAN_PACKAGE_SECTION, "utils")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
find_program(HAVE_RPMBUILD "rpmbuild")
if(HAVE_RPMBUILD)
set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
endif()
endif()
set(CPACK_SET_DESTDIR ON)
-34
View File
@@ -1,34 +0,0 @@
# Development help
This file is not an official documentation!
Here i just add things that are easy to forget.
## Features i am planning to implement
### Specific
- [ ] Split the project in different libs / executables, all linking static by default:
- `libffdetect`: contains all the detection stuff. To be used by anything that needs system information
- `libffprint`: contains the printing functions, logos, format etc
- `fastfetch` and `flashfetch`: Executables, that initialize the config of libffprint. Fist one at runtime, second one at compile time
- [ ] Make LocalIP module more configurable
- [ ] Automatic migrate old config files to newer versions
- [ ] ZSH completions
- [ ] Fish completions
- [ ] Make CPU usage detection much faster and more accurate
- [ ] Detect CPU usage in a common detection method and expose it both to the cpuUsage module and the cpu format string
- [ ] Per session caching
### General
- More presets
- More logos
- More package managers
- More DE detections
- More WM theme detections
- More terminal font detections
- Performance optimizations
- More module specific options
- Better error handling, especially the messages shown when using --show-errors
- Using package managers libraries for package count detection instead own. E.g. using libalpm instead of counting files in /var/lib/pacman/local
- Better documentation (especially default config file and the various --help options. Colored output?)
- General feature parity with neofetch, to demonstrate supremity of c
+85 -6
View File
@@ -29,8 +29,8 @@ There are [screenshots on different platforms](https://github.com/fastfetch-cli/
Some distros packaged an outdated fastfetch version. Older version is not supported, please always ensure that the latest version is used.
* Ubuntu: [`ppa:zhangsongcui3371/fastfetch`](https://launchpad.net/~zhangsongcui3371/+archive/ubuntu/fastfetch) (for Ubuntu 22.04 or above)
* Debian / Ubuntu: Download `fastfetch-<version>-Linux.deb` from [Github release page](https://github.com/fastfetch-cli/fastfetch/releases/latest) and `dpkg -i fastfetch-<version>-Linux.deb` (for Ubuntu 22.04 or above and Debian 12 or above).
* Ubuntu: [`ppa:zhangsongcui3371/fastfetch`](https://launchpad.net/~zhangsongcui3371/+archive/ubuntu/fastfetch) (for Ubuntu 22.04 or newer)
* Debian / Ubuntu: Download `fastfetch-linux-<proper architecture>.deb` from [Github release page](https://github.com/fastfetch-cli/fastfetch/releases/latest) and double-click it (for Ubuntu 20.04 or newer and Debian 11 or newer).
* Arch Linux: `sudo pacman -S fastfetch`
* Fedora: `sudo dnf install fastfetch`
* Gentoo: `sudo emerge --ask app-misc/fastfetch`
@@ -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
View File
@@ -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 -1
View File
@@ -85,7 +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()))
###> temp: str = ' '.join(flag["arg"]["enum"])
###> print(f'{command_prefix} -x -a "{temp}"')
###> elif type == 'logo':
###> print(f'{command_prefix} -x -a "(__fastfetch_complete_logo)"')
+5 -8
View File
@@ -107,12 +107,12 @@ To list all available modules, use \fB \-\-list\-modules \fR
.SS "Config Files"
fastfetch supports two types of config files. The legacy
configuration files and a JSONC based format.
Fastfetch uses JSONC based format for configuration. Fastfetch doesn't generate
config file automatically; it should be generated manually by \fB \-\-gen\-config\fR.
The config file will be saved in \fB~/.config/fastfetch/config.jsonc\fR by default.
A JSONC config file is a JSON file that also supports comments with (//). Those
files must have the extension '.jsonc'. You can migrate a legacy config
file to the JSONC format by using \fB\-\-gen\-config\fR.
files must have the extension '.jsonc'.
The specified configuration/preset files are searched in the following order:
@@ -122,10 +122,7 @@ The specified configuration/preset files are searched in the following order:
3. relative to /usr/share/fastfetch/presets/
When both a '.jsonc' and a '.conf' file with the same name is found,
the '.jsonc' file is preferred.
Fastfetch provides some default presets. List them with \fB \-\-print\-available\-presets\fR.
Fastfetch provides some default presets. List them with \fB\-\-list\-presets\fR.
.SH "SEE ALSO"
.BR neofetch (1)
+189 -18
View File
@@ -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 &lt;module&gt;-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",
@@ -294,10 +297,6 @@
"type": "string",
"description": "The name of the player to use for module Media and Player. Linux only"
},
"osFile": {
"type": "string",
"description": "Set the path to the file containing OS information. Linux only"
},
"dsForceDrm": {
"description": "Force display detection to use DRM. Linux only",
"oneOf": [
@@ -384,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"
}
}
}
@@ -677,8 +680,10 @@
"bios",
"bluetooth",
"board",
"bootmgr",
"break",
"brightness",
"camera",
"chassis",
"cpu",
"cpuusage",
@@ -690,6 +695,7 @@
"disk",
"diskio",
"de",
"editor",
"font",
"gamepad",
"gpu",
@@ -697,6 +703,7 @@
"icons",
"kernel",
"lm",
"loadavg",
"locale",
"localip",
"media",
@@ -708,6 +715,7 @@
"os",
"packages",
"physicaldisk",
"physicalmemory",
"player",
"poweradapter",
"processes",
@@ -766,12 +774,20 @@
"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"
},
{
"const": "cursor",
"description": "Print cursor style name"
@@ -780,6 +796,10 @@
"const": "datetime",
"description": "Print current date and time"
},
{
"const": "editor",
"description": "Print information of the default editor ($VISUAL or $EDITOR)"
},
{
"const": "font",
"description": "Print system font name"
@@ -820,6 +840,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"
@@ -892,6 +916,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -926,6 +953,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -957,6 +987,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -983,6 +1016,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"
}
}
},
@@ -1001,6 +1049,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1028,12 +1079,20 @@
"maximum": 9,
"default": 2
},
"showPeCoreCount": {
"description": "Detect and display CPU frequency of different core types (eg. Pcore and Ecore) if supported",
"type": "boolean",
"default": false
},
"key": {
"$ref": "#/$defs/key"
},
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1112,6 +1171,9 @@
"maxItems": 2
}
}
},
"key": {
"$ref": "#/$defs/key"
}
}
},
@@ -1138,6 +1200,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1162,6 +1227,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1169,10 +1237,7 @@
"description": "Text to print",
"type": "string"
}
},
"required": [
"format"
]
}
},
{
"title": "Display",
@@ -1214,6 +1279,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1233,7 +1301,7 @@
},
"folders": {
"type": "string",
"description": "A colon (semicolon on Windows) separated list of folder paths for the disk output\nDefault: auto detection using mount-points"
"description": "A colon (semicolon on Windows) separated list of folder paths for the disk output\nDefault: auto detection using mount-points\nThis option overrides other `show*` options"
},
"showExternal": {
"type": "boolean",
@@ -1274,6 +1342,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1306,6 +1377,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1334,6 +1408,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1360,6 +1437,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1385,10 +1465,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",
@@ -1405,6 +1491,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1447,6 +1536,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",
@@ -1467,6 +1561,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1493,6 +1590,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"
},
@@ -1530,6 +1663,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1563,6 +1699,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1617,6 +1756,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1647,6 +1789,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1676,12 +1821,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"
},
@@ -1703,6 +1856,9 @@
"description": "Set the string to be printed",
"type": "string",
"default": "-"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
}
}
},
@@ -1734,6 +1890,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1760,6 +1919,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1807,6 +1969,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1845,6 +2010,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
@@ -1873,6 +2041,9 @@
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
+13 -2
View File
@@ -6,13 +6,16 @@
"os",
"host",
"bios",
"bootmgr",
"board",
"chassis",
"kernel",
"uptime",
"loadavg",
"processes",
"packages",
"shell",
"editor",
"display",
"brightness",
"monitor",
@@ -29,10 +32,14 @@
"terminalfont",
"terminalsize",
"terminaltheme",
"cpu",
{
"type": "cpu",
"showPeCoreCount": true
},
"cpuusage",
"gpu",
"memory",
"physicalmemory",
"swap",
"disk",
"battery",
@@ -40,7 +47,11 @@
"player",
"media",
"publicip",
"localip",
{
"type": "localip",
"showIpV6": true,
"showMac": true
},
"wifi",
"datetime",
"locale",
+84
View File
@@ -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"
}
]
}
+14 -2
View File
@@ -6,19 +6,23 @@
"showErrors": true,
"noBuffer": true
},
"logo": null,
"modules": [
"title",
"separator",
"os",
"host",
"bios",
"bootmgr",
"board",
"chassis",
"kernel",
"uptime",
"loadavg",
"processes",
"packages",
"shell",
"editor",
"display",
"brightness",
"monitor",
@@ -35,10 +39,14 @@
"terminalfont",
"terminalsize",
"terminaltheme",
"cpu",
{
"type": "cpu",
"showPeCoreCount": true
},
"cpuusage",
"gpu",
"memory",
"physicalmemory",
"swap",
"disk",
"battery",
@@ -46,7 +54,11 @@
"player",
"media",
"publicip",
"localip",
{
"type": "localip",
"showIpV6": true,
"showMac": true
},
"wifi",
"datetime",
"locale",
+1 -1
View File
@@ -1,5 +1,5 @@
{
"$schema": "file:///C:/msys64/home/zhang/fastfetch/doc/json_schema.json",
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small"
},
+85
View File
@@ -0,0 +1,85 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small",
"padding": {
"top": 1
}
},
"display": {
"separator": "",
"keyWidth": 15
},
"modules": [
{
"key": "╭───────────╮",
"type": "custom"
},
{
// draw borders first to make colors of left and right border consistant
"key": "│ │\u001b[11D\u001b[31m user",
"type": "title",
"format": "{1}"
},
{
"key": "│ │\u001b[11D\u001b[32m󰇅 hname",
"type": "title",
"format": "{2}"
},
{
"key": "│ │\u001b[11D\u001b[33m󰅐 uptime",
"type": "uptime"
},
{
"key": "│ │\u001b[11D\u001b[34m󰟾 distro",
"type": "os"
},
{
"key": "│ │\u001b[11D\u001b[35m kernel",
"type": "kernel"
},
{
"key": "│ │\u001b[11D\u001b[36m󰇄 desktop",
"type": "de"
},
{
"key": "│ │\u001b[11D\u001b[31m term",
"type": "terminal"
},
{
"key": "│ │\u001b[11D\u001b[32m shell",
"type": "shell"
},
{
"key": "│ │\u001b[11D\u001b[33m󰍛 cpu",
"type": "cpu"
},
{
"key": "│ │\u001b[11D\u001b[34m󰉉 disk",
"type": "disk",
"folders": "/"
},
{
"key": "│ │\u001b[11D\u001b[35m memory",
"type": "memory"
},
{
"key": "│ │\u001b[11D\u001b[36m󰩟 network",
"type": "localip",
"format": "{1} ({4})"
},
{
"key": "├───────────┤",
"type": "custom"
},
{
"key": "│ │\u001b[11D\u001b[m colors",
"type": "colors",
"symbol": "circle"
},
{
"key": "╰───────────╯",
"type": "custom"
}
]
}
+1 -2
View File
@@ -9,8 +9,7 @@
"modules": [
{
"type": "theme",
"key": "T",
"format": "{7}"
"key": "T"
},
{
"type": "icons",
+5 -5
View File
@@ -24,24 +24,24 @@
},
{
"type": "os",
"key": "",
"key": "",
"format": "{2} {8}"
},
{
"type": "kernel",
"key": ""
"key": ""
},
{
"type": "memory",
"key": "󰻠"
"key": ""
},
{
"type": "packages",
"key": ""
"key": "󰏖"
},
{
"type": "uptime",
"key": ""
"key": "󰅐"
},
{
"type": "custom",
+25 -13
View File
@@ -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"
]
}
+9 -12
View File
@@ -1,16 +1,16 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"display": {
"size": {
"maxPrefix": "MB",
"ndigits": 0
}
},
"modules": [
"title",
"separator",
{
"type": "os",
"format": "{3} {12}"
},
{
"type": "host",
"format": "{/2}{-}{/}{2}{?3} {3}{?}"
},
"os",
"host",
"kernel",
"uptime",
"packages",
@@ -23,10 +23,7 @@
"de",
"wm",
"wmtheme",
{
"type": "theme",
"format": "{?1}{1}{?3} {3}{?} [Plasma], {?}{7}"
},
"theme",
"icons",
"terminal",
{
-11074
View File
File diff suppressed because it is too large Load Diff
-6
View File
@@ -1,6 +0,0 @@
{
"home": "https://github.com/NVIDIA/nvidia-settings/blob/main/src/nvml.h",
"license": "Embed in source",
"version": "550.54.14",
"author": "NVIDIA Corporation"
}
+4 -23
View File
@@ -11,7 +11,7 @@
bool ffParseModuleOptions(const char* key, const char* value)
{
if (!ffStrStartsWith(key, "--") || !isalpha(key[2])) return false;
if (!ffStrStartsWith(key, "--") || !ffCharIsEnglishAlphabet(key[2])) return false;
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(key[2]) - 'A']; *modules; ++modules)
{
@@ -79,30 +79,11 @@ 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(isalpha(line[0]))
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;
}
-8
View File
@@ -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;
+5 -5
View File
@@ -238,9 +238,6 @@ void ffListFeatures(void)
#ifdef FF_HAVE_DDCUTIL
"libddcutil\n"
#endif
#if __has_include(<linux/videodev2.h>)
"videodev2\n"
#endif
#ifdef FF_HAVE_DIRECTX_HEADERS
"Directx Headers\n"
#endif
@@ -250,8 +247,11 @@ void ffListFeatures(void)
#ifdef FF_USE_SYSTEM_YYJSON
"System yyjson\n"
#endif
#ifdef FF_USE_PCI_MEMORY
"PCI memory\n"
#if __has_include(<linux/videodev2.h>)
"linux/videodev2\n"
#endif
#if __has_include(<linux/wireless.h>)
"linux/wireless\n"
#endif
""
, stdout);
+6 -1
View File
@@ -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);
@@ -94,7 +99,7 @@ static inline void genJsonResult(FFModuleBaseInfo* baseInfo, yyjson_mut_doc* doc
static bool parseModuleJsonObject(const char* type, yyjson_val* jsonVal, yyjson_mut_doc* jsonDoc)
{
if(!isalpha(type[0])) return false;
if(!ffCharIsEnglishAlphabet(type[0])) return false;
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(type[0]) - 'A']; *modules; ++modules)
{
+1 -1
View File
@@ -4,7 +4,7 @@
#include <stdarg.h>
//Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
#if defined(__has_feature)
#if !defined(__SANITIZE_ADDRESS__) && defined(__has_feature)
#if __has_feature(address_sanitizer)
#define __SANITIZE_ADDRESS__
#endif
+4
View File
@@ -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,
@@ -36,6 +37,7 @@ static FFModuleBaseInfo* D[] = {
};
static FFModuleBaseInfo* E[] = {
(void*) &instance.config.modules.editor,
NULL,
};
@@ -71,6 +73,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 +101,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,
+1
View File
@@ -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);
+1 -1
View File
@@ -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)
{
+1 -1
View File
@@ -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";
+18
View File
@@ -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);
}
+1
View File
@@ -50,6 +50,7 @@ typedef struct FFModuleArgs
FFstrbuf key;
FFstrbuf keyColor;
FFstrbuf outputFormat;
FFstrbuf outputColor;
uint32_t keyWidth;
} FFModuleArgs;
+15 -3
View File
@@ -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)
+3 -2
View File
@@ -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;
+6 -1
View File
@@ -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))
{
+2 -8
View File
@@ -8,10 +8,7 @@ static inline const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const ar
{
const char* error = ffProcessAppendOutput(buffer, argv, false);
if (!error)
{
ffStrbufTrimRight(buffer, '\n');
ffStrbufTrimRight(buffer, ' ');
}
ffStrbufTrimRightSpace(buffer);
return error;
}
@@ -19,9 +16,6 @@ static inline const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const ar
{
const char* error = ffProcessAppendOutput(buffer, argv, true);
if (!error)
{
ffStrbufTrimRight(buffer, '\n');
ffStrbufTrimRight(buffer, ' ');
}
ffStrbufTrimRightSpace(buffer);
return error;
}
+1 -1
View File
@@ -68,7 +68,7 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
{
kill(childPid, SIGTERM);
waitpid(childPid, NULL, 0);
return "poll(&pollfd, 1, timeout) timeout";
return "poll(&pollfd, 1, timeout) timeout (try increasing --processing-timeout)";
}
else if (pollfd.revents & POLLERR)
{
+1 -1
View File
@@ -96,7 +96,7 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
{
CancelIo(hChildPipeRead);
TerminateProcess(hProcess, 1);
return "WaitForSingleObject(hChildPipeRead) failed or timeout";
return "WaitForSingleObject(hChildPipeRead) failed or timeout (try increasing --processing-timeout)";
}
if (!GetOverlappedResult(hChildPipeRead, &overlapped, &nRead, FALSE))
+25 -29
View File
@@ -1,5 +1,7 @@
#include "fastfetch.h"
#include "common/properties.h"
#include "common/io/io.h"
#include "util/mallocHelper.h"
#include <stdlib.h>
#ifdef _WIN32
@@ -95,50 +97,44 @@ bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer)
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries)
{
FILE* file = fopen(filename, "r");
if(file == NULL)
FF_AUTO_CLOSE_FILE FILE* file = fopen(filename, "r");
if (file == NULL)
return false;
bool valueStorage[4];
bool* unsetValues;
bool valueStorage[32];
bool* unsetValues = valueStorage;
if(numQueries > sizeof(valueStorage) / sizeof(valueStorage[0]))
if (numQueries > sizeof(valueStorage) / sizeof(valueStorage[0]))
unsetValues = malloc(sizeof(bool) * numQueries);
else
unsetValues = valueStorage;
bool allSet = true;
for(uint32_t i = 0; i < numQueries; i++)
for (uint32_t i = 0; i < numQueries; i++)
{
if((unsetValues[i] = queries[i].buffer->length == 0))
unsetValues[i] = queries[i].buffer->length == 0;
if (unsetValues[i])
allSet = false;
}
if(allSet)
goto done;
char* line = NULL;
size_t len = 0;
while (getline(&line, &len, file) != -1)
if (!allSet)
{
for(uint32_t i = 0; i < numQueries; i++)
{
if(!unsetValues[i])
continue;
FF_AUTO_FREE char* line = NULL;
size_t len = 0;
uint32_t currentLength = queries[i].buffer->length;
queries[i].buffer->length = 0;
if(!ffParsePropLine(line, queries[i].start, queries[i].buffer))
queries[i].buffer->length = currentLength;
while (getline(&line, &len, file) != -1)
{
for(uint32_t i = 0; i < numQueries; i++)
{
if(!unsetValues[i])
continue;
uint32_t currentLength = queries[i].buffer->length;
queries[i].buffer->length = 0;
if(!ffParsePropLine(line, queries[i].start, queries[i].buffer))
queries[i].buffer->length = currentLength;
}
}
}
if(line != NULL)
free(line);
done:
fclose(file);
if(unsetValues != valueStorage)
free(unsetValues);
return true;
+8 -2
View File
@@ -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
View File
@@ -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);
+69 -29
View File
@@ -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,16 +930,17 @@
}
},
{
"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"
}
},
{
"long": "disk-folders",
"desc": "A colon (semicolon on Windows) separated list of folder paths for the disk output",
"desc": "A colon (semicolon on Windows) separated list of folder paths to be detected",
"remark": "On Windows, a drive latter must be upper cased and end with \"\\\". \"/\" is used as an alias of the system drive. This option overrides other disk-show-* options",
"arg": {
"type": "path",
"default": "Auto detection using mount-points"
@@ -1159,6 +1152,15 @@
"default": 2
}
},
{
"long": "cpu-show-pe-core-count",
"desc": "Detect and display CPU frequency of different core types (eg. Pcore and Ecore) if supported",
"arg": {
"type": "bool",
"optional": true,
"default": false
}
},
{
"long": "cpuusage-separate",
"desc": "Display CPU usage per CPU logical core, instead of an average result",
@@ -1204,13 +1206,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": "Will fall back to next methods if the specified method fails",
"arg": {
"type": "bool",
"optional": true,
"default": false
"type": "enum",
"enum": {
"auto": "Query platform specific graphic APIs. Requires proper GPU drivers installed. Not supported on FreeBSD",
"pci": "Search PCI devices, which do not requires GPU driver installed. Not supported on Windows and macOS",
"vulkan": "Use Vulkan API. Slow and requires vulkan driver installed. Used for Android",
"opengl": "Use OpenGL API. Slow and only detects one GPU"
},
"default": "auto"
}
},
{
@@ -1235,6 +1242,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",
@@ -1297,6 +1312,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",
@@ -1347,6 +1371,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",
@@ -1521,6 +1553,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",
+4 -3
View File
@@ -3,7 +3,8 @@ Usage: fastfetch --color <color>
<color> must be a color encoding as ANSI escape sequences. It is inserted between "ESC[" and "m".
Infos about them can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters.
Examples:
--color 35: sets the color to magenta. `--color magenta` is also supported
--color 4;92: sets the color to bright Green with underline
--color 5;104: blinking text on a blue background
--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 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.
+3
View File
@@ -40,6 +40,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results)
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->serial);
ffStrbufInit(&battery->manufactureDate);
battery->capacity = yyjson_get_num(yyjson_obj_get(root, "percentage"));
@@ -77,6 +78,8 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results)
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->serial);
ffStrbufInit(&battery->manufactureDate);
if (ffParsePropLines(start, "AC powered: ", &temp) && ffStrbufEqualS(&temp, "true"))
ffStrbufAppendS(&battery->status, "AC powered");
-3
View File
@@ -170,8 +170,5 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
ffStrbufSubstrBefore(&baseDir, baseDirLength);
}
if(results->length == 0)
return "\"/sys/class/power_supply/\" doesn't contain any battery folder";
return NULL;
}
+13 -20
View File
@@ -1,4 +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"
@@ -10,21 +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 wrapCloseHandle(HANDLE* handle)
{
if(*handle)
CloseHandle(*handle);
}
static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
{
if(*hdev)
@@ -52,7 +40,7 @@ static const char* detectWithSetupApi(FFBatteryOptions* options, FFlist* results
if(!SetupDiGetDeviceInterfaceDetailW(hdev, &did, pdidd, cbRequired, &cbRequired, NULL))
continue;
HANDLE __attribute__((__cleanup__(wrapCloseHandle))) hBattery =
HANDLE FF_AUTO_CLOSE_FD hBattery =
CreateFileW(pdidd->DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hBattery == INVALID_HANDLE_VALUE)
@@ -157,8 +145,6 @@ static const char* detectWithSetupApi(FFBatteryOptions* options, FFlist* results
return NULL;
}
typedef struct FFSmbiosPortableBattery
{
FFSmbiosHeader Header;
@@ -181,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";
+1 -1
View File
@@ -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);
+11 -3
View File
@@ -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";
+11 -4
View File
@@ -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";
+50
View File
@@ -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;
}
+12
View File
@@ -0,0 +1,12 @@
#pragma once
#include "fastfetch.h"
typedef struct FFBootmgrResult
{
FFstrbuf name;
FFstrbuf firmware;
bool secureBoot;
} FFBootmgrResult;
const char* ffDetectBootmgr(FFBootmgrResult* bios);
+12
View File
@@ -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;
}
+43
View File
@@ -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;
}
+27
View File
@@ -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";
}
+53
View File
@@ -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;
}
+24
View File
@@ -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"
+26 -2
View File
@@ -1,10 +1,32 @@
#include "camera.h"
#include "common/io/io.h"
#import <AVFoundation/AVCaptureDevice.h>
// warning: 'AVCaptureDeviceTypeExternalUnknown' is deprecated
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
const char* ffDetectCamera(FFlist* result)
{
AVCaptureDeviceDiscoverySession* session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
#ifdef MAC_OS_X_VERSION_10_15
FF_SUPPRESS_IO(); // #822
AVCaptureDeviceType deviceType;
#ifdef MAC_OS_VERSION_14_0
if (@available(macOS 14.0, *))
{
deviceType = AVCaptureDeviceTypeExternal;
}
else
#endif
{
deviceType = AVCaptureDeviceTypeExternalUnknown;
}
AVCaptureDeviceDiscoverySession* session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera, deviceType]
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionUnspecified];
if (!session)
return "Failed to create AVCaptureDeviceDiscoverySession";
@@ -26,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
}
+9 -2
View File
@@ -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";
+9 -1
View File
@@ -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);
+23 -5
View File
@@ -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, &current, &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);
if (options->showPeCoreCount) detectCoreCount(cpu);
cpu->temperature = options->temp ? detectCpuTemp(&cpu->name) : FF_CPU_TEMP_UNSET;
+58
View File
@@ -11,6 +11,64 @@ 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>");
}
}
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;
if (options->showPeCoreCount)
{
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;
+54 -13
View File
@@ -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,13 +103,31 @@ 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 bool detectFrequency(FFCPUResult* cpu)
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, const FFCPUOptions* options)
{
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/devices/system/cpu/cpufreq/");
FF_AUTO_CLOSE_DIR DIR* dir = opendir(path.chars);
@@ -119,38 +137,61 @@ 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;
}
if (options->showPeCoreCount)
{
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;
}
@@ -232,7 +273,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
cpu->coresOnline = (uint16_t) get_nprocs();
cpu->coresPhysical = (uint16_t) ffStrbufToUInt(&physicalCoresBuffer, cpu->coresLogical);
if (!detectFrequency(cpu) || cpu->frequencyBase != cpu->frequencyBase)
if (!detectFrequency(cpu, options) || cpu->frequencyBase != cpu->frequencyBase)
cpu->frequencyBase = ffStrbufToDouble(&cpuMHz) / 1000;
if(cpuUarch.length > 0)
+65 -9
View File
@@ -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,11 +49,43 @@ 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__)
#include <cpuid.h>
inline static const char* detectSpeedByCpuid(FFCPUResult* cpu)
{
uint32_t base = 0, max = 0, bus = 0, unused = 0;
if (!__get_cpuid(0x16, &base, &max, &bus, &unused))
return "Unsupported instruction";
// cpuid returns 0 MHz when hyper-v is enabled
if (base) cpu->frequencyBase = base / 1000.0;
if (max) cpu->frequencyMax = max / 1000.0;
return NULL;
}
#else
inline static const char* detectSpeedByCpuid(FF_MAYBE_UNUSED FFCPUResult* cpu)
{
return "Unsupported platform";
}
#endif
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";
@@ -114,12 +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";
{
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);
@@ -130,6 +157,31 @@ static const char* detectByRegistry(FFCPUResult* cpu)
cpu->coresOnline = cpu->coresPhysical = cpu->coresLogical = (uint16_t) cores;
}
uint32_t mhz;
if(ffRegReadUint(hKey, L"~MHz", &mhz, NULL))
cpu->frequencyBase = mhz / 1000.0;
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;
}
@@ -141,7 +193,11 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
if (error)
return error;
detectMaxSpeedBySmbios(cpu);
detectSpeedByCpuid(cpu);
if (options->showPeCoreCount) detectCoreTypes(cpu);
if (cpu->frequencyMax != cpu->frequencyMax)
detectMaxSpeedBySmbios(cpu);
if(options->temp)
ffDetectSmbiosTemp(&cpu->temperature, NULL);
+25 -2
View File
@@ -1,6 +1,29 @@
#include "disk.h"
const char* ffDetectDisksImpl(FFlist* disks);
bool ffDiskMatchMountpoint(FFDiskOptions* options, const char* mountpoint)
{
#ifdef _WIN32
const char separator = ';';
#else
const char separator = ':';
#endif
uint32_t mountpointLength = (uint32_t) strlen(mountpoint);
uint32_t startIndex = 0;
while(startIndex < options->folders.length)
{
uint32_t colonIndex = ffStrbufNextIndexC(&options->folders, startIndex, separator);
uint32_t folderLength = colonIndex - startIndex;
if (folderLength == mountpointLength && memcmp(options->folders.chars + startIndex, mountpoint, mountpointLength) == 0)
return true;
startIndex = colonIndex + 1;
}
return false;
}
static int compareDisks(const FFDisk* disk1, const FFDisk* disk2)
{
@@ -9,7 +32,7 @@ static int compareDisks(const FFDisk* disk1, const FFDisk* disk2)
const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks)
{
const char* error = ffDetectDisksImpl(disks);
const char* error = ffDetectDisksImpl(options, disks);
if (error) return error;
if (disks->length == 0) return "No disks found";
+3
View File
@@ -26,3 +26,6 @@ typedef struct FFDisk
* If error is not set, disks contains at least one disk.
*/
const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks /* list of FFDisk */);
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks);
bool ffDiskMatchMountpoint(FFDiskOptions* options, const char* mountpoint);
+14 -3
View File
@@ -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;
@@ -90,7 +94,7 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
}
#endif
const char* ffDetectDisksImpl(FFlist* disks)
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
{
int size = getfsstat(NULL, 0, MNT_WAIT);
@@ -103,7 +107,12 @@ const char* ffDetectDisksImpl(FFlist* disks)
for(struct statfs* fs = buf; fs < buf + size; ++fs)
{
if(!ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs"))
if(__builtin_expect(options->folders.length, 0))
{
if(!ffDiskMatchMountpoint(options, fs->f_mntonname))
continue;
}
else if(!ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs"))
continue;
#ifdef __FreeBSD__
@@ -127,13 +136,15 @@ const char* ffDetectDisksImpl(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));
}
+7 -2
View File
@@ -250,7 +250,7 @@ static void detectStats(FFDisk* disk)
#endif
}
const char* ffDetectDisksImpl(FFlist* disks)
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
{
FILE* mountsFile = setmntent("/proc/mounts", "r");
if(mountsFile == NULL)
@@ -260,7 +260,12 @@ const char* ffDetectDisksImpl(FFlist* disks)
while((device = getmntent(mountsFile)))
{
if(!isPhysicalDevice(device))
if (__builtin_expect(options->folders.length, 0))
{
if (!ffDiskMatchMountpoint(options, device->mnt_dir))
continue;
}
else if(!isPhysicalDevice(device))
continue;
//We have a valid device, add it to the list
+71 -41
View File
@@ -1,53 +1,102 @@
#include "disk.h"
#include "common/io/io.h"
#include "common/thread.h"
#include "util/windows/unicode.h"
#include <windows.h>
#include <winioctl.h>
#include <assert.h>
const char* ffDetectDisksImpl(FFlist* disks)
static unsigned __stdcall testRemoteVolumeAccessable(void* mountpoint)
{
FF_AUTO_CLOSE_FD HANDLE handle = CreateFileW(
(wchar_t*) mountpoint,
READ_CONTROL,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
return 0;
}
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
{
wchar_t buf[MAX_PATH + 1];
uint32_t length = GetLogicalDriveStringsW(sizeof(buf) / sizeof(*buf), buf);
if (length == 0 || length >= sizeof(buf) / sizeof(*buf))
return "GetLogicalDriveStringsW(sizeof(buf) / sizeof(*buf), buf) failed";
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
// For cross-platform portability; used by `presets/examples/13.jsonc`
if (__builtin_expect(options->folders.length == 1 && options->folders.chars[0] == '/', 0))
{
wchar_t path[MAX_PATH + 1];
GetSystemWindowsDirectoryW(path, sizeof(path) / sizeof(*path));
ffStrbufSetF(&options->folders, "%c:\\", (char) path[0]);
}
for(uint32_t i = 0; i < length; i++)
{
wchar_t* mountpoint = buf + i;
ffStrbufSetWS(&buffer, mountpoint);
i += buffer.length;
UINT driveType = GetDriveTypeW(mountpoint);
if(driveType == DRIVE_NO_ROOT_DIR)
if (__builtin_expect((long) options->folders.length, 0))
{
i += (uint32_t)wcslen(mountpoint);
continue;
if (!ffDiskMatchMountpoint(options, buffer.chars))
continue;
}
else if(driveType == DRIVE_NO_ROOT_DIR)
continue;
FFDisk* disk = ffListAdd(disks);
if(!GetDiskFreeSpaceExW(
disk->filesUsed = 0;
disk->filesTotal = 0;
disk->bytesTotal = 0;
disk->bytesFree = 0;
disk->bytesUsed = 0; // To be filled in ./disk.c
disk->bytesAvailable = 0;
disk->createTime = 0;
ffStrbufInit(&disk->filesystem);
ffStrbufInit(&disk->name);
ffStrbufInitMove(&disk->mountpoint, &buffer);
ffStrbufInit(&disk->mountFrom);
disk->type = driveType == DRIVE_REMOVABLE || driveType == DRIVE_REMOTE || driveType == DRIVE_CDROM
? FF_DISK_VOLUME_TYPE_EXTERNAL_BIT
: driveType == DRIVE_FIXED
? FF_DISK_VOLUME_TYPE_REGULAR_BIT
: FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
if (mountpoint[2] == L'\\' && mountpoint[3] == L'\0')
{
wchar_t volumeName[MAX_PATH + 1];
mountpoint[2] = L'\0';
if(QueryDosDeviceW(mountpoint, volumeName, sizeof(volumeName) / sizeof(*volumeName)))
ffStrbufSetWS(&disk->mountFrom, volumeName);
mountpoint[2] = L'\\';
}
#ifdef FF_HAVE_THREADS
if (driveType == DRIVE_REMOTE)
{
FFThreadType thread = ffThreadCreate(testRemoteVolumeAccessable, mountpoint);
if (!ffThreadJoin(thread, 500))
continue;
}
#endif
GetDiskFreeSpaceExW(
mountpoint,
(PULARGE_INTEGER)&disk->bytesAvailable,
(PULARGE_INTEGER)&disk->bytesTotal,
(PULARGE_INTEGER)&disk->bytesFree
))
{
disk->bytesTotal = 0;
disk->bytesFree = 0;
disk->bytesAvailable = 0;
}
disk->bytesUsed = 0; // To be filled in ./disk.c
);
if(driveType == DRIVE_REMOVABLE || driveType == DRIVE_REMOTE || driveType == DRIVE_CDROM)
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
else if(driveType == DRIVE_FIXED)
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
else
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
ffStrbufInit(&disk->filesystem);
ffStrbufInit(&disk->name);
wchar_t diskName[MAX_PATH + 1], diskFileSystem[MAX_PATH + 1];
//https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa#remarks
@@ -74,25 +123,6 @@ const char* ffDetectDisksImpl(FFlist* disks)
WIN32_FILE_ATTRIBUTE_DATA data;
if(GetFileAttributesExW(mountpoint, GetFileExInfoStandard, &data) && data.ftCreationTime.dwHighDateTime > 0)
disk->createTime = (*(uint64_t*) &data.ftCreationTime - 116444736000000000ull) / 10000ull;
else
disk->createTime = 0;
ffStrbufInitWS(&disk->mountpoint, mountpoint);
if (mountpoint[2] == L'\\' && mountpoint[3] == L'\0')
{
wchar_t volumeName[MAX_PATH + 1];
mountpoint[2] = L'\0';
if(QueryDosDeviceW(mountpoint, volumeName, sizeof(volumeName) / sizeof(*volumeName)))
ffStrbufInitWS(&disk->mountFrom, volumeName);
else
ffStrbufInit(&disk->mountFrom);
}
//Unsupported
disk->filesUsed = 0;
disk->filesTotal = 0;
i += disk->mountpoint.length;
}
return NULL;
@@ -13,6 +13,7 @@
#define FF_DE_PRETTY_BUDGIE "Budgie"
#define FF_DE_PRETTY_CDE "CDE"
#define FF_DE_PRETTY_UNITY "Unity"
#define FF_DE_PRETTY_UKUI "UKUI"
#define FF_WM_PRETTY_KWIN "KWin"
#define FF_WM_PRETTY_MUTTER "Mutter"
@@ -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),
@@ -118,7 +118,8 @@ void ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* regist
rotation,
display.edidName.length
? &display.edidName
: display.description.length
// Try ignoring `eDP-1-unknown`, where `unknown` is localized
: display.description.length && !(ffStrbufStartsWithS(&display.description, display.name.chars) && display.description.chars[display.name.length] == '-')
? &display.description
: &display.name,
display.type,
@@ -135,7 +135,7 @@ void ffdsConnectWayland(FFDisplayServerResult* result)
const char* xdgSessionType = getenv("XDG_SESSION_TYPE");
//If XDG_SESSION_TYPE is set, and doesn't contain "wayland", we are probably not running in a wayland session.
if(xdgSessionType != NULL && ffStrEqualsIgnCase(xdgSessionType, "wayland"))
if(xdgSessionType != NULL && !ffStrEqualsIgnCase(xdgSessionType, "wayland"))
return;
//If XDG_SESSION_TYPE is not set, check if WAYLAND_DISPLAY or WAYLAND_SOCKET is set.
@@ -6,7 +6,7 @@
static void waylandZwlrTransformListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1 *zwlr_output_head_v1, int32_t transform)
{
WaylandDisplay* wldata = (WaylandDisplay*) data;
wldata->transform = transform;
wldata->transform = (enum wl_output_transform) transform;
}
static void waylandZwlrScaleListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1 *zwlr_output_head_v1, wl_fixed_t scale)
+10 -1
View File
@@ -75,7 +75,9 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* name)
ffStrEqualsIgnCase(name, "kwin_wayland_wrapper") ||
ffStrEqualsIgnCase(name, "kwin_x11") ||
ffStrEqualsIgnCase(name, "kwin_x11_wrapper") ||
ffStrEqualsIgnCase(name, "kwin")
ffStrEqualsIgnCase(name, "kwin") ||
ffStrEndsWithIgnCase(name, "-kwin_wayland") ||
ffStrEndsWithIgnCase(name, "-kwin_x11")
) ffStrbufSetS(&result->wmPrettyName, FF_WM_PRETTY_KWIN);
else if(
ffStrEqualsIgnCase(name, "gnome-shell") ||
@@ -231,6 +233,13 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name)
ffStrbufSetS(&result->deProcessName, "dtsession");
ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_CDE);
}
else if(
ffStrEqualsIgnCase(name, "ukui-session")
) {
ffStrbufSetS(&result->deProcessName, "ukui-session");
ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_UKUI);
}
}
static void getWMProtocolNameFromEnv(FFDisplayServerResult* result)
+91
View File
@@ -0,0 +1,91 @@
#include "editor.h"
#include "common/processing.h"
#include "util/stringUtils.h"
#include <stdlib.h>
const char* ffDetectEditor(FFEditorResult* result)
{
ffStrbufSetS(&result->name, getenv("VISUAL"));
if (result->name.length == 0)
ffStrbufSetS(&result->name, getenv("EDITOR"));
if (result->name.length == 0)
return "$VISUAL or $EDITOR not set";
#ifndef _WIN32
if (result->name.chars[0] != '/')
{
if (ffProcessAppendStdOut(&result->path, (char* const[]){
FASTFETCH_TARGET_DIR_USR "/bin/which",
result->name.chars,
NULL,
}) != NULL || result->path.length == 0)
return NULL;
}
else
ffStrbufSet(&result->path, &result->name);
char buf[PATH_MAX + 1];
if (!realpath(result->path.chars, buf))
return NULL;
ffStrbufSetS(&result->path, buf);
const char* exe = &result->path.chars[ffStrbufLastIndexC(&result->path, '/')];
if (!*exe) return NULL;
++exe;
result->exe = exe;
const char* param = NULL;
if (
ffStrEquals(exe, "nano") ||
ffStrEquals(exe, "vim") ||
ffStrEquals(exe, "nvim") ||
ffStrEquals(exe, "micro") ||
ffStrEquals(exe, "emacs") ||
ffStrStartsWith(exe, "emacs-") || // emacs-29.3
ffStrEquals(exe, "hx") ||
ffStrEquals(exe, "code") ||
ffStrEquals(exe, "sublime_text")
) param = "--version";
else if (
ffStrEquals(exe, "kak") ||
ffStrEquals(exe, "pico")
) param = "-version";
else if (
ffStrEquals(exe, "ne")
) param = "-h";
else return NULL;
ffProcessAppendStdOut(&result->version, (char* const[]){
result->path.chars,
(char*) param,
NULL,
});
if (result->version.length == 0)
return NULL;
ffStrbufSubstrBeforeFirstC(&result->version, '\n');
for (uint32_t iStart = 0; iStart < result->version.length; ++iStart)
{
char c = result->version.chars[iStart];
if (c >= '0' && c <= '9')
{
for (uint32_t iEnd = iStart + 1; iEnd < result->version.length; ++iEnd)
{
char c = result->version.chars[iEnd];
if (isspace(c))
{
ffStrbufSubstrBefore(&result->version, iEnd);
break;
}
}
if (iStart > 0)
ffStrbufSubstrAfter(&result->version, iStart - 1);
break;
}
}
#endif
return NULL;
}
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include "fastfetch.h"
typedef struct FFEditorResult
{
FFstrbuf name;
const char* exe;
FFstrbuf path;
FFstrbuf version;
} FFEditorResult;
const char* ffDetectEditor(FFEditorResult* result);
+4
View File
@@ -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
View File
@@ -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";
}
+15 -4
View File
@@ -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;
}
-1
View File
@@ -2,7 +2,6 @@
#include "common/io/io.h"
#include "common/properties.h"
#include "3rdparty/nvml/nvml.h"
#include "util/mallocHelper.h"
#include <dev/pci/pcireg.h>
+198 -109
View File
@@ -15,24 +15,25 @@
#include <inttypes.h>
FF_MAYBE_UNUSED static void pciDetectTemp(FFGPUResult* gpu, uint32_t deviceClass)
{
const FFlist* tempsResult = ffDetectTemps();
#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
FF_LIST_FOR_EACH(FFTempValue, tempValue, *tempsResult)
{
// https://www.kernel.org/doc/html/v5.10/gpu/amdgpu.html#hwmon-interfaces
// FIXME: this code doesn't take multiGPUs into count
// The kernel exposes the device class multiplied by 256 for some reason
if(tempValue->deviceClass == deviceClass * 256)
{
gpu->temperature = tempValue->value;
return;
}
}
}
#if FF_HAVE_DRM_H
#include <fcntl.h>
#include <sys/ioctl.h>
static void pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer)
#if __aarch64__ && __has_include(<drm/asahi_drm.h>)
#include <drm/asahi_drm.h>
#define FF_HAVE_ASAHI_DRM_H 1
#endif
#endif
static bool pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey)
{
ffStrbufAppendS(pciDir, "/driver");
char pathBuf[PATH_MAX];
@@ -52,60 +53,104 @@ static void pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer
ffStrbufTrimRightSpace(buffer);
ffStrbufAppendC(&gpu->driver, ' ');
ffStrbufAppend(&gpu->driver, buffer);
return true;
}
}
return false;
}
static void pciDetectVmem(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer)
static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer)
{
// Works for AMD GPUs
// https://www.kernel.org/doc/html/v5.10/gpu/amdgpu.html#mem-info-vis-vram-total
ffStrbufAppendS(pciDir, "/mem_info_vis_vram_total");
uint64_t size = 0;
if (ffReadFileBuffer(pciDir->chars, buffer) && (size = ffStrbufToUInt(buffer, 0)))
{
gpu->type = size > 1024UL * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
if (gpu->type == FF_GPU_TYPE_DISCRETE)
gpu->dedicated.total = size;
else
gpu->shared.total = size;
const uint32_t pciDirLen = pciDir->length;
ffStrbufSubstrBefore(pciDir, pciDir->length - (uint32_t) strlen("/mem_info_vis_vram_total"));
ffStrbufAppendS(pciDir, "/mem_info_vram_used");
if (ffReadFileBuffer(pciDir->chars, buffer) && (size = ffStrbufToUInt(buffer, 0)))
ffStrbufAppendS(pciDir, "/hwmon/");
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(pciDir->chars);
if (!dirp) return;
struct dirent* entry;
while ((entry = readdir(dirp)) != NULL)
{
if (entry->d_name[0] == '.') continue;
break;
}
if (!entry) return;
ffStrbufAppendS(pciDir, entry->d_name);
ffStrbufAppendC(pciDir, '/');
const uint32_t hwmonLen = pciDir->length;
ffStrbufAppendS(pciDir, "in1_input"); // Northbridge voltage in millivolts (APUs only)
if (ffPathExists(pciDir->chars, FF_PATHTYPE_FILE))
gpu->type = FF_GPU_TYPE_INTEGRATED;
else
gpu->type = FF_GPU_TYPE_DISCRETE;
uint64_t value = 0;
if (options->temp)
{
ffStrbufSubstrBefore(pciDir, hwmonLen);
ffStrbufAppendS(pciDir, "temp1_input"); // The on die GPU temperature in millidegrees Celsius
if (ffReadFileBuffer(pciDir->chars, buffer) && (value = ffStrbufToUInt(buffer, 0)))
gpu->temperature = (double) value / 1000;
}
ffStrbufSubstrBefore(pciDir, hwmonLen);
ffStrbufAppendS(pciDir, "freq1_input"); // The gfx/compute clock in hertz
if (ffReadFileBuffer(pciDir->chars, buffer) && (value = ffStrbufToUInt(buffer, 0)))
gpu->frequency = (double) value / (1000 * 1000 * 1000);
if (options->driverSpecific)
{
ffStrbufSubstrBefore(pciDir, pciDirLen);
ffStrbufAppendS(pciDir, "/mem_info_vis_vram_total");
if (ffReadFileBuffer(pciDir->chars, buffer) && (value = ffStrbufToUInt(buffer, 0)))
{
if (gpu->type == FF_GPU_TYPE_DISCRETE)
gpu->dedicated.used = size;
else
gpu->shared.used = size;
ffStrbufSubstrBefore(pciDir, pciDir->length - (uint32_t) strlen("/mem_info_vis_vram_total"));
ffStrbufAppendS(pciDir, "/mem_info_vis_vram_used");
if (ffReadFileBuffer(pciDir->chars, buffer) && (value = ffStrbufToUInt(buffer, 0)))
{
if (gpu->type == FF_GPU_TYPE_DISCRETE)
gpu->dedicated.used = value;
else
gpu->shared.used = value;
}
}
}
}
static void pciDetectVfreq(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer)
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)
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)
{
str[len] = '\0';
gpu->frequency = (double) strtoul(str, NULL, 10) / 1000.0;
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)
{
#ifdef FF_CUSTOM_PCI_IDS_PATH
ffReadFileBuffer(FF_STR(FF_CUSTOM_PCI_IDS_PATH), pciids);
if (pciids->length > 0) return true;
#endif
#else
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/hwdata/pci.ids", pciids);
if (pciids->length > 0) return true;
@@ -116,12 +161,14 @@ static bool loadPciIds(FFstrbuf* pciids)
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/local/share/hwdata/pci.ids", pciids);
if (pciids->length > 0) return true;
#endif
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)
@@ -131,15 +178,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)
@@ -157,10 +212,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);
@@ -168,10 +225,14 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
{
char query[32];
snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision);
#ifdef FF_CUSTOM_AMDGPU_IDS_PATH
ffParsePropFile(FF_STR(FF_CUSTOM_AMDGPU_IDS_PATH), query, &gpu->name);
#else
ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name);
#endif
}
}
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
}
if (gpu->name.length == 0)
@@ -182,70 +243,96 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
ffStrbufInit(&pciids);
loadPciIds(&pciids);
}
if (pciids.length)
ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu);
ffGPUParsePciIds(&pciids, subclassId, (uint16_t) vendorId, (uint16_t) deviceId, gpu);
}
pciDetectVmem(gpu, drmDir, buffer);
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
pciDetectDriver(gpu, deviceDir, buffer, drmKey);
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
pciDetectVfreq(gpu, drmDir, buffer);
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
pciDetectDriver(gpu, drmDir, buffer);
ffStrbufSubstrBefore(drmDir, drmDirPathLength);
#ifdef FF_USE_PROPRIETARY_GPU_DRIVER_API
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->driverSpecific))
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD)
{
ffDetectNvidiaGpuInfo(&(FFGpuDriverCondition) {
.type = FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID,
.pciBusId = {
.domain = pciDomain,
.bus = pciBus,
.device = pciDevice,
.func = pciFunc,
},
}, (FFGpuDriverResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
.type = &gpu->type,
.frequency = &gpu->frequency,
}, "libnvidia-ml.so");
if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET)
gpu->type = gpu->dedicated.total > (uint64_t)1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
pciDetectAmdSpecific(options, gpu, deviceDir, buffer);
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
}
#endif // FF_USE_PROPRIETARY_GPU_DRIVER_API
else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL)
{
pciDetectIntelSpecific(gpu, deviceDir, buffer);
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
}
else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA)
{
#ifdef FF_USE_PROPRIETARY_GPU_DRIVER_API
if (options->temp || options->driverSpecific)
{
ffDetectNvidiaGpuInfo(&(FFGpuDriverCondition) {
.type = FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID,
.pciBusId = {
.domain = pciDomain,
.bus = pciBus,
.device = pciDevice,
.func = pciFunc,
},
}, (FFGpuDriverResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
.type = &gpu->type,
.frequency = &gpu->frequency,
}, "libnvidia-ml.so");
}
#endif // FF_USE_PROPRIETARY_GPU_DRIVER_API
#ifdef __linux__
if(options->temp && gpu->temperature != gpu->temperature)
pciDetectTemp(gpu, ((uint32_t) classId << 8) + subclassId);
#endif
if (gpu->type == FF_GPU_TYPE_UNKNOWN)
{
if (ffStrbufStartsWithIgnCaseS(&gpu->name, "GeForce") ||
ffStrbufStartsWithIgnCaseS(&gpu->name, "Quadro") ||
ffStrbufStartsWithIgnCaseS(&gpu->name, "Tesla"))
gpu->type = FF_GPU_TYPE_DISCRETE;
}
}
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?";
index += strlen("apple,agx-t");
index += (uint32_t) strlen("apple,agx-t");
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
gpu->deviceId = strtoul(buffer->chars + index, NULL, 10);
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) &paramsGlobal,
.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;
}
@@ -277,10 +364,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);
@@ -322,7 +409,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);
}
@@ -331,14 +418,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);
}
+1 -1
View File
@@ -1,7 +1,7 @@
#include "gpu_driver_specific.h"
#include "3rdparty/nvml/nvml.h"
#include "common/library.h"
#include "nvml.h"
struct FFNvmlData {
FF_LIBRARY_SYMBOL(nvmlDeviceGetCount_v2)
+120
View File
@@ -0,0 +1,120 @@
#pragma once
// DISCLAIMER:
// THIS FILE IS CREATED FROM SCRATCH, BY READING THE OFFICIAL NVML API
// DOCUMENTATION REFERENCED BELOW, IN ORDER TO MAKE FASTFETCH MIT COMPLIANT.
// https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceStructs.html
#define NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE 32
#define NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE 16
typedef enum { NVML_SUCCESS = 0 } nvmlReturn_t;
typedef struct nvmlDevice_t* nvmlDevice_t;
// https://docs.nvidia.com/deploy/nvml-api/structnvmlPciInfo__t.html
// PCI information about a GPU device
typedef struct {
// The legacy tuple domain:bus:device.function PCI identifier (& NULL terminator)
char busIdLegacy[NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE];
// The PCI domain on which the device's bus resides, 0 to 0xffffffff
unsigned int domain;
// The bus on which the device resides, 0 to 0xff
unsigned int bus;
// The device's id on the bus, 0 to 31
unsigned int device;
// The combined 16-bit device id and 16-bit vendor id
unsigned int pciDeviceId;
// The 32-bit Sub System Device ID
unsigned int pciSubSystemId;
// The tuple domain:bus:device.function PCI identifier (& NULL terminator)
char busId[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE];
} nvmlPciInfo_t;
// https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceEnumvs.html#group__nvmlDeviceEnumvs_1g2650b526841fa38b8f293c2d509a1de0
// Temperature sensors
typedef enum {
// Temperature sensor for the GPU die
NVML_TEMPERATURE_GPU = 0,
NVML_TEMPERATURE_COUNT,
} nvmlTemperatureSensors_t;
// https://docs.nvidia.com/deploy/nvml-api/structnvmlMemory__v2__t.html#structnvmlMemory__v2__t
// Memory allocation information for a device (v2)
typedef struct {
// Structure format version (must be 2)
unsigned int version;
// Total physical device memory (in bytes)
unsigned long long total;
// Device memory (in bytes) reserved for system use (driver or firmware)
unsigned long long reserved;
// Unallocated device memory (in bytes)
unsigned long long free;
// Allocated device memory (in bytes)
unsigned long long used;
} nvmlMemory_v2_t;
enum { nvmlMemory_v2 = 2 };
// https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceEnumvs.html#group__nvmlDeviceEnumvs_1g805c0647be9996589fc5e3f6ff680c64
// Clock types
typedef enum {
// Graphics clock domain
NVML_CLOCK_GRAPHICS = 0,
// SM clock domain
NVML_CLOCK_SM = 1,
// Memory clock domain
NVML_CLOCK_MEM = 2,
// Video encoder/decoder clock domain
NVML_CLOCK_VIDEO = 3,
// Count of clock types
NVML_CLOCK_COUNT,
} nvmlClockType_t;
// https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceEnumvs.html#group__nvmlDeviceEnumvs_1gfa6b01990b212f7b49089b7158eafd2b
// The Brand of the GPU
typedef enum {
NVML_BRAND_UNKNOWN = 0,
NVML_BRAND_QUADRO = 1,
NVML_BRAND_TESLA = 2,
NVML_BRAND_NVS = 3,
NVML_BRAND_GRID = 4,
NVML_BRAND_GEFORCE = 5,
NVML_BRAND_TITAN = 6,
NVML_BRAND_NVIDIA_VAPPS = 7,
NVML_BRAND_NVIDIA_VPC = 8,
NVML_BRAND_NVIDIA_VCS = 9,
NVML_BRAND_NVIDIA_VWS = 10,
NVML_BRAND_NVIDIA_CLOUD_GAMING = 11,
NVML_BRAND_NVIDIA_VGAMING = NVML_BRAND_NVIDIA_CLOUD_GAMING,
NVML_BRAND_QUADRO_RTX = 12,
NVML_BRAND_NVIDIA_RTX = 13,
NVML_BRAND_NVIDIA = 14,
NVML_BRAND_GEFORCE_RTX = 15,
NVML_BRAND_TITAN_RTX = 16,
NVML_BRAND_COUNT,
} nvmlBrandType_t;
// https://docs.nvidia.com/deploy/nvml-api/group__nvmlInitializationAndCleanup.html#group__nvmlInitializationAndCleanup
// Initialize NVML, but don't initialize any GPUs yet
nvmlReturn_t nvmlInit_v2(void);
// Shut down NVML by releasing all GPU resources previously allocated with nvmlInit_v2()
nvmlReturn_t nvmlShutdown(void);
// https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceQueries.html
// Retrieves the number of compute devices in the system. A compute device is a single GPU
extern nvmlReturn_t nvmlDeviceGetCount_v2(unsigned int* deviceCount);
// Acquire the handle for a particular device, based on its index
extern nvmlReturn_t nvmlDeviceGetHandleByIndex_v2(unsigned int index, nvmlDevice_t* device);
// Acquire the handle for a particular device, based on its PCI bus id
extern nvmlReturn_t nvmlDeviceGetHandleByPciBusId_v2(const char* pciBusId, nvmlDevice_t* device);
// Retrieves the PCI attributes of this device
extern nvmlReturn_t nvmlDeviceGetPciInfo_v3(nvmlDevice_t device, nvmlPciInfo_t* pci);
// Retrieves the current temperature readings for the device, in degrees C
extern nvmlReturn_t nvmlDeviceGetTemperature(nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int* temp);
// Retrieves the amount of used, free, reserved and total memory available on the device, in bytes. The reserved amount is supported on version 2 only
extern nvmlReturn_t nvmlDeviceGetMemoryInfo_v2(nvmlDevice_t device, nvmlMemory_v2_t* memory);
// Gets the device's core count
extern nvmlReturn_t nvmlDeviceGetNumGpuCores(nvmlDevice_t device, unsigned int* numCores);
// Retrieves the maximum clock speeds for the device
extern nvmlReturn_t nvmlDeviceGetMaxClockInfo(nvmlDevice_t device, nvmlClockType_t type, unsigned int* clock);
// Retrieves the brand of this device
extern nvmlReturn_t nvmlDeviceGetBrand(nvmlDevice_t device, nvmlBrandType_t* type);
+10 -3
View File
@@ -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";
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include "fastfetch.h"
const char* ffDetectLoadavg(double result[3]);
+20
View File
@@ -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;
}
+31
View File
@@ -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";
}
+16 -8
View File
@@ -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
}
+13 -1
View File
@@ -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;
}
}
}
+22 -1
View File
@@ -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;
+10 -3
View File
@@ -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;
+1 -2
View File
@@ -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);
+83 -22
View File
@@ -2,11 +2,15 @@
#include "common/properties.h"
#include "common/parsing.h"
#include "common/io/io.h"
#include "common/processing.h"
#include "util/stringUtils.h"
#include <string.h>
#include <stdlib.h>
#define FF_STR_INDIR(x) #x
#define FF_STR(x) FF_STR_INDIR(x)
static inline bool allRelevantValuesSet(const FFOSResult* result)
{
return result->id.length > 0
@@ -15,22 +19,30 @@ static inline bool allRelevantValuesSet(const FFOSResult* result)
;
}
static bool parseFile(const char* fileName, FFOSResult* result)
static bool parseLsbRelease(const char* fileName, FFOSResult* result)
{
return ffParsePropFileValues(fileName, 13, (FFpropquery[]) {
{"NAME =", &result->name},
{"DISTRIB_DESCRIPTION =", &result->prettyName},
{"PRETTY_NAME =", &result->prettyName},
return ffParsePropFileValues(fileName, 4, (FFpropquery[]) {
{"DISTRIB_ID =", &result->id},
{"DISTRIB_DESCRIPTION =", &result->prettyName},
{"DISTRIB_RELEASE =", &result->version},
{"DISTRIB_CODENAME =", &result->codename},
});
}
static bool parseOsRelease(const char* fileName, FFOSResult* result)
{
return ffParsePropFileValues(fileName, 11, (FFpropquery[]) {
{"PRETTY_NAME =", &result->prettyName},
{"NAME =", &result->name},
{"ID =", &result->id},
{"ID_LIKE =", &result->idLike},
{"VARIANT =", &result->variant},
{"VARIANT_ID =", &result->variantID},
{"DISTRIB_RELEASE =", &result->version},
{"VERSION =", &result->version},
{"VERSION_ID =", &result->versionID},
{"VERSION_CODENAME =", &result->codename},
{"BUILD_ID =", &result->buildID}
{"CODENAME =", &result->codename},
{"BUILD_ID =", &result->buildID},
});
}
@@ -132,15 +144,48 @@ static void getDebianVersion(FFOSResult* result)
ffStrbufSet(&result->versionID, &debianVersion);
}
static bool detectDebianDerived(FFOSResult* result)
{
if (ffStrbufStartsWithS(&result->prettyName, "Armbian ")) // Armbian 24.2.1 bookworm
{
ffStrbufSetS(&result->name, "Armbian");
ffStrbufSetS(&result->id, "armbian");
ffStrbufSetS(&result->idLike, "debian");
ffStrbufClear(&result->versionID);
uint32_t versionStart = ffStrbufFirstIndexC(&result->prettyName, ' ') + 1;
uint32_t versionEnd = ffStrbufNextIndexC(&result->prettyName, versionStart, ' ');
ffStrbufSetNS(&result->versionID, versionEnd - versionStart, result->prettyName.chars + versionStart);
return true;
}
else if (ffPathExists("/usr/bin/pveversion", FF_PATHTYPE_FILE))
{
ffStrbufSetS(&result->id, "pve");
ffStrbufSetS(&result->idLike, "debian");
ffStrbufSetS(&result->name, "Proxmox VE");
ffStrbufClear(&result->versionID);
if (ffProcessAppendStdOut(&result->versionID, (char* const[]) {
"/usr/bin/pveversion",
NULL,
}) == NULL) // pve-manager/8.2.2/9355359cd7afbae4 (running kernel: 6.8.4-2-pve)
{
ffStrbufSubstrBeforeLastC(&result->versionID, '/');
ffStrbufSubstrAfterFirstC(&result->versionID, '/');
}
ffStrbufSetF(&result->prettyName, "Proxmox VE %s", result->versionID.chars);
return true;
}
return false;
}
static void detectOS(FFOSResult* os)
{
if(instance.config.general.osFile.length > 0)
{
parseFile(instance.config.general.osFile.chars, os);
return;
}
#ifdef FF_CUSTOM_OS_RELEASE_PATH
parseOsRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os);
parseLsbRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os);
return;
#endif
if(instance.config.general.escapeBedrock && parseFile(FASTFETCH_TARGET_DIR_ROOT"/bedrock"FASTFETCH_TARGET_DIR_ETC"/bedrock-release", os))
if(instance.config.general.escapeBedrock && parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock" FASTFETCH_TARGET_DIR_ETC "/bedrock-release", os))
{
if(os->id.length == 0)
ffStrbufAppendS(&os->id, "bedrock");
@@ -151,18 +196,31 @@ static void detectOS(FFOSResult* os)
if(os->prettyName.length == 0)
ffStrbufAppendS(&os->prettyName, "Bedrock Linux");
return;
if(parseOsRelease("/bedrock" FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os))
return;
}
parseFile(FASTFETCH_TARGET_DIR_ETC"/os-release", os);
if(allRelevantValuesSet(os))
// Refer: https://gist.github.com/natefoo/814c5bf936922dad97ff
// Hack for MX Linux. See #847
if(parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os))
{
if (ffStrbufEqualS(&os->id, "MX"))
{
ffStrbufSetStatic(&os->name, "MX");
ffStrbufSetStatic(&os->idLike, "debian");
return;
}
// For archlinux
if (ffStrbufEqualS(&os->version, "rolling"))
ffStrbufClear(&os->version);
}
if(parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os))
return;
parseFile(FASTFETCH_TARGET_DIR_USR"/lib/os-release", os);
if(allRelevantValuesSet(os))
return;
parseFile(FASTFETCH_TARGET_DIR_ETC"/lsb-release", os);
parseOsRelease(FASTFETCH_TARGET_DIR_USR "/lib/os-release", os);
}
void ffDetectOSImpl(FFOSResult* os)
@@ -172,5 +230,8 @@ void ffDetectOSImpl(FFOSResult* os)
if(ffStrbufIgnCaseEqualS(&os->id, "ubuntu"))
getUbuntuFlavour(os);
else if(ffStrbufIgnCaseEqualS(&os->id, "debian"))
getDebianVersion(os);
{
if (!detectDebianDerived(os))
getDebianVersion(os);
}
}
+3
View File
@@ -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;
@@ -26,6 +28,7 @@ typedef struct FFPackagesResult
uint32_t rpm;
uint32_t scoop;
uint32_t snap;
uint32_t sorcery;
uint32_t winget;
uint32_t xbps;
+160 -12
View File
@@ -118,28 +118,146 @@ static uint32_t countFilesRecursive(FFstrbuf* baseDir, const char* dirname, cons
return sum;
}
static bool isValidNixPkg(FFstrbuf* pkg)
{
if (!ffPathExists(pkg->chars, FF_PATHTYPE_DIRECTORY))
return false;
ffStrbufSubstrAfterLastC(pkg, '/');
if (
ffStrbufStartsWithS(pkg, "nixos-system-nixos-") ||
ffStrbufEndsWithS(pkg, "-doc") ||
ffStrbufEndsWithS(pkg, "-man") ||
ffStrbufEndsWithS(pkg, "-info") ||
ffStrbufEndsWithS(pkg, "-dev") ||
ffStrbufEndsWithS(pkg, "-bin")
) return false;
enum { START, DIGIT, DOT, MATCH } state = START;
for (uint32_t i = 0; i < pkg->length; i++)
{
char c = pkg->chars[i];
switch (state)
{
case START:
if (c >= '0' && c <= '9')
state = DIGIT;
break;
case DIGIT:
if (c >= '0' && c <= '9')
continue;
if (c == '.')
state = DOT;
else
state = START;
break;
case DOT:
if (c >= '0' && c <= '9')
state = MATCH;
else
state = START;
break;
case MATCH:
break;
}
}
return state == MATCH;
}
static bool checkNixCache(FFstrbuf* cacheDir, FFstrbuf* hash, uint32_t* count)
{
if (!ffPathExists(cacheDir->chars, FF_PATHTYPE_FILE))
return false;
FF_STRBUF_AUTO_DESTROY cacheContent = ffStrbufCreate();
if (!ffReadFileBuffer(cacheDir->chars, &cacheContent))
return false;
// Format: <hash>\n<count>
uint32_t split = ffStrbufFirstIndexC(&cacheContent, '\n');
if (split == cacheContent.length)
return false;
ffStrbufSetNS(hash, split, cacheContent.chars);
*count = (uint32_t)atoi(cacheContent.chars + split + 1);
return true;
}
static bool writeNixCache(FFstrbuf* cacheDir, FFstrbuf* hash, uint32_t count)
{
FF_STRBUF_AUTO_DESTROY cacheContent = ffStrbufCreateCopy(hash);
ffStrbufAppendF(&cacheContent, "\n%u", count);
return ffWriteFileBuffer(cacheDir->chars, &cacheContent);
}
static uint32_t getNixPackagesImpl(char* path)
{
//Nix detection is kinda slow, so we only do it if the dir exists
if(!ffPathExists(path, FF_PATHTYPE_DIRECTORY))
return 0;
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(128);
FF_STRBUF_AUTO_DESTROY cacheDir = ffStrbufCreateCopy(&instance.state.platform.cacheDir);
ffStrbufEnsureEndsWithC(&cacheDir, '/');
ffStrbufAppendS(&cacheDir, "fastfetch/packages/nix");
ffStrbufAppendS(&cacheDir, path);
//https://github.com/fastfetch-cli/fastfetch/issues/195#issuecomment-1191748222
FF_STRBUF_AUTO_DESTROY command = ffStrbufCreateA(255);
ffStrbufAppendS(&command, "for x in $(nix-store --query --requisites ");
ffStrbufAppendS(&command, path);
ffStrbufAppendS(&command, "); do if [ -d $x ]; then echo $x ; fi ; done | cut -d- -f2- | egrep '([0-9]{1,}\\.)+[0-9]{1,}' | egrep -v '\\-doc$|\\-man$|\\-info$|\\-dev$|\\-bin$|^nixos-system-nixos-' | uniq | wc -l");
//Check the hash first to determine if we need to recompute the count
FF_STRBUF_AUTO_DESTROY hash = ffStrbufCreateA(64);
FF_STRBUF_AUTO_DESTROY cacheHash = ffStrbufCreateA(64);
uint32_t count = 0;
ffProcessAppendStdOut(&output, (char* const[]) {
"sh",
"-c",
command.chars,
ffProcessAppendStdOut(&hash, (char* const[]) {
"nix-store",
"--query",
"--hash",
path,
NULL
});
return (uint32_t) strtol(output.chars, NULL, 10);
if (checkNixCache(&cacheDir, &cacheHash, &count) && ffStrbufEqual(&hash, &cacheHash))
return count;
//Cache is invalid, recompute the count
count = 0;
//Implementation based on bash script from here:
//https://github.com/fastfetch-cli/fastfetch/issues/195#issuecomment-1191748222
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(1024);
ffProcessAppendStdOut(&output, (char* const[]) {
"nix-store",
"--query",
"--requisites",
path,
NULL
});
uint32_t lineLength = 0;
for (uint32_t i = 0; i < output.length; i++)
{
if (output.chars[i] != '\n')
{
lineLength++;
continue;
}
output.chars[i] = '\0';
FFstrbuf line = {
.allocated = 0,
.length = lineLength,
.chars = output.chars + i - lineLength
};
if (isValidNixPkg(&line))
count++;
lineLength = 0;
}
writeNixCache(&cacheDir, &hash, count);
return count;
}
static uint32_t getNixPackages(FFstrbuf* baseDir, const char* dirname)
@@ -294,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");
@@ -303,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);
@@ -315,6 +435,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts,
if (!(options->disabled & FF_PACKAGES_FLAG_PALUDIS_BIT)) packageCounts->paludis += countFilesRecursive(baseDir, "/var/db/paludis/repositories", "environment.bz2");
if (!(options->disabled & FF_PACKAGES_FLAG_OPKG_BIT)) packageCounts->opkg += getNumStrings(baseDir, "/usr/lib/opkg/status", "Package:"); // openwrt
if (!(options->disabled & FF_PACKAGES_FLAG_AM_BIT)) packageCounts->am = getAM(baseDir);
if (!(options->disabled & FF_PACKAGES_FLAG_SORCERY_BIT)) packageCounts->sorcery += getNumStrings(baseDir, "/var/state/sorcery/packages", ":installed:");
}
static void getPackageCountsRegular(FFstrbuf* baseDir, FFPackagesResult* packageCounts, FFPackagesOptions* options)
@@ -383,7 +504,34 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
ffStrbufSet(&baseDir, &instance.state.platform.homeDir);
if (!(options->disabled & FF_PACKAGES_FLAG_NIX_BIT))
result->nixUser = getNixPackages(&baseDir, "/.nix-profile");
{
// check if ~/.nix-profile exists
FF_STRBUF_AUTO_DESTROY profilePath = ffStrbufCreateCopy(&baseDir);
ffStrbufAppendS(&profilePath, ".nix-profile");
if (ffPathExists(profilePath.chars, FF_PATHTYPE_DIRECTORY))
{
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
{
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);
}

Some files were not shown because too many files have changed in this diff Show More