Compare commits

...

138 Commits

Author SHA1 Message Date
Carter Li 18d530103f Merge pull request #1353 from fastfetch-cli/dev
Release: v2.28.0
2024-10-23 09:55:23 +08:00
李通洲 4d235a9fe9 Release: v2.28.0 2024-10-23 09:24:42 +08:00
李通洲 5c06d34b49 Windows: use system provided CM_Get_Device_Interface_PropertyW 2024-10-23 09:21:30 +08:00
Carter Li 6cd7f6c2f6 Doc: update changelog [ci skip] 2024-10-22 14:50:38 +08:00
李通洲 c8521b55b9 CPUUsage / DiskIO / NetIO: add option waitTime 2024-10-22 11:08:44 +08:00
李通洲 40b8023ff9 CI: fix build for old compilers 2024-10-18 21:07:50 +08:00
李通洲 7a3afa4adf PhysicalDisk (Linux): don't report obviously invalid temp 2024-10-18 16:49:36 +08:00
李通洲 b257134d74 Chore: introduce macro ARRAY_SIZE 2024-10-18 16:44:41 +08:00
李通洲 5497cb64c2 Processing (Windows): generate unique pipe name
Fix #1346
2024-10-18 14:08:55 +08:00
李通洲 bd4bc87c38 CMake: add comments 2024-10-17 22:34:37 +08:00
李通洲 188dbde595 Chore: remove all #ifndef guards 2024-10-17 22:33:52 +08:00
李通洲 48bb5b8746 Chore: use ffStrCopyN instead of strlcpy 2024-10-17 22:29:38 +08:00
Carter Li 9bd692dffb Presets: add showAllIps to all.jsonc 2024-10-17 19:39:26 +08:00
李通洲 dee5f1b339 CMake: enable fortify if available 2024-10-17 19:38:48 +08:00
Carter Li ecd73667df DiskIO (Linux): fix multi-namespace nvme drive detection 2024-10-17 19:38:48 +08:00
李通洲 993902916d Chore: don't use strncpy in favor of strlcpy
strncpy doesn't require target to be NUL terminated
2024-10-17 16:16:04 +08:00
李通洲 8f79d6ab1d Chore: silence some warnings 2024-10-17 15:39:11 +08:00
李通洲 6500cddc09 Disk (Android): fix compiling 2024-10-17 15:25:54 +08:00
李通洲 4146bb6731 OS (Windows): hard linking winbrand 2024-10-17 09:30:48 +08:00
李通洲 9188715efd TPM (Windows): use system headers 2024-10-17 09:20:17 +08:00
李通洲 bf1cd3388d Battery (macOS): fix remaining time detection 2024-10-16 09:15:04 +08:00
李通洲 a0ad38d1d4 Disk: check for mntopt instead of statvfs when detecting read only flags
Ref: #1343
2024-10-15 23:08:10 +08:00
李通洲 cc86c2c428 CI (Linux): try fixing build 2024-10-15 21:43:55 +08:00
李通洲 67a35c92ff Chore (Linux): code cleanup 2024-10-15 21:43:41 +08:00
李通洲 ae76d2d032 IO (Linux): improve performance of ffPathExists 2024-10-15 19:40:03 +08:00
Carter Li 2b2c223d22 Btrfs (Linux): simplify 2024-10-15 11:11:11 +08:00
Carter Li d6fa03d9e6 Fastfetch: don't use invalid paths when printing preset files 2024-10-15 10:31:37 +08:00
Carter Li 21ab56ad00 DiskIO (Linux): simplify 2024-10-15 10:30:58 +08:00
Carter Li b5a9d64e75 PhysicalDisk (Linux): simplify 2024-10-15 10:29:50 +08:00
Carter Li e73d6db2e5 Battery (Linux): improve performance by specifying O_PATH 2024-10-15 10:18:26 +08:00
Carter Li 1c598add39 Chore (Linux): always ignore hidden files when enumerating directories 2024-10-15 10:16:58 +08:00
XeroArch f87f345918 Fixing wrong color in the XeroArch ASCII logo (#1342)
* putting xeroarch logo in askii

* updating logo

* updating

* updating

* uploading xeroarch ascii logo

* upgrading fetch ascii logo

* fixing a very small issue

* removing unecessary line

* removing trailing lines

* fixing erroneous colors in the logo

---------

Co-authored-by: xeroarch <xeroarch.os@gmail.com>
2024-10-15 08:52:42 +08:00
李通洲 fba33df1d3 Kernel: don't print ( - 2024-10-14 16:28:53 +08:00
李通洲 a11b10fb37 Doc: update changelog 2024-10-14 16:07:01 +08:00
李通洲 c73b5914ab Battery (macOS): report time remaining only when discharging 2024-10-14 15:58:31 +08:00
李通洲 e70589483d Kernel (Windows): detect wine 2024-10-14 15:52:12 +08:00
Carter Li 71a8978f41 Display: report platform api used for detection 2024-10-14 14:42:11 +08:00
apocelipes 0f1ad5750d Netif (Linux): fix unused-result warning (#1340) 2024-10-14 12:30:39 +08:00
apocelipes bbc9cf4980 Processing(Linux, SunOS): little optimizations (#1341) 2024-10-14 11:35:29 +08:00
李通洲 fbed730dac Netif (Linux): don't use fseek
Turns out that `fseek` generates two extra syscalls, which causes unnecessary overhead.
2024-10-13 21:32:17 +08:00
李通洲 f847a23fb9 CI: remove musl-aarch64 2024-10-13 18:54:46 +08:00
Carter Li c5527fa4e6 Zpool: don't report invalid fragmentation 2024-10-13 17:18:53 +08:00
Carter Li c92d6f9eb6 CI: fix spellcheck errors 2024-10-13 17:07:01 +08:00
李通洲 3a914f2d27 LocalIP (Linux): simplify ffNetifGetDefaultRouteImpl
Fix #1336
2024-10-13 08:55:03 +08:00
Shu Niu 986d36c028 fix build in ancient MacOS (#1334) 2024-10-12 19:45:14 +08:00
李通洲 746cff471f IO (Windows): fix build 2024-10-12 19:44:30 +08:00
Carter Li 08cdeb3bcf PhysicalDisk (Linux): simplify code 2024-10-12 13:29:58 +08:00
Carter Li b5a8d6b86d PowerAdapter (Linux): simplify 2024-10-12 10:42:13 +08:00
Carter Li 29dd6d88c9 IO: add function ffReadFileDataRelative 2024-10-12 10:41:58 +08:00
Carter Li 49076ec69d Battery (Linux): simplify 2024-10-12 10:41:25 +08:00
李通洲 15fc3bcc92 IO (Windows): add ffAppendFileBufferRelative 2024-10-12 10:13:23 +08:00
Carter Li 1178f46aac Battery (Linux): check if AC is connected 2024-10-12 09:38:19 +08:00
Carter Li 68406cd044 IO (Linux): use openat to simplify code 2024-10-11 16:36:08 +08:00
Carter Li 782474b068 Battery (Linux): revert back not to use uevent
Reading `uevent` is slow...
2024-10-11 16:24:19 +08:00
李通洲 cd9cfa5d99 Memory (SunOS): simplify 2024-10-11 14:48:56 +08:00
李通洲 ded38efb1a Memory (OpenBSD): fix detection of used memory size
Fix #1331
2024-10-11 14:48:11 +08:00
Carter Li e2474d1238 OpenCL: print more detailed error messages 2024-10-11 13:28:10 +08:00
Carter Li ec7c1855b3 Battery (FreeBSD): fix time remaining detection
oops
2024-10-11 00:23:04 +08:00
red-magic 99c0e9e719 run.sh: Improve compatibility with other systems (#1332)
* run.sh: Improve compatibility with other systems

For example $OSTYPE is empty in OpenBSD and the script fallsback to Linux option, with nproc isn't present it fails to build.

* Update run.sh

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2024-10-10 23:38:49 +08:00
李通洲 af09de319b Battery (Android): better status detection 2024-10-10 21:03:27 +08:00
李通洲 ff21dabfb7 Battery (FreeBSD): detect time remaining 2024-10-10 21:01:12 +08:00
Carter Li 27910cf6ec Battery (Linux): calcuate time remaining with current & charge if time_to_empty is unavailable 2024-10-10 08:38:58 +00:00
Carter Li daab70fafc Battery (Linux): rewrite with uevent, add remaining time support 2024-10-10 16:04:27 +08:00
李通洲 4dccb92bb2 Battery: support time remaining detection 2024-10-10 15:57:17 +08:00
李通洲 8c74745076 CI (SunOS): fix build 2024-10-10 10:06:54 +08:00
李通洲 3eb081561d Gamepad: report joystick too 2024-10-10 09:42:56 +08:00
Carter Li 9dcfdcae83 Mouse / Keyboard (FreeBSD): add support 2024-10-10 09:30:20 +08:00
李通洲 4dbc9566da Keyboard: fix CI 2024-10-09 23:22:45 +08:00
李通洲 492010b325 Mouse / Keyboard: try fixing x86 link errors 2024-10-09 23:14:52 +08:00
李通洲 6647d36f85 Mouse / Keyboard (macOS): don't detect vendor name 2024-10-09 21:46:49 +08:00
李通洲 ee29f767a0 Mouse / Keyboard: try harder to get device name 2024-10-09 21:43:33 +08:00
李通洲 aece7cb550 Mouse / Keyboard: add placeholders for unsupported platforms
Fix #1327
2024-10-09 16:41:52 +08:00
李通洲 6f0e6587ac Mouse / Keyboard (Windows): add support 2024-10-09 16:33:47 +08:00
李通洲 bf9963cf85 Gamepad (Windows): fix invalid handle testing 2024-10-09 16:26:00 +08:00
Carter Li a2b32ef564 Mouse / Keyboard: add new modules 2024-10-09 14:36:09 +08:00
李通洲 dbe7aaaa1b CI: use mingw32 for windows-i686 2024-10-08 20:55:55 +08:00
Carter Li d0f52162f3 Logo (Builtin): add MidOS
Fix #1304
2024-10-08 15:31:15 +08:00
Yukari Chiba c624c36754 Logo (Builtin): add eweOS (#1328)
* Logo (Builtin): add eweOS

* Update eweos.txt

* Update builtin.c

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2024-10-08 15:20:51 +08:00
apocelipes 84cc9e3b15 Chore: fix some unused paramater/function warnings (#1324) 2024-10-06 23:01:49 +08:00
Carter Li 8855c0b851 Packaging: update debian stuff [ci skip] 2024-10-06 12:57:17 +08:00
Carter Li 4059bca941 Merge pull request #1323 from fastfetch-cli/dev
Release: v2.27.1
2024-10-06 12:35:51 +08:00
Carter Li bb94ac7832 Release: v2.27.1 2024-10-06 12:31:47 +08:00
Carter Li d5d935a658 DisplayServer (Linux): fix invalid display name detection 2024-10-06 12:27:49 +08:00
Carter Li 44ccc69834 Merge pull request #1320 from fastfetch-cli/dev
Release:v 2.27.0
2024-10-06 11:15:18 +08:00
Carter Li 6bcfc3a61e Doc: update README.md [ci skip] 2024-10-06 10:25:50 +08:00
李通洲 2d356aa644 IO: don't reuse va_list
Fix #1321
2024-10-06 09:29:54 +08:00
李通洲 9ea887e841 TerminalFont: fix possible buffer overflow 2024-10-06 09:27:55 +08:00
Carter Li 5f3ce50022 Display (Linux): prefer detecting physical size from EDID 2024-10-05 23:56:16 +08:00
apocelipes acfab74d4b LocalIP: document show-mtu and show-speed command line options (#1318)
Also add these options to shell completions.
2024-10-05 21:49:29 +08:00
李通洲 24c3f0d6b9 Version (Android): correctly report sysName 2024-10-05 18:47:00 +08:00
李通洲 c2ec1e9606 CMake: fix building on Android 2024-10-05 18:42:47 +08:00
李通洲 951a15b61b LocalIP: only print properties if detected in JSON results 2024-10-05 17:45:45 +08:00
Carter Li f30501f365 Display (macOS): fix invalid physical size on old Intel Mac 2024-10-05 17:22:32 +08:00
李通洲 bde6c3b829 Logo (Builtin): add ValhallaOS
Fix #1316
2024-10-05 15:46:20 +08:00
李通洲 7fac54e7b8 Doc: update changelog 2024-10-05 11:52:59 +08:00
XeroArch d4c8a4c9fd Logo (Builtin): add XeroArch Ascii logo (#1312)
* putting xeroarch logo in askii

* updating logo

* updating

* updating

* uploading xeroarch ascii logo

* upgrading fetch ascii logo

* fixing a very small issue

* removing unecessary line

* removing trailing lines
2024-10-05 11:42:27 +08:00
李通洲 b34283eaf0 Chore: fix a warning of warning 2024-10-05 11:33:57 +08:00
李通洲 67964363e8 Doc: update changelog [ci skip] 2024-10-05 10:41:42 +08:00
李通洲 41a1b3a9d5 CI: test showFlags 2024-10-05 10:33:14 +08:00
Carter Li 320283a538 LocalIP: fix bug that flags are appended multiple times 2024-10-05 10:28:43 +08:00
apocelipes 40ab735e6b LocalIp: support get interface flags (#1315) 2024-10-05 09:49:27 +08:00
Carter Li 716bfe7cc1 Global: use glob(3) if wordexp(3) is not available 2024-10-04 20:00:28 +08:00
李通洲 84fc5b4503 TPM (Windows): corrently report TPM device is not found
Fix #1314
2024-10-04 19:58:55 +08:00
李通洲 729085e054 CI: add OpenBSD 2024-10-04 18:01:02 +08:00
Carter Li a32d9d788c OpenBSD: init platform support 2024-10-04 17:49:18 +08:00
李通洲 d06f9a1509 Chore (Windows): silence some warnings 2024-10-04 17:49:18 +08:00
李通洲 c2b60a2ebf Logo (Builtin): remove some paddings 2024-10-03 21:58:38 +08:00
李通洲 937b2e41ed Terminal (Linux): remove invalid info when fail to detect terminal by process tracing 2024-10-03 21:58:37 +08:00
李通洲 aa734e2220 Doc: fix Json schema [ci skip] 2024-10-03 21:58:37 +08:00
Carter Li a4fe933625 Doc: update changelog for 2.27.0 2024-10-03 21:05:36 +08:00
Carter Li 53a373c9cf Monitor: don't deprecate this module 2024-10-03 20:58:14 +08:00
Carter Li 46c8bc1f99 Board (Linux): trim strings 2024-10-03 20:47:31 +08:00
Andrew Davis 8a11aa0f8f Completions (zsh, fish): check for python3 (#1310)
Both the zsh and fish completions depend on python3.
When the completitions kick in with those shells where no python3 is
found it throws errors.

Check python3 is installed, otherwise return no completitions to avoid
throwing errors

Co-authored-by: Andrew Davis <adavis@adavis.net>
2024-10-02 21:30:19 +08:00
kralverde 89d3924659 CPU (Linux): fix temperature detection (#1308)
Return proper NaN instead of false -> 0.0 coercion
2024-10-02 07:43:58 +08:00
Carter Li b49c509a6c DateTime: add day-pretty
Fix #1305
2024-10-01 17:44:23 +08:00
Carter Li 99626149f6 Display (FreeBSD): add guards between linux specific code 2024-10-01 17:26:29 +08:00
李通洲 3381262930 Monitor: make it an alias of Display module 2024-10-01 12:10:15 +08:00
李通洲 6dd6266a2a GPU (Linux): fix possible buffer overflow 2024-10-01 09:30:39 +08:00
李通洲 18be6c8fd1 Display: don't use non-ascii charactors
Which cannot be displayed in Linux console
2024-09-30 23:42:08 +08:00
李通洲 5bdae7afc3 Display: display ppi in integer 2024-09-30 23:40:47 +08:00
李通洲 316849e5df Monitor: remove module 2024-09-30 23:35:34 +08:00
李通洲 d5c395fb85 Display (Windows): merge features of Monitor module 2024-09-30 23:25:08 +08:00
李通洲 46eb0e4b1c Display (Linux): merge features of Monitor module 2024-09-30 22:43:29 +08:00
李通洲 fb0a18dc82 Display (macOS): merge monitor module features 2024-09-30 20:16:24 +08:00
李通洲 ca442b3da4 Monitor (macOS): improve performance 2024-09-30 19:53:10 +08:00
李通洲 a32361fdc5 Brightness: add new option --brightness-compact 2024-09-30 15:45:06 +08:00
Carter Li d77f0fe3d9 CPU (Linux): detect SOC name if available 2024-09-30 15:09:06 +08:00
Carter Li 1df129083b GPU (Linux): add a special case for brcm 2024-09-30 15:02:49 +08:00
Carter Li 2cd6cb3ca1 Board (Linux): use /proc/device-tree/board if available 2024-09-30 15:00:55 +08:00
李通洲 eeb2d1c746 Doc: update README.md [ci skip] 2024-09-30 10:26:44 +08:00
李通洲 d97999ddc9 GPU (Linux): trim trailing new line
Fix #1303
2024-09-29 23:08:41 +08:00
Carter Li 70e8398f05 Packaging: update debian stuff [ci skip] 2024-09-29 16:22:54 +08:00
Carter Li 0b32abd5a7 Merge pull request #1302 from fastfetch-cli/dev
Release: v2.26.1
2024-09-29 15:50:33 +08:00
李通洲 73e61c2b89 Release: v2.26.1 2024-09-29 15:42:31 +08:00
李通洲 1901b9308f GPU: use adapterLuid as deviceID for non-pci devices 2024-09-29 15:42:31 +08:00
李通洲 a7c7493733 GPU (Windows): fix uninitialized variables 2024-09-29 15:34:57 +08:00
李通洲 73f98f9509 CMake: allow to disable pacstall 2024-09-29 14:18:23 +08:00
Carter Li 3d82d55e5d Packaging: update debian stuff [ci skip] 2024-09-29 13:34:25 +08:00
227 changed files with 3318 additions and 1843 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
check-filenames =
builtin = clear,rare,usage,informal
skip = */.git,*/cmake-build-*,*/.idea,*/completions,*/presets,*/screenshots,*/tests,*/3rdparty,*/logo/ascii
ignore-words-list = iterm,compiletime,unknwn,pengwin,siduction,master,sur,doas,conexant
ignore-words-list = iterm,compiletime,unknwn,pengwin,siduction,master,slave,sur,doas,conexant,ags
+41 -46
View File
@@ -272,47 +272,6 @@ jobs:
name: fastfetch-musl-amd64
path: ./fastfetch-*.*
musl-aarch64:
name: Musl-aarch64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup alpine linux
uses: jirutka/setup-alpine@master
with:
branch: v3.19
arch: aarch64
- name: install dependencies
run: |
cat /etc/alpine-release
uname -a
apk add cmake samurai vulkan-loader-dev libxcb-dev wayland-dev libdrm-dev dconf-dev imagemagick-dev chafa-dev zlib-dev dbus-dev mesa-dev opencl-dev xfconf-dev sqlite-dev networkmanager-dev pulseaudio-dev ddcutil-dev elfutils-dev gcc g++
shell: alpine.sh --root {0}
- name: build
run: |
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DIS_MUSL=ON -GNinja .
cmake --build . --target package --verbose -j4
shell: alpine.sh {0}
- name: run
run: |
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest
shell: alpine.sh {0}
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: fastfetch-musl-aarch64
path: ./fastfetch-*.*
macos-universal:
name: macOS-universal
runs-on: macos-12
@@ -438,6 +397,42 @@ jobs:
name: fastfetch-freebsd-amd64
path: ./fastfetch-*.*
openbsd-amd64:
name: OpenBSD-amd64
runs-on: ubuntu-latest
permissions:
security-events: write
contents: read
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: run VM
uses: cross-platform-actions/action@master
with:
operating_system: openbsd
architecture: x86-64
cpu_count: 4
shell: bash
version: '7.5'
run: |
uname -a
sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: fastfetch-openbsd-amd64
path: ./fastfetch-*.*
windows-amd64:
name: Windows-amd64
runs-on: windows-latest
@@ -519,9 +514,9 @@ jobs:
- name: setup-msys2
uses: msys2/setup-msys2@v2
with:
msystem: CLANG32
msystem: MINGW32
update: true
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 mingw-w64-clang-i686-opencl-headers
install: git p7zip mingw-w64-i686-cmake mingw-w64-i686-clang mingw-w64-i686-vulkan-loader mingw-w64-i686-vulkan-headers mingw-w64-i686-opencl-icd mingw-w64-i686-opencl-headers
- name: print msys version
run: uname -a
@@ -532,7 +527,7 @@ jobs:
languages: c, cpp
- name: configure project
run: env PKG_CONFIG_PATH=/clang32/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
run: env PKG_CONFIG_PATH=/mingw32/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build . --verbose -j4
@@ -541,7 +536,7 @@ jobs:
uses: github/codeql-action/analyze@v3
- name: copy necessary dlls
run: cp /clang32/bin/{OpenCL,vulkan-1}.dll .
run: cp /mingw32/bin/{OpenCL,vulkan-1}.dll .
- name: download amd_ags
run: curl -LO https://github.com/GPUOpen-LibrariesAndSDKs/AGS_SDK/raw/master/ags_lib/lib/amd_ags_x86.dll
@@ -583,9 +578,9 @@ jobs:
- linux-armv7
- linux-riscv64
- musl-amd64
- musl-aarch64
- macos-universal
- freebsd-amd64
- openbsd-amd64
- sunos-amd64
- windows-amd64
- windows-i686
+64
View File
@@ -1,3 +1,67 @@
# 2.28.0
Features:
* Add new module `Mouse` and `Keyboard` which display connected mice and keyboards
* Support remaining time detection (Battery)
* Report if AC is connected (Battery, Linux)
* Report platform API used for display detection for debugging (Display)
* Report Wine version when running in Wine (Kernel, Windows)
* Add option `waitTime` in modules `CPUUsage`, `DiskIO` and `NetIO`
Bugfixes:
* Fix used memory size detection (Memory, OpenBSD)
* Don't report invalid fragmentation percentage when fails to detect it (Zpool)
* Fix unexpected errors when running fastfetch in parallel (#1346, Windows)
* Don't report obviously invalid temperature values (PhysicalDisk, Linux)
Logos:
* Add eweOS
* Add MidOS
* Update XeroArch
# 2.27.1
Bugfixes:
* Fix invalid display name detection on GNOME, wayland (Display, Linux)
# 2.27.0
Changes:
* We now print `"` instead of `″` when displaying diagonal length in inches, so that the character can be correctly displayed in Linux console (Display)
* All detection code of `monitor` module is merged into `display` module. Now `monitor` just prints the same information as `display` with different format. Notably:
* The resolution reported by `monitor` module is now current resolution instead of native / maximum resolution. PPI is calculated based on current resolution too.
* The refresh rate reported by `monitor` module is the current refresh rate.
Features:
* Add basic, highly experimental support of OpenBSD (OpenBSD)
* Improve support for Raspberry pi (CPU / GPU, Linux)
* Detect SOC name, instead of displaying components used in the SOC, if available (CPU, Linux)
* Add option `--brightness-compact` to display multiple brightness values in one line (Brightness)
* Add `day-pretty` (#1305, DateTime)
* Support network interface adapter flag detection (#1315, LocalIP)
* Enable it with `--localip-show-flags`
Bugfixes:
* Remove trailing newline in GPU name for Raspberry pi (#1303, GPU, Linux)
* Fix a possible buffer overflow (GPU, Linux)
* Fix CPU temp incorrectly reported as 0 celsius (#1308, CPU, Linux)
* Correctly report `TPM device is not found` error (#1314, TPM, Windows)
* Fix errors when triggering shell completion with python3 uninstalled (#1310)
* To package managers: as shell completion scripts of fastfetch use python3, it should be added as an optional dependency of fastfetch
* Fix possible crashes when detecting term font of kitty (#1321, TerminalFont, Linux)
Logos:
* Add XeroArch
* Add ValhallaOS
# 2.26.1
Features:
* Allow to disable pacstall packager detection in CMake
Bugfixes:
* Fix uninitialized variables (GPU, Windows)
# 2.26.0
Changes:
+151 -38
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.26.0
VERSION 2.28.0
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
@@ -18,6 +18,8 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(LINUX TRUE CACHE BOOL "..." FORCE) # LINUX means GNU/Linux, not just the kernel
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
set(FreeBSD TRUE CACHE BOOL "..." FORCE)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
set(OpenBSD TRUE CACHE BOOL "..." FORCE)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
set(SunOS TRUE CACHE BOOL "..." FORCE)
elseif(NOT APPLE AND NOT WIN32)
@@ -44,30 +46,30 @@ include(CheckIncludeFile)
include(CMakeDependentOption)
cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR WIN32 OR ANDROID OR SunOS" OFF)
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD" OFF)
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR OpenBSD OR WIN32 OR ANDROID OR SunOS" OFF)
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD OR OpenBSD" OFF)
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_DRM_AMDGPU "Enable libdrm_amdgpu" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR SunOS" OFF)
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR FreeBSD OR APPLE OR WIN32 OR SunOS" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR FreeBSD OR APPLE OR SunOS" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR FreeBSD OR OpenBSD OR APPLE OR WIN32 OR SunOS" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR FreeBSD OR OpenBSD OR APPLE OR SunOS" OFF)
cmake_dependent_option(ENABLE_CHAFA "Enable chafa" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF)
cmake_dependent_option(ENABLE_ZLIB "Enable zlib" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF)
cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR WIN32 OR SunOS" OFF)
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR FreeBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR WIN32 OR ANDROID OR SunOS" OFF)
cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR OpenBSD OR WIN32 OR SunOS" OFF)
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR WIN32 OR ANDROID OR SunOS" OFF)
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR SunOS" OFF)
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR OpenBSD OR SunOS" OFF)
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID" OFF)
@@ -90,7 +92,7 @@ if(NOT BINARY_LINK_TYPE IN_LIST BINARY_LINK_TYPE_OPTIONS)
message(FATAL_ERROR "BINARY_LINK_TYPE must be one of ${BINARY_LINK_TYPE_OPTIONS}")
endif()
set(PACKAGE_MANAGERS AM APK BREW CHOCO DPKG EMERGE EOPKG FLATPAK GUIX LINGLONG LPKG LPKGBUILD MACPORTS NIX OPKG PACMAN PALUDIS PKG PKGTOOL RPM SCOOP SNAP SORCERY WINGET XBPS)
set(PACKAGE_MANAGERS AM APK BREW CHOCO DPKG EMERGE EOPKG FLATPAK GUIX LINGLONG LPKG LPKGBUILD MACPORTS NIX OPKG PACMAN PACSTALL PALUDIS PKG PKGTOOL RPM SCOOP SNAP SORCERY WINGET XBPS)
foreach(package_manager ${PACKAGE_MANAGERS})
if(package_manager STREQUAL "WINGET")
option(PACKAGES_DISABLE_${package_manager} "Disable ${package_manager} package manager detection by default" ON)
@@ -377,6 +379,7 @@ set(LIBFASTFETCH_SRC
src/modules/initsystem/initsystem.c
src/modules/gamepad/gamepad.c
src/modules/kernel/kernel.c
src/modules/keyboard/keyboard.c
src/modules/lm/lm.c
src/modules/loadavg/loadavg.c
src/modules/locale/locale.c
@@ -400,6 +403,7 @@ set(LIBFASTFETCH_SRC
src/modules/sound/sound.c
src/modules/swap/swap.c
src/modules/media/media.c
src/modules/mouse/mouse.c
src/modules/terminal/terminal.c
src/modules/terminaltheme/terminaltheme.c
src/modules/terminalfont/terminalfont.c
@@ -476,6 +480,7 @@ if(LINUX)
src/detection/host/host_linux.c
src/detection/icons/icons_linux.c
src/detection/initsystem/initsystem_linux.c
src/detection/keyboard/keyboard_linux.c
src/detection/libc/libc_linux.c
src/detection/lm/lm_linux.c
src/detection/loadavg/loadavg_linux.c
@@ -484,7 +489,7 @@ if(LINUX)
src/detection/gamepad/gamepad_linux.c
src/detection/media/media_linux.c
src/detection/memory/memory_linux.c
src/detection/monitor/monitor_linux.c
src/detection/mouse/mouse_linux.c
src/detection/netio/netio_linux.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_linux.c
@@ -541,6 +546,7 @@ elseif(ANDROID)
src/detection/host/host_android.c
src/detection/icons/icons_nosupport.c
src/detection/initsystem/initsystem_linux.c
src/detection/keyboard/keyboard_nosupport.c
src/detection/libc/libc_android.c
src/detection/lm/lm_nosupport.c
src/detection/loadavg/loadavg_linux.c
@@ -549,7 +555,7 @@ elseif(ANDROID)
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_nosupport.c
src/detection/memory/memory_linux.c
src/detection/monitor/monitor_nosupport.c
src/detection/mouse/mouse_nosupport.c
src/detection/netio/netio_linux.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_android.c
@@ -622,6 +628,7 @@ elseif(FreeBSD)
src/detection/lm/lm_linux.c
src/detection/icons/icons_linux.c
src/detection/initsystem/initsystem_linux.c
src/detection/keyboard/keyboard_bsd.c
src/detection/libc/libc_bsd.c
src/detection/loadavg/loadavg_bsd.c
src/detection/locale/locale_linux.c
@@ -629,7 +636,7 @@ elseif(FreeBSD)
src/detection/gamepad/gamepad_bsd.c
src/detection/media/media_linux.c
src/detection/memory/memory_bsd.c
src/detection/monitor/monitor_linux.c
src/detection/mouse/mouse_bsd.c
src/detection/netio/netio_bsd.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_linux.c
@@ -656,6 +663,87 @@ elseif(FreeBSD)
src/util/platform/FFPlatform_unix.c
src/util/binary_linux.c
)
elseif(OpenBSD)
list(APPEND LIBFASTFETCH_SRC
src/common/dbus.c
src/common/io/io_unix.c
src/common/netif/netif_bsd.c
src/common/networking_linux.c
src/common/processing_linux.c
src/common/sysctl.c
src/detection/battery/battery_nosupport.c
src/detection/bios/bios_nosupport.c
src/detection/bluetooth/bluetooth_nosupport.c
src/detection/bluetoothradio/bluetoothradio_nosupport.c
src/detection/board/board_nosupport.c
src/detection/bootmgr/bootmgr_nosupport.c
src/detection/brightness/brightness_nosupport.c
src/detection/btrfs/btrfs_nosupport.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_obsd.c
src/detection/cpucache/cpucache_nosupport.c
src/detection/cpuusage/cpuusage_bsd.c
src/detection/cursor/cursor_linux.c
src/detection/disk/disk_bsd.c
src/detection/dns/dns_linux.c
src/detection/physicaldisk/physicaldisk_nosupport.c
src/detection/physicalmemory/physicalmemory_nosupport.c
src/detection/diskio/diskio_nosupport.c
src/detection/displayserver/linux/displayserver_linux.c
src/detection/displayserver/linux/drm.c
src/detection/displayserver/linux/wayland/wayland.c
src/detection/displayserver/linux/wayland/global-output.c
src/detection/displayserver/linux/wayland/zwlr-output.c
src/detection/displayserver/linux/wayland/kde-output.c
src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c
src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c
src/detection/displayserver/linux/wayland/kde-output-order-v1-protocol.c
src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c
src/detection/displayserver/linux/wmde.c
src/detection/displayserver/linux/xcb.c
src/detection/displayserver/linux/xlib.c
src/detection/font/font_linux.c
src/detection/gpu/gpu_nosupport.c
src/detection/gtk_qt/gtk.c
src/detection/host/host_obsd.c
src/detection/lm/lm_nosupport.c
src/detection/icons/icons_linux.c
src/detection/initsystem/initsystem_linux.c
src/detection/keyboard/keyboard_nosupport.c
src/detection/libc/libc_nosupport.c
src/detection/loadavg/loadavg_bsd.c
src/detection/locale/locale_linux.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_linux.c
src/detection/memory/memory_obsd.c
src/detection/mouse/mouse_nosupport.c
src/detection/netio/netio_nosupport.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_obsd.c
src/detection/packages/packages_obsd.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_obsd.c
src/detection/gtk_qt/qt.c
src/detection/sound/sound_linux.c
src/detection/swap/swap_obsd.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/terminalsize/terminalsize_linux.c
src/detection/theme/theme_linux.c
src/detection/tpm/tpm_nosupport.c
src/detection/uptime/uptime_bsd.c
src/detection/users/users_nosupport.c
src/detection/wallpaper/wallpaper_linux.c
src/detection/wifi/wifi_nosupport.c
src/detection/wm/wm_nosupport.c
src/detection/de/de_linux.c
src/detection/wmtheme/wmtheme_linux.c
src/detection/camera/camera_nosupport.c
src/detection/zpool/zpool_nosupport.c
src/util/platform/FFPlatform_unix.c
src/util/binary_linux.c
)
elseif(APPLE)
list(APPEND LIBFASTFETCH_SRC
src/common/io/io_unix.c
@@ -688,6 +776,7 @@ elseif(APPLE)
src/detection/host/host_apple.c
src/detection/icons/icons_nosupport.c
src/detection/initsystem/initsystem_linux.c
src/detection/keyboard/keyboard_apple.c
src/detection/lm/lm_nosupport.c
src/detection/loadavg/loadavg_bsd.c
src/detection/libc/libc_apple.c
@@ -696,7 +785,7 @@ elseif(APPLE)
src/detection/gamepad/gamepad_apple.c
src/detection/media/media_apple.m
src/detection/memory/memory_apple.c
src/detection/monitor/monitor_apple.m
src/detection/mouse/mouse_apple.c
src/detection/netio/netio_bsd.c
src/detection/opengl/opengl_apple.c
src/detection/os/os_apple.m
@@ -755,6 +844,7 @@ elseif(WIN32)
src/detection/host/host_windows.c
src/detection/icons/icons_windows.c
src/detection/initsystem/initsystem_nosupport.c
src/detection/keyboard/keyboard_windows.c
src/detection/libc/libc_windows.cpp
src/detection/lm/lm_nosupport.c
src/detection/loadavg/loadavg_nosupport.c
@@ -763,11 +853,11 @@ elseif(WIN32)
src/detection/gamepad/gamepad_windows.c
src/detection/media/media_windows.c
src/detection/memory/memory_windows.c
src/detection/mouse/mouse_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
src/detection/os/os_windows.cpp
src/detection/os/os_windows.c
src/detection/packages/packages_windows.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_windows.c
@@ -840,6 +930,7 @@ elseif(SunOS)
src/detection/host/host_windows.c
src/detection/icons/icons_linux.c
src/detection/initsystem/initsystem_linux.c
src/detection/keyboard/keyboard_nosupport.c
src/detection/libc/libc_nosupport.c
src/detection/lm/lm_nosupport.c
src/detection/loadavg/loadavg_sunos.c
@@ -848,7 +939,7 @@ elseif(SunOS)
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_linux.c
src/detection/memory/memory_sunos.c
src/detection/monitor/monitor_linux.c
src/detection/mouse/mouse_nosupport.c
src/detection/netio/netio_sunos.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_sunos.c
@@ -951,13 +1042,18 @@ if(FreeBSD AND EXISTS "/usr/local/bin/objdump")
endif()
endif()
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)
if(LINUX)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE _ATFILE_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64) # "$<$<CONFIG:Release>:_FORTIFY_SOURCE=3>"
elseif(ANDROID)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE _FILE_OFFSET_BITS=64 "$<$<CONFIG:DEBUG>:__BIONIC_FORTIFY>" "$<$<CONFIG:DEBUG>:__BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED>")
elseif(WIN32)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE WIN32_LEAN_AND_MEAN=1 _WIN32_WINNT=0x0A00) # "$<$<CONFIG:Release>:_FORTIFY_SOURCE=3>"
elseif(APPLE)
target_compile_definitions(libfastfetch PUBLIC _DARWIN_C_SOURCE)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 _DARWIN_C_SOURCE)
elseif(OpenBSD)
target_compile_definitions(libfastfetch PUBLIC _XOPEN_SOURCE=700 _FILE_OFFSET_BITS=64 _BSD_SOURCE)
elseif(SunOS)
target_compile_definitions(libfastfetch PUBLIC __EXTENSIONS__ _POSIX_C_SOURCE=1)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 __EXTENSIONS__ _POSIX_C_SOURCE)
endif()
if(HAVE_STATX)
@@ -1103,10 +1199,17 @@ ff_lib_enable(EGL
"egl"
"EGL"
)
ff_lib_enable(GLX
"glx"
"GLX"
)
if(NOT OpenBSD)
ff_lib_enable(GLX
"glx"
"GLX"
)
else()
ff_lib_enable(GLX
"gl"
"GL"
)
endif()
ff_lib_enable(OSMESA
"osmesa"
"OSMesa"
@@ -1200,7 +1303,6 @@ elseif(APPLE)
PRIVATE "-weak_framework Apple80211"
)
elseif(WIN32)
target_compile_definitions(libfastfetch PRIVATE -D_WIN32_WINNT=0x0A00)
target_link_libraries(libfastfetch
PRIVATE "dwmapi"
PRIVATE "gdi32"
@@ -1214,6 +1316,8 @@ elseif(WIN32)
PRIVATE "hid"
PRIVATE "wtsapi32"
PRIVATE "imagehlp"
PRIVATE "cfgmgr32"
PRIVATE "winbrand"
)
elseif(FreeBSD)
target_link_libraries(libfastfetch
@@ -1221,6 +1325,11 @@ elseif(FreeBSD)
PRIVATE "usbhid"
PRIVATE "geom"
)
elseif(OpenBSD)
target_link_libraries(libfastfetch
PRIVATE "m"
PRIVATE "kvm"
)
elseif(SunOS)
target_link_libraries(libfastfetch
PRIVATE "m"
@@ -1296,6 +1405,10 @@ if(NOT WIN32)
if(HAVE_WORDEXP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WORDEXP=1)
endif()
CHECK_INCLUDE_FILE("glob.h" HAVE_GLOB)
if(HAVE_GLOB)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_GLOB=1)
endif()
if(ENABLE_THREADS AND CMAKE_USE_PTHREADS_INIT)
CHECK_INCLUDE_FILE("pthread_np.h" HAVE_PTHREAD_NP)
if(HAVE_PTHREAD_NP)
+15 -1
View File
@@ -175,6 +175,10 @@ pyfiglet -s -f small_slant $(fastfetch -s os --format json | jq -r '.[0].result.
![image](https://github.com/fastfetch-cli/fastfetch/assets/6134068/6466524e-ab8c-484f-848d-eec7ddeb7df2)
### Q: My image logo behaves weird. How can I fix it?
See troubleshooting section: <https://github.com/fastfetch-cli/fastfetch/wiki/Logo-options#troubleshooting>
### 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.
@@ -186,9 +190,19 @@ You can always use `fastfetch --pipe false` to force fastfetch running in colorf
See [#1096](https://github.com/fastfetch-cli/fastfetch/issues/1096).
### Q: Fastfetch shows less dpkg packages than neofetch, is it a bug?
Neofetch incorrectly counts `rc` packages ( the package has been removed, but that the configuration files remain ). Bug https://github.com/dylanaraps/neofetch/issues/2278
### Q: I use Debian / Ubuntu / Debian deserved distro. My GPU is detected as `XXXX Device XXXX (VGA compatible)`. Is it a bug?
See [#1282](https://github.com/fastfetch-cli/fastfetch/issues/1282)
Try upgrading `pci.ids`: Download <https://pci-ids.ucw.cz/v2.2/pci.ids> and overwrite file `/usr/share/hwdata/pci.ids`. For AMD GPUs, you should also upgrade `amdgpu.ids`: Download <https://gitlab.freedesktop.org/mesa/drm/-/raw/main/data/amdgpu.ids> and overwrite file `/usr/share/libdrm/amdgpu.ids`
Alternatively, you may try to use `fastfetch --gpu-driver-specific`, so that `fastfetch` will try to ask the driver for GPU name if supported.
### Q: Fastfetch cannot detect my awesome 3rd-party macOS window manager!
Try `fastfetch --wm-detect-plugin`. See also [#984](https://github.com/fastfetch-cli/fastfetch/issues/984)
### Q: I want feature A / B / C. Will fastfetch support it?
+3
View File
@@ -183,7 +183,10 @@ __fastfetch_completion()
"--display-precise-refresh-rate"
"--localip-show-ipv4"
"--localip-show-ipv6"
"--localip-show-flags"
"--localip-show-loop"
"--localip-show-mtu"
"--localip-show-speed"
"--localip-name-prefix"
"--localip-compact-type"
"--escape-bedrock"
+5
View File
@@ -2,6 +2,11 @@ if not type -q fastfetch
exit
end
command -q python3
if test $status -ne 0
exit
end
complete -c fastfetch -f
function __fastfetch_complete_bool
+7
View File
@@ -1,6 +1,13 @@
#compdef fastfetch
function _fastfetch() {
whence python3 &> /dev/null
if [ $? -ne 0 ]
then
return
fi
local state
local -a opts=("${(f)$(
+24
View File
@@ -1,3 +1,27 @@
fastfetch (2.27.1) jammy; urgency=medium
* Update to 2.27.1
-- Carter Li <zhangsongcui@live.cn> Sun, 06 Oct 2024 12:55:18 +0800
fastfetch (2.26.1ubuntu1) jammy; urgency=medium
* Update correct code
-- Carter Li <zhangsongcui@live.cn> Mon, 30 Sep 2024 00:21:20 +0800
fastfetch (2.26.1) jammy; urgency=medium
* Update to 2.26.1
-- Carter Li <zhangsongcui@live.cn> Sun, 29 Sep 2024 16:15:31 +0800
fastfetch (2.26.0) jammy; urgency=medium
* Update to 2.26.0
-- Carter Li <zhangsongcui@live.cn> Sun, 29 Sep 2024 13:31:25 +0800
fastfetch (2.25.0) jammy; urgency=medium
* Update to 2.25.0
+1 -1
View File
@@ -1 +1 @@
fastfetch_2.25.0_source.buildinfo universe/utils optional
fastfetch_2.27.1_source.buildinfo universe/utils optional
+30 -2
View File
@@ -344,7 +344,7 @@
"description": "Set the command to be executed before printing logos",
"default": ""
},
"showVersion": {
"detectVersion": {
"type": "boolean",
"description": "Whether to detect and display component versions. Mainly for benchmarking",
"default": true
@@ -816,7 +816,7 @@
},
{
"const": "monitor",
"description": "Print connected physical monitor information"
"description": "Alias of Display module"
},
{
"const": "opencl",
@@ -1041,6 +1041,11 @@
"maximum": 400,
"default": 10
},
"compact": {
"description": "Set if multiple results should be printed in one line",
"type": "boolean",
"default": false
},
"key": {
"$ref": "#/$defs/key"
},
@@ -1176,6 +1181,12 @@
"description": "Display CPU usage per CPU logical core, instead of an average result",
"default": false
},
"waitTime": {
"type": "integer",
"description": "Wait time (in ms). CPU usage = (inUseEnd - inUseStart) / waitTime",
"default": 200,
"minimum": 1
},
"key": {
"$ref": "#/$defs/key"
},
@@ -1467,6 +1478,12 @@
"type": "boolean",
"default": false
},
"waitTime": {
"type": "integer",
"description": "Wait time (in ms). Disk I/O = (totalBytesEnd - totalBytesStart) / waitTime",
"default": 200,
"minimum": 1
},
"key": {
"$ref": "#/$defs/key"
},
@@ -1698,6 +1715,11 @@
"type": "boolean",
"default": false
},
"showFlags": {
"description": "Show the interface's flags",
"type": "boolean",
"default": false
},
"compact": {
"description": "Show all IPs in one line",
"type": "boolean",
@@ -1831,6 +1853,12 @@
"type": "boolean",
"default": false
},
"waitTime": {
"type": "integer",
"description": "Wait time (in ms). Disk I/O = (totalBytesEnd - totalBytesStart) / waitTime",
"default": 200,
"minimum": 1
},
"key": {
"$ref": "#/$defs/key"
},
+4 -1
View File
@@ -72,7 +72,10 @@
"showIpv6": true,
"showMac": true,
"showSpeed": true,
"showMtu": true
"showMtu": true,
"showLoop": true,
"showFlags": true,
"showAllIps": true
},
"dns",
"wifi",
+4 -1
View File
@@ -74,7 +74,10 @@
"showIpv6": true,
"showMac": true,
"showSpeed": true,
"showMtu": true
"showMtu": true,
"showLoop": true,
"showFlags": true,
"showAllIps": true
},
"dns",
"wifi",
+3 -2
View File
@@ -119,9 +119,10 @@
"keyColor": "blue"
},
{
"type": "monitor",
"type": "display",
"key": "MONITOR ({name})",
"keyColor": "blue"
"keyColor": "blue",
"format": "{width}x{height} @ {refresh-rate} Hz - {physical-width}x{physical-height} mm ({inch} inches, {ppi} ppi)"
},
{
"type": "custom", // DesignInfo
+16 -12
View File
@@ -5,18 +5,22 @@ set -e
mkdir -p build/
cd build/
if [ -z "${CMAKE_BUILD_TYPE}" ]; then
CMAKE_BUILD_TYPE=Release
fi
cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ..
cmake ..
if [ -z "$OSTYPE" ] || [ "$OSTYPE" = "linux-gnu" ]; then
cmake_build_args="-j$(nproc)"
elif [ "$OSTYPE" = "darwin" ]; then
cmake_build_args="-j$(sysctl -n hw.ncpu)"
else
cmake_build_args=""
fi
cmake --build . --target fastfetch ${cmake_build_args}
kernel_name="$(uname -s)"
case "${kernel_name}" in
"Linux" | "MINGW"*)
cmake_build_args="-j$(nproc)"
;;
"Darwin" | *"BSD" | "DragonFly")
cmake_build_args="-j$(sysctl -n hw.ncpu)"
;;
*)
cmake_build_args=""
;;
esac
cmake --build . --target fastfetch "${cmake_build_args}"
./fastfetch "$@"
+1 -1
View File
@@ -43,6 +43,6 @@ typedef struct FFformatarg
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
#define FF_PARSE_FORMAT_STRING_CHECKED(buffer, formatstr, numArgs, arguments) do {\
static_assert(sizeof(arguments) / sizeof(*(arguments)) == (numArgs), "Invalid number of format arguments");\
static_assert(sizeof(arguments) / sizeof(*arguments) == (numArgs), "Invalid number of format arguments");\
ffParseFormatString((buffer), (formatstr), (numArgs), (arguments));\
} while (0)
+1 -1
View File
@@ -245,7 +245,7 @@ void ffListFeatures(void)
#if FF_HAVE_DDCUTIL
"libddcutil\n"
#endif
#if FF_HAVE_ELF || __sun || __FreeBSD__
#if FF_HAVE_ELF || __sun || __FreeBSD__ || __OpenBSD__
"libelf\n"
#endif
#if FF_HAVE_LIBZFS
+30 -10
View File
@@ -13,6 +13,8 @@
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <errno.h>
#include <limits.h>
typedef int FFNativeFD;
#define FF_INVALID_FD (-1)
// procfs's file can be changed between read calls such as /proc/meminfo and /proc/uptime.
@@ -66,9 +68,11 @@ static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data)
}
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data);
ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileName, size_t dataSize, void* data);
bool ffAppendFDBuffer(FFNativeFD fd, FFstrbuf* buffer);
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer);
bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer);
static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer)
{
@@ -76,6 +80,12 @@ static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer)
return ffAppendFileBuffer(fileName, buffer);
}
static inline bool ffReadFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer)
{
ffStrbufClear(buffer);
return ffAppendFileBufferRelative(dfd, fileName, buffer);
}
//Bit flags, combine with |
typedef enum FFPathType
{
@@ -108,17 +118,22 @@ static inline bool ffPathExists(const char* path, FFPathType pathType)
}
else
{
struct stat fileStat;
if(stat(path, &fileStat) != 0)
return false;
size_t len = strlen(path);
assert(len < PATH_MAX);
if (len == 0) return false;
unsigned int mode = fileStat.st_mode & S_IFMT;
if(pathType & FF_PATHTYPE_FILE && mode != S_IFDIR)
return true;
if(pathType & FF_PATHTYPE_DIRECTORY && mode == S_IFDIR)
return true;
int ret;
if (path[len - 1] != '/')
{
char buf[PATH_MAX + 1];
memcpy(buf, path, len);
buf[len] = '/';
buf[len + 1] = 0;
ret = access(buf, F_OK);
}
else
ret = access(path, F_OK);
return pathType == FF_PATHTYPE_DIRECTORY ? ret == 0 : ret == -1 && errno == ENOTDIR;
}
#endif
@@ -211,3 +226,8 @@ static inline bool ffSearchUserConfigFile(const FFlist* configDirs, const char*
return false;
}
#ifdef _WIN32
// Only O_RDONLY is supported
HANDLE openat(HANDLE dfd, const char* fileName, bool directory);
#endif
+49 -4
View File
@@ -14,8 +14,11 @@
#if FF_HAVE_WORDEXP
#include <wordexp.h>
#elif FF_HAVE_GLOB
#warning "<wordexp.h> is not available, use <glob.h> instead"
#include <glob.h>
#else
#warning "<wordexp.h> not available"
#warning "Neither <wordexp.h> nor <glob.h> is available"
#endif
static void createSubfolders(const char* fileName)
@@ -34,7 +37,7 @@ static void createSubfolders(const char* fileName)
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
{
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC;
int openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
mode_t openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
int FF_AUTO_CLOSE_FD fd = open(fileName, openFlagsModes, openFlagsRights);
if(fd == -1)
@@ -105,6 +108,15 @@ ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
return ffReadFDData(fd, dataSize, data);
}
ssize_t ffReadFileDataRelative(int dfd, const char* fileName, size_t dataSize, void* data)
{
int FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
if(fd == -1)
return -1;
return ffReadFDData(fd, dataSize, data);
}
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
{
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY | O_CLOEXEC);
@@ -114,6 +126,15 @@ bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
return ffAppendFDBuffer(fd, buffer);
}
bool ffAppendFileBufferRelative(int dfd, const char* fileName, FFstrbuf* buffer)
{
int FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
if(fd == -1)
return false;
return ffAppendFDBuffer(fd, buffer);
}
bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* out)
{
bool result = false;
@@ -121,7 +142,7 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o
#if FF_HAVE_WORDEXP // https://github.com/termux/termux-packages/pull/7056
wordexp_t exp;
if(wordexp(in, &exp, 0) != 0)
if (wordexp(in, &exp, 0) != 0)
return false;
if (exp.we_wordc == 1)
@@ -132,6 +153,20 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o
wordfree(&exp);
#elif FF_HAVE_GLOB
glob_t gb;
if (glob(in, GLOB_NOSORT | GLOB_TILDE, NULL, &gb) != 0)
return false;
if (gb.gl_matchc == 1)
{
result = true;
ffStrbufSetS(out, gb.gl_pathv[0]);
}
globfree(&gb);
#endif
return result;
@@ -191,14 +226,24 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
ssize_t nRead = read(ftty, buffer + bytesRead, sizeof(buffer) - bytesRead - 1);
if (nRead <= 0)
{
va_end(args);
return "read(STDIN_FILENO, buffer, sizeof(buffer) - 1) failed";
}
bytesRead += (size_t) nRead;
buffer[bytesRead] = '\0';
int ret = vsscanf(buffer, format, args);
va_list cargs;
va_copy(cargs, args);
int ret = vsscanf(buffer, format, cargs);
va_end(cargs);
if (ret <= 0)
{
va_end(args);
return "vsscanf(buffer, format, args) failed";
}
if (ret >= nParams)
break;
}
+56 -1
View File
@@ -3,6 +3,8 @@
#include "util/stringUtils.h"
#include <windows.h>
#include <ntstatus.h>
#include <winternl.h>
static void createSubfolders(const char* fileName)
{
@@ -38,7 +40,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
static inline void readWithLength(HANDLE handle, FFstrbuf* buffer, uint32_t length)
{
ffStrbufEnsureFixedLengthFree(buffer, length);
ffStrbufEnsureFree(buffer, length);
DWORD bytesRead = 0;
while(
length > 0 &&
@@ -100,6 +102,49 @@ bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
return ffAppendFDBuffer(handle, buffer);
}
HANDLE openat(HANDLE dfd, const char* fileName, bool directory)
{
NTSTATUS ret;
UNICODE_STRING fileNameW;
ret = RtlAnsiStringToUnicodeString(&fileNameW, &(ANSI_STRING) {
.Length = (USHORT) strlen(fileName),
.Buffer = (PCHAR) fileName
}, TRUE);
if (!NT_SUCCESS(ret)) return INVALID_HANDLE_VALUE;
FF_AUTO_CLOSE_FD HANDLE hFile;
IO_STATUS_BLOCK iosb = {};
ret = NtOpenFile(&hFile, FILE_READ_DATA | SYNCHRONIZE, &(OBJECT_ATTRIBUTES) {
.Length = sizeof(OBJECT_ATTRIBUTES),
.RootDirectory = dfd,
.ObjectName = &fileNameW,
}, &iosb, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_NONALERT | (directory ? FILE_DIRECTORY_FILE : FILE_NON_DIRECTORY_FILE));
RtlFreeUnicodeString(&fileNameW);
if(!NT_SUCCESS(ret) || iosb.Information != FILE_OPENED)
return INVALID_HANDLE_VALUE;
return hFile;
}
bool ffAppendFileBufferRelative(HANDLE dfd, const char* fileName, FFstrbuf* buffer)
{
HANDLE FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, false);
if(fd == INVALID_HANDLE_VALUE)
return false;
return ffAppendFDBuffer(fd, buffer);
}
ssize_t ffReadFileDataRelative(HANDLE dfd, const char* fileName, size_t dataSize, void* data)
{
HANDLE FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, false);
if(fd == INVALID_HANDLE_VALUE)
return -1;
return ffReadFDData(fd, dataSize, data);
}
bool ffPathExpandEnv(const char* in, FFstrbuf* out)
{
DWORD length = ExpandEnvironmentStringsA(in, NULL, 0);
@@ -266,14 +311,24 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
{
DWORD bytes = 0;
if (!ReadFile(hInput, buffer, sizeof(buffer) - 1, &bytes, NULL) || bytes == 0)
{
va_end(args);
return "ReadFile() failed";
}
bytesRead += bytes;
buffer[bytesRead] = '\0';
va_list cargs;
va_copy(cargs, args);
int ret = vsscanf(buffer, format, args);
va_end(cargs);
if (ret <= 0)
{
va_end(args);
return "vsscanf(buffer, format, args) failed";
}
if (ret >= nParams)
break;
}
+2
View File
@@ -73,6 +73,7 @@ static FFModuleBaseInfo* J[] = {
static FFModuleBaseInfo* K[] = {
(void*) &instance.config.modules.kernel,
(void*) &instance.config.modules.keyboard,
NULL,
};
@@ -88,6 +89,7 @@ static FFModuleBaseInfo* M[] = {
(void*) &instance.config.modules.media,
(void*) &instance.config.modules.memory,
(void*) &instance.config.modules.monitor,
(void*) &instance.config.modules.mouse,
NULL,
};
+2 -4
View File
@@ -13,11 +13,9 @@ bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex)
if (!netRoute) return false;
// skip first line
flockfile(netRoute);
while (getc_unlocked(netRoute) != '\n');
funlockfile(netRoute);
unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu,
FF_UNUSED(fscanf(netRoute, "%*[^\n]\n"));
unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu,
while (fscanf(netRoute, "%" FF_STR(IF_NAMESIZE) "s%llx%*[^\n]", iface, &destination) == 2)
{
if (destination != 0) continue;
+42
View File
@@ -190,6 +190,48 @@ void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, co
}
}
void ffParseDuration(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds, FFstrbuf* result)
{
if(days == 0 && hours == 0 && minutes == 0)
{
ffStrbufAppendF(result, "%u seconds", seconds);
return;
}
if(days > 0)
{
ffStrbufAppendF(result, "%u day", days);
if(days > 1)
ffStrbufAppendC(result, 's');
if(days >= 100)
ffStrbufAppendS(result, "(!)");
if(hours > 0 || minutes > 0)
ffStrbufAppendS(result, ", ");
}
if(hours > 0)
{
ffStrbufAppendF(result, "%u hour", hours);
if(hours > 1)
ffStrbufAppendC(result, 's');
if(minutes > 0)
ffStrbufAppendS(result, ", ");
}
if(minutes > 0)
{
ffStrbufAppendF(result, "%u min", minutes);
if(minutes > 1)
ffStrbufAppendC(result, 's');
}
}
#ifdef _WIN32
#pragma GCC diagnostic pop
#endif
+1
View File
@@ -27,3 +27,4 @@ int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2);
void ffParseSize(uint64_t bytes, FFstrbuf* result);
bool ffParseFrequency(uint32_t mhz, FFstrbuf* result);
void ffParseDuration(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds, FFstrbuf* result);
+2 -2
View File
@@ -14,7 +14,7 @@ typedef enum FFPrintType {
void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType);
void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments);
#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, numArgs, arguments) do {\
static_assert(sizeof(arguments) / sizeof(*(arguments)) == (numArgs), "Invalid number of format arguments");\
static_assert(sizeof(arguments) / sizeof(*arguments) == (numArgs), "Invalid number of format arguments");\
ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (numArgs), (arguments));\
} while (0)
FF_C_PRINTF(5, 6) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
@@ -23,6 +23,6 @@ void ffPrintCharTimes(char c, uint32_t times);
void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[]);
#define FF_PRINT_MODULE_FORMAT_HELP_CHECKED(moduleName, def, numArgs, args) do {\
static_assert(sizeof(args) / sizeof(*(args)) == (numArgs), "Invalid number of format arguments");\
static_assert(sizeof(args) / sizeof(*args) == (numArgs), "Invalid number of format arguments");\
ffPrintModuleFormatHelp((moduleName), (def), (numArgs), (args));\
} while (0)
+46 -11
View File
@@ -22,6 +22,10 @@
#include <libproc.h>
#elif defined(__sun)
#include <procfs.h>
#elif defined(__OpenBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#include <kvm.h>
#endif
enum { FF_PIPE_BUFSIZ = 8192 };
@@ -135,12 +139,13 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
if (exePath)
{
snprintf(filePath, sizeof(filePath), "/proc/%d/exe", (int)pid);
ffStrbufEnsureFixedLengthFree(exePath, PATH_MAX);
ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1);
char buf[PATH_MAX];
ssize_t length = readlink(filePath, buf, PATH_MAX - 1);
if (length > 0) // doesn't contain trailing NUL
{
exePath->chars[length] = '\0';
exePath->length = (uint32_t) length;
buf[length] = '\0';
ffStrbufEnsureFixedLengthFree(exePath, (uint32_t)length + 1); // +1 for the NUL
ffStrbufAppendNS(exePath, (uint32_t)length, buf);
}
}
@@ -148,14 +153,14 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
size_t len = 0;
int mibs[] = { CTL_KERN, KERN_PROCARGS2, pid };
if (sysctl(mibs, sizeof(mibs) / sizeof(*mibs), NULL, &len, NULL, 0) == 0)
if (sysctl(mibs, ARRAY_SIZE(mibs), NULL, &len, NULL, 0) == 0)
{// try get arg0
#ifndef MAC_OS_X_VERSION_10_15
//don't know why if don't let len longer, proArgs2 and len will change during the following sysctl() in old MacOS version.
len++;
#endif
FF_AUTO_FREE char* const procArgs2 = malloc(len);
if (sysctl(mibs, sizeof(mibs) / sizeof(*mibs), procArgs2, &len, NULL, 0) == 0)
if (sysctl(mibs, ARRAY_SIZE(mibs), procArgs2, &len, NULL, 0) == 0)
{
// https://gist.github.com/nonowarn/770696#file-getargv-c-L46
uint32_t argc = *(uint32_t*) procArgs2;
@@ -238,7 +243,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
#elif defined(__sun)
char filePath[PATH_MAX];
char filePath[128];
snprintf(filePath, sizeof(filePath), "/proc/%d/psinfo", (int) pid);
psinfo_t proc;
if (ffReadFileData(filePath, sizeof(proc), &proc) == sizeof(proc))
@@ -250,15 +255,28 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
if (exePath)
{
snprintf(filePath, sizeof(filePath), "/proc/%d/path/a.out", (int) pid);
ffStrbufEnsureFixedLengthFree(exePath, PATH_MAX);
ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1);
char buf[PATH_MAX];
ssize_t length = readlink(filePath, buf, PATH_MAX - 1);
if (length > 0) // doesn't contain trailing NUL
{
exePath->chars[length] = '\0';
exePath->length = (uint32_t) length;
buf[length] = '\0';
ffStrbufEnsureFixedLengthFree(exePath, (uint32_t)length + 1); // +1 for the NUL
ffStrbufAppendNS(exePath, (uint32_t)length, buf);
}
}
#elif defined(__OpenBSD__)
kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL);
int count = 0;
const struct kinfo_proc* proc = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count);
if (proc)
{
char** argv = kvm_getargv(kd, proc, 0);
if (argv) ffStrbufSetS(exe, argv[0]);
}
kvm_close(kd);
#endif
if(exe->length == 0)
@@ -373,6 +391,23 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
if (tty)
*tty = (int) proc.pr_ttydev;
#elif defined(__OpenBSD__)
kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL);
int count = 0;
const struct kinfo_proc* proc = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count);
if (proc)
{
ffStrbufSetS(name, proc->p_comm);
if (ppid)
*ppid = proc->p_ppid;
if (tty)
*tty = (int) proc->p_tdev;
}
kvm_close(kd);
if (!proc)
return "kvm_getprocs() failed";
#else
return "Unsupported platform";
+7 -4
View File
@@ -49,8 +49,11 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
{
int timeout = instance.config.general.processingTimeout;
wchar_t pipeName[32];
swprintf(pipeName, ARRAY_SIZE(pipeName), L"\\\\.\\pipe\\FASTFETCH-%u", GetCurrentProcessId());
FF_AUTO_CLOSE_FD HANDLE hChildPipeRead = CreateNamedPipeW(
L"\\\\.\\pipe\\LOCAL\\",
pipeName,
PIPE_ACCESS_INBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE | (timeout < 0 ? 0 : FILE_FLAG_OVERLAPPED),
0,
1,
@@ -60,10 +63,10 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
NULL
);
if (hChildPipeRead == INVALID_HANDLE_VALUE)
return "CreateNamedPipeW(L\"\\\\.\\pipe\\LOCAL\\\") failed";
return "CreateNamedPipeW(L\"\\\\.\\pipe\\FASTFETCH-$(PID)\") failed";
HANDLE hChildPipeWrite = CreateFileW(
L"\\\\.\\pipe\\LOCAL\\",
pipeName,
GENERIC_WRITE,
0,
&(SECURITY_ATTRIBUTES){
@@ -76,7 +79,7 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
NULL
);
if (hChildPipeWrite == INVALID_HANDLE_VALUE)
return "CreateFileW(L\"\\\\.\\pipe\\LOCAL\\\") failed";
return "CreateFileW(L\"\\\\.\\pipe\\FASTFETCH-$(PID)\") failed";
PROCESS_INFORMATION piProcInfo = {0};
+1 -1
View File
@@ -100,7 +100,7 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
bool valueStorage[32];
bool* unsetValues = valueStorage;
if (numQueries > sizeof(valueStorage) / sizeof(valueStorage[0]))
if (numQueries > ARRAY_SIZE(valueStorage))
unsetValues = malloc(sizeof(bool) * numQueries);
bool allSet = true;
+36
View File
@@ -2,6 +2,41 @@
#include <stdlib.h>
#ifdef __OpenBSD__
const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result)
{
size_t neededLength;
if (sysctl((int[]) {mib1, mib2}, 2, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) //neededLength is 1 for empty strings, because of the null terminator
return "sysctlbyname() failed";
ffStrbufEnsureFree(result, (uint32_t) neededLength - 1);
if (sysctl((int[]) {mib1, mib2}, 2, result->chars + result->length, &neededLength, NULL, 0) == 0)
result->length += (uint32_t) neededLength - 1;
result->chars[result->length] = '\0';
return NULL;
}
int ffSysctlGetInt(int mib1, int mib2, int defaultValue)
{
int result;
size_t neededLength = sizeof(result);
if (sysctl((int[]) {mib1, mib2}, 2, &result, &neededLength, NULL, 0) != 0)
return defaultValue;
return result;
}
int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue)
{
int64_t result;
size_t neededLength = sizeof(result);
if(sysctl((int[]) {mib1, mib2}, 2, &result, &neededLength, NULL, 0) != 0)
return defaultValue;
return result;
}
#else
const char* ffSysctlGetString(const char* propName, FFstrbuf* result)
{
size_t neededLength;
@@ -35,6 +70,7 @@ int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue)
return defaultValue;
return result;
}
#endif // OpenBSD
void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength)
{
+6
View File
@@ -6,7 +6,13 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#ifdef __OpenBSD__
const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result);
FF_C_NODISCARD int ffSysctlGetInt(int mib1, int mib2, int defaultValue);
FF_C_NODISCARD int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue);
#else
const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
#endif
FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
+59
View File
@@ -916,6 +916,14 @@
"type": "str"
}
},
{
"long": "diskio-wait-time",
"desc": "Set the wait time (in ms) when detecting disk usage",
"arg": {
"type": "num",
"default": 1000
}
},
{
"long": "physicaldisk-name-prefix",
"desc": "Show disks with given name prefix only",
@@ -1000,6 +1008,14 @@
"default": 10
}
},
{
"long": "brightness-compact",
"desc": "Set if multiple results should be printed in one line",
"arg": {
"type": "bool",
"default": false
}
},
{
"long": "sound-type",
"desc": "Set what type of sound devices should be printed",
@@ -1062,6 +1078,14 @@
"default": false
}
},
{
"long": "cpuusage-wait-time",
"desc": "Set the wait time (in ms) when detecting CPU usage",
"arg": {
"type": "num",
"default": 200
}
},
{
"long": "de-slow-version-detection",
"desc": "Set if DE version should be detected with slow operations",
@@ -1188,6 +1212,24 @@
"default": false
}
},
{
"long": "localip-show-mtu",
"desc": "Show net interface's MTU (Maximum Transmission Unit) size in bytes",
"arg": {
"type": "bool",
"optional": true,
"default": false
}
},
{
"long": "localip-show-speed",
"desc": "Show net interface's link speed with human-readable format (or an 1Mb units integer in JSON format)",
"arg": {
"type": "bool",
"optional": true,
"default": false
}
},
{
"long": "localip-show-prefix-len",
"desc": "Show network prefix length (/N) in local ip module",
@@ -1223,6 +1265,15 @@
"default": false
}
},
{
"long": "localip-show-flags",
"desc": "Show net interface flags in local ip module",
"arg": {
"type": "bool",
"optional": true,
"default": false
}
},
{
"long": "localip-compact",
"desc": "Show all IPs in one line",
@@ -1270,6 +1321,14 @@
"default": false
}
},
{
"long": "netio-wait-time",
"desc": "Set the wait time (in ms) when detecting network usage",
"arg": {
"type": "num",
"default": 1000
}
},
{
"long": "publicip-timeout",
"desc": "Time in milliseconds to wait for the public ip server to respond",
+1
View File
@@ -15,6 +15,7 @@ typedef struct FFBatteryResult
double capacity;
double temperature;
uint32_t cycleCount;
int32_t timeRemaining;
} FFBatteryResult;
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results);
+24 -2
View File
@@ -1,6 +1,6 @@
#include "fastfetch.h"
#include "battery.h"
#include "util/stringUtils.h"
#include "common/processing.h"
#include "common/properties.h"
@@ -36,6 +36,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results)
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
battery->cycleCount = 0;
battery->timeRemaining = -1;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
@@ -44,7 +45,27 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results)
ffStrbufInit(&battery->manufactureDate);
battery->capacity = yyjson_get_num(yyjson_obj_get(root, "percentage"));
ffStrbufAppendS(&battery->status, yyjson_get_str(yyjson_obj_get(root, "status")));
const char* acStatus = yyjson_get_str(yyjson_obj_get(root, "plugged"));
if (acStatus)
{
if (ffStrEquals(acStatus, "PLUGGED_AC"))
ffStrbufAppendS(&battery->status, "AC Connected, ");
else if (ffStrEquals(acStatus, "PLUGGED_USB"))
ffStrbufAppendS(&battery->status, "USB Connected, ");
else if (ffStrEquals(acStatus, "PLUGGED_WIRELESS"))
ffStrbufAppendS(&battery->status, "Wireless Connected, ");
}
const char* status = yyjson_get_str(yyjson_obj_get(root, "status"));
if (status)
{
if (ffStrEquals(status, "CHARGING"))
ffStrbufAppendS(&battery->status, "Charging");
else if (ffStrEquals(status, "DISCHARGING"))
ffStrbufAppendS(&battery->status, "Discharging");
}
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
if(options->temp)
battery->temperature = yyjson_get_num(yyjson_obj_get(root, "temperature"));
@@ -74,6 +95,7 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results)
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
battery->cycleCount = 0;
battery->timeRemaining = -1;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
+17 -6
View File
@@ -57,13 +57,24 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
ffCfDictGetInt(properties, CFSTR(kIOPMPSCycleCountKey), &cycleCount);
battery->cycleCount = cycleCount < 0 ? 0 : (uint32_t) cycleCount;
if (!ffCfDictGetBool(properties, CFSTR(kIOPMPSExternalConnectedKey), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "AC connected, ");
else
ffStrbufAppendS(&battery->status, "Discharging, ");
if (!ffCfDictGetBool(properties, CFSTR(kIOPMPSIsChargingKey), &boolValue) && boolValue)
battery->timeRemaining = -1;
if (ffCfDictGetBool(properties, CFSTR(kIOPMPSExternalConnectedKey), &boolValue) == NULL)
{
if (boolValue)
ffStrbufAppendS(&battery->status, "AC connected, ");
else
{
ffStrbufAppendS(&battery->status, "Discharging, ");
ffCfDictGetInt(properties, CFSTR("AvgTimeToEmpty"), &battery->timeRemaining); // in minutes
if (battery->timeRemaining < 0 || battery->timeRemaining >= 0xFFFF)
battery->timeRemaining = -1;
else
battery->timeRemaining *= 60;
}
}
if (ffCfDictGetBool(properties, CFSTR(kIOPMPSIsChargingKey), &boolValue) == NULL && boolValue)
ffStrbufAppendS(&battery->status, "Charging, ");
if (!ffCfDictGetBool(properties, CFSTR(kIOPMPSAtCriticalLevelKey), &boolValue) && boolValue)
if (ffCfDictGetBool(properties, CFSTR(kIOPMPSAtCriticalLevelKey), &boolValue) == NULL && boolValue)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
+4 -1
View File
@@ -41,7 +41,9 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->serial);
ffStrbufInit(&battery->manufactureDate);
battery->timeRemaining = -1;
if (battio.battinfo.min > 0)
battery->timeRemaining = battio.battinfo.min * 60;
battery->capacity = battio.battinfo.cap;
if(battio.battinfo.state == ACPI_BATT_STAT_INVALID)
{
@@ -74,6 +76,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r
ffStrbufAppendS(&battery->manufacturer, battio.bix.oeminfo);
ffStrbufAppendS(&battery->modelName, battio.bix.model);
ffStrbufAppendS(&battery->technology, battio.bix.type);
battery->cycleCount = battio.bix.cycles;
}
}
return NULL;
+76 -71
View File
@@ -3,39 +3,45 @@
#include "util/stringUtils.h"
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
// https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-power
static void parseBattery(FFstrbuf* dir, const char* id, FFBatteryOptions* options, FFlist* results)
static bool checkAc(const char* id, FFstrbuf* tmpBuffer)
{
uint32_t dirLength = dir->length;
if (ffStrStartsWith(id, "BAT"))
ffStrbufSetS(tmpBuffer, "/sys/class/power_supply/ADP1/online");
else if (ffStrStartsWith(id, "macsmc-battery"))
ffStrbufSetS(tmpBuffer, "/sys/class/power_supply/macsmc-ac/online");
else
ffStrbufClear(tmpBuffer);
char online = '\0';
return ffReadFileData(tmpBuffer->chars, 1, &online) == 1 && online == '1';
}
static void parseBattery(int dfd, const char* id, FFBatteryOptions* options, FFlist* results)
{
FF_STRBUF_AUTO_DESTROY tmpBuffer = ffStrbufCreate();
//type must exist and be "Battery"
ffStrbufAppendS(dir, "/type");
if (ffReadFileBuffer(dir->chars, &tmpBuffer))
ffStrbufTrimRightSpace(&tmpBuffer);
ffStrbufSubstrBefore(dir, dirLength);
// type must exist and be "Battery"
if (!ffReadFileBufferRelative(dfd, "type", &tmpBuffer))
return;
ffStrbufTrimRightSpace(&tmpBuffer);
if(!ffStrbufIgnCaseEqualS(&tmpBuffer, "Battery"))
return;
//scope may not exist or must not be "Device"
ffStrbufAppendS(dir, "/scope");
if (ffReadFileBuffer(dir->chars, &tmpBuffer))
// scope may not exist or must not be "Device"
if (ffReadFileBufferRelative(dfd, "scope", &tmpBuffer))
ffStrbufTrimRightSpace(&tmpBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(ffStrbufIgnCaseEqualS(&tmpBuffer, "Device"))
return;
//capacity must exist and be not empty
ffStrbufAppendS(dir, "/capacity");
bool available = ffReadFileBuffer(dir->chars, &tmpBuffer); // This is expensive in my laptop
ffStrbufSubstrBefore(dir, dirLength);
if (!available)
// capacity must exist and be not empty
// This is expensive in my laptop
if (!ffReadFileBufferRelative(dfd, "capacity", &tmpBuffer))
return;
FFBatteryResult* result = ffListAdd(results);
@@ -44,39 +50,63 @@ static void parseBattery(FFstrbuf* dir, const char* id, FFBatteryOptions* option
//At this point, we have a battery. Try to get as much values as possible.
ffStrbufInit(&result->manufacturer);
ffStrbufAppendS(dir, "/manufacturer");
if (ffReadFileBuffer(dir->chars, &result->manufacturer))
if (ffReadFileBufferRelative(dfd, "manufacturer", &result->manufacturer))
ffStrbufTrimRightSpace(&result->manufacturer);
else if (ffStrEquals(id, "macsmc-battery")) // asahi
ffStrbufSetStatic(&result->manufacturer, "Apple Inc.");
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->modelName);
ffStrbufAppendS(dir, "/model_name");
if (ffReadFileBuffer(dir->chars, &result->modelName))
if (ffReadFileBufferRelative(dfd, "model_name", &result->modelName))
ffStrbufTrimRightSpace(&result->modelName);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->technology);
ffStrbufAppendS(dir, "/technology");
if (ffReadFileBuffer(dir->chars, &result->technology))
if (ffReadFileBufferRelative(dfd, "technology", &result->technology))
ffStrbufTrimRightSpace(&result->technology);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->status);
ffStrbufAppendS(dir, "/status");
if (ffReadFileBuffer(dir->chars, &result->status))
if (ffReadFileBufferRelative(dfd, "status", &result->status))
ffStrbufTrimRightSpace(&result->status);
ffStrbufSubstrBefore(dir, dirLength);
// Unknown, Charging, Discharging, Not charging, Full
if (ffStrbufEqualS(&result->status, "Not charging") || ffStrbufEqualS(&result->status, "Full"))
ffStrbufSetStatic(&result->status, "AC Connected");
else if (ffStrbufEqualS(&result->status, "Unknown"))
ffStrbufClear(&result->status);
ffStrbufAppendS(dir, "/capacity_level");
if (ffReadFileBuffer(dir->chars, &tmpBuffer))
result->timeRemaining = -1;
if (ffStrbufEqualS(&result->status, "Discharging"))
{
if (ffReadFileBufferRelative(dfd, "time_to_empty_now", &tmpBuffer))
result->timeRemaining = (int32_t) ffStrbufToSInt(&tmpBuffer, 0);
else
{
if (ffReadFileBufferRelative(dfd, "charge_now", &tmpBuffer))
{
int64_t chargeNow = ffStrbufToSInt(&tmpBuffer, 0);
if (chargeNow > 0)
{
if (ffReadFileBufferRelative(dfd, "current_now", &tmpBuffer))
{
int64_t currentNow = ffStrbufToSInt(&tmpBuffer, INT64_MIN);
if (currentNow < 0) currentNow = -currentNow;
if (currentNow > 0)
result->timeRemaining = (int32_t) ((chargeNow * 3600) / currentNow);
}
}
}
}
if (checkAc(id, &tmpBuffer))
ffStrbufAppendS(&result->status, ", AC Connected");
}
else if (ffStrbufEqualS(&result->status, "Not charging") || ffStrbufEqualS(&result->status, "Full"))
ffStrbufSetStatic(&result->status, "AC Connected");
else if (ffStrbufEqualS(&result->status, "Charging"))
ffStrbufAppendS(&result->status, ", AC Connected");
else if (ffStrbufEqualS(&result->status, "Unknown"))
{
ffStrbufClear(&result->status);
if (checkAc(id, &tmpBuffer))
ffStrbufAppendS(&result->status, "AC Connected");
}
if (ffReadFileBufferRelative(dfd, "capacity_level", &tmpBuffer))
{
ffStrbufTrimRightSpace(&result->manufacturer);
if (ffStrbufEqualS(&tmpBuffer, "Critical"))
@@ -87,50 +117,33 @@ static void parseBattery(FFstrbuf* dir, const char* id, FFBatteryOptions* option
ffStrbufSetStatic(&result->status, "Critical");
}
}
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->serial);
ffStrbufAppendS(dir, "/serial_number");
if (ffReadFileBuffer(dir->chars, &result->serial))
if (ffReadFileBufferRelative(dfd, "serial_number", &result->serial))
ffStrbufTrimRightSpace(&result->serial);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufAppendS(dir, "/cycle_count");
available = ffReadFileBuffer(dir->chars, &tmpBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if (available)
if (ffReadFileBufferRelative(dfd, "cycle_count", &tmpBuffer))
{
int64_t cycleCount = ffStrbufToSInt(&tmpBuffer, 0);
result->cycleCount = cycleCount < 0 || cycleCount > UINT32_MAX ? 0 : (uint32_t) cycleCount;
}
ffStrbufInit(&result->manufactureDate);
ffStrbufAppendS(dir, "/manufacture_year");
available = ffReadFileBuffer(dir->chars, &tmpBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if (available)
if (ffReadFileBufferRelative(dfd, "manufacture_year", &tmpBuffer))
{
int year = (int) ffStrbufToSInt(&tmpBuffer, 0);
if (year > 0)
{
ffStrbufAppendS(dir, "/manufacture_month");
available = ffReadFileBuffer(dir->chars, &tmpBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if (available)
if (ffReadFileBufferRelative(dfd, "manufacture_month", &tmpBuffer))
{
int month = (int) ffStrbufToSInt(&tmpBuffer, 0);
if (month > 0)
{
ffStrbufAppendS(dir, "/manufacture_day");
available = ffReadFileBuffer(dir->chars, &tmpBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if (available)
if (ffReadFileBufferRelative(dfd, "manufacture_day", &tmpBuffer))
{
int day = (int) ffStrbufToSInt(&tmpBuffer, 0);
if (day > 0)
{
ffStrbufSetF(&result->manufactureDate, "%.4d-%.2d-%.2d", year, month, day);
}
}
}
}
@@ -140,33 +153,25 @@ static void parseBattery(FFstrbuf* dir, const char* id, FFBatteryOptions* option
result->temperature = FF_BATTERY_TEMP_UNSET;
if (options->temp)
{
ffStrbufAppendS(dir, "/temp");
if (ffReadFileBuffer(dir->chars, &tmpBuffer))
if (ffReadFileBufferRelative(dfd, "temp", &tmpBuffer))
result->temperature = ffStrbufToDouble(&tmpBuffer) / 10;
ffStrbufSubstrBefore(dir, dirLength);
}
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
{
FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64);
ffStrbufAppendS(&baseDir, "/sys/class/power_supply/");
uint32_t baseDirLength = baseDir.length;
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir.chars);
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/class/power_supply/");
if(dirp == NULL)
return "opendir(\"/sys/class/power_supply/\") == NULL";
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, ".."))
if(entry->d_name[0] == '.')
continue;
ffStrbufAppendS(&baseDir, entry->d_name);
parseBattery(&baseDir, entry->d_name, options, results);
ffStrbufSubstrBefore(&baseDir, baseDirLength);
FF_AUTO_CLOSE_FD int dfd = openat(dirfd(dirp), entry->d_name, O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY);
if (dfd > 0) parseBattery(dfd, entry->d_name, options, results);
}
return NULL;
+9
View File
@@ -121,6 +121,13 @@ static const char* detectWithSetupApi(FFBatteryOptions* options, FFlist* results
battery->temperature = temp / 10.0 - 273.15;
}
{
bqi.InformationLevel = BatteryEstimatedTime;
ULONG time;
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &time, sizeof(time), &dwOut, NULL))
battery->timeRemaining = time == BATTERY_UNKNOWN_TIME ? -1 : (int32_t) time;
}
{
BATTERY_STATUS bs;
BATTERY_WAIT_STATUS bws = { .BatteryTag = bqi.BatteryTag };
@@ -241,6 +248,7 @@ static const char* detectWithNtApi(FF_MAYBE_UNUSED FFBatteryOptions* options, FF
ffStrbufInit(&battery->serial);
battery->temperature = FF_BATTERY_TEMP_UNSET;
battery->cycleCount = 0;
battery->timeRemaining = info.EstimatedTime == BATTERY_UNKNOWN_TIME ? -1 : (int32_t) info.EstimatedTime;
battery->capacity = info.RemainingCapacity * 100.0 / info.MaxCapacity;
if(info.AcOnLine)
@@ -252,6 +260,7 @@ static const char* detectWithNtApi(FF_MAYBE_UNUSED FFBatteryOptions* options, FF
else if(info.Discharging)
ffStrbufAppendS(&battery->status, "Discharging");
detectBySmbios(battery);
return NULL;
+1 -1
View File
@@ -25,7 +25,7 @@ const char* ffDetectBios(FFBiosResult* result)
{
ffStrbufSetStatic(&result->type,
ffPathExists("/dev/efi" /*efidev*/, FF_PATHTYPE_FILE) ||
ffPathExists("/boot/efi/efi" /*efi partition*/, FF_PATHTYPE_DIRECTORY)
ffPathExists("/boot/efi/efi/" /*efi partition*/, FF_PATHTYPE_DIRECTORY)
? "UEFI" : "BIOS");
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ const char *ffDetectBios(FFBiosResult *bios)
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->release);
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->vendor);
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->version);
if (ffPathExists("/sys/firmware/efi", FF_PATHTYPE_DIRECTORY) || ffPathExists("/sys/firmware/acpi/tables/UEFI", FF_PATHTYPE_FILE))
if (ffPathExists("/sys/firmware/efi/", FF_PATHTYPE_DIRECTORY) || ffPathExists("/sys/firmware/acpi/tables/UEFI", FF_PATHTYPE_FILE))
ffStrbufSetStatic(&bios->type, "UEFI");
else
ffStrbufSetStatic(&bios->type, "BIOS");
+1 -1
View File
@@ -1,6 +1,6 @@
#include "bios.h"
const char* ffDetectBios(FFBiosResult* bios)
const char* ffDetectBios(FF_MAYBE_UNUSED FFBiosResult* bios)
{
return "Not supported on this platform";
}
@@ -202,6 +202,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
#ifdef FF_HAVE_DBUS
return detectBluetooth(devices);
#else
FF_UNUSED(devices)
return "Fastfetch was compiled without DBus support";
#endif
}
+5 -1
View File
@@ -12,13 +12,17 @@ const char* ffDetectBoard(FFBoardResult* board)
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->vendor);
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->version);
}
else if (ffReadFileBuffer("/proc/device-tree/board", &board->name))
{
ffStrbufTrimRightSpace(&board->name);
}
else if (ffReadFileBuffer("/proc/device-tree/compatible", &board->vendor))
{
// use model name as board name
uint32_t comma = ffStrbufFirstIndexC(&board->vendor, ',');
if (comma < board->vendor.length)
{
ffStrbufSetS(&board->name, board->vendor.chars + comma + 1);
ffStrbufTrimRightSpace(&board->name);
ffStrbufSubstrBefore(&board->vendor, comma);
}
}
+2 -2
View File
@@ -38,9 +38,9 @@ const char* ffDetectBootmgr(FFBootmgrResult* result)
uint8_t buffer[2048];
wchar_t key[16];
swprintf(key, sizeof(key) / sizeof(*key), L"Boot%04X", value);
swprintf(key, ARRAY_SIZE(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))
if (size < sizeof(FFEfiLoadOption) || size == ARRAY_SIZE(buffer))
return "GetFirmwareEnvironmentVariableW(Boot####) failed";
ffEfiFillLoadOption((FFEfiLoadOption *)buffer, result);
+5 -5
View File
@@ -92,13 +92,13 @@ static const char* detectWithDdcci(FF_MAYBE_UNUSED const FFDisplayServerResult*
for (uint32_t i = 0; i < 2; ++i)
{
IOAVServiceWriteI2C(service, 0x37, 0x51, i2cIn, sizeof(i2cIn));
IOAVServiceWriteI2C(service, 0x37, 0x51, i2cIn, ARRAY_SIZE(i2cIn));
usleep(options->ddcciSleep * 1000);
}
}
uint8_t i2cOut[12] = {};
if (IOAVServiceReadI2C(service, 0x37, 0x51, i2cOut, sizeof(i2cOut)) == KERN_SUCCESS)
if (IOAVServiceReadI2C(service, 0x37, 0x51, i2cOut, ARRAY_SIZE(i2cOut)) == KERN_SUCCESS)
{
if (i2cOut[2] != 0x02 || i2cOut[3] != 0x00)
continue;
@@ -113,7 +113,7 @@ static const char* detectWithDdcci(FF_MAYBE_UNUSED const FFDisplayServerResult*
ffStrbufInit(&brightness->name);
uint8_t edid[128] = {};
if (IOAVServiceReadI2C(service, 0x50, 0x00, edid, sizeof(edid)) == KERN_SUCCESS)
if (IOAVServiceReadI2C(service, 0x50, 0x00, edid, ARRAY_SIZE(edid)) == KERN_SUCCESS)
ffEdidGetName(edid, &brightness->name);
}
}
@@ -155,12 +155,12 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F
.sendAddress = 0x6e,
.sendTransactionType = kIOI2CSimpleTransactionType,
.sendBuffer = (vm_address_t) i2cIn,
.sendBytes = sizeof(i2cIn) / sizeof(i2cIn[0]),
.sendBytes = ARRAY_SIZE(i2cIn),
.minReplyDelay = options->ddcciSleep,
.replyAddress = 0x6F,
.replySubAddress = 0x51,
.replyTransactionType = kIOI2CDDCciReplyTransactionType,
.replyBytes = sizeof(i2cOut) / sizeof(i2cOut[0]),
.replyBytes = ARRAY_SIZE(i2cOut),
.replyBuffer = (vm_address_t) i2cOut,
};
IOReturn ret = IOI2CSendRequest(connect, kNilOptions, &request);
+1 -1
View File
@@ -16,7 +16,7 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFl
for (char i = '0'; i <= '9'; ++i)
{
path[sizeof(path) - 2] = i;
path[ARRAY_SIZE(path) - 2] = i;
FF_AUTO_CLOSE_FD int blfd = open(path, O_RDONLY | O_CLOEXEC);
if (blfd < 0)
+2 -2
View File
@@ -25,7 +25,7 @@ static const char* detectWithBacklight(FFlist* result)
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, ".."))
if(entry->d_name[0] == '.')
continue;
ffStrbufAppendS(&backlightDir, entry->d_name);
@@ -48,7 +48,7 @@ static const char* detectWithBacklight(FFlist* result)
// if we managed to get edid, use it
ffStrbufAppendS(&brightness->name, "/edid");
uint8_t edidData[128];
if(ffReadFileData(brightness->name.chars, sizeof(edidData), edidData) == sizeof(edidData))
if(ffReadFileData(brightness->name.chars, ARRAY_SIZE(edidData), edidData) == ARRAY_SIZE(edidData))
{
ffStrbufClear(&brightness->name);
ffEdidGetName(edidData, &brightness->name);
+41 -67
View File
@@ -1,16 +1,18 @@
#include "btrfs.h"
#include "common/io/io.h"
#include <fcntl.h>
enum { uuidLen = (uint32_t) __builtin_strlen("00000000-0000-0000-0000-000000000000") };
static const char* enumerateDevices(FFBtrfsResult* item, FFstrbuf* path, FFstrbuf* buffer)
static const char* enumerateDevices(FFBtrfsResult* item, int dfd, FFstrbuf* buffer)
{
ffStrbufAppendS(path, "devices/");
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(path->chars);
int subfd = openat(dfd, "devices", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (subfd < 0) return "openat(\"/sys/fs/btrfs/UUID/devices\") == -1";
FF_AUTO_CLOSE_DIR DIR* dirp = fdopendir(subfd);
if(dirp == NULL)
return "opendir(\"/sys/fs/btrfs/UUID/devices\") == NULL";
const uint32_t devicesPathLen = path->length;
return "fdopendir(\"/sys/fs/btrfs/UUID/devices\") == NULL";
struct dirent* entry;
while ((entry = readdir(dirp)) != NULL)
@@ -21,25 +23,25 @@ static const char* enumerateDevices(FFBtrfsResult* item, FFstrbuf* path, FFstrbu
if (item->devices.length)
ffStrbufAppendC(&item->devices, ',');
ffStrbufAppendS(&item->devices, entry->d_name);
ffStrbufAppendS(path, entry->d_name);
ffStrbufAppendS(path, "/size");
if (ffReadFileBuffer(path->chars, buffer))
char path[ARRAY_SIZE(entry->d_name) + ARRAY_SIZE("/size") + 1];
snprintf(path, ARRAY_SIZE(path), "%s/size", entry->d_name);
if (ffReadFileBufferRelative(subfd, path, buffer))
item->totalSize += ffStrbufToUInt(buffer, 0) * 512;
ffStrbufSubstrBefore(path, devicesPathLen);
}
return NULL;
}
static const char* enumerateFeatures(FFBtrfsResult* item, FFstrbuf* path)
static const char* enumerateFeatures(FFBtrfsResult* item, int dfd)
{
ffStrbufAppendS(path, "features/");
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(path->chars);
int subfd = openat(dfd, "features", O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (subfd < 0) return "openat(\"/sys/fs/btrfs/UUID/features\") == -1";
FF_AUTO_CLOSE_DIR DIR* dirp = fdopendir(subfd);
if(dirp == NULL)
return "opendir(\"/sys/fs/btrfs/UUID/features\") == NULL";
const uint32_t featuresPathLen = path->length;
return "fdopendir(\"/sys/fs/btrfs/UUID/features\") == NULL";
struct dirent* entry;
while ((entry = readdir(dirp)) != NULL)
@@ -49,45 +51,33 @@ static const char* enumerateFeatures(FFBtrfsResult* item, FFstrbuf* path)
if (item->features.length)
ffStrbufAppendC(&item->features, ',');
ffStrbufAppendS(&item->features, entry->d_name);
ffStrbufSubstrBefore(path, featuresPathLen);
}
return NULL;
}
static const char* detectAllocation(FFBtrfsResult* item, FFstrbuf* path, FFstrbuf* buffer)
static const char* detectAllocation(FFBtrfsResult* item, int dfd, FFstrbuf* buffer)
{
ffStrbufAppendS(path, "allocation/");
const uint32_t AllocationPathLen = path->length;
FF_AUTO_CLOSE_FD int subfd = openat(dfd, "allocation", O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY);
if (subfd < 0) return "openat(\"/sys/fs/btrfs/UUID/allocation\") == -1";
ffStrbufAppendS(path, "global_rsv_size");
if (ffReadFileBuffer(path->chars, buffer))
if (ffReadFileBufferRelative(subfd, "global_rsv_size", buffer))
item->globalReservationTotal = ffStrbufToUInt(buffer, 0);
else
return "ffReadFileBuffer(\"/sys/fs/btrfs/UUID/allocation/global_rsv_size\") == NULL";
ffStrbufSubstrBefore(path, AllocationPathLen);
ffStrbufAppendS(path, "global_rsv_reserved");
if (ffReadFileBuffer(path->chars, buffer))
if (ffReadFileBufferRelative(subfd, "global_rsv_reserved", buffer))
item->globalReservationUsed = ffStrbufToUInt(buffer, 0);
ffStrbufSubstrBefore(path, AllocationPathLen);
item->globalReservationUsed = item->globalReservationTotal - item->globalReservationUsed;
#define FF_BTRFS_DETECT_TYPE(index, _type) \
ffStrbufAppendS(path, #_type "/total_bytes"); \
if (ffReadFileBuffer(path->chars, buffer)) \
if (ffReadFileBufferRelative(subfd, #_type "/total_bytes", buffer)) \
item->allocation[index].total = ffStrbufToUInt(buffer, 0); \
ffStrbufSubstrBefore(path, AllocationPathLen); \
\
ffStrbufAppendS(path, #_type "/bytes_used"); \
if (ffReadFileBuffer(path->chars, buffer)) \
if (ffReadFileBufferRelative(subfd, #_type "/bytes_used", buffer)) \
item->allocation[index].used = ffStrbufToUInt(buffer, 0); \
ffStrbufSubstrBefore(path, AllocationPathLen); \
\
ffStrbufAppendS(path, #_type "/dup"); \
item->allocation[index].dup = ffPathExists(path->chars, FF_PATHTYPE_DIRECTORY); \
ffStrbufSubstrBefore(path, AllocationPathLen); \
item->allocation[index].dup = faccessat(subfd, #_type "/dup/", F_OK, 0) == 0; \
\
item->allocation[index].type = #_type;
@@ -102,10 +92,7 @@ static const char* detectAllocation(FFBtrfsResult* item, FFstrbuf* path, FFstrbu
const char* ffDetectBtrfs(FFlist* result)
{
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/fs/btrfs/");
const uint32_t basePathLen = path.length;
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(path.chars);
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/sys/fs/btrfs/");
if(dirp == NULL)
return "opendir(\"/sys/fs/btrfs\") == NULL";
@@ -120,46 +107,33 @@ const char* ffDetectBtrfs(FFlist* result)
continue;
FFBtrfsResult* item = ffListAdd(result);
(*item) = (FFBtrfsResult){};
ffStrbufInitNS(&item->uuid, uuidLen, entry->d_name);
ffStrbufInit(&item->name);
ffStrbufInit(&item->devices);
ffStrbufInit(&item->features);
(*item) = (FFBtrfsResult){
.uuid = ffStrbufCreateNS(uuidLen, entry->d_name),
.name = ffStrbufCreate(),
.devices = ffStrbufCreate(),
.features = ffStrbufCreate(),
};
ffStrbufAppendNS(&path, uuidLen, entry->d_name);
ffStrbufAppendC(&path, '/');
const uint32_t itemPathLen = path.length;
FF_AUTO_CLOSE_FD int dfd = openat(dirfd(dirp), entry->d_name, O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY);
if (dfd < 0) continue;
ffStrbufAppendS(&path, "label");
if (ffAppendFileBuffer(path.chars, &item->name))
if (ffAppendFileBufferRelative(dfd, "label", &item->name))
ffStrbufTrimRightSpace(&item->name);
ffStrbufSubstrBefore(&path, itemPathLen);
enumerateDevices(item, &path, &buffer);
ffStrbufSubstrBefore(&path, itemPathLen);
enumerateDevices(item, dfd, &buffer);
enumerateFeatures(item, &path);
ffStrbufSubstrBefore(&path, itemPathLen);
enumerateFeatures(item, dfd);
ffStrbufAppendS(&path, "generation");
if (ffReadFileBuffer(path.chars, &buffer))
if (ffReadFileBufferRelative(dfd, "generation", &buffer))
item->generation = (uint32_t) ffStrbufToUInt(&buffer, 0);
ffStrbufSubstrBefore(&path, itemPathLen);
ffStrbufAppendS(&path, "nodesize");
if (ffReadFileBuffer(path.chars, &buffer))
if (ffReadFileBufferRelative(dfd, "nodesize", &buffer))
item->nodeSize = (uint32_t) ffStrbufToUInt(&buffer, 0);
ffStrbufSubstrBefore(&path, itemPathLen);
ffStrbufAppendS(&path, "sectorsize");
if (ffReadFileBuffer(path.chars, &buffer))
if (ffReadFileBufferRelative(dfd, "sectorsize", &buffer))
item->sectorSize = (uint32_t) ffStrbufToUInt(&buffer, 0);
ffStrbufSubstrBefore(&path, itemPathLen);
detectAllocation(item, &path, &buffer);
// finally
ffStrbufSubstrBefore(&path, basePathLen);
detectAllocation(item, dfd, &buffer);
}
return NULL;
+1 -1
View File
@@ -16,7 +16,7 @@ const char* ffDetectCamera(FFlist* result)
for (uint32_t i = 0; i <= 9; ++i)
{
path[sizeof(path) - 2] = (char) (i + '0');
path[ARRAY_SIZE(path) - 2] = (char) (i + '0');
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY);
if (fd < 0)
break;
+2 -2
View File
@@ -52,7 +52,7 @@ const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result)
wchar_t buffer[256];
uint32_t length = 0;
if (FAILED(device->GetString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, buffer, sizeof(buffer), &length)) || length == 0)
if (FAILED(device->GetString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, buffer, ARRAY_SIZE(buffer), &length)) || length == 0)
continue;
FFCameraResult* camera = (FFCameraResult*) ffListAdd(result);
@@ -63,7 +63,7 @@ const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result)
camera->width = 0;
camera->height = 0;
if (SUCCEEDED(device->GetString(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, buffer, sizeof(buffer), &length)) && length > 0)
if (SUCCEEDED(device->GetString(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, buffer, ARRAY_SIZE(buffer), &length)) && length > 0)
ffStrbufSetNWS(&camera->id, length, buffer);
IMFMediaSource* FF_AUTO_RELEASE_COM_OBJECT source = nullptr;
+1 -1
View File
@@ -13,7 +13,7 @@ const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu)
" 2-Core", " 4-Core", " 6-Core", " 8-Core", " 10-Core", " 12-Core", " 14-Core", " 16-Core",
" with Radeon Graphics"
};
ffStrbufRemoveStrings(&cpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings);
ffStrbufRemoveStrings(&cpu->name, ARRAY_SIZE(removeStrings), removeStrings);
ffStrbufSubstrBeforeFirstC(&cpu->name, '@'); //Cut the speed output in the name as we append our own
ffStrbufTrimRight(&cpu->name, ' '); //If we removed the @ in previous step there was most likely a space before it
return NULL;
+2 -2
View File
@@ -85,8 +85,8 @@ static const char* detectCoreCount(FFCPUResult* cpu)
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]);
if (nPerfLevels > ARRAY_SIZE(cpu->coreTypes))
nPerfLevels = ARRAY_SIZE(cpu->coreTypes);
for (uint32_t i = 0; i < nPerfLevels; ++i)
{
sysctlKey[strlen("hw.perflevel")] = (char) ('0' + i);
+53 -21
View File
@@ -47,7 +47,7 @@ static double parseHwmonDir(FFstrbuf* dir, FFstrbuf* buffer)
ffStrbufEqualS(buffer, "coretemp") // Intel
) return value / 1000.;
return false;
return 0.0/0.0;
}
static double detectCPUTemp(void)
@@ -388,38 +388,53 @@ FF_MAYBE_UNUSED static void detectArmSoc(FFCPUResult* cpu)
return;
// device-vendor,device-model\0soc-vendor,soc-model\0
char content[64];
ssize_t length = ffReadFileData("/proc/device-tree/compatible", sizeof(content), content);
char content[256];
ssize_t length = ffReadFileData("/proc/device-tree/compatible", ARRAY_SIZE(content), content);
if (length <= 2) return;
// get the second NUL terminated string
char* modelName = memchr(content, '\0', (size_t) length) + 1;
if (!modelName || modelName - content >= length) return;
// get the second NUL terminated string if it exists
char* vendor = memchr(content, '\0', (size_t) length) + 1;
if (!vendor || vendor - content >= length) vendor = content;
if (ffStrStartsWith(modelName, "apple,t"))
char* model = strchr(vendor, ',');
if (!model) return;
*model = '\0';
++model;
if (false) {}
#if __aarch64__
else if (ffStrEquals(vendor, "apple"))
{
// https://elixir.bootlin.com/linux/v6.11-rc7/source/arch/arm64/boot/dts/apple
const char* code = modelName + strlen("apple,t");
uint32_t deviceId = (uint32_t) strtoul(code, NULL, 10);
ffStrbufSetStatic(&cpu->name, ffCPUAppleCodeToName(deviceId));
if (!cpu->name.length)
// https://elixir.bootlin.com/linux/v6.11/source/arch/arm64/boot/dts/apple
if (model[0] == 't')
{
ffStrbufAppendS(&cpu->name, "Apple Silicon T");
ffStrbufAppendS(&cpu->name, code);
uint32_t deviceId = (uint32_t) strtoul(model + 1, NULL, 10);
ffStrbufSetStatic(&cpu->name, ffCPUAppleCodeToName(deviceId));
if (!cpu->name.length)
{
ffStrbufSetS(&cpu->name, "Apple Silicon ");
ffStrbufAppendS(&cpu->name, model);
}
}
else
ffStrbufSetS(&cpu->name, model);
ffStrbufSetStatic(&cpu->vendor, "Apple");
}
else if (ffStrStartsWith(modelName, "qcom,"))
#endif
else if (ffStrEquals(vendor, "qcom"))
{
// https://elixir.bootlin.com/linux/v6.11-rc7/source/arch/arm64/boot/dts/qcom
if (ffStrStartsWith(modelName + strlen("qcom,"), "x"))
// https://elixir.bootlin.com/linux/v6.11/source/arch/arm64/boot/dts/qcom
if (ffStrStartsWith(model, "x"))
{
ffStrbufSetS(&cpu->name, "Qualcomm Snapdragon X Elite ");
for (const char* p = modelName + strlen("qcom,"); *p; ++p)
for (const char* p = model + 1; *p; ++p)
ffStrbufAppendC(&cpu->name, (char) toupper(*p));
}
else if (ffStrStartsWith(modelName + strlen("qcom,"), "sc"))
else if (ffStrStartsWith(model, "sc"))
{
const char* code = modelName + strlen("qcom,sc");
const char* code = model + 2;
uint32_t deviceId = (uint32_t) strtoul(code, NULL, 10);
ffStrbufSetStatic(&cpu->name, ffCPUQualcommCodeToName(deviceId));
if (!cpu->name.length)
@@ -428,6 +443,23 @@ FF_MAYBE_UNUSED static void detectArmSoc(FFCPUResult* cpu)
ffStrbufAppendS(&cpu->name, code);
}
}
else
ffStrbufSetS(&cpu->name, model);
ffStrbufSetStatic(&cpu->vendor, "Qualcomm");
}
else if (ffStrEquals(vendor, "brcm"))
{
// Raspberry Pi
ffStrbufSetStatic(&cpu->vendor, "Broadcom");
for (const char* p = model; *p; ++p)
ffStrbufAppendC(&cpu->name, (char) toupper(*p));
}
else
{
ffStrbufSetS(&cpu->name, model);
ffStrbufSetS(&cpu->vendor, vendor);
cpu->vendor.chars[0] = (char) toupper(vendor[0]);
}
}
@@ -480,7 +512,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
#if __ANDROID__
detectAndroid(cpu);
#elif __aarch64__
#else
detectArmSoc(cpu);
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
#include "cpu.h"
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FF_MAYBE_UNUSED FFCPUResult* cpu)
{
return "Not supported on this platform";
}
+19
View File
@@ -0,0 +1,19 @@
#include "cpu.h"
#include "common/sysctl.h"
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
{
if (ffSysctlGetString(CTL_HW, HW_MODEL, &cpu->name))
return "sysctl(hw.model) failed";
cpu->coresPhysical = (uint16_t) ffSysctlGetInt(CTL_HW, HW_NCPU, 1);
cpu->coresLogical = cpu->coresPhysical;
cpu->coresOnline = (uint16_t) ffSysctlGetInt(CTL_HW, HW_NCPUONLINE, cpu->coresLogical);
ffCPUDetectSpeedByCpuid(cpu);
cpu->frequencyBase = (uint32_t) ffSysctlGetInt(CTL_HW, HW_CPUSPEED, 0);
cpu->temperature = FF_CPU_TEMP_UNSET; // HW_SENSORS?
return NULL;
}
+10 -9
View File
@@ -1,5 +1,6 @@
#include "cpucache.h"
#include "common/sysctl.h"
#include "util/stringUtils.h"
const char* ffDetectCPUCache(FFCPUCacheResult* result)
{
@@ -10,44 +11,44 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result)
// macOS provides the global system cache line size
uint32_t lineSize = (uint32_t) ffSysctlGetInt("hw.cachelinesize", 0);
char sysctlKey[256] = "hw.perflevelN.";
char sysctlKey[128] = "hw.perflevelN.";
char* pNum = sysctlKey + strlen("hw.perflevel");
char* pSubkey = sysctlKey + strlen("hw.perflevelN.");
const size_t lenLeft = sizeof(sysctlKey) - strlen("hw.perflevelN.");
const size_t lenLeft = ARRAY_SIZE(sysctlKey) - strlen("hw.perflevelN.");
for (uint32_t i = 0; i < nPerfLevels; ++i)
{
*pNum = (char) ('0' + i);
strncpy(pSubkey, "physicalcpu", lenLeft);
ffStrCopyN(pSubkey, "physicalcpu", lenLeft);
uint32_t ncpu = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (ncpu <= 0) continue;
strncpy(pSubkey, "l1icachesize", lenLeft);
ffStrCopyN(pSubkey, "l1icachesize", lenLeft);
uint32_t size = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (size)
ffCPUCacheAddItem(result, 1, size, lineSize, FF_CPU_CACHE_TYPE_INSTRUCTION)->num = ncpu;
strncpy(pSubkey, "l1dcachesize", lenLeft);
ffStrCopyN(pSubkey, "l1dcachesize", lenLeft);
size = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (size)
ffCPUCacheAddItem(result, 1, size, lineSize, FF_CPU_CACHE_TYPE_DATA)->num = ncpu;
strncpy(pSubkey, "l2cachesize", lenLeft);
ffStrCopyN(pSubkey, "l2cachesize", lenLeft);
size = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (size)
{
strncpy(pSubkey, "cpusperl2", lenLeft);
ffStrCopyN(pSubkey, "cpusperl2", lenLeft);
uint32_t cpuSper = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (cpuSper)
ffCPUCacheAddItem(result, 2, size, lineSize, FF_CPU_CACHE_TYPE_UNIFIED)->num = ncpu / cpuSper;
}
strncpy(pSubkey, "l3cachesize", lenLeft);
ffStrCopyN(pSubkey, "l3cachesize", lenLeft);
size = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (size)
{
strncpy(pSubkey, "cpusperl3", lenLeft);
ffStrCopyN(pSubkey, "cpusperl3", lenLeft);
uint32_t cpuSper = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (cpuSper)
ffCPUCacheAddItem(result, 3, size, lineSize, FF_CPU_CACHE_TYPE_UNIFIED)->num = ncpu / cpuSper;
+3 -3
View File
@@ -13,7 +13,7 @@ void ffPrepareCPUUsage(void)
ffGetCpuUsageInfo(&cpuTimes1);
}
const char* ffGetCpuUsageResult(FFlist* result)
const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result)
{
const char* error = NULL;
if(cpuTimes1.elementSize == 0)
@@ -21,7 +21,7 @@ const char* ffGetCpuUsageResult(FFlist* result)
ffListInit(&cpuTimes1, sizeof(FFCpuUsageInfo));
error = ffGetCpuUsageInfo(&cpuTimes1);
if(error) return error;
ffTimeSleep(200);
ffTimeSleep(options->waitTime);
}
if(cpuTimes1.length == 0) return "No CPU cores found";
@@ -43,7 +43,7 @@ retry:
if (++retryCount <= 3)
{
ffListClear(&cpuTimes2);
ffTimeSleep(200);
ffTimeSleep(options->waitTime);
goto retry;
}
}
+1 -1
View File
@@ -8,4 +8,4 @@ typedef struct FFCpuUsageInfo {
} FFCpuUsageInfo;
const char* ffGetCpuUsageInfo(FFlist* cpuTimes);
const char* ffGetCpuUsageResult(FFlist* result); // list of double
const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result); // list of double
+16
View File
@@ -6,18 +6,34 @@
#include <sys/resource.h>
#include <stdlib.h>
#ifdef __OpenBSD__
#include <sys/sched.h>
#endif
const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
{
size_t neededLength = 0;
#ifdef __OpenBSD__
int ctls[] = {CTL_KERN, KERN_CPTIME};
if (sysctl(ctls, 2, NULL, &neededLength, NULL, 0) != 0)
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
#else
if(sysctlbyname("kern.cp_times", NULL, &neededLength, NULL, 0) != 0)
return "sysctlbyname(kern.cp_times, NULL) failed";
#endif
uint32_t coreCount = (uint32_t) (neededLength / (CPUSTATES * sizeof(uint64_t)));
assert(coreCount > 0);
FF_AUTO_FREE uint64_t (*cpTimes)[CPUSTATES] = malloc(neededLength);
#ifdef __OpenBSD__
if (sysctl(ctls, 2, cpTimes, &neededLength, NULL, 0) != 0)
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
#else
if(sysctlbyname("kern.cp_times", cpTimes, &neededLength, NULL, 0) != 0)
return "sysctlbyname(kern.cp_times, cpTime) failed";
#endif
for (uint32_t i = 0; i < coreCount; ++i)
{
+2 -2
View File
@@ -8,13 +8,13 @@
const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
{
char buf[PROC_FILE_BUFFSIZ];
ssize_t nRead = ffReadFileData("/proc/stat", sizeof(buf) - 1, buf);
ssize_t nRead = ffReadFileData("/proc/stat", ARRAY_SIZE(buf) - 1, buf);
if(nRead < 0)
{
#ifdef __ANDROID__
return "Accessing \"/proc/stat\" is restricted on Android O+";
#else
return "ffReadFileData(\"/proc/stat\", sizeof(buf) - 1, buf) failed";
return "ffReadFileData(\"/proc/stat\", ARRAY_SIZE(buf) - 1, buf) failed";
#endif
}
buf[nRead] = '\0';
+1 -1
View File
@@ -1,7 +1,7 @@
#include "fastfetch.h"
#include "detection/cpuusage/cpuusage.h"
const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
const char* ffGetCpuUsageInfo(FF_MAYBE_UNUSED FFlist* cpuTimes)
{
return "Not support on this platform";
}
+9
View File
@@ -92,6 +92,11 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
}, &attrBuf, sizeof(attrBuf), 0) == 0)
ffStrbufInitNS(&disk->name, attrBuf.nameRef.attr_length - 1 /* excluding '\0' */, attrBuf.nameSpace);
}
#else
static void detectFsInfo(struct statfs* fs, FFDisk* disk)
{
FF_UNUSED(fs, disk);
}
#endif
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
@@ -143,6 +148,10 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
if(fs->f_flags & MNT_RDONLY)
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
#ifdef __OpenBSD__
#define st_birthtimespec __st_birthtim
#endif
struct stat st;
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));
+12 -8
View File
@@ -149,7 +149,7 @@ static void detectName(FFDisk* disk)
#ifdef __ANDROID__
static void detectType(FF_MAYBE_UNUSED const FFlist* disks, FFDisk* currentDisk)
static void detectType(FF_MAYBE_UNUSED const FFlist* disks, FFDisk* currentDisk, FF_MAYBE_UNUSED struct mntent* device)
{
if(ffStrbufEqualS(&currentDisk->mountpoint, "/") || ffStrbufEqualS(&currentDisk->mountpoint, "/storage/emulated"))
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
@@ -204,7 +204,7 @@ static bool isRemovable(FFDisk* currentDisk)
return false;
char sysBlockPartition[64];
snprintf(sysBlockPartition, sizeof(sysBlockPartition), "/sys/class/block/%s", currentDisk->mountFrom.chars + strlen("/dev/"));
snprintf(sysBlockPartition, ARRAY_SIZE(sysBlockPartition), "/sys/class/block/%s", currentDisk->mountFrom.chars + strlen("/dev/"));
char sysBlockVolume[PATH_MAX]; // /sys/devices/pci0000:00/0000:00:14.0/usb4/4-3/4-3:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1
if (realpath(sysBlockPartition, sysBlockVolume) == NULL)
@@ -215,7 +215,7 @@ static bool isRemovable(FFDisk* currentDisk)
return ffReadFileData(sysBlockVolume, 1, &removableChar) > 0 && removableChar == '1';
}
static void detectType(const FFlist* disks, FFDisk* currentDisk)
static void detectType(const FFlist* disks, FFDisk* currentDisk, struct mntent* device)
{
if(ffStrbufStartsWithS(&currentDisk->mountpoint, "/boot") || ffStrbufStartsWithS(&currentDisk->mountpoint, "/efi"))
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
@@ -225,6 +225,8 @@ static void detectType(const FFlist* disks, FFDisk* currentDisk)
currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
else
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
if (hasmntopt(device, MNTOPT_RO))
currentDisk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
}
#endif
@@ -233,7 +235,7 @@ static void detectStats(FFDisk* disk)
{
struct statvfs fs;
if(statvfs(disk->mountpoint.chars, &fs) != 0)
memset(&fs, 0, sizeof(struct statvfs)); //Set all values to 0, so our values get initialized to 0 too
memset(&fs, 0, sizeof(fs)); //Set all values to 0, so our values get initialized to 0 too
disk->bytesTotal = fs.f_blocks * fs.f_frsize;
disk->bytesFree = fs.f_bfree * fs.f_frsize;
@@ -251,15 +253,17 @@ static void detectStats(FFDisk* disk)
disk->filesTotal = disk->filesUsed = 0;
}
if(fs.f_flag & ST_RDONLY)
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
disk->createTime = 0;
#ifdef FF_HAVE_STATX
struct statx stx;
if (statx(0, disk->mountpoint.chars, 0, STATX_BTIME, &stx) == 0 && (stx.stx_mask & STATX_BTIME))
disk->createTime = (uint64_t)((stx.stx_btime.tv_sec * 1000) + (stx.stx_btime.tv_nsec / 1000000));
#endif
#ifdef __ANDROID__ // hasmntopt requires a higher Android API level
if(fs.f_flag & ST_RDONLY)
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
#endif
}
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
@@ -298,7 +302,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
detectName(disk); // Also detects external devices
//detect type
detectType(disks, disk);
detectType(disks, disk, device);
//Detects stats
detectStats(disk);
+1 -1
View File
@@ -1,6 +1,6 @@
#include "disk.h"
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_UNUSED FFlist* disks)
{
return "Not supported on this platform";
}
+4 -5
View File
@@ -72,19 +72,21 @@ static bool isSubvolume(const FFlist* disks, FFDisk* currentDisk)
static void detectType(const FFlist* disks, FFDisk* currentDisk, struct mnttab* device)
{
if(ffStrContains(device->mnt_mntopts, MNTOPT_NOBROWSE))
if(hasmntopt(device, MNTOPT_NOBROWSE))
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
else if(isSubvolume(disks, currentDisk))
currentDisk->type = FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
else
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
if (hasmntopt(device, MNTOPT_RO))
currentDisk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
}
static void detectStats(FFDisk* disk)
{
struct statvfs fs;
if(statvfs(disk->mountpoint.chars, &fs) != 0)
memset(&fs, 0, sizeof(struct statvfs));
memset(&fs, 0, sizeof(fs));
disk->bytesTotal = fs.f_blocks * fs.f_frsize;
disk->bytesFree = fs.f_bfree * fs.f_frsize;
@@ -94,9 +96,6 @@ static void detectStats(FFDisk* disk)
disk->filesTotal = (uint32_t) fs.f_files;
disk->filesUsed = (uint32_t) (disk->filesTotal - fs.f_ffree);
if(fs.f_flag & ST_RDONLY)
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
ffStrbufSetS(&disk->name, fs.f_fstr);
disk->createTime = 0;
+7 -7
View File
@@ -22,9 +22,9 @@ static unsigned __stdcall testRemoteVolumeAccessible(void* mountpoint)
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";
uint32_t length = GetLogicalDriveStringsW(ARRAY_SIZE(buf), buf);
if (length == 0 || length >= ARRAY_SIZE(buf))
return "GetLogicalDriveStringsW(ARRAY_SIZE(buf), buf) failed";
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
@@ -32,7 +32,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
if (__builtin_expect(options->folders.length == 1 && options->folders.chars[0] == '/', 0))
{
wchar_t path[MAX_PATH + 1];
GetSystemWindowsDirectoryW(path, sizeof(path) / sizeof(*path));
GetSystemWindowsDirectoryW(path, ARRAY_SIZE(path));
ffStrbufSetF(&options->folders, "%c:\\", (char) path[0]);
}
@@ -76,7 +76,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
{
wchar_t volumeName[MAX_PATH + 1];
mountpoint[2] = L'\0';
if(QueryDosDeviceW(mountpoint, volumeName, sizeof(volumeName) / sizeof(*volumeName)))
if(QueryDosDeviceW(mountpoint, volumeName, ARRAY_SIZE(volumeName)))
ffStrbufSetWS(&disk->mountFrom, volumeName);
mountpoint[2] = L'\\';
}
@@ -104,11 +104,11 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
DWORD diskFlags;
BOOL result = GetVolumeInformationW(mountpoint,
diskName, sizeof(diskName) / sizeof(*diskName), //Volume name
diskName, ARRAY_SIZE(diskName), //Volume name
NULL, //Serial number
NULL, //Max component length
&diskFlags, //File system flags
diskFileSystem, sizeof(diskFileSystem) / sizeof(*diskFileSystem)
diskFileSystem, ARRAY_SIZE(diskFileSystem)
);
SetErrorMode(errorMode);
+2 -2
View File
@@ -41,9 +41,9 @@ const char* ffDetectDiskIO(FFlist* result, FFDiskIOOptions* options)
return "No physical disk found";
uint64_t time2 = ffTimeGetNow();
while (time2 - time1 < 1000)
while (time2 - time1 < options->waitTime)
{
ffTimeSleep((uint32_t) (1000 - (time2 - time1)));
ffTimeSleep((uint32_t) (options->waitTime - (time2 - time1)));
time2 = ffTimeGetNow();
}
+68 -77
View File
@@ -6,6 +6,71 @@
#include <ctype.h>
#include <limits.h>
#include <inttypes.h>
#include <fcntl.h>
static void parseDiskIOCounters(int dfd, const char* devName, FFlist* result, FFDiskIOOptions* options)
{
FF_AUTO_CLOSE_FD int devfd = openat(dfd, "device", O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY);
if (devfd < 0) return; // virtual device
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
{
if (ffAppendFileBufferRelative(devfd, "vendor", &name))
{
ffStrbufTrimRightSpace(&name);
if (name.length > 0)
ffStrbufAppendC(&name, ' ');
}
if (ffAppendFileBufferRelative(devfd, "model", &name))
ffStrbufTrimRightSpace(&name);
if (name.length == 0)
ffStrbufSetS(&name, devName);
else if (ffStrStartsWith(devName, "nvme"))
{
int devid, nsid;
if (sscanf(devName, "nvme%dn%d", &devid, &nsid) == 2)
{
bool multiNs = nsid > 1;
if (!multiNs)
{
char pathSysBlock[16];
snprintf(pathSysBlock, ARRAY_SIZE(pathSysBlock), "nvme%dn2", devid);
multiNs = faccessat(devfd, pathSysBlock, F_OK, 0) == 0;
}
if (multiNs)
{
// In Asahi Linux, there are multiple namespaces for the same NVMe drive.
ffStrbufAppendF(&name, " - %d", nsid);
}
}
}
if (options->namePrefix.length && !ffStrbufStartsWith(&name, &options->namePrefix))
return;
}
// I/Os merges sectors ticks ...
uint64_t nRead, sectorRead, nWritten, sectorWritten;
{
char sysBlockStat[PROC_FILE_BUFFSIZ];
ssize_t fileSize = ffReadFileDataRelative(dfd, "stat", ARRAY_SIZE(sysBlockStat) - 1, sysBlockStat);
if (fileSize <= 0) return;
sysBlockStat[fileSize] = '\0';
if (sscanf(sysBlockStat, "%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u", &nRead, &sectorRead, &nWritten, &sectorWritten) <= 0)
return;
}
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
ffStrbufInitMove(&device->name, &name);
ffStrbufInitF(&device->devPath, "/dev/%s", devName);
device->bytesRead = sectorRead * 512;
device->bytesWritten = sectorWritten * 512;
device->readCount = nRead;
device->writeCount = nWritten;
}
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
{
@@ -18,84 +83,10 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
{
const char* const devName = sysBlockEntry->d_name;
if (devName[0] == '.')
continue;
if (devName[0] == '.') continue;;
char pathSysBlock[PATH_MAX];
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s", devName);
char pathSysDeviceReal[PATH_MAX];
ssize_t pathLength = readlink(pathSysBlock, pathSysDeviceReal, sizeof(pathSysDeviceReal) - 1);
if (pathLength < 0)
continue;
pathSysDeviceReal[pathLength] = '\0';
if (strstr(pathSysDeviceReal, "/virtual/")) // virtual device
continue;
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/device", devName);
if (!ffPathExists(pathSysBlock, FF_PATHTYPE_DIRECTORY))
continue;
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
{
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/device/vendor", devName);
if (ffAppendFileBuffer(pathSysBlock, &name))
{
ffStrbufTrimRightSpace(&name);
if (name.length > 0)
ffStrbufAppendC(&name, ' ');
}
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/device/model", devName);
ffAppendFileBuffer(pathSysBlock, &name);
ffStrbufTrimRightSpace(&name);
if (name.length == 0)
ffStrbufSetS(&name, devName);
else if (ffStrStartsWith(devName, "nvme"))
{
int devid, nsid;
if (sscanf(devName, "nvme%dn%d", &devid, &nsid) == 2)
{
bool multiNs = nsid > 1;
if (!multiNs)
{
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/device/nvme%dn2", devName, devid);
multiNs = ffPathExists(pathSysBlock, FF_PATHTYPE_DIRECTORY);
}
if (multiNs)
{
// In Asahi Linux, there are multiple namespaces for the same NVMe drive.
ffStrbufAppendF(&name, " - %d", nsid);
}
}
}
if (options->namePrefix.length && !ffStrbufStartsWith(&name, &options->namePrefix))
continue;
}
// I/Os merges sectors ticks ...
uint64_t nRead, sectorRead, nWritten, sectorWritten;
{
char sysBlockStat[PROC_FILE_BUFFSIZ];
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/stat", devName);
ssize_t fileSize = ffReadFileData(pathSysBlock, sizeof(sysBlockStat) - 1, sysBlockStat);
if (fileSize <= 0) continue;
sysBlockStat[fileSize] = '\0';
if (sscanf(sysBlockStat, "%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u", &nRead, &sectorRead, &nWritten, &sectorWritten) <= 0)
continue;
}
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
ffStrbufInitMove(&device->name, &name);
ffStrbufInitF(&device->devPath, "/dev/%s", devName);
device->bytesRead = sectorRead * 512;
device->bytesWritten = sectorWritten * 512;
device->readCount = nRead;
device->writeCount = nWritten;
FF_AUTO_CLOSE_FD int dfd = openat(dirfd(sysBlockDirp), devName, O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY);
if (dfd > 0) parseDiskIOCounters(dfd, devName, result, options);
}
return NULL;
+1 -1
View File
@@ -1,6 +1,6 @@
#include "diskio.h"
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
const char* ffDiskIOGetIoCounters(FF_MAYBE_UNUSED FFlist* result, FF_MAYBE_UNUSED FFDiskIOOptions* options)
{
return "Not supported on this platform";
}
+1 -1
View File
@@ -22,7 +22,7 @@ static bool detectPhysicalDisk(const wchar_t* szDevice, FFlist* result, FFDiskIO
},
sizeof(STORAGE_PROPERTY_QUERY),
&sddBuffer,
sizeof(sddBuffer),
ARRAY_SIZE(sddBuffer),
&retSize,
NULL
) || retSize == 0)
+7 -2
View File
@@ -13,7 +13,8 @@ FFDisplayResult* ffdsAppendDisplay(
bool primary,
uint64_t id,
uint32_t physicalWidth,
uint32_t physicalHeight)
uint32_t physicalHeight,
const char* platformApi)
{
if(width == 0 || height == 0)
return NULL;
@@ -31,9 +32,13 @@ FFDisplayResult* ffdsAppendDisplay(
display->physicalWidth = physicalWidth;
display->physicalHeight = physicalHeight;
display->primary = primary;
display->platformApi = platformApi;
display->bitDepth = 0;
display->hdrEnabled = false;
display->hdrStatus = FF_DISPLAY_HDR_STATUS_UNKNOWN;
display->manufactureYear = 0;
display->manufactureWeek = 0;
display->serial = 0;
return display;
}
+15 -2
View File
@@ -48,6 +48,14 @@ typedef enum FFDisplayType {
FF_DISPLAY_TYPE_EXTERNAL,
} FFDisplayType;
typedef enum FFDisplayHdrStatus
{
FF_DISPLAY_HDR_STATUS_UNKNOWN,
FF_DISPLAY_HDR_STATUS_UNSUPPORTED,
FF_DISPLAY_HDR_STATUS_SUPPORTED,
FF_DISPLAY_HDR_STATUS_ENABLED,
} FFDisplayHdrStatus;
typedef struct FFDisplayResult
{
uint32_t width;
@@ -62,8 +70,12 @@ typedef struct FFDisplayResult
uint32_t physicalWidth;
uint32_t physicalHeight;
bool primary;
const char* platformApi;
uint8_t bitDepth;
bool hdrEnabled;
FFDisplayHdrStatus hdrStatus;
uint16_t manufactureYear;
uint16_t manufactureWeek;
uint32_t serial;
} FFDisplayResult;
typedef struct FFDisplayServerResult
@@ -91,4 +103,5 @@ FFDisplayResult* ffdsAppendDisplay(
bool primary,
uint64_t id,
uint32_t physicalWidth,
uint32_t physicalHeight);
uint32_t physicalHeight,
const char* platformApi);
@@ -66,7 +66,8 @@ static void detectWithDumpsys(FFDisplayServerResult* ds)
false,
0,
0,
0
0,
"dumpsys"
);
}
@@ -100,7 +101,8 @@ static bool detectWithGetprop(FFDisplayServerResult* ds)
false,
0,
0,
0
0,
"getprop"
);
}
@@ -1,6 +1,7 @@
#include "displayserver.h"
#include "util/apple/cf_helpers.h"
#include "util/stringUtils.h"
#include "util/edidHelper.h"
#include <stdlib.h>
#include <string.h>
@@ -9,8 +10,9 @@
#include <CoreVideo/CVDisplayLink.h>
#ifdef MAC_OS_X_VERSION_10_15
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import));
extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display) __attribute__((weak_import));
extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display) __attribute__((weak_import));
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import));
#else
#include <IOKit/graphics/IOGraphicsLib.h>
#endif
@@ -19,9 +21,10 @@ static void detectDisplays(FFDisplayServerResult* ds)
{
CGDirectDisplayID screens[128];
uint32_t screenCount;
if(CGGetOnlineDisplayList(sizeof(screens) / sizeof(screens[0]), screens, &screenCount) != kCGErrorSuccess)
if(CGGetOnlineDisplayList(ARRAY_SIZE(screens), screens, &screenCount) != kCGErrorSuccess)
return;
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
for(uint32_t i = 0; i < screenCount; i++)
{
CGDirectDisplayID screen = screens[i];
@@ -43,7 +46,7 @@ static void detectDisplays(FFDisplayServerResult* ds)
}
}
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
ffStrbufClear(&buffer);
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = NULL;
#ifdef MAC_OS_X_VERSION_10_15
if(CoreDisplay_DisplayCreateInfoDictionary)
@@ -54,14 +57,30 @@ static void detectDisplays(FFDisplayServerResult* ds)
displayInfo = IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName);
}
#endif
uint32_t physicalWidth = 0, physicalHeight = 0;
if(displayInfo)
{
CFDictionaryRef productNames;
if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames))
ffCfDictGetString(productNames, CFSTR("en_US"), &name);
ffCfDictGetString(productNames, CFSTR("en_US"), &buffer);
// CGDisplayScreenSize reports invalid result for external displays on old Intel MacBook Pro
CFDataRef edidRef = (CFDataRef) CFDictionaryGetValue(displayInfo, CFSTR(kIODisplayEDIDKey));
if (edidRef && CFGetTypeID(edidRef) == CFDataGetTypeID())
{
const uint8_t* edidData = CFDataGetBytePtr(edidRef);
uint32_t edidLength = (uint32_t) CFDataGetLength(edidRef);
if (edidLength >= 128)
ffEdidGetPhysicalSize(edidData, &physicalWidth, &physicalHeight);
}
}
CGSize size = CGDisplayScreenSize(screen);
if (!physicalWidth || !physicalHeight)
{
CGSize size = CGDisplayScreenSize(screen);
physicalWidth = (uint32_t) (size.width + 0.5);
physicalHeight = (uint32_t) (size.height + 0.5);
}
FFDisplayResult* display = ffdsAppendDisplay(ds,
(uint32_t)CGDisplayModeGetPixelWidth(mode),
@@ -70,12 +89,13 @@ static void detectDisplays(FFDisplayServerResult* ds)
(uint32_t)CGDisplayModeGetWidth(mode),
(uint32_t)CGDisplayModeGetHeight(mode),
(uint32_t)CGDisplayRotation(screen),
&name,
&buffer,
CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL,
CGDisplayIsMain(screen),
(uint64_t)screen,
(uint32_t) (size.width + 0.5),
(uint32_t) (size.height + 0.5)
physicalWidth,
physicalHeight,
"CoreGraphics"
);
if (display)
{
@@ -89,12 +109,29 @@ static void detectDisplays(FFDisplayServerResult* ds)
display->bitDepth = (uint8_t) bitDepth;
}
if (display->type == FF_DISPLAY_TYPE_BUILTIN)
display->hdrStatus = CFDictionaryContainsKey(displayInfo, CFSTR("ReferencePeakHDRLuminance"))
? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
#ifdef MAC_OS_X_VERSION_10_15
if (CoreDisplay_Display_IsHDRModeEnabled)
else if (CoreDisplay_Display_SupportsHDRMode)
{
display->hdrEnabled = CoreDisplay_Display_IsHDRModeEnabled(screen);
if (CoreDisplay_Display_SupportsHDRMode(screen))
{
display->hdrStatus = FF_DISPLAY_HDR_STATUS_SUPPORTED;
if (CoreDisplay_Display_IsHDRModeEnabled && CoreDisplay_Display_IsHDRModeEnabled(screen))
display->hdrStatus = FF_DISPLAY_HDR_STATUS_ENABLED;
}
else
display->hdrStatus = FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
}
#endif
display->serial = CGDisplaySerialNumber(screen);
int value;
if (ffCfDictGetInt(displayInfo, CFSTR(kDisplayYearOfManufacture), &value) == NULL)
display->manufactureYear = (uint16_t) value;
if (ffCfDictGetInt(displayInfo, CFSTR(kDisplayWeekOfManufacture), &value) == NULL)
display->manufactureWeek = (uint16_t) value;
}
CGDisplayModeRelease(mode);
}
@@ -36,9 +36,9 @@ static void detectDisplays(FFDisplayServerResult* ds)
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM) &monitors);
DISPLAYCONFIG_PATH_INFO paths[128];
uint32_t pathCount = sizeof(paths) / sizeof(paths[0]);
uint32_t pathCount = ARRAY_SIZE(paths);
DISPLAYCONFIG_MODE_INFO modes[256];
uint32_t modeCount = sizeof(modes) / sizeof(modes[0]);
uint32_t modeCount = ARRAY_SIZE(modes);
if (QueryDisplayConfig(
QDC_ONLY_ACTIVE_PATHS,
@@ -66,7 +66,7 @@ static void detectDisplays(FFDisplayServerResult* ds)
{
FF_LIST_FOR_EACH(FFMonitorInfo, item, monitors)
{
if (wcsncmp(item->info.szDevice, sourceName.viewGdiDeviceName, sizeof(sourceName.viewGdiDeviceName) / sizeof(wchar_t)) == 0)
if (wcsncmp(item->info.szDevice, sourceName.viewGdiDeviceName, ARRAY_SIZE(sourceName.viewGdiDeviceName)) == 0)
{
monitorInfo = item;
break;
@@ -86,6 +86,9 @@ static void detectDisplays(FFDisplayServerResult* ds)
.id = path->targetInfo.id,
},
};
uint8_t edidData[1024];
DWORD edidLength = 0;
if(DisplayConfigGetDeviceInfo(&targetName.header) == ERROR_SUCCESS)
{
wchar_t regPath[256] = L"SYSTEM\\CurrentControlSet\\Enum";
@@ -99,12 +102,11 @@ static void detectDisplays(FFDisplayServerResult* ds)
*pRegPath = *pDevPath;
++pRegPath;
++pDevPath;
assert(pRegPath < regPath + sizeof(regPath) / sizeof(wchar_t) + strlen("Device Parameters"));
assert(pRegPath < regPath + ARRAY_SIZE(regPath) + strlen("Device Parameters"));
}
wcscpy(pRegPath, L"Device Parameters");
uint8_t edidData[1024];
DWORD edidLength = sizeof(edidData);
edidLength = ARRAY_SIZE(edidData);
if (RegGetValueW(HKEY_LOCAL_MACHINE, regPath, L"EDID", RRF_RT_REG_BINARY, NULL, edidData, &edidLength) == ERROR_SUCCESS &&
edidLength > 0 && edidLength % 128 == 0)
{
@@ -113,6 +115,7 @@ static void detectDisplays(FFDisplayServerResult* ds)
}
else
{
edidLength = 0;
if (targetName.flags.friendlyNameFromEdid)
ffStrbufSetWS(&name, targetName.monitorFriendlyDeviceName);
else
@@ -162,7 +165,8 @@ static void detectDisplays(FFDisplayServerResult* ds)
!!(monitorInfo->info.dwFlags & MONITORINFOF_PRIMARY),
(uint64_t)(uintptr_t) monitorInfo->handle,
physicalWidth,
physicalHeight
physicalHeight,
"GDI"
);
if (display)
@@ -177,9 +181,18 @@ static void detectDisplays(FFDisplayServerResult* ds)
};
if (DisplayConfigGetDeviceInfo(&advColorInfo.header) == ERROR_SUCCESS)
{
display->hdrEnabled = !!advColorInfo.advancedColorEnabled;
if (advColorInfo.advancedColorEnabled)
display->hdrStatus = FF_DISPLAY_HDR_STATUS_ENABLED;
else if (advColorInfo.advancedColorSupported)
display->hdrStatus = FF_DISPLAY_HDR_STATUS_SUPPORTED;
else
display->hdrStatus = FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
display->bitDepth = (uint8_t) advColorInfo.bitsPerColorChannel;
}
else
display->hdrStatus = FF_DISPLAY_HDR_STATUS_UNKNOWN;
if (edidLength > 0)
ffEdidGetSerialAndManufactureDate(edidData, &display->serial, &display->manufactureYear, &display->manufactureWeek);
}
}
}
@@ -1,6 +1,5 @@
#include "displayserver_linux.h"
#include "common/io/io.h"
#include "util/edidHelper.h"
#include "util/stringUtils.h"
#ifdef __FreeBSD__
@@ -87,7 +86,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
if (ffSettingsGetFreeBSDKenv("screen.height", &buf))
{
uint32_t height = (uint32_t) ffStrbufToUInt(&buf, 0);
ffdsAppendDisplay(ds, width, height, 0, 0, 0, 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, false, 0, 0, 0);
ffdsAppendDisplay(ds, width, height, 0, 0, 0, 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, false, 0, 0, 0, "kenv");
}
}
}
@@ -104,44 +103,6 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
}
}
bool ffdsMatchDrmConnector(const char* connName, FFstrbuf* edidName)
{
// https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-event-name
// The doc says that "do not assume that the name is a reflection of an underlying DRM connector, X11 connection, etc."
// However I can't find a better method to get the edid data
const char* drmDirPath = "/sys/class/drm/";
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath);
if(dirp == NULL)
return false;
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
const char* plainName = entry->d_name;
if (ffStrStartsWith(plainName, "card"))
{
const char* tmp = strchr(plainName + strlen("card"), '-');
if (tmp) plainName = tmp + 1;
}
if (ffStrEquals(plainName, connName))
{
ffStrbufAppendF(edidName, "%s%s/edid", drmDirPath, entry->d_name);
uint8_t edidData[128];
if(ffReadFileData(edidName->chars, sizeof(edidData), edidData) == sizeof(edidData))
{
ffStrbufClear(edidName);
ffEdidGetName(edidData, edidName);
return true;
}
break;
}
}
ffStrbufClear(edidName);
return false;
}
FFDisplayType ffdsGetDisplayType(const char* name)
{
if(ffStrStartsWith(name, "eDP-") || ffStrStartsWith(name, "LVDS-"))
@@ -1,12 +1,7 @@
#pragma once
#ifndef FASTFETCH_INCLUDED_DISPLAYSERVER
#define FASTFETCH_INCLUDED_DISPLAYSERVER
#include "detection/displayserver/displayserver.h"
bool ffdsMatchDrmConnector(const char* connName, FFstrbuf* edidName);
const char* ffdsConnectWayland(FFDisplayServerResult* result);
const char* ffdsConnectXcbRandr(FFDisplayServerResult* result);
@@ -20,5 +15,3 @@ const char* ffdsConnectDrm(FFDisplayServerResult* result);
void ffdsDetectWMDE(FFDisplayServerResult* result);
FFDisplayType ffdsGetDisplayType(const char* drmConnectorName);
#endif
+73 -38
View File
@@ -22,7 +22,7 @@ static const char* drmParseSysfs(FFDisplayServerResult* result)
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, ".."))
if(entry->d_name[0] == '.')
continue;
ffStrbufAppendS(&drmDir, entry->d_name);
@@ -50,45 +50,54 @@ static const char* drmParseSysfs(FFDisplayServerResult* result)
ffStrbufSubstrBefore(&drmDir, drmDirWithDnameLength);
ffStrbufAppendS(&drmDir, "/edid");
uint8_t edidData[128];
if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) == sizeof(edidData))
const char* plainName = entry->d_name;
if (ffStrStartsWith(plainName, "card"))
{
const char* tmp = strchr(plainName + strlen("card"), '-');
if (tmp) plainName = tmp + 1;
}
uint8_t edidData[512];
ssize_t edidLength = ffReadFileData(drmDir.chars, ARRAY_SIZE(edidData), edidData);
if(edidLength <= 0 || edidLength % 128 != 0)
{
edidLength = 0;
ffStrbufSubstrBefore(&drmDir, drmDirWithDnameLength);
ffStrbufAppendS(&drmDir, "/modes");
char modes[32];
if (ffReadFileData(drmDir.chars, ARRAY_SIZE(modes), modes) >= 3)
{
sscanf(modes, "%ux%u", &width, &height);
ffStrbufAppendS(&name, plainName);
}
}
else
{
ffEdidGetName(edidData, &name);
ffEdidGetPreferredResolutionAndRefreshRate(edidData, &width, &height, &refreshRate);
ffEdidGetPhysicalSize(edidData, &physicalWidth, &physicalHeight);
}
else
{
ffStrbufSubstrBefore(&drmDir, drmDirWithDnameLength);
ffStrbufAppendS(&drmDir, "/modes");
char modes[32];
if (ffReadFileData(drmDir.chars, sizeof(modes), modes) >= 3)
{
sscanf(modes, "%ux%u", &width, &height);
const char* plainName = entry->d_name;
if (ffStrStartsWith(plainName, "card"))
{
const char* tmp = strchr(plainName + strlen("card"), '-');
if (tmp) plainName = tmp + 1;
}
ffStrbufAppendS(&name, plainName);
}
}
ffdsAppendDisplay(
FFDisplayResult* item = ffdsAppendDisplay(
result,
width, height,
refreshRate,
0, 0,
0,
&name,
FF_DISPLAY_TYPE_UNKNOWN,
ffdsGetDisplayType(plainName),
false,
0,
physicalWidth,
physicalHeight
physicalHeight,
"sysfs-drm"
);
if (item && edidLength)
{
item->hdrStatus = ffEdidGetHdrCompatible(edidData, (uint32_t) edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
ffEdidGetSerialAndManufactureDate(edidData, &item->serial, &item->manufactureYear, &item->manufactureWeek);
}
ffStrbufSubstrBefore(&drmDir, drmDirLength);
}
@@ -160,7 +169,7 @@ static inline const char* drmType2Name(uint32_t connector_type)
}
}
static const char* drmGetNameByConnId(uint32_t connId, FFstrbuf* name)
FF_MAYBE_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edidData, ssize_t* edidLength)
{
const char* drmDirPath = "/sys/class/drm/";
@@ -176,30 +185,28 @@ static const char* drmGetNameByConnId(uint32_t connId, FFstrbuf* name)
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, ".."))
if(entry->d_name[0] == '.')
continue;
ffStrbufAppendS(&drmDir, entry->d_name);
uint32_t drmDirWithDnameLength = drmDir.length;
char connectorId[16] = {};
ffStrbufAppendS(&drmDir, "/connector_id");
ffReadFileBuffer(drmDir.chars, name);
if (ffStrbufToUInt(name, 0) != connId)
ffReadFileData(drmDir.chars, ARRAY_SIZE(connectorId), connectorId);
if (strtoul(connectorId, NULL, 10) != connId)
{
ffStrbufSubstrBefore(&drmDir, drmDirLength);
continue;
}
ffStrbufSubstrBefore(&drmDir, drmDirWithDnameLength);
ffStrbufClear(name);
ffStrbufAppendS(&drmDir, "/edid");
uint8_t edidData[128];
if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) == sizeof(edidData))
ffEdidGetName(edidData, name);
*edidLength = ffReadFileData(drmDir.chars, (uint32_t) *edidLength, edidData);
return NULL;
}
ffStrbufClear(name);
return "Failed to match connector ID";
}
@@ -222,8 +229,8 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmFreeDevices)
drmDevice* devices[64];
int nDevices = ffdrmGetDevices(devices, sizeof(devices) / sizeof(devices[0]));
if (nDevices < 0)
int nDevices = ffdrmGetDevices(devices, ARRAY_SIZE(devices));
if (nDevices <= 0)
return "drmGetDevices() failed";
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
@@ -237,11 +244,13 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
const char* path = dev->nodes[DRM_NODE_PRIMARY];
#if __linux__
ffStrbufSetF(&name, "/sys/class/drm/%s/device/power/runtime_status", strrchr(path, '/') + 1);
char buffer[8] = "";
if (ffReadFileData(name.chars, strlen("suspend"), buffer) > 0 && ffStrStartsWith(buffer, "suspend"))
continue;
#endif
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0)
@@ -309,6 +318,9 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
ffStrbufClear(&name);
uint16_t myear = 0, mweak = 0;
uint32_t serial = 0;
FFDisplayHdrStatus hdrStatus = FF_DISPLAY_HDR_STATUS_UNKNOWN;
for (int iProp = 0; iProp < conn->count_props; ++iProp)
{
@@ -329,7 +341,11 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
if (blob)
{
if (blob->length >= 128)
{
ffEdidGetName(blob->data, &name);
hdrStatus = ffEdidGetHdrCompatible(blob->data, blob->length) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
ffEdidGetSerialAndManufactureDate(blob->data, &serial, &myear, &mweak);
}
ffdrmModeFreePropertyBlob(blob);
}
break;
@@ -337,10 +353,20 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
ffdrmModeFreeProperty(prop);
}
#if __linux__
if (name.length == 0)
{
drmGetNameByConnId(conn->connector_id, &name);
uint8_t edidData[512];
ssize_t edidLength = 0;
drmGetEdidByConnId(conn->connector_id, edidData, &edidLength);
if (edidLength > 0 && edidLength % 128 == 0)
{
ffEdidGetName(edidData, &name);
hdrStatus = ffEdidGetHdrCompatible(edidData, (uint32_t) edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
ffEdidGetSerialAndManufactureDate(edidData, &serial, &myear, &mweak);
}
}
#endif
if (name.length == 0)
{
@@ -350,7 +376,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
ffStrbufSetF(&name, "%s-%d", connectorTypeName, iConn + 1);
}
ffdsAppendDisplay(result,
FFDisplayResult* item = ffdsAppendDisplay(result,
width,
height,
refreshRate,
@@ -365,8 +391,17 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
false,
conn->connector_id,
conn->mmWidth,
conn->mmHeight
conn->mmHeight,
"libdrm"
);
if (item)
{
item->hdrStatus = hdrStatus;
item->serial = serial;
item->manufactureYear = myear;
item->manufactureWeek = mweak;
}
}
ffdrmModeFreeConnector(conn);
@@ -112,7 +112,7 @@ void ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* regist
uint32_t rotation = ffWaylandHandleRotation(&display);
ffdsAppendDisplay(wldata->result,
FFDisplayResult* item = ffdsAppendDisplay(wldata->result,
(uint32_t) display.width,
(uint32_t) display.height,
display.refreshRate / 1000.0,
@@ -129,8 +129,22 @@ void ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* regist
false,
display.id,
(uint32_t) display.physicalWidth,
(uint32_t) display.physicalHeight
(uint32_t) display.physicalHeight,
"wayland-global"
);
if (item)
{
if (display.hdrSupported)
item->hdrStatus = FF_DISPLAY_HDR_STATUS_SUPPORTED;
else if (display.hdrInfoAvailable)
item->hdrStatus = FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
else
item->hdrStatus = FF_DISPLAY_HDR_STATUS_UNKNOWN;
item->manufactureYear = display.myear;
item->manufactureWeek = display.mweek;
item->serial = display.serial;
}
ffStrbufDestroy(&display.description);
ffStrbufDestroy(&display.name);
@@ -80,6 +80,9 @@ static void waylandKdeEdidListener(void* data, FF_MAYBE_UNUSED struct kde_output
FF_STRBUF_AUTO_DESTROY edid = ffBase64DecodeStrbuf(&b64);
if (edid.length < 128) return;
ffEdidGetName((const uint8_t*) edid.chars, &wldata->edidName);
wldata->hdrSupported = ffEdidGetHdrCompatible((const uint8_t*) edid.chars, edid.length);
ffEdidGetSerialAndManufactureDate((const uint8_t*) edid.chars, &wldata->serial, &wldata->myear, &wldata->mweek);
wldata->hdrInfoAvailable = true;
}
static void waylandKdeEnabledListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, int32_t enabled)
@@ -109,6 +112,7 @@ static void waylandKdeNameListener(void* data, FF_MAYBE_UNUSED struct kde_output
{
WaylandDisplay* display = data;
display->type = ffdsGetDisplayType(name);
// As display->id is used as an internal identifier, we don't need it to be NUL terminated
strncpy((char*) &display->id, name, sizeof(display->id));
ffStrbufAppendS(&display->name, name);
}
@@ -191,11 +195,23 @@ void ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* registry,
false,
display.id,
(uint32_t) display.physicalWidth,
(uint32_t) display.physicalHeight
(uint32_t) display.physicalHeight,
"wayland-kde"
);
if (item)
{
item->hdrEnabled = display.hdrEnabled;
if (display.hdrEnabled)
item->hdrStatus = FF_DISPLAY_HDR_STATUS_ENABLED;
else if (display.hdrSupported)
item->hdrStatus = FF_DISPLAY_HDR_STATUS_SUPPORTED;
else if (display.hdrInfoAvailable)
item->hdrStatus = FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
else
item->hdrStatus = FF_DISPLAY_HDR_STATUS_UNKNOWN;
item->manufactureYear = display.myear;
item->manufactureWeek = display.mweek;
item->serial = display.serial;
}
ffStrbufDestroy(&display.description);
@@ -1,5 +1,6 @@
#include "../displayserver_linux.h"
#include "common/io/io.h"
#include "util/edidHelper.h"
#include "util/stringUtils.h"
#include <stdlib.h>
@@ -21,7 +22,7 @@
static bool waylandDetectWM(int fd, FFDisplayServerResult* result)
{
struct ucred ucred;
socklen_t len = sizeof(struct ucred);
socklen_t len = sizeof(ucred);
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1 || ucred.pid <= 0)
return false;
@@ -82,6 +83,46 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
}
}
static bool matchDrmConnector(const char* connName, WaylandDisplay* wldata)
{
// https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-event-name
// The doc says that "do not assume that the name is a reflection of an underlying DRM connector, X11 connection, etc."
// However I can't find a better method to get the edid data
const char* drmDirPath = "/sys/class/drm/";
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath);
if(dirp == NULL)
return false;
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
const char* plainName = entry->d_name;
if (ffStrStartsWith(plainName, "card"))
{
const char* tmp = strchr(plainName + strlen("card"), '-');
if (tmp) plainName = tmp + 1;
}
if (ffStrEquals(plainName, connName))
{
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateF("%s%s/edid", drmDirPath, entry->d_name);
uint8_t edidData[512];
ssize_t edidLength = ffReadFileData(path.chars, ARRAY_SIZE(edidData), edidData);
if (edidLength > 0 && edidLength % 128 == 0)
{
ffEdidGetName(edidData, &wldata->edidName);
ffEdidGetHdrCompatible(edidData, (uint32_t) edidLength);
ffEdidGetSerialAndManufactureDate(edidData, &wldata->serial, &wldata->myear, &wldata->mweek);
wldata->hdrInfoAvailable = true;
return true;
}
break;
}
}
return false;
}
void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const char *name)
{
WaylandDisplay* display = data;
@@ -89,7 +130,7 @@ void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const
display->type = ffdsGetDisplayType(name);
if (!display->edidName.length)
ffdsMatchDrmConnector(name, &display->edidName);
matchDrmConnector(name, display);
display->id = ffWaylandGenerateIdFromName(name);
ffStrbufAppendS(&display->name, name);
}
@@ -208,7 +249,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result)
FF_LIST_FOR_EACH(FFstrbuf, basePath, instance.state.platform.configDirs)
{
char path[1024];
snprintf(path, sizeof(path) - 1, "%s%s", basePath->chars, fileName);
snprintf(path, ARRAY_SIZE(path) - 1, "%s%s", basePath->chars, fileName);
if (ffReadFileBuffer(path, &monitorsXml))
break;
}
@@ -46,7 +46,12 @@ typedef struct WaylandDisplay
FFstrbuf description;
FFstrbuf edidName;
uint64_t id;
bool hdrInfoAvailable;
bool hdrSupported;
bool hdrEnabled;
uint16_t myear;
uint16_t mweek;
uint32_t serial;
void* internal;
} WaylandDisplay;
@@ -122,7 +122,7 @@ static void waylandHandleZwlrHead(void *data, FF_MAYBE_UNUSED struct zwlr_output
uint32_t rotation = ffWaylandHandleRotation(&display);
ffdsAppendDisplay(wldata->result,
FFDisplayResult* item = ffdsAppendDisplay(wldata->result,
(uint32_t) display.width,
(uint32_t) display.height,
display.refreshRate / 1000.0,
@@ -138,8 +138,22 @@ static void waylandHandleZwlrHead(void *data, FF_MAYBE_UNUSED struct zwlr_output
false,
display.id,
(uint32_t) display.physicalWidth,
(uint32_t) display.physicalHeight
(uint32_t) display.physicalHeight,
"wayland-zwlr"
);
if (item)
{
if (display.hdrSupported)
item->hdrStatus = FF_DISPLAY_HDR_STATUS_SUPPORTED;
else if (display.hdrInfoAvailable)
item->hdrStatus = FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
else
item->hdrStatus = FF_DISPLAY_HDR_STATUS_UNKNOWN;
item->manufactureYear = display.myear;
item->manufactureWeek = display.mweek;
item->serial = display.serial;
}
ffStrbufDestroy(&display.description);
ffStrbufDestroy(&display.name);
+28 -5
View File
@@ -12,6 +12,10 @@
#include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/user.h>
#elif defined(__OpenBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#include <kvm.h>
#elif defined(__sun)
#include <procfs.h>
#endif
@@ -252,15 +256,15 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
{
uint32_t userId = getuid();
#ifdef __FreeBSD__
#if __FreeBSD__
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId};
size_t length = 0;
if(sysctl(request, sizeof(request) / sizeof(*request), NULL, &length, NULL, 0) != 0)
if(sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0)
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, NULL) failed";
FF_AUTO_FREE struct kinfo_proc* procs = (struct kinfo_proc*) malloc(length);
if(sysctl(request, sizeof(request) / sizeof(*request), procs, &length, NULL, 0) != 0)
if(sysctl(request, ARRAY_SIZE(request), procs, &length, NULL, 0) != 0)
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_UID}, procs) failed";
length /= sizeof(*procs);
@@ -276,7 +280,26 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0)
break;
}
#elif defined(__sun)
#elif __OpenBSD__
kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL);
int count = 0;
const struct kinfo_proc* proc = kvm_getprocs(kd, KERN_PROC_UID, userId, sizeof(*proc), &count);
if (proc)
{
for (int i = 0; i < count; ++i)
{
if(result->dePrettyName.length == 0)
applyPrettyNameIfDE(result, proc->p_comm);
if(result->wmPrettyName.length == 0)
applyNameIfWM(result, proc->p_comm);
if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0)
break;
}
}
kvm_close(kd);
#elif __sun
FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc");
if(procdir == NULL)
return "opendir(\"/proc\") failed";
@@ -312,7 +335,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
break;
}
}
#else
#elif __linux__
FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc");
if(procdir == NULL)
return "opendir(\"/proc\") failed";
+36 -38
View File
@@ -118,7 +118,8 @@ const char* ffdsConnectXcb(FFDisplayServerResult* result)
false,
0,
(uint32_t) screen->width_in_millimeters,
(uint32_t) screen->height_in_millimeters
(uint32_t) screen->height_in_millimeters,
"xcb"
);
ffxcb_screen_next(&iterator);
}
@@ -180,47 +181,29 @@ typedef struct XcbRandrData
xcb_randr_get_screen_resources_current_reply_t* screenResources;
} XcbRandrData;
static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* modeInfo, FFstrbuf* name, uint32_t rotation, bool primary, xcb_randr_get_output_info_reply_t* output, FFDisplayType displayType)
{
double refreshRate = (double) modeInfo->dot_clock / (double) (modeInfo->htotal * modeInfo->vtotal);
return ffdsAppendDisplay(
data->result,
(uint32_t) modeInfo->width,
(uint32_t) modeInfo->height,
refreshRate,
(uint32_t) modeInfo->width,
(uint32_t) modeInfo->height,
rotation,
name,
displayType,
primary,
0,
(uint32_t) output->mm_width,
(uint32_t) output->mm_height
);
}
static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrbuf* name, uint32_t rotation, bool primary, xcb_randr_get_output_info_reply_t* output, FFDisplayType displayType)
static double xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode)
{
//We do the check here, because we want the best fallback display if this call failed
if(data->screenResources == NULL)
return false;
return 0;
xcb_randr_mode_info_iterator_t modesIterator = data->ffxcb_randr_get_screen_resources_current_modes_iterator(data->screenResources);
while(modesIterator.rem > 0)
{
if(modesIterator.data->id == mode)
return xcbRandrHandleModeInfo(data, modesIterator.data, name, rotation, primary, output, displayType);
{
xcb_randr_mode_info_t* modeInfo = modesIterator.data;
return (double) modeInfo->dot_clock / (double) (modeInfo->htotal * modeInfo->vtotal);
}
data->ffxcb_randr_mode_info_next(&modesIterator);
}
return false;
return 0;
}
static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrbuf* name, bool primary, xcb_randr_get_output_info_reply_t* output, FFDisplayType displayType)
static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrbuf* name, bool primary, xcb_randr_get_output_info_reply_t* output, FFDisplayType displayType, uint8_t* edidData, uint32_t edidLength)
{
xcb_randr_get_crtc_info_cookie_t crtcInfoCookie = data->ffxcb_randr_get_crtc_info(data->connection, crtc, XCB_CURRENT_TIME);
FF_AUTO_FREE xcb_randr_get_crtc_info_reply_t* crtcInfoReply = data->ffxcb_randr_get_crtc_info_reply(data->connection, crtcInfoCookie, NULL);
@@ -243,12 +226,12 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb
rotation = 0;
break;
}
bool res = xcbRandrHandleMode(data, crtcInfoReply->mode, name, rotation, primary, output, displayType);
res = res ? true : !!ffdsAppendDisplay(
FFDisplayResult* item = ffdsAppendDisplay(
data->result,
(uint32_t) crtcInfoReply->width,
(uint32_t) crtcInfoReply->height,
0,
xcbRandrHandleMode(data, crtcInfoReply->mode),
(uint32_t) crtcInfoReply->width,
(uint32_t) crtcInfoReply->height,
rotation,
@@ -257,10 +240,17 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb
primary,
0,
(uint32_t) output->mm_width,
(uint32_t) output->mm_height
(uint32_t) output->mm_height,
"xcb-randr-crtc"
);
if (item && edidLength)
{
item->hdrStatus = ffEdidGetHdrCompatible(edidData, (uint32_t) edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
ffEdidGetSerialAndManufactureDate(edidData, &item->serial, &item->manufactureYear, &item->manufactureWeek);
ffEdidGetPhysicalSize(edidData, &item->physicalWidth, &item->physicalHeight);
}
return res;
return !!item;
}
static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name, bool primary, FFDisplayType displayType)
@@ -272,21 +262,27 @@ static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output,
xcb_intern_atom_cookie_t requestAtomCookie = data->ffxcb_intern_atom(data->connection, true, (uint16_t) strlen("EDID"), "EDID");
FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(data->connection, requestAtomCookie, NULL);
FF_AUTO_FREE xcb_randr_get_output_property_reply_t* outputPropertyReply = NULL;
uint8_t* edidData = NULL;
uint32_t edidLength = 0;
if(requestAtomReply)
{
xcb_randr_get_output_property_cookie_t outputPropertyCookie = data->ffxcb_randr_get_output_property(data->connection, output, requestAtomReply->atom, XCB_GET_PROPERTY_TYPE_ANY, 0, 100, false, false);
FF_AUTO_FREE xcb_randr_get_output_property_reply_t* outputPropertyReply = data->ffxcb_randr_get_output_property_reply(data->connection, outputPropertyCookie, NULL);
outputPropertyReply = data->ffxcb_randr_get_output_property_reply(data->connection, outputPropertyCookie, NULL);
if(outputPropertyReply)
{
if(data->ffxcb_randr_get_output_property_data_length(outputPropertyReply) >= 128)
int len = data->ffxcb_randr_get_output_property_data_length(outputPropertyReply);
if(len >= 128)
{
ffStrbufClear(name);
ffEdidGetName(data->ffxcb_randr_get_output_property_data(outputPropertyReply), name);
edidData = data->ffxcb_randr_get_output_property_data(outputPropertyReply);
ffEdidGetName(edidData, name);
edidLength = (uint32_t) len;
}
}
}
bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name, primary, outputInfoReply, displayType);
bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name, primary, outputInfoReply, displayType, edidData, edidLength);
return res;
}
@@ -333,7 +329,8 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
!!monitor->primary,
0,
(uint32_t) monitor->width_in_millimeters,
(uint32_t) monitor->height_in_millimeters
(uint32_t) monitor->height_in_millimeters,
"xcb-randr-monitor"
);
}
@@ -387,7 +384,8 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
false,
0,
(uint32_t) screen->width_in_millimeters,
(uint32_t) screen->height_in_millimeters
(uint32_t) screen->height_in_millimeters,
"xcb-randr-screen"
);
}
+30 -15
View File
@@ -89,7 +89,8 @@ const char* ffdsConnectXlib(FFDisplayServerResult* result)
false,
0,
(uint32_t) WidthMMOfScreen(screen),
(uint32_t) HeightMMOfScreen(screen)
(uint32_t) HeightMMOfScreen(screen),
"xlib"
);
}
@@ -153,13 +154,13 @@ static double xrandrHandleMode(XrandrData* data, RRMode mode)
return 0;
}
static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, FFstrbuf* name, bool primary, XRROutputInfo* output, FFDisplayType displayType)
static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf* name, bool primary, FFDisplayType displayType, uint8_t* edidData, uint32_t edidLength)
{
//We do the check here, because we want the best fallback display if this call failed
if(data->screenResources == NULL)
return false;
XRRCrtcInfo* crtcInfo = data->ffXRRGetCrtcInfo(data->display, data->screenResources, crtc);
XRRCrtcInfo* crtcInfo = data->ffXRRGetCrtcInfo(data->display, data->screenResources, output->crtc);
if(crtcInfo == NULL)
return false;
@@ -180,7 +181,7 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, FFstrbuf* name, bool
break;
}
bool res = ffdsAppendDisplay(
FFDisplayResult* item = ffdsAppendDisplay(
data->result,
(uint32_t) crtcInfo->width,
(uint32_t) crtcInfo->height,
@@ -193,11 +194,19 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, FFstrbuf* name, bool
primary,
0,
(uint32_t) output->mm_width,
(uint32_t) output->mm_height
(uint32_t) output->mm_height,
"xlib-randr-crtc"
);
if (edidLength)
{
item->hdrStatus = ffEdidGetHdrCompatible(edidData, edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED;
ffEdidGetSerialAndManufactureDate(edidData, &item->serial, &item->manufactureYear, &item->manufactureWeek);
ffEdidGetPhysicalSize(edidData, &item->physicalWidth, &item->physicalHeight);
}
data->ffXRRFreeCrtcInfo(crtcInfo);
return res;
return !!item;
}
static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name, bool primary, FFDisplayType displayType)
@@ -206,26 +215,30 @@ static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name
if(outputInfo == NULL)
return false;
uint8_t* edidData = NULL;
unsigned long edidLength = 0;
Atom atomEdid = data->ffXInternAtom(data->display, "EDID", true);
if (atomEdid != None)
{
int actual_format = 0;
unsigned long nitems = 0, bytes_after = 0;
unsigned long bytes_after = 0;
Atom actual_type = None;
uint8_t* edidData = NULL;
if (data->ffXRRGetOutputProperty(data->display, output, atomEdid, 0, 100, false, false, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &edidData) == Success)
if (data->ffXRRGetOutputProperty(data->display, output, atomEdid, 0, 100, false, false, AnyPropertyType, &actual_type, &actual_format, &edidLength, &bytes_after, &edidData) == Success)
{
if (nitems >= 128)
if (edidLength >= 128)
{
ffStrbufClear(name);
ffEdidGetName(edidData, name);
}
else
edidLength = 0;
}
if (edidData)
data->ffXFree(edidData);
}
bool res = xrandrHandleCrtc(data, outputInfo->crtc, name, primary, outputInfo, displayType);
bool res = xrandrHandleCrtc(data, outputInfo, name, primary, displayType, edidData, (uint32_t) edidLength);
if (edidData)
data->ffXFree(edidData);
data->ffXRRFreeOutputInfo(outputInfo);
return res;
@@ -257,7 +270,8 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
!!monitorInfo->primary,
0,
(uint32_t) monitorInfo->mwidth,
(uint32_t) monitorInfo->mheight
(uint32_t) monitorInfo->mheight,
"xlib-randr-monitor"
);
}
@@ -307,7 +321,8 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
false,
0,
(uint32_t) WidthMMOfScreen(screen),
(uint32_t) HeightMMOfScreen(screen)
(uint32_t) HeightMMOfScreen(screen),
"xlib_randr_screen"
);
}
+4 -1
View File
@@ -17,11 +17,14 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results)
{
if (ffStrStartsWith(line, "nameserver"))
{
const char* nameserver = line + strlen("nameserver");
char* nameserver = line + strlen("nameserver");
while (*nameserver == ' ' || *nameserver == '\t')
nameserver++;
if (*nameserver == '\0') continue;
char* comment = strchr(nameserver, '#');
if (comment) *comment = '\0';
if ((ffStrContainsC(nameserver, ':') && !(options->showType & FF_DNS_TYPE_IPV6_BIT)) ||
(ffStrContainsC(nameserver, '.') && !(options->showType & FF_DNS_TYPE_IPV4_BIT)))
continue;
+1 -1
View File
@@ -11,7 +11,7 @@ static void generateString(FFFontResult* font)
ffStrbufAppend(&font->display, &font->fonts[0]);
ffStrbufAppendS(&font->display, " [Qt]");
for(uint8_t i = 1; i < sizeof(font->fonts) / sizeof(font->fonts[0]); i++)
for(uint8_t i = 1; i < ARRAY_SIZE(font->fonts); i++)
{
if(font->fonts[i].length > 0)
{
+2 -2
View File
@@ -6,7 +6,7 @@
static void generateString(FFFontResult* font)
{
const char* types[] = { "Caption", "Menu", "Message", "Status" };
for(uint32_t i = 0; i < sizeof(types) / sizeof(types[0]); ++i)
for(uint32_t i = 0; i < ARRAY_SIZE(types); ++i)
{
if(i == 0 || !ffStrbufEqual(&font->fonts[i - 1], &font->fonts[i]))
{
@@ -31,7 +31,7 @@ const char* ffDetectFontImpl(FFFontResult* result)
LOGFONTW* fonts[4] = { &info.lfCaptionFont, &info.lfMenuFont, &info.lfMessageFont, &info.lfStatusFont };
for(uint32_t i = 0; i < sizeof(fonts) / sizeof(fonts[0]); ++i)
for(uint32_t i = 0; i < ARRAY_SIZE(fonts); ++i)
{
ffStrbufSetWS(&result->fonts[i], fonts[i]->lfFaceName);
if(fonts[i]->lfHeight < 0)
+4 -3
View File
@@ -13,7 +13,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
char path[16];
for (int i = 0; i < MAX_UHID_JOYS; i++)
{
snprintf(path, sizeof(path), "/dev/uhid%d", i);
snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i);
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) continue;
@@ -31,8 +31,9 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
if (HID_PAGE(hItem.usage) != 1) continue;
switch (HID_USAGE(hItem.usage))
{
case 1: // FreeBSD returns 1 for my Pro Controller for some reason
case 5:
case 1: // Pointer. FreeBSD returns 1 for my Pro Controller for some reason
case 4: // Joystick
case 5: // Gamepad
break;
default:
continue;
+3 -3
View File
@@ -28,7 +28,7 @@ static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path)
ffStrbufAppendS(path, entry->d_name);
ffStrbufAppendS(path, "/capacity"); // /sys/class/input/jsX/device/device/power_supply/XXX/capacity
char capacity[32];
ssize_t nRead = ffReadFileData(path->chars, sizeof(capacity) - 1, capacity);
ssize_t nRead = ffReadFileData(path->chars, ARRAY_SIZE(capacity) - 1, capacity);
if (nRead > 0) // Tested with a PS4 controller
{
capacity[nRead] = '\0';
@@ -37,7 +37,7 @@ static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path)
}
ffStrbufAppendS(path, "_level");
nRead = ffReadFileData(path->chars, sizeof(capacity) - 1, capacity);
nRead = ffReadFileData(path->chars, ARRAY_SIZE(capacity) - 1, capacity);
if (nRead > 0) // Tested with a NS Pro controller
{
// https://github.com/torvalds/linux/blob/52b1853b080a082ec3749c3a9577f6c71b1d4a90/drivers/power/supply/power_supply_sysfs.c#L124
@@ -68,7 +68,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
{
if (!ffStrStartsWith(entry->d_name, "js"))
continue;
if (!ffCharIsDigit(entry->d_name[2]))
if (!ffCharIsDigit(entry->d_name[strlen("js")]))
continue;
ffStrbufAppendS(&path, entry->d_name);
+9 -9
View File
@@ -78,7 +78,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
for (UINT i = 0; i < nDevices; ++i)
{
if (pRawInputDeviceList[i].dwType != 2) continue;
if (pRawInputDeviceList[i].dwType != RIM_TYPEHID) continue;
HANDLE hDevice = pRawInputDeviceList[i].hDevice;
@@ -87,7 +87,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
if (GetRawInputDeviceInfoW(hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) == (UINT) -1)
continue;
if (rdi.hid.usUsagePage != 1 || rdi.hid.usUsage != 5) // Gamepad
if (rdi.hid.usUsagePage != 1 || (rdi.hid.usUsage != 4/*Joystick*/ && rdi.hid.usUsage != 5/*Gamepad*/))
continue;
WCHAR devName[MAX_PATH] = L"";
@@ -104,7 +104,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
if (knownGamepad)
ffStrbufSetS(&device->name, knownGamepad);
HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (!hHidFile)
if (hHidFile == INVALID_HANDLE_VALUE)
{
if (!knownGamepad)
ffStrbufSetF(&device->name, "Unknown gamepad %04X-%04X", (unsigned) rdi.hid.dwVendorId, (unsigned) rdi.hid.dwProductId);
@@ -114,10 +114,10 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
if (!knownGamepad)
{
wchar_t displayName[126];
if (HidD_GetProductString(hHidFile, displayName, sizeof(displayName)))
if (HidD_GetProductString(hHidFile, displayName, sizeof(displayName) /*in bytes*/))
{
wchar_t manufacturer[126];
if (HidD_GetManufacturerString(hHidFile, manufacturer, sizeof(manufacturer)))
if (HidD_GetManufacturerString(hHidFile, manufacturer, sizeof(manufacturer) /*in bytes*/))
{
ffStrbufSetWS(&device->name, manufacturer);
FF_STRBUF_AUTO_DESTROY displayNameStr = ffStrbufCreateWS(displayName);
@@ -131,6 +131,10 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
}
}
wchar_t serialNumber[127] = L"";
if (HidD_GetSerialNumberString(hHidFile, serialNumber, sizeof(serialNumber) /*in bytes*/))
ffStrbufSetWS(&device->serial, serialNumber);
PHIDP_PREPARSED_DATA preparsedData = NULL;
if (HidD_GetPreparsedData(hHidFile, &preparsedData))
{
@@ -140,10 +144,6 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
if (!NT_SUCCESS(capsResult))
continue;
wchar_t serialNumber[127] = L"";
if (HidD_GetSerialNumberString(hHidFile, serialNumber, sizeof(serialNumber)))
ffStrbufSetWS(&device->serial, serialNumber);
if (
(rdi.hid.dwVendorId == 0x054C && (
rdi.hid.dwProductId == 0x05C4 || // PS4 Gen1
+1 -1
View File
@@ -76,7 +76,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD)
{
char query[32];
snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) pc->pc_device, (unsigned) pc->pc_revid);
snprintf(query, ARRAY_SIZE(query), "%X,\t%X,", (unsigned) pc->pc_device, (unsigned) pc->pc_revid);
ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name);
}
if (gpu->name.length == 0)
+3 -3
View File
@@ -128,7 +128,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
if (result.memory)
{
ctl_mem_handle_t memoryModules[16];
uint32_t memoryCount = sizeof(memoryModules) / sizeof(memoryModules[0]);
uint32_t memoryCount = ARRAY_SIZE(memoryModules);
if (igclData.ffctlEnumMemoryModules(device, &memoryCount, memoryModules) == CTL_RESULT_SUCCESS && memoryCount > 0)
{
result.memory->used = 0;
@@ -157,7 +157,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
if (result.temp)
{
ctl_temp_handle_t sensors[16];
uint32_t sensorCount = sizeof(sensors) / sizeof(sensors[0]);
uint32_t sensorCount = ARRAY_SIZE(sensors);
if (igclData.ffctlEnumTemperatureSensors(device, &sensorCount, sensors) == CTL_RESULT_SUCCESS && sensorCount > 0)
{
double sumValue = 0;
@@ -178,7 +178,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
if (result.frequency)
{
ctl_freq_handle_t domains[16];
uint32_t domainCount = sizeof(domains) / sizeof(domains[0]);
uint32_t domainCount = ARRAY_SIZE(domains);
if (igclData.ffctlEnumFrequencyDomains(device, &domainCount, domains) == CTL_RESULT_SUCCESS && domainCount > 0)
{
double maxValue = 0;
+17 -9
View File
@@ -32,7 +32,7 @@ static bool pciDetectDriver(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer
uint32_t pciDirLength = pciDir->length;
ffStrbufAppendS(pciDir, "/driver");
char pathBuf[PATH_MAX];
ssize_t resultLength = readlink(pciDir->chars, pathBuf, sizeof(pathBuf));
ssize_t resultLength = readlink(pciDir->chars, pathBuf, ARRAY_SIZE(pathBuf));
if(resultLength <= 0) return false;
const char* slash = memrchr(pathBuf, '/', (size_t) resultLength);
@@ -78,7 +78,7 @@ static bool pciDetectDriver(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer
return true;
}
static const char* drmFindRenderFromCard(const char* drmCardKey, FFstrbuf* result)
FF_MAYBE_UNUSED static const char* drmFindRenderFromCard(const char* drmCardKey, FFstrbuf* result)
{
char path[PATH_MAX];
sprintf(path, "/sys/class/drm/%s/device/drm", drmCardKey);
@@ -395,6 +395,7 @@ static const char* drmDetectIntelSpecific(FFGPUResult* gpu, const char* drmKey,
}
return NULL;
#else
FF_UNUSED(gpu, drmKey, buffer);
return "Fastfetch is not compiled with drm support";
#endif
}
@@ -414,7 +415,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
const char* pPciPath = NULL;
if (drmKey)
{
ssize_t pathLength = readlink(deviceDir->chars, pciPath, sizeof(pciPath) - 1);
ssize_t pathLength = readlink(deviceDir->chars, pciPath, ARRAY_SIZE(pciPath) - 1);
if (pathLength <= 0)
return "Unable to get PCI device path";
pciPath[pathLength] = '\0';
@@ -459,8 +460,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
{
if (ffStrStartsWith(entry->d_name, "card"))
{
strncpy(drmKeyBuffer, entry->d_name, sizeof(drmKeyBuffer) - 1);
drmKeyBuffer[sizeof(drmKeyBuffer) - 1] = '\0';
ffStrCopyN(drmKeyBuffer, entry->d_name, ARRAY_SIZE(drmKeyBuffer));
drmKey = drmKeyBuffer;
break;
}
@@ -493,7 +493,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
if (pend != buffer->chars)
{
char query[32];
snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision);
snprintf(query, ARRAY_SIZE(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision);
#ifdef FF_CUSTOM_AMDGPU_IDS_PATH
ffParsePropFile(FF_STR(FF_CUSTOM_AMDGPU_IDS_PATH), query, &gpu->name);
#else
@@ -625,7 +625,7 @@ FF_MAYBE_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, cons
static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, const char* drmKey)
{
char compatible[256]; // vendor,model-name
if (sscanf(buffer->chars + strlen("of:"), "NgpuT%*[^C]C%256[^C]", compatible) != 1)
if (sscanf(buffer->chars + strlen("of:"), "NgpuT%*[^C]C%255[^C]", compatible) != 1)
return "Failed to parse of modalias or not a GPU device";
char* name = strchr(compatible, ',');
@@ -657,11 +657,19 @@ static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, co
#endif
if (!gpu->name.length)
{
ffStrbufSetS(&gpu->name, name ? name : compatible);
ffStrbufTrimRightSpace(&gpu->name);
}
if (!gpu->vendor.length && name)
{
compatible[0] = (char) toupper(compatible[0]);
ffStrbufSetS(&gpu->vendor, compatible);
if (ffStrEquals(compatible, "brcm"))
ffStrbufSetStatic(&gpu->vendor, "Broadcom"); // Raspberry Pi
else
{
ffStrbufSetS(&gpu->vendor, compatible);
gpu->vendor.chars[0] = (char) toupper(compatible[0]);
}
}
return NULL;
+2 -2
View File
@@ -86,7 +86,7 @@ const char *ffDetectMthreadsGpuInfo(const FFGpuDriverCondition *cond, FFGpuDrive
if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID)
{
char pciBusIdStr[32];
snprintf(pciBusIdStr, sizeof(pciBusIdStr) - 1, "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func);
snprintf(pciBusIdStr, ARRAY_SIZE(pciBusIdStr) - 1, "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func);
MtmlReturn ret = mtmlData.ffmtmlLibraryInitDeviceByPciSbdf(mtmlData.lib, pciBusIdStr, &device);
if (ret != MTML_SUCCESS)
@@ -195,7 +195,7 @@ const char *ffDetectMthreadsGpuInfo(const FFGpuDriverCondition *cond, FFGpuDrive
if (result.name)
{
char name[MTML_DEVICE_NAME_BUFFER_SIZE];
if (mtmlData.ffmtmlDeviceGetName(device, name, sizeof(name)) == MTML_SUCCESS)
if (mtmlData.ffmtmlDeviceGetName(device, name, ARRAY_SIZE(name)) == MTML_SUCCESS)
ffStrbufSetS(result.name, name);
}
+2 -2
View File
@@ -59,7 +59,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID)
{
char pciBusIdStr[32];
snprintf(pciBusIdStr, sizeof(pciBusIdStr) - 1, "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func);
snprintf(pciBusIdStr, ARRAY_SIZE(pciBusIdStr) - 1, "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func);
nvmlReturn_t ret = nvmlData.ffnvmlDeviceGetHandleByPciBusId_v2(pciBusIdStr, &device);
if (ret != NVML_SUCCESS)
@@ -148,7 +148,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
if (result.name)
{
char name[NVML_DEVICE_NAME_V2_BUFFER_SIZE];
if (nvmlData.ffnvmlDeviceGetName(device, name, sizeof(name)) == NVML_SUCCESS)
if (nvmlData.ffnvmlDeviceGetName(device, name, ARRAY_SIZE(name)) == NVML_SUCCESS)
ffStrbufSetS(result.name, name);
}
+3 -3
View File
@@ -55,7 +55,7 @@ static void parsePciIdsFile(const FFstrbuf* content, uint8_t subclass, uint16_t
char buffer[32];
// Search for vendor
uint32_t len = (uint32_t) snprintf(buffer, sizeof(buffer), "\n%04x ", vendor);
uint32_t len = (uint32_t) snprintf(buffer, ARRAY_SIZE(buffer), "\n%04x ", vendor);
char* start = (char*) memmem(content->chars, content->length, buffer, len);
char* end = content->chars + content->length;
if (start)
@@ -83,7 +83,7 @@ static void parsePciIdsFile(const FFstrbuf* content, uint8_t subclass, uint16_t
}
// Search for device
len = (uint32_t) snprintf(buffer, sizeof(buffer), "\n\t%04x ", device);
len = (uint32_t) snprintf(buffer, ARRAY_SIZE(buffer), "\n\t%04x ", device);
start = memmem(start, (size_t) (end - start), buffer, len);
if (start)
{
@@ -138,7 +138,7 @@ static bool loadPciidsInc(uint8_t subclass, uint16_t vendor, uint16_t device, FF
if (!gpu->vendor.length)
ffStrbufSetS(&gpu->vendor, pvendor->name);
const FFPciDevice* pdevice = (const FFPciDevice*) bsearch(&device, pvendor->devices, pvendor->nDevices, sizeof(FFPciDevice), (void*) pciDeviceCmp);
const FFPciDevice* pdevice = (const FFPciDevice*) bsearch(&device, pvendor->devices, pvendor->nDevices, sizeof(*pdevice), (void*) pciDeviceCmp);
if (pdevice)
{
+1 -1
View File
@@ -67,7 +67,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD)
{
char query[32];
snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision);
snprintf(query, ARRAY_SIZE(query), "%X,\t%X,", (unsigned) deviceId, (unsigned) revision);
ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name);
}
+6 -3
View File
@@ -47,7 +47,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
gpu->deviceId = 0;
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
uint32_t pciBus, pciAddr, pciDev, pciFunc;
uint32_t pciBus = 0, pciAddr = UINT32_MAX, pciDev = 0, pciFunc = 0;
if (SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_BUSNUMBER, NULL, (PBYTE) &pciBus, sizeof(pciBus), NULL) &&
SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_ADDRESS, NULL, (PBYTE) &pciAddr, sizeof(pciAddr), NULL))
{
@@ -92,7 +92,10 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
gpu->shared.total = sharedSystemMemory;
}
ffRegReadUint64(hDirectxKey, L"AdapterLuid", &adapterLuid, NULL);
if (ffRegReadUint64(hDirectxKey, L"AdapterLuid", &adapterLuid, NULL))
{
if (!gpu->deviceId) gpu->deviceId = adapterLuid;
}
uint32_t featureLevel = 0;
if(ffRegReadUint(hDirectxKey, L"MaxD3D12FeatureLevel", &featureLevel, NULL) && featureLevel)
@@ -151,7 +154,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
&(FFGpuDriverCondition) {
.type = FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID
| (adapterLuid > 0 ? FF_GPU_DRIVER_CONDITION_TYPE_LUID : 0)
| (vendorId > 0 ? FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID : 0),
| (pciAddr > 0 ? FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID : 0),
.pciDeviceId = {
.deviceId = deviceId,
.vendorId = vendorId,
+1 -1
View File
@@ -1,6 +1,6 @@
#include "host.h"
const char* ffDetectHost(FFHostResult* host)
const char* ffDetectHost(FF_MAYBE_UNUSED FFHostResult* host)
{
return "Not supported on this platform";
}

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