mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Compare commits
107 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3247aabd74 | |||
| 312d4cc518 | |||
| b24877af0b | |||
| 1de97fa3ed | |||
| 6ca65b9166 | |||
| b2cc5c4f04 | |||
| f683351fe3 | |||
| d81cd50f64 | |||
| 1101d2e90e | |||
| 8284d73cc9 | |||
| 6b0db6fa74 | |||
| 3a61b31e0a | |||
| 493cf8ff6c | |||
| e6cf7fdb9f | |||
| 831d2a05ce | |||
| d0b72c5457 | |||
| 0c82a84266 | |||
| d501c8b41a | |||
| 0354fd5d9d | |||
| a856350416 | |||
| 4efe12c0d2 | |||
| 1a66bc4ec0 | |||
| d96d794d1f | |||
| 45659854d2 | |||
| b111626fe9 | |||
| dccbdba242 | |||
| 884fd097c6 | |||
| 08dea9fe21 | |||
| 98fc793386 | |||
| 121e9b911e | |||
| b9fe2fb4dd | |||
| 812a13c871 | |||
| dcbfae7f72 | |||
| 65883766a0 | |||
| 104cb43158 | |||
| 114cc753d9 | |||
| d68c4cef13 | |||
| c549a5cab8 | |||
| cbf8fdf3fc | |||
| 1e8b9aa461 | |||
| 5d32eba1a6 | |||
| 2ce7c8c60d | |||
| 7eaaed6024 | |||
| bd5012edc8 | |||
| cf0d1cf294 | |||
| a070519721 | |||
| fa0007ac6f | |||
| ced67e81a5 | |||
| 88a7468489 | |||
| ec8391f6c6 | |||
| 4371e719ae | |||
| bbbb493cdf | |||
| 6cb565e379 | |||
| 2bb988a7f8 | |||
| 0929b940c8 | |||
| c14ba32b82 | |||
| 7a75615d9e | |||
| 96c58148f6 | |||
| 2c7cd6df98 | |||
| db1fbe0a30 | |||
| a102f0505c | |||
| 8a3af14d22 | |||
| ce648e9e44 | |||
| 2cc94ee095 | |||
| 16dd9fb213 | |||
| 873285b083 | |||
| ce43f06863 | |||
| 3c92e7013d | |||
| 8e5017aa3a | |||
| dc89336fc1 | |||
| 952152edf0 | |||
| 6862747c48 | |||
| f91be6442d | |||
| bdce8ea3a1 | |||
| 44c8fa0470 | |||
| 9f9a5ba39a | |||
| 7c37d719e5 | |||
| cc78d6b16c | |||
| e7b7645f08 | |||
| 6a17ef6a54 | |||
| 5b687727c0 | |||
| 9b038dc848 | |||
| 597dd32caf | |||
| 8d08a65611 | |||
| 263c54a81e | |||
| cba5560068 | |||
| 0703b2b88f | |||
| 86e5572a7e | |||
| 3b3c1a9f63 | |||
| 14b9e88a82 | |||
| bee7c62000 | |||
| 8fa4d7ae6e | |||
| 640d0666fc | |||
| 165b0b0a69 | |||
| dc216362d5 | |||
| 57ffe3bad2 | |||
| cdee6e2997 | |||
| fb03c95d68 | |||
| 5b76a0b45a | |||
| fa5a74c746 | |||
| 4c6e14bcc2 | |||
| deacecdc11 | |||
| 83dcdaa726 | |||
| 2c29465f69 | |||
| f3e48a00a0 | |||
| 9559db556d | |||
| b89eeaa954 |
+1
-1
@@ -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
|
||||
ignore-words-list = iterm,compiletime,unknwn,pengwin,siduction,master,sur,doas,conexant
|
||||
|
||||
@@ -15,6 +15,9 @@ Paste content of /etc/os-release and /etc/lsb-release here. If none of these fil
|
||||
```
|
||||
|
||||
# Ascii
|
||||
|
||||
An ASCII logo should not take up too much space (smaller than 50x20 characters). Please also include the color codes if not available in `os-release`
|
||||
|
||||
```
|
||||
Paste ascii art here.
|
||||
```
|
||||
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
run: uname -a
|
||||
|
||||
- name: configure project
|
||||
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_XFCONF=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OSMESA=OFF -DENABLE_OPENCL=OFF -DENABLE_LIBNM=OFF -DENABLE_FREETYPE=OFF -DENABLE_PULSE=OFF -DENABLE_DDCUTIL=OFF -DENABLE_DIRECTX_HEADERS=OFF -DENABLE_THREADS=OFF
|
||||
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_XFCONF=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OSMESA=OFF -DENABLE_OPENCL=OFF -DENABLE_FREETYPE=OFF -DENABLE_PULSE=OFF -DENABLE_DDCUTIL=OFF -DENABLE_DIRECTX_HEADERS=OFF -DENABLE_THREADS=OFF
|
||||
|
||||
- name: build project
|
||||
run: cmake --build . --target package --verbose -j4
|
||||
@@ -74,7 +74,7 @@ jobs:
|
||||
run: uname -a
|
||||
|
||||
- name: install required packages
|
||||
run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev directx-headers-dev
|
||||
run: sudo apt-get update && sudo apt-get install -y libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev directx-headers-dev
|
||||
|
||||
- name: install linuxbrew packages
|
||||
run: |
|
||||
@@ -138,11 +138,11 @@ jobs:
|
||||
id: runcmd
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu22.04
|
||||
distro: ubuntu20.04
|
||||
githubToken: ${{ github.token }}
|
||||
run: |
|
||||
uname -a
|
||||
apt-get update && apt-get install -y cmake make g++ libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev libddcutil-dev libchafa-dev directx-headers-dev rpm
|
||||
apt-get update && apt-get install -y cmake make g++ libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev directx-headers-dev rpm
|
||||
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
|
||||
cmake --build . --target package --verbose -j4
|
||||
./fastfetch --list-features
|
||||
@@ -181,7 +181,7 @@ jobs:
|
||||
# CMake installed by apt has bug `list sub-command REMOVE_ITEM requires two or more arguments`
|
||||
wget --no-check-certificate https://apt.kitware.com/ubuntu/pool/main/c/cmake/{cmake_3.29.2-0kitware1ubuntu20.04.1_armhf.deb,cmake-data_3.29.2-0kitware1ubuntu20.04.1_all.deb}
|
||||
dpkg -i *.deb
|
||||
apt-get install -y make g++ libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev directx-headers-dev rpm
|
||||
apt-get install -y make g++ libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev directx-headers-dev rpm
|
||||
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
|
||||
cmake --build . --target package --verbose -j4
|
||||
./fastfetch --list-features
|
||||
@@ -216,7 +216,7 @@ jobs:
|
||||
githubToken: ${{ github.token }}
|
||||
run: |
|
||||
uname -a
|
||||
apt-get update && apt-get install -y cmake make g++ libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev libddcutil-dev libchafa-dev directx-headers-dev rpm
|
||||
apt-get update && apt-get install -y cmake make g++ libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libddcutil-dev libchafa-dev directx-headers-dev rpm
|
||||
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
|
||||
cmake --build . --target package --verbose -j4
|
||||
./fastfetch --list-features
|
||||
|
||||
@@ -1,3 +1,79 @@
|
||||
# 2.21.0
|
||||
|
||||
Changes:
|
||||
* We no longer use `libnm` for Wifi detection on Linux. Instead, we use `libdbus` to communicate with NetworkManager directly
|
||||
* To package managers: libnm dependency should be removed
|
||||
|
||||
Features:
|
||||
* Add module `BluetoothRadio` that prints bluetooth radios installed on the system
|
||||
* Don't confuse with module `Bluetooth` which lists connected bluetooth devices
|
||||
* Detect more information when `--gpu-driver-specific` is used (GPU)
|
||||
* Detect which type of nvidia driver (open source or proprietary) is used (GPU, Linux)
|
||||
* `--gpu-driver-specific` adds supports for Moore Threads GPU (#1142, GPU, Linux / Windows)
|
||||
* Use SetupAPI for detecting GPUs to support GPU detection when running fastfetch as a Windows Service (GPU, Windows)
|
||||
* See https://github.com/gpustack/gpustack/pull/97#issuecomment-2264699787 for detail
|
||||
* Detect playback status (Media, Linux)
|
||||
|
||||
Bugfixes:
|
||||
* Don't try to connect display server in tty mode (Linux, #1110)
|
||||
* Improve ssh detection
|
||||
* Fix max frequency printing in custom format (CPU)
|
||||
* Fix displaying random characters when detecting kitty term font (#1136 / #1145, TerminalFont, Linux)
|
||||
* Make sure to detect all physical memory devices (#1137)
|
||||
* Don't detect `wl-restart` as WM (#1135, WM, Linux)
|
||||
* Use PCI bus ID to match Nvidia cards; fix multi-GPU detection (GPU)
|
||||
* Ignore invalid GPU (#1066, GPU, macOS)
|
||||
* Print error when invalid color code is found (#1138)
|
||||
* Fix invalid refresh rate detection on old macOS versions (Display, macOS)
|
||||
* Fix disk size detection on 32-bit systems (Disk, BSD)
|
||||
* Don't ignore disabled GPUs (#1140, GPU, Linux)
|
||||
* Fix GPU type detection on FreeBSD (GPU, FreeBSD)
|
||||
* Remove shell version detection for unknown shells (#1144, Shell)
|
||||
* Don't detect hyfetch as shell on NixOS (Shell, NixOS)
|
||||
|
||||
Logos:
|
||||
* Update EndeavourOS_small
|
||||
* Add QTS
|
||||
|
||||
# 2.20.0
|
||||
|
||||
This release fixes regression of `2.19.0` on M1 MacBook Air. It also introduces a new option `--key-type icon` to display predefined icons in keys (requires newest nerd font). See `fastfetch -h key-type` for detail.
|
||||
|
||||
Changes:
|
||||
* JSON option `display.keyWidth` has been renamed to `display.key.width`
|
||||
* Previously: `{ "display": { "keyWidth": 3 } }`
|
||||
* Now: `{ "display": { "key": { "width": 3 } } }`
|
||||
* Windows Terminal font detection **in WSL** has been removed due to [issue #1113](https://github.com/fastfetch-cli/fastfetch/issues/1113)
|
||||
|
||||
Features:
|
||||
* Add option `display.key.type: <enum>` to print icons in keys
|
||||
* Supported value `string`, `icon` and `both`. Default to `string` (don't display icons)
|
||||
* Example: `{ "display": { "key": { "type": "icon" } } }`
|
||||
* Add option `display.key.paddingLeft: <num>` to print left padding (whitespaces) in keys
|
||||
* Example: `{ "display": { "key": { "paddingLeft": 2 } } }`
|
||||
* Add option `modules.keyIcon` to set icon for specified module
|
||||
* Example: `{ "modules": { "type": "command", "keyIcon": "🔑" } }`
|
||||
* Report system mono font name for Terminator if used (TerminalFont, Linux)
|
||||
* Don't require logo height to be set when using `--logo-position right`
|
||||
* Report Snapdragon SOC marketing name for newer Android phones (CPU, Android)
|
||||
* Detect MTK SOC part name (CPU, Android)
|
||||
|
||||
Bugfixes:
|
||||
* Don't wake up suspended GPUs when using `--ds-force-drm` (Display, Linux)
|
||||
* Fix printing editor type in JSON result (Editor)
|
||||
* Fix `--logo-padding-*` not working correctly (#1121, Logo)
|
||||
* Fix possible segfault when detecting GPU frequency (#1121, macOS, GPU)
|
||||
|
||||
# 2.19.1
|
||||
|
||||
Bugfixes
|
||||
* Fix frequency value printing when using custom format (#1111, CPU / GPU)
|
||||
* Fix display detection for XiaoMi Android phone (Display, Android)
|
||||
|
||||
Features:
|
||||
* Display if HDR mode is enabled for screens (Display)
|
||||
* Supported in Windows and Linux (KDE) correctly
|
||||
|
||||
# 2.19.0
|
||||
|
||||
Changes:
|
||||
|
||||
+62
-31
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
|
||||
|
||||
project(fastfetch
|
||||
VERSION 2.19.0
|
||||
VERSION 2.21.0
|
||||
LANGUAGES C
|
||||
DESCRIPTION "Fast neofetch-like system information tool"
|
||||
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
|
||||
@@ -17,7 +17,7 @@ if(ANDROID)
|
||||
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(BSD TRUE CACHE BOOL "..." FORCE)
|
||||
set(FreeBSD TRUE CACHE BOOL "..." FORCE)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
|
||||
set(SunOS TRUE CACHE BOOL "..." FORCE)
|
||||
elseif(NOT APPLE AND NOT WIN32)
|
||||
@@ -44,28 +44,27 @@ include(CheckIncludeFile)
|
||||
|
||||
include(CMakeDependentOption)
|
||||
|
||||
cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR BSD OR APPLE OR SunOS" OFF)
|
||||
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_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_RPM "Enable rpm" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR BSD OR APPLE OR WIN32 OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR BSD OR APPLE OR SunOS" 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_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 BSD OR WIN32 OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR BSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32 OR ANDROID OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" 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_FREETYPE "Enable freetype" ON "ANDROID" OFF)
|
||||
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
|
||||
@@ -294,6 +293,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/common/properties.c
|
||||
src/common/settings.c
|
||||
src/common/temps.c
|
||||
src/detection/bluetoothradio/bluetoothradio.c
|
||||
src/detection/bootmgr/bootmgr.c
|
||||
src/detection/chassis/chassis.c
|
||||
src/detection/cpu/cpu.c
|
||||
@@ -326,6 +326,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/modules/battery/battery.c
|
||||
src/modules/bios/bios.c
|
||||
src/modules/bluetooth/bluetooth.c
|
||||
src/modules/bluetoothradio/bluetoothradio.c
|
||||
src/modules/board/board.c
|
||||
src/modules/bootmgr/bootmgr.c
|
||||
src/modules/brightness/brightness.c
|
||||
@@ -421,6 +422,7 @@ if(LINUX)
|
||||
src/detection/cpuusage/cpuusage_linux.c
|
||||
src/detection/cursor/cursor_linux.c
|
||||
src/detection/bluetooth/bluetooth_linux.c
|
||||
src/detection/bluetoothradio/bluetoothradio_linux.c
|
||||
src/detection/disk/disk_linux.c
|
||||
src/detection/dns/dns_linux.c
|
||||
src/detection/physicaldisk/physicaldisk_linux.c
|
||||
@@ -488,6 +490,7 @@ elseif(ANDROID)
|
||||
src/detection/battery/battery_android.c
|
||||
src/detection/bios/bios_android.c
|
||||
src/detection/bluetooth/bluetooth_nosupport.c
|
||||
src/detection/bluetoothradio/bluetoothradio_nosupport.c
|
||||
src/detection/board/board_android.c
|
||||
src/detection/bootmgr/bootmgr_nosupport.c
|
||||
src/detection/brightness/brightness_nosupport.c
|
||||
@@ -539,7 +542,7 @@ elseif(ANDROID)
|
||||
src/detection/camera/camera_android.c
|
||||
src/util/platform/FFPlatform_unix.c
|
||||
)
|
||||
elseif(BSD)
|
||||
elseif(FreeBSD)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/common/dbus.c
|
||||
src/common/io/io_unix.c
|
||||
@@ -550,6 +553,7 @@ elseif(BSD)
|
||||
src/detection/battery/battery_bsd.c
|
||||
src/detection/bios/bios_bsd.c
|
||||
src/detection/bluetooth/bluetooth_linux.c
|
||||
src/detection/bluetoothradio/bluetoothradio_linux.c
|
||||
src/detection/board/board_bsd.c
|
||||
src/detection/bootmgr/bootmgr_bsd.c
|
||||
src/detection/brightness/brightness_bsd.c
|
||||
@@ -626,6 +630,7 @@ elseif(APPLE)
|
||||
src/detection/battery/battery_apple.c
|
||||
src/detection/bios/bios_apple.c
|
||||
src/detection/bluetooth/bluetooth_apple.m
|
||||
src/detection/bluetoothradio/bluetoothradio_apple.m
|
||||
src/detection/board/board_apple.c
|
||||
src/detection/bootmgr/bootmgr_apple.c
|
||||
src/detection/brightness/brightness_apple.c
|
||||
@@ -689,6 +694,7 @@ elseif(WIN32)
|
||||
src/detection/battery/battery_windows.c
|
||||
src/detection/bios/bios_windows.c
|
||||
src/detection/bluetooth/bluetooth_windows.c
|
||||
src/detection/bluetoothradio/bluetoothradio_windows.c
|
||||
src/detection/board/board_windows.c
|
||||
src/detection/bootmgr/bootmgr_windows.c
|
||||
src/detection/brightness/brightness_windows.cpp
|
||||
@@ -763,6 +769,7 @@ elseif(SunOS)
|
||||
src/detection/cpuusage/cpuusage_sunos.c
|
||||
src/detection/cursor/cursor_linux.c
|
||||
src/detection/bluetooth/bluetooth_nosupport.c
|
||||
src/detection/bluetoothradio/bluetoothradio_nosupport.c
|
||||
src/detection/disk/disk_sunos.c
|
||||
src/detection/dns/dns_linux.c
|
||||
src/detection/physicaldisk/physicaldisk_nosupport.c
|
||||
@@ -828,14 +835,14 @@ if(ENABLE_DIRECTX_HEADERS)
|
||||
endif()
|
||||
|
||||
# Proprietary GPU driver APIs
|
||||
if(LINUX OR BSD OR WIN32)
|
||||
if(LINUX OR FreeBSD OR WIN32)
|
||||
list(APPEND LIBFASTFETCH_SRC src/detection/gpu/gpu_nvidia.c)
|
||||
list(APPEND LIBFASTFETCH_SRC src/detection/gpu/gpu_mthreads.c)
|
||||
endif()
|
||||
if(WIN32)
|
||||
list(APPEND LIBFASTFETCH_SRC src/detection/gpu/gpu_intel.c)
|
||||
list(APPEND LIBFASTFETCH_SRC src/detection/gpu/gpu_amd.c)
|
||||
endif()
|
||||
|
||||
include(CheckFunctionExists)
|
||||
check_function_exists(wcwidth HAVE_WCWIDTH)
|
||||
if(NOT HAVE_WCWIDTH)
|
||||
@@ -888,7 +895,7 @@ if(APPLE AND EXISTS "/usr/bin/otool")
|
||||
target_compile_definitions(libfastfetch PUBLIC FF_LIBSYSTEM_VERSION="${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
if(BSD AND EXISTS "/usr/local/bin/objdump")
|
||||
if(FreeBSD AND EXISTS "/usr/local/bin/objdump")
|
||||
execute_process(COMMAND /bin/sh -c "/usr/local/bin/objdump -T /lib/libc.so.* | grep 'FBSD_[^ )]*' -o | sort -Vru | head -1"
|
||||
OUTPUT_VARIABLE OBJDUMP_T_RESULT)
|
||||
if("${OBJDUMP_T_RESULT}" MATCHES "FBSD_([0-9]+\\.[0-9]+)")
|
||||
@@ -1056,10 +1063,6 @@ ff_lib_enable(OPENCL
|
||||
"OpenCL"
|
||||
"OpenCL"
|
||||
)
|
||||
ff_lib_enable(LIBNM
|
||||
"libnm"
|
||||
"libnm"
|
||||
)
|
||||
ff_lib_enable(FREETYPE
|
||||
"freetype2"
|
||||
"FreeType2"
|
||||
@@ -1125,7 +1128,7 @@ elseif(WIN32)
|
||||
PRIVATE "hid"
|
||||
PRIVATE "wtsapi32"
|
||||
)
|
||||
elseif(BSD)
|
||||
elseif(FreeBSD)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "m"
|
||||
PRIVATE "usbhid"
|
||||
@@ -1178,7 +1181,35 @@ if(WIN32)
|
||||
PRIVATE "-static" # stdc++, winpthread, gcc_s, etc.
|
||||
)
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
endif()
|
||||
if(LINUX)
|
||||
CHECK_INCLUDE_FILE("linux/videodev2.h" HAVE_LINUX_VIDEODEV2)
|
||||
if(HAVE_LINUX_VIDEODEV2)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LINUX_VIDEODEV2=1)
|
||||
endif()
|
||||
CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS)
|
||||
if(HAVE_LINUX_WIRELESS)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LINUX_WIRELESS=1)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
CHECK_INCLUDE_FILE("utmpx.h" HAVE_UTMPX)
|
||||
if(HAVE_UTMPX)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX=1)
|
||||
endif()
|
||||
CHECK_INCLUDE_FILE("wordexp.h" HAVE_WORDEXP)
|
||||
if(HAVE_WORDEXP)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WORDEXP=1)
|
||||
endif()
|
||||
CHECK_INCLUDE_FILE("pthread_np.h" HAVE_PTHREAD_NP)
|
||||
if(HAVE_PTHREAD_NP)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_PTHREAD_NP=1)
|
||||
endif()
|
||||
check_function_exists("pthread_timedjoin_np" HAVE_TIMEDJOIN_NP)
|
||||
if(HAVE_TIMEDJOIN_NP)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_TIMEDJOIN_NP=1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
######################
|
||||
|
||||
@@ -128,6 +128,8 @@ Alternatively, you can refer to the presets in [`presets` directory](https://git
|
||||
|
||||
The **correct** way to edit the configuration:
|
||||
|
||||
This is an example that [changes size prefix from MiB / GiB to MB / GB](https://github.com/fastfetch-cli/fastfetch/discussions/1014). Editor used: [helix](https://github.com/helix-editor/helix)
|
||||
|
||||
[](https://asciinema.org/a/1uF6sTPGKrHKI1MVaFcikINSQ)
|
||||
|
||||
### Q: I WANT THE DOCUMENTATION!
|
||||
|
||||
Vendored
+12
@@ -1,3 +1,15 @@
|
||||
fastfetch (2.19.1) jammy; urgency=medium
|
||||
|
||||
* Update to 2.19.1
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Tue, 23 Jul 2024 10:25:14 +0800
|
||||
|
||||
fastfetch (2.19.0) jammy; urgency=medium
|
||||
|
||||
* Update to 2.19.0
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Mon, 22 Jul 2024 14:17:55 +0800
|
||||
|
||||
fastfetch (2.18.1) jammy; urgency=medium
|
||||
|
||||
* Update to 2.18.1
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ Source: fastfetch
|
||||
Section: universe/utils
|
||||
Priority: optional
|
||||
Maintainer: Carter Li <zhangsongcui@live.cn>
|
||||
Build-Depends: libvulkan-dev, libwayland-dev, libxrandr-dev, libxcb-randr0-dev, libdconf-dev, libdbus-1-dev, libmagickcore-dev, libxfconf-0-dev, libsqlite3-dev, librpm-dev, libegl-dev, libglx-dev, libosmesa6-dev, ocl-icd-opencl-dev, libnm-dev, libpulse-dev, libdrm-dev, libddcutil-dev, libchafa-dev, directx-headers-dev, pkgconf, cmake (>= 3.12), debhelper (>= 11.2), dh-cmake, dh-cmake-compat (= 1), dh-sequence-cmake, dh-sequence-ctest, ninja-build
|
||||
Build-Depends: libvulkan-dev, libwayland-dev, libxrandr-dev, libxcb-randr0-dev, libdconf-dev, libdbus-1-dev, libmagickcore-dev, libxfconf-0-dev, libsqlite3-dev, librpm-dev, libegl-dev, libglx-dev, libosmesa6-dev, ocl-icd-opencl-dev, libpulse-dev, libdrm-dev, libddcutil-dev, libchafa-dev, directx-headers-dev, pkgconf, cmake (>= 3.12), debhelper (>= 11.2), dh-cmake, dh-cmake-compat (= 1), dh-sequence-cmake, dh-sequence-ctest, ninja-build
|
||||
Standards-Version: 4.0.0
|
||||
Homepage: https://github.com/fastfetch-cli/fastfetch
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
fastfetch_2.18.1_source.buildinfo universe/utils optional
|
||||
fastfetch_2.19.1_source.buildinfo universe/utils optional
|
||||
|
||||
+217
-66
@@ -22,6 +22,10 @@
|
||||
"minimum": 0,
|
||||
"default": 0
|
||||
},
|
||||
"keyIcon": {
|
||||
"description": "Set the icon to be displayed by `display.keyType: \"icon\"`",
|
||||
"type": "string"
|
||||
},
|
||||
"format": {
|
||||
"description": "Output format of the module. See `-h <module>-format` for detail. I.e: fastfetch -h disk-format",
|
||||
"type": "string"
|
||||
@@ -418,11 +422,35 @@
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"keyWidth": {
|
||||
"description": "Align the width of keys to number of characters, 0 to disable",
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"default": 0
|
||||
"key": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Set how module keys should be displayed",
|
||||
"properties": {
|
||||
"width": {
|
||||
"description": "Align the width of keys to number of characters, 0 to disable",
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"default": 0
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "Set whether to show icon before string keys",
|
||||
"enum": [
|
||||
"none",
|
||||
"string",
|
||||
"icon",
|
||||
"both"
|
||||
],
|
||||
"default": "string"
|
||||
},
|
||||
"paddingLeft": {
|
||||
"type": "integer",
|
||||
"description": "Set the left padding of keys",
|
||||
"minimum": 0,
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"size": {
|
||||
"type": "object",
|
||||
@@ -717,6 +745,7 @@
|
||||
"battery",
|
||||
"bios",
|
||||
"bluetooth",
|
||||
"bluetoothradio",
|
||||
"board",
|
||||
"bootmgr",
|
||||
"break",
|
||||
@@ -961,12 +990,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -998,12 +1030,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1015,7 +1050,7 @@
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"description": "List bluetooth devices",
|
||||
"description": "List (connected) bluetooth devices",
|
||||
"const": "bluetooth"
|
||||
},
|
||||
"showDisconnected": {
|
||||
@@ -1032,12 +1067,44 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "Bluetooth Radio",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"description": "List bluetooth radios width supported version and vendor",
|
||||
"const": "bluetoothradio"
|
||||
},
|
||||
"key": {
|
||||
"$ref": "#/$defs/key"
|
||||
},
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1068,12 +1135,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1094,12 +1164,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1128,12 +1201,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1162,12 +1238,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1228,6 +1307,9 @@
|
||||
},
|
||||
"key": {
|
||||
"$ref": "#/$defs/key"
|
||||
},
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1254,12 +1336,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1281,12 +1366,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"description": "Text to print",
|
||||
"type": "string"
|
||||
@@ -1333,12 +1421,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1396,12 +1487,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1431,12 +1525,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1462,12 +1559,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1497,12 +1597,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1526,12 +1629,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1581,12 +1687,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1651,12 +1760,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1680,12 +1792,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1721,12 +1836,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1761,12 +1879,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1797,12 +1918,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1858,12 +1982,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1891,12 +2018,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1934,12 +2064,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1999,12 +2132,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -2028,12 +2164,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -2078,12 +2217,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -2114,12 +2256,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -2155,12 +2300,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -2186,12 +2334,15 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
"keyIcon": {
|
||||
"$ref": "#/$defs/keyIcon"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"outputColor": {
|
||||
"$ref": "#/$defs/outputColor"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
"opencl",
|
||||
"users",
|
||||
"bluetooth",
|
||||
"bluetoothradio",
|
||||
"sound",
|
||||
"camera",
|
||||
"gamepad",
|
||||
|
||||
+9
-12
@@ -4,12 +4,12 @@
|
||||
{
|
||||
"type": "title",
|
||||
"key": "User",
|
||||
"format": "{1}"
|
||||
"format": "{user-name}"
|
||||
},
|
||||
{
|
||||
"type": "title",
|
||||
"key": "Hostname",
|
||||
"format": "{2}"
|
||||
"format": "{host-name}"
|
||||
},
|
||||
{
|
||||
"type": "host",
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
{
|
||||
"type": "os",
|
||||
"format": "{3} {9} {12}"
|
||||
"format": "{pretty-name} {version-id} {arch}"
|
||||
},
|
||||
"kernel",
|
||||
"uptime",
|
||||
@@ -34,32 +34,29 @@
|
||||
"type": "de",
|
||||
"key": "Desktop Environment"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"format": "{7}"
|
||||
},
|
||||
"shell",
|
||||
{
|
||||
"type": "terminal",
|
||||
"format": "{5} {6} {#37}█{#97}█ {#36}█{#96}█ {#35}█{#95}█ {#34}█{#94}█ {#33}█{#93}█ {#32}█{#92}█ {#31}█{#91}█ {#30}█{#90}█"
|
||||
"format": "{pretty-name} {version} {#37}█{#97}█ {#36}█{#96}█ {#35}█{#95}█ {#34}█{#94}█ {#33}█{#93}█ {#32}█{#92}█ {#31}█{#91}█ {#30}█{#90}█"
|
||||
},
|
||||
{
|
||||
"type": "packages",
|
||||
"format": "{1}"
|
||||
"format": "{all}"
|
||||
},
|
||||
{
|
||||
"type": "cpu",
|
||||
"key": "Temperature",
|
||||
"temp": true,
|
||||
"format": "{8}"
|
||||
"format": "{temperature}"
|
||||
},
|
||||
{
|
||||
"type": "cpu",
|
||||
"key": "CPU",
|
||||
"format": "{4} x {1}"
|
||||
"format": "{cores-logical} x {name}"
|
||||
},
|
||||
{
|
||||
"type": "gpu",
|
||||
"format": "{2}"
|
||||
"format": "{name}"
|
||||
},
|
||||
{
|
||||
"type": "memory",
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"logo": {
|
||||
"type": "builtin",
|
||||
"source": "arch"
|
||||
},
|
||||
"modules": [
|
||||
"title",
|
||||
"separator",
|
||||
{
|
||||
"type": "os",
|
||||
"format": "Arch Linux ({12})"
|
||||
},
|
||||
"host",
|
||||
"kernel",
|
||||
"uptime",
|
||||
{
|
||||
"type": "packages",
|
||||
"format": "{} (pacman)"
|
||||
},
|
||||
"shell",
|
||||
"display",
|
||||
"de",
|
||||
"wm",
|
||||
"wmtheme",
|
||||
"theme",
|
||||
"icons",
|
||||
"font",
|
||||
"cursor",
|
||||
"terminal",
|
||||
"terminalfont",
|
||||
"cpu",
|
||||
"gpu",
|
||||
"memory",
|
||||
"disk",
|
||||
"battery",
|
||||
"poweradapter",
|
||||
"locale",
|
||||
"break",
|
||||
"colors"
|
||||
]
|
||||
}
|
||||
@@ -75,6 +75,7 @@
|
||||
"opencl",
|
||||
"users",
|
||||
"bluetooth",
|
||||
"bluetoothradio",
|
||||
"sound",
|
||||
"camera",
|
||||
"gamepad",
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
},
|
||||
{
|
||||
"type": "os",
|
||||
"key": " OS",
|
||||
"key": "{icon} OS",
|
||||
"keyColor": "yellow"
|
||||
},
|
||||
{
|
||||
|
||||
+22
-18
@@ -6,16 +6,20 @@
|
||||
"display": {
|
||||
"separator": "-> ",
|
||||
"color": {
|
||||
"separator": "1"
|
||||
"separator": "1" // Bold
|
||||
},
|
||||
"constants": [
|
||||
"─────────────────────────────"
|
||||
]
|
||||
"───────────────────────────"
|
||||
],
|
||||
"key": {
|
||||
"type": "both",
|
||||
"paddingLeft": 4
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"type": "title",
|
||||
"format": " {6}{7}{8}"
|
||||
"format": " {user-name-colored}{at-symbol-colored}{host-name-colored}"
|
||||
},
|
||||
"break",
|
||||
{
|
||||
@@ -24,74 +28,74 @@
|
||||
},
|
||||
"break",
|
||||
{
|
||||
"key": " OS ",
|
||||
"key": "OS ",
|
||||
"keyColor": "red",
|
||||
"type": "os"
|
||||
},
|
||||
{
|
||||
"key": " Machine ",
|
||||
"key": "Machine ",
|
||||
"keyColor": "green",
|
||||
"type": "host"
|
||||
},
|
||||
{
|
||||
"key": " Kernel ",
|
||||
"key": "Kernel ",
|
||||
"keyColor": "magenta",
|
||||
"type": "kernel"
|
||||
},
|
||||
{
|
||||
"key": " Uptime ",
|
||||
"key": "Uptime ",
|
||||
"keyColor": "red",
|
||||
"type": "uptime"
|
||||
},
|
||||
{
|
||||
"key": " Resolution ",
|
||||
"key": "Resolution ",
|
||||
"keyColor": "yellow",
|
||||
"type": "display",
|
||||
"compactType": "original-with-refresh-rate"
|
||||
},
|
||||
{
|
||||
"key": " WM ",
|
||||
"key": "WM ",
|
||||
"keyColor": "blue",
|
||||
"type": "wm"
|
||||
},
|
||||
{
|
||||
"key": " DE ",
|
||||
"key": "DE ",
|
||||
"keyColor": "green",
|
||||
"type": "de"
|
||||
},
|
||||
{
|
||||
"key": " Shell ",
|
||||
"key": "Shell ",
|
||||
"keyColor": "cyan",
|
||||
"type": "shell"
|
||||
},
|
||||
{
|
||||
"key": " Terminal ",
|
||||
"key": "Terminal ",
|
||||
"keyColor": "red",
|
||||
"type": "terminal"
|
||||
},
|
||||
{
|
||||
"key": " CPU ",
|
||||
"key": "CPU ",
|
||||
"keyColor": "yellow",
|
||||
"type": "cpu"
|
||||
},
|
||||
{
|
||||
"key": " GPU ",
|
||||
"key": "GPU ",
|
||||
"keyColor": "blue",
|
||||
"type": "gpu"
|
||||
},
|
||||
{
|
||||
"key": " Memory ",
|
||||
"key": "Memory ",
|
||||
"keyColor": "magenta",
|
||||
"type": "memory"
|
||||
},
|
||||
{
|
||||
"key": " Local IP ",
|
||||
"key": "Local IP ",
|
||||
"keyColor": "red",
|
||||
"type": "localip",
|
||||
"compact": true
|
||||
},
|
||||
{
|
||||
"key": " Public IP ",
|
||||
"key": "Public IP ",
|
||||
"keyColor": "cyan",
|
||||
"type": "publicip"
|
||||
},
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
}
|
||||
},
|
||||
"display": {
|
||||
"separator": "",
|
||||
"keyWidth": 15
|
||||
"separator": " "
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
@@ -19,19 +18,19 @@
|
||||
{
|
||||
"key": "│ {#31} user {#keys}│",
|
||||
"type": "title",
|
||||
"format": "{1}"
|
||||
"format": "{user-name}"
|
||||
},
|
||||
{
|
||||
"key": "│ {#32} hname {#keys}│",
|
||||
"type": "title",
|
||||
"format": "{2}"
|
||||
"format": "{host-name}"
|
||||
},
|
||||
{
|
||||
"key": "│ {#33} uptime {#keys}│",
|
||||
"type": "uptime"
|
||||
},
|
||||
{
|
||||
"key": "│ {#34} distro {#keys}│",
|
||||
"key": "│ {#34}{icon} distro {#keys}│",
|
||||
"type": "os"
|
||||
},
|
||||
{
|
||||
@@ -67,7 +66,7 @@
|
||||
{
|
||||
"key": "│ {#36} network {#keys}│",
|
||||
"type": "localip",
|
||||
"format": "{1} ({4})"
|
||||
"format": "{ipv4} ({ifname})"
|
||||
},
|
||||
{
|
||||
"key": "├───────────┤",
|
||||
|
||||
@@ -6,20 +6,22 @@
|
||||
},
|
||||
"display": {
|
||||
"separator": "",
|
||||
"keyWidth": 12
|
||||
"key": {
|
||||
"width": 15
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
// draw borders first to make colors of left and right border consistant
|
||||
"key": " user",
|
||||
"type": "title",
|
||||
"format": "{1}",
|
||||
"format": "{user-name}",
|
||||
"keyColor": "31"
|
||||
},
|
||||
{
|
||||
"key": " hname",
|
||||
"type": "title",
|
||||
"format": "{2}",
|
||||
"format": "{host-name}",
|
||||
"keyColor": "32"
|
||||
|
||||
},
|
||||
@@ -29,7 +31,7 @@
|
||||
"keyColor": "33"
|
||||
},
|
||||
{
|
||||
"key": " distro",
|
||||
"key": "{icon} distro",
|
||||
"type": "os",
|
||||
"keyColor": "34"
|
||||
},
|
||||
@@ -73,7 +75,7 @@
|
||||
{
|
||||
"key": " network",
|
||||
"type": "localip",
|
||||
"format": "{1} ({4})",
|
||||
"format": "{ipv4} ({ifname})",
|
||||
"keyColor": "36"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
}
|
||||
},
|
||||
"display": {
|
||||
"separator": "",
|
||||
"keyWidth": 15
|
||||
"separator": " "
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
@@ -19,19 +18,19 @@
|
||||
{
|
||||
"key": "• {#31} user {#keys}•",
|
||||
"type": "title",
|
||||
"format": "{1}"
|
||||
"format": "{user-name}"
|
||||
},
|
||||
{
|
||||
"key": "• {#32} hname {#keys}•",
|
||||
"type": "title",
|
||||
"format": "{2}"
|
||||
"format": "{host-name}"
|
||||
},
|
||||
{
|
||||
"key": "• {#33} uptime {#keys}•",
|
||||
"type": "uptime"
|
||||
},
|
||||
{
|
||||
"key": "• {#34} distro {#keys}•",
|
||||
"key": "• {#34}{icon} distro {#keys}•",
|
||||
"type": "os"
|
||||
},
|
||||
{
|
||||
@@ -67,7 +66,7 @@
|
||||
{
|
||||
"key": "• {#36} network {#keys}•",
|
||||
"type": "localip",
|
||||
"format": "{1} ({4})"
|
||||
"format": "{ipv4} ({ifname})"
|
||||
},
|
||||
{
|
||||
"key": "•••••••••••••",
|
||||
|
||||
@@ -18,19 +18,19 @@
|
||||
{
|
||||
"key": "║ {#31} user {#keys}║",
|
||||
"type": "title",
|
||||
"format": "{1}"
|
||||
"format": "{user-name}"
|
||||
},
|
||||
{
|
||||
"key": "║ {#32} hname {#keys}║",
|
||||
"type": "title",
|
||||
"format": "{2}"
|
||||
"format": "{host-name}"
|
||||
},
|
||||
{
|
||||
"key": "║ {#33} uptime {#keys}║",
|
||||
"type": "uptime"
|
||||
},
|
||||
{
|
||||
"key": "║ {#34} distro {#keys}║",
|
||||
"key": "║ {#34}{icon} distro {#keys}║",
|
||||
"type": "os"
|
||||
},
|
||||
{
|
||||
@@ -66,7 +66,7 @@
|
||||
{
|
||||
"key": "║ {#36} network {#keys}║",
|
||||
"type": "localip",
|
||||
"format": "{1} ({4})"
|
||||
"format": "{ipv4} ({ifname})"
|
||||
},
|
||||
{
|
||||
"key": "╠═══════════╣",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"format": "{#1}{#keys}╭{$1}╮\u001b[76D {6}{7}{8} 🖥 ",
|
||||
"format": "{#1}{#keys}╭{$1}╮\u001b[76D {user-name-colored}{at-symbol-colored}{host-name-colored} 🖥 ",
|
||||
"type": "title"
|
||||
},
|
||||
{
|
||||
@@ -31,7 +31,7 @@
|
||||
"type": "uptime"
|
||||
},
|
||||
{
|
||||
"key": "{$2}{#33} distro ",
|
||||
"key": "{$2}{#33}{icon} distro ",
|
||||
"type": "os"
|
||||
},
|
||||
{
|
||||
@@ -68,7 +68,7 @@
|
||||
{
|
||||
"key": "{$2}{#31} network ",
|
||||
"type": "localip",
|
||||
"format": "{1} ({4})"
|
||||
"format": "{ipv4} ({ifname})"
|
||||
},
|
||||
{
|
||||
"format": "{#1}{#keys}├{$1}┤",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"format": "{#1}{#keys}╔{$1}╗\u001b[76D {6}{7}{8} 💻 ",
|
||||
"format": "{#1}{#keys}╔{$1}╗\u001b[76D {user-name-colored}{at-symbol-colored}{host-name-colored} 💻 ",
|
||||
"type": "title"
|
||||
},
|
||||
{
|
||||
@@ -31,7 +31,7 @@
|
||||
"type": "uptime"
|
||||
},
|
||||
{
|
||||
"key": "{$2}{#33} distro ",
|
||||
"key": "{$2}{#33}{icon} distro ",
|
||||
"type": "os"
|
||||
},
|
||||
{
|
||||
@@ -68,7 +68,7 @@
|
||||
{
|
||||
"key": "{$2}{#31} network ",
|
||||
"type": "localip",
|
||||
"format": "{1} ({4})"
|
||||
"format": "{ipv4} ({ifname})"
|
||||
},
|
||||
{
|
||||
"format": "{#1}{#keys}╠{$1}╣",
|
||||
|
||||
+39
-124
@@ -12,8 +12,12 @@
|
||||
"display": {
|
||||
"separator": " ",
|
||||
"constants": [
|
||||
"───────────────"
|
||||
]
|
||||
"─────────────────" // {$1}, used in Custom module
|
||||
],
|
||||
"key": {
|
||||
"type": "icon",
|
||||
"paddingLeft": 2
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
@@ -21,142 +25,53 @@
|
||||
// {#1} is equivalent to `\u001b[1m`. {#} is equivalent to `\u001b[m`
|
||||
"format": "┌{$1} {#1}Hardware Information{#} {$1}┐"
|
||||
},
|
||||
{
|
||||
"type": "host",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "cpu",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "gpu",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "disk",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "memory",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "swap",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "display",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "brightness",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "battery",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "poweradapter",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "bluetooth",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "sound",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "gamepad",
|
||||
"key": " "
|
||||
},
|
||||
"host",
|
||||
"cpu",
|
||||
"gpu",
|
||||
"disk",
|
||||
"memory",
|
||||
"swap",
|
||||
"display",
|
||||
"brightness",
|
||||
"battery",
|
||||
"poweradapter",
|
||||
"bluetooth",
|
||||
"sound",
|
||||
"gamepad",
|
||||
{
|
||||
"type": "custom", // SoftwareStart
|
||||
"format": "├{$1} {#1}Software Information{#} {$1}┤"
|
||||
},
|
||||
{
|
||||
"type": "title",
|
||||
"key": " ",
|
||||
"format": "{1}${2}"
|
||||
},
|
||||
{
|
||||
"type": "os",
|
||||
"key": " " // Just get your distro's logo off nerdfonts.com
|
||||
},
|
||||
{
|
||||
"type": "kernel",
|
||||
"key": " ",
|
||||
"format": "{1} {2}"
|
||||
},
|
||||
{
|
||||
"type": "lm",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "de",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "wm",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "terminal",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "terminalfont",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "theme",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "icons",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "wallpaper",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "packages",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "uptime",
|
||||
"key": " "
|
||||
},
|
||||
{
|
||||
"type": "media",
|
||||
"key": " "
|
||||
"keyIcon": "",
|
||||
"key": "Title", // Title module has no key by default, so that icon is not displayed
|
||||
"format": "{user-name}@{host-name}"
|
||||
},
|
||||
"os",
|
||||
"kernel",
|
||||
"lm",
|
||||
"de",
|
||||
"wm",
|
||||
"shell",
|
||||
"terminal",
|
||||
"terminalfont",
|
||||
"theme",
|
||||
"icons",
|
||||
"wallpaper",
|
||||
"packages",
|
||||
"uptime",
|
||||
"media",
|
||||
{
|
||||
"type": "localip",
|
||||
"key": " ",
|
||||
"compact": true
|
||||
},
|
||||
{
|
||||
"type": "publicip",
|
||||
"key": " "
|
||||
},
|
||||
"publicip",
|
||||
{
|
||||
"type": "wifi",
|
||||
"key": " ",
|
||||
"format": "{4}" // ssid
|
||||
},
|
||||
{
|
||||
"type": "locale",
|
||||
"key": " "
|
||||
"format": "{ssid}"
|
||||
},
|
||||
"locale",
|
||||
{
|
||||
"type": "custom", // InformationEnd
|
||||
"format": "└{$1}──────────────────────{$1}┘"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
"logo": null,
|
||||
"display": {
|
||||
"pipe": true,
|
||||
"keyWidth": 16,
|
||||
"key": {
|
||||
"width": 16
|
||||
},
|
||||
"separator": "│ ",
|
||||
"percent": {
|
||||
"type": 6
|
||||
@@ -104,7 +106,7 @@
|
||||
{
|
||||
"type": "cpu",
|
||||
"key": "│ CPU FREQ │{$1}",
|
||||
"format": "{freq-max}{/freq-max}{freq-base}{/} GHz"
|
||||
"format": "{freq-max}{/freq-max}{freq-base}{/}"
|
||||
},
|
||||
{
|
||||
"type": "loadavg",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Designed for Arch Linux
|
||||
// Modified from: https://github.com/fastfetch-cli/fastfetch/pull/1025#issuecomment-2177566138
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
|
||||
@@ -124,18 +124,17 @@
|
||||
{
|
||||
"type": "title",
|
||||
"key": "╭─",
|
||||
"format": "{1}@{2}",
|
||||
"format": "{user-name}@{host-name}",
|
||||
"keyColor": "blue"
|
||||
},
|
||||
{
|
||||
"type": "os",
|
||||
"key": "├─", // Just get your distro's logo off nerdfonts.com
|
||||
"key": "├─{icon}", // Just get your distro's logo off nerdfonts.com
|
||||
"keyColor": "blue"
|
||||
},
|
||||
{
|
||||
"type": "kernel",
|
||||
"key": "├─",
|
||||
"format": "{1} {2}",
|
||||
"keyColor": "blue"
|
||||
},
|
||||
{
|
||||
@@ -167,7 +166,7 @@
|
||||
{
|
||||
"type": "wifi",
|
||||
"key": "├─",
|
||||
"format": "{4}", // ssid
|
||||
"format": "{ssid}",
|
||||
"keyColor": "blue"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
},
|
||||
{
|
||||
"type": "os",
|
||||
"key": "├", // Just get your distro's logo off nerdfonts.com
|
||||
"keyColor": "yellow",
|
||||
"format": "{6}{?6} {?}{10}{?10} {?}{8}{?8} {?}{11}"
|
||||
"key": "├{icon}", // Just get your distro's logo off nerdfonts.com
|
||||
"keyColor": "yellow"
|
||||
},
|
||||
{
|
||||
"type": "kernel",
|
||||
@@ -106,13 +105,13 @@
|
||||
"keyColor": "green"
|
||||
},
|
||||
{
|
||||
"type": "uptime",
|
||||
"key": "├",
|
||||
"type": "display",
|
||||
"key": "├",
|
||||
"keyColor": "green"
|
||||
},
|
||||
{
|
||||
"type": "display",
|
||||
"key": "└",
|
||||
"type": "uptime",
|
||||
"key": "└",
|
||||
"keyColor": "green"
|
||||
},
|
||||
|
||||
|
||||
+13
-24
@@ -11,6 +11,9 @@
|
||||
"size": {
|
||||
"ndigits": 0,
|
||||
"maxPrefix": "MB"
|
||||
},
|
||||
"key": {
|
||||
"type": "icon"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
@@ -22,31 +25,17 @@
|
||||
"host": "blue"
|
||||
}
|
||||
},
|
||||
"os",
|
||||
"kernel",
|
||||
"memory",
|
||||
"packages",
|
||||
"uptime",
|
||||
{
|
||||
"type": "os",
|
||||
"key": "",
|
||||
"format": "{2} {8}"
|
||||
},
|
||||
{
|
||||
"type": "kernel",
|
||||
"key": ""
|
||||
},
|
||||
{
|
||||
"type": "memory",
|
||||
"key": ""
|
||||
},
|
||||
{
|
||||
"type": "packages",
|
||||
"key": ""
|
||||
},
|
||||
{
|
||||
"type": "uptime",
|
||||
"key": ""
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"key": "",
|
||||
"format": "{#31}███{#32}███{#33}███{#34}███{#35}███{#36}███"
|
||||
"type": "colors",
|
||||
"key": "Colors", // For printing icon
|
||||
"block": {
|
||||
"range": [1, 6]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
"type": "small"
|
||||
},
|
||||
"display": {
|
||||
"keyWidth": 11,
|
||||
"key": {
|
||||
"width": 11
|
||||
},
|
||||
"bar": {
|
||||
"charElapsed": "=",
|
||||
"charTotal": "-",
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"modules": [
|
||||
{
|
||||
"type": "host",
|
||||
"format": "{?2}{2}{?}{?5} ({5}){?}"
|
||||
},
|
||||
"chassis",
|
||||
{
|
||||
"type": "board",
|
||||
"format": "{?1}{1}{?}{?2} ({2}){?}"
|
||||
},
|
||||
"cpu",
|
||||
{
|
||||
"type": "memory",
|
||||
"format": "{?2}{2}{?}"
|
||||
},
|
||||
"physicaldisk",
|
||||
"gpu",
|
||||
"display",
|
||||
"monitor",
|
||||
{
|
||||
"type": "wifi",
|
||||
"format": "{?1}{1}{?}{?6} - {6}{?}"
|
||||
},
|
||||
{
|
||||
"type": "sound",
|
||||
"format": "{?2}{2}{?}"
|
||||
},
|
||||
"camera",
|
||||
{
|
||||
"type": "battery",
|
||||
"format": "{?1}{1}{?}{?2} {2}{?}{?3} ({3}){?}"
|
||||
},
|
||||
"poweradapter"
|
||||
]
|
||||
}
|
||||
@@ -11,7 +11,10 @@
|
||||
"separator",
|
||||
"os",
|
||||
"host",
|
||||
"kernel",
|
||||
{
|
||||
"type": "kernel",
|
||||
"format": "{release}"
|
||||
},
|
||||
"uptime",
|
||||
"packages",
|
||||
"shell",
|
||||
@@ -28,7 +31,7 @@
|
||||
"terminal",
|
||||
{
|
||||
"type": "terminalfont",
|
||||
"format": "{/2}{-}{/}{2}{?3} {3}{?}"
|
||||
"format": "{/name}{-}{/}{name}{?size} {size}{?}"
|
||||
},
|
||||
"cpu",
|
||||
{
|
||||
@@ -37,7 +40,7 @@
|
||||
},
|
||||
{
|
||||
"type": "memory",
|
||||
"format": "{/1}{-}{/}{/2}{-}{/}{} / {}"
|
||||
"format": "{} / {}"
|
||||
},
|
||||
"break",
|
||||
"colors"
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"modules": [
|
||||
"os",
|
||||
"kernel",
|
||||
"shell",
|
||||
"de",
|
||||
"wm",
|
||||
"wmtheme",
|
||||
"theme",
|
||||
"icons",
|
||||
"font",
|
||||
"cursor",
|
||||
"terminal",
|
||||
"terminalfont"
|
||||
]
|
||||
}
|
||||
+64
-29
@@ -10,9 +10,8 @@ static bool loadLibSymbols(FFDBusLibrary* lib)
|
||||
FF_LIBRARY_LOAD(dbus, &instance.config.library.libDBus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4);
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_bus_get, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_new_method_call, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_append_args, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_init, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_init_append, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_append_basic, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_get_arg_type, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_get_basic, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_recurse, false)
|
||||
@@ -20,10 +19,6 @@ static bool loadLibSymbols(FFDBusLibrary* lib)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_next, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_unref, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_connection_send_with_reply_and_block, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_connection_flush, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_pending_call_block, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_pending_call_steal_reply, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_pending_call_unref, false)
|
||||
dbus = NULL; // don't auto dlclose
|
||||
return true;
|
||||
}
|
||||
@@ -56,11 +51,11 @@ const char* ffDBusLoadData(DBusBusType busType, FFDBusData* data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ffDBusGetValue(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result)
|
||||
bool ffDBusGetString(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result)
|
||||
{
|
||||
int argType = dbus->lib->ffdbus_message_iter_get_arg_type(iter);
|
||||
|
||||
if(argType == DBUS_TYPE_STRING)
|
||||
if(argType == DBUS_TYPE_STRING || argType == DBUS_TYPE_OBJECT_PATH)
|
||||
{
|
||||
const char* value = NULL;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(iter, &value);
|
||||
@@ -72,6 +67,14 @@ bool ffDBusGetValue(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argType == DBUS_TYPE_BYTE)
|
||||
{
|
||||
uint8_t value;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(iter, &value);
|
||||
ffStrbufAppendC(result, (char) value);
|
||||
return false; // Don't append a comma
|
||||
}
|
||||
|
||||
if(argType != DBUS_TYPE_VARIANT && argType != DBUS_TYPE_ARRAY)
|
||||
return false;
|
||||
|
||||
@@ -79,7 +82,7 @@ bool ffDBusGetValue(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result)
|
||||
dbus->lib->ffdbus_message_iter_recurse(iter, &subIter);
|
||||
|
||||
if(argType == DBUS_TYPE_VARIANT)
|
||||
return ffDBusGetValue(dbus, &subIter, result);
|
||||
return ffDBusGetString(dbus, &subIter, result);
|
||||
|
||||
//At this point we have an array
|
||||
|
||||
@@ -87,13 +90,16 @@ bool ffDBusGetValue(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result)
|
||||
|
||||
while(true)
|
||||
{
|
||||
if(ffDBusGetValue(dbus, &subIter, result))
|
||||
if(ffDBusGetString(dbus, &subIter, result))
|
||||
{
|
||||
foundAValue = true;
|
||||
ffStrbufAppendS(result, ", ");
|
||||
}
|
||||
|
||||
FF_DBUS_ITER_CONTINUE(dbus, &subIter);
|
||||
if(!dbus->lib->ffdbus_message_iter_next(&subIter))
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
if(foundAValue)
|
||||
@@ -122,11 +128,27 @@ bool ffDBusGetBool(FFDBusData* dbus, DBusMessageIter* iter, bool* result)
|
||||
return ffDBusGetBool(dbus, &subIter, result);
|
||||
}
|
||||
|
||||
bool ffDBusGetByte(FFDBusData* dbus, DBusMessageIter* iter, uint8_t* result)
|
||||
bool ffDBusGetUint(FFDBusData* dbus, DBusMessageIter* iter, uint32_t* result)
|
||||
{
|
||||
int argType = dbus->lib->ffdbus_message_iter_get_arg_type(iter);
|
||||
|
||||
if(argType == DBUS_TYPE_BYTE)
|
||||
{
|
||||
uint8_t value = 0;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(iter, &value);
|
||||
*result = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(argType == DBUS_TYPE_UINT16)
|
||||
{
|
||||
uint16_t value = 0;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(iter, &value);
|
||||
*result = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(argType == DBUS_TYPE_UINT32)
|
||||
{
|
||||
dbus->lib->ffdbus_message_iter_get_basic(iter, result);
|
||||
return true;
|
||||
@@ -137,15 +159,18 @@ bool ffDBusGetByte(FFDBusData* dbus, DBusMessageIter* iter, uint8_t* result)
|
||||
|
||||
DBusMessageIter subIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(iter, &subIter);
|
||||
return ffDBusGetByte(dbus, &subIter, result);
|
||||
return ffDBusGetUint(dbus, &subIter, result);
|
||||
}
|
||||
|
||||
DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* method)
|
||||
DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* method, const char* arg)
|
||||
{
|
||||
DBusMessage* message = dbus->lib->ffdbus_message_new_method_call(busName, objectPath, interface, method);
|
||||
if(message == NULL)
|
||||
return NULL;
|
||||
|
||||
if (arg)
|
||||
dbus->lib->ffdbus_message_append_args(message, DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID);
|
||||
|
||||
DBusMessage* reply = dbus->lib->ffdbus_connection_send_with_reply_and_block(dbus->connection, message, FF_DBUS_TIMEOUT_MILLISECONDS, NULL);
|
||||
|
||||
dbus->lib->ffdbus_message_unref(message);
|
||||
@@ -159,20 +184,10 @@ DBusMessage* ffDBusGetProperty(FFDBusData* dbus, const char* busName, const char
|
||||
if(message == NULL)
|
||||
return NULL;
|
||||
|
||||
DBusMessageIter requestIterator;
|
||||
dbus->lib->ffdbus_message_iter_init_append(message, &requestIterator);
|
||||
|
||||
if(!dbus->lib->ffdbus_message_iter_append_basic(&requestIterator, DBUS_TYPE_STRING, &interface))
|
||||
{
|
||||
dbus->lib->ffdbus_message_unref(message);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!dbus->lib->ffdbus_message_iter_append_basic(&requestIterator, DBUS_TYPE_STRING, &property))
|
||||
{
|
||||
dbus->lib->ffdbus_message_unref(message);
|
||||
return NULL;
|
||||
}
|
||||
dbus->lib->ffdbus_message_append_args(message,
|
||||
DBUS_TYPE_STRING, &interface,
|
||||
DBUS_TYPE_STRING, &property,
|
||||
DBUS_TYPE_INVALID);
|
||||
|
||||
DBusMessage* reply = dbus->lib->ffdbus_connection_send_with_reply_and_block(dbus->connection, message, FF_DBUS_TIMEOUT_MILLISECONDS, NULL);
|
||||
|
||||
@@ -194,7 +209,27 @@ bool ffDBusGetPropertyString(FFDBusData* dbus, const char* busName, const char*
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = ffDBusGetValue(dbus, &rootIterator, result);
|
||||
bool ret = ffDBusGetString(dbus, &rootIterator, result);
|
||||
|
||||
dbus->lib->ffdbus_message_unref(reply);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ffDBusGetPropertyUint(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property, uint32_t* result)
|
||||
{
|
||||
DBusMessage* reply = ffDBusGetProperty(dbus, busName, objectPath, interface, property);
|
||||
if(reply == NULL)
|
||||
return false;
|
||||
|
||||
DBusMessageIter rootIterator;
|
||||
if(!dbus->lib->ffdbus_message_iter_init(reply, &rootIterator))
|
||||
{
|
||||
dbus->lib->ffdbus_message_unref(reply);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = ffDBusGetUint(dbus, &rootIterator, result);
|
||||
|
||||
dbus->lib->ffdbus_message_unref(reply);
|
||||
|
||||
|
||||
+5
-18
@@ -7,22 +7,12 @@
|
||||
#include "common/library.h"
|
||||
|
||||
#define FF_DBUS_TIMEOUT_MILLISECONDS 35
|
||||
|
||||
#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
|
||||
{ \
|
||||
if(!(dbus)->lib->ffdbus_message_iter_has_next(iterator)) \
|
||||
break; \
|
||||
(dbus)->lib->ffdbus_message_iter_next(iterator); \
|
||||
continue; \
|
||||
}
|
||||
|
||||
typedef struct FFDBusLibrary
|
||||
{
|
||||
FF_LIBRARY_SYMBOL(dbus_bus_get)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_new_method_call)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_append_args)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_iter_init)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_iter_init_append)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_iter_append_basic)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_iter_get_arg_type)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_iter_get_basic)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_iter_recurse)
|
||||
@@ -30,10 +20,6 @@ typedef struct FFDBusLibrary
|
||||
FF_LIBRARY_SYMBOL(dbus_message_iter_next)
|
||||
FF_LIBRARY_SYMBOL(dbus_message_unref)
|
||||
FF_LIBRARY_SYMBOL(dbus_connection_send_with_reply_and_block)
|
||||
FF_LIBRARY_SYMBOL(dbus_connection_flush)
|
||||
FF_LIBRARY_SYMBOL(dbus_pending_call_block)
|
||||
FF_LIBRARY_SYMBOL(dbus_pending_call_steal_reply)
|
||||
FF_LIBRARY_SYMBOL(dbus_pending_call_unref)
|
||||
} FFDBusLibrary;
|
||||
|
||||
typedef struct FFDBusData
|
||||
@@ -43,11 +29,12 @@ typedef struct FFDBusData
|
||||
} FFDBusData;
|
||||
|
||||
const char* ffDBusLoadData(DBusBusType busType, FFDBusData* data); //Returns an error message or NULL on success
|
||||
bool ffDBusGetValue(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result);
|
||||
bool ffDBusGetString(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result);
|
||||
bool ffDBusGetBool(FFDBusData* dbus, DBusMessageIter* iter, bool* result);
|
||||
bool ffDBusGetByte(FFDBusData* dbus, DBusMessageIter* iter, uint8_t* result);
|
||||
DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* method);
|
||||
bool ffDBusGetUint(FFDBusData* dbus, DBusMessageIter* iter, uint32_t* result);
|
||||
DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* method, const char* arg);
|
||||
DBusMessage* ffDBusGetProperty(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property);
|
||||
bool ffDBusGetPropertyString(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property, FFstrbuf* result);
|
||||
bool ffDBusGetPropertyUint(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property, uint32_t* result);
|
||||
|
||||
#endif // FF_HAVE_DBUS
|
||||
|
||||
+29
-32
@@ -173,94 +173,91 @@ void ffDestroyInstance(void)
|
||||
void ffListFeatures(void)
|
||||
{
|
||||
fputs(
|
||||
#ifdef FF_HAVE_THREADS
|
||||
#if FF_HAVE_THREADS
|
||||
"threads\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_VULKAN
|
||||
#if FF_HAVE_VULKAN
|
||||
"vulkan\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_WAYLAND
|
||||
#if FF_HAVE_WAYLAND
|
||||
"wayland\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_XCB_RANDR
|
||||
#if FF_HAVE_XCB_RANDR
|
||||
"xcb-randr\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_XCB
|
||||
#if FF_HAVE_XCB
|
||||
"xcb\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_XRANDR
|
||||
#if FF_HAVE_XRANDR
|
||||
"xrandr\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_X11
|
||||
#if FF_HAVE_X11
|
||||
"x11\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_DRM
|
||||
#if FF_HAVE_DRM
|
||||
"drm\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_GIO
|
||||
#if FF_HAVE_GIO
|
||||
"gio\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_DCONF
|
||||
#if FF_HAVE_DCONF
|
||||
"dconf\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_DBUS
|
||||
#if FF_HAVE_DBUS
|
||||
"dbus\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_IMAGEMAGICK7
|
||||
#if FF_HAVE_IMAGEMAGICK7
|
||||
"imagemagick7\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_IMAGEMAGICK6
|
||||
#if FF_HAVE_IMAGEMAGICK6
|
||||
"imagemagick6\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_CHAFA
|
||||
#if FF_HAVE_CHAFA
|
||||
"chafa\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_ZLIB
|
||||
#if FF_HAVE_ZLIB
|
||||
"zlib\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_XFCONF
|
||||
#if FF_HAVE_XFCONF
|
||||
"xfconf\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_SQLITE3
|
||||
#if FF_HAVE_SQLITE3
|
||||
"sqlite3\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_RPM
|
||||
#if FF_HAVE_RPM
|
||||
"rpm\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_EGL
|
||||
#if FF_HAVE_EGL
|
||||
"egl\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_GLX
|
||||
#if FF_HAVE_GLX
|
||||
"glx\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_OSMESA
|
||||
#if FF_HAVE_OSMESA
|
||||
"osmesa\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_OPENCL
|
||||
#if FF_HAVE_OPENCL
|
||||
"opencl\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_FREETYPE
|
||||
#if FF_HAVE_FREETYPE
|
||||
"freetype\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_PULSE
|
||||
#if FF_HAVE_PULSE
|
||||
"libpulse\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_LIBNM
|
||||
"libnm\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_DDCUTIL
|
||||
#if FF_HAVE_DDCUTIL
|
||||
"libddcutil\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_DIRECTX_HEADERS
|
||||
#if FF_HAVE_DIRECTX_HEADERS
|
||||
"Directx Headers\n"
|
||||
#endif
|
||||
#ifdef FF_USE_SYSTEM_YYJSON
|
||||
#if FF_USE_SYSTEM_YYJSON
|
||||
"System yyjson\n"
|
||||
#endif
|
||||
#if __has_include(<linux/videodev2.h>)
|
||||
#if FF_HAVE_LINUX_VIDEODEV2
|
||||
"linux/videodev2\n"
|
||||
#endif
|
||||
#if __has_include(<linux/wireless.h>)
|
||||
#if FF_HAVE_LINUX_WIRELESS
|
||||
"linux/wireless\n"
|
||||
#endif
|
||||
""
|
||||
|
||||
+28
-33
@@ -8,8 +8,10 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if __has_include(<wordexp.h>)
|
||||
#include <wordexp.h>
|
||||
#if FF_HAVE_WORDEXP
|
||||
#include <wordexp.h>
|
||||
#else
|
||||
#warning "<wordexp.h> not available"
|
||||
#endif
|
||||
|
||||
static void createSubfolders(const char* fileName)
|
||||
@@ -112,7 +114,7 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
#if __has_include(<wordexp.h>) // https://github.com/termux/termux-packages/pull/7056
|
||||
#if FF_HAVE_WORDEXP // https://github.com/termux/termux-packages/pull/7056
|
||||
|
||||
wordexp_t exp;
|
||||
if(wordexp(in, &exp, 0) != 0)
|
||||
@@ -131,46 +133,39 @@ bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* o
|
||||
return result;
|
||||
}
|
||||
|
||||
static int ftty = -1;
|
||||
static struct termios oldTerm;
|
||||
void restoreTerm(void)
|
||||
{
|
||||
tcsetattr(ftty, TCSAFLUSH, &oldTerm);
|
||||
}
|
||||
|
||||
const char* ffGetTerminalResponse(const char* request, const char* format, ...)
|
||||
{
|
||||
int fin = STDIN_FILENO, fout = STDOUT_FILENO;
|
||||
FF_AUTO_CLOSE_FD int ftty = -1;
|
||||
if (ftty < 0)
|
||||
{
|
||||
ftty = open("/dev/tty", O_RDWR | O_NOCTTY | O_CLOEXEC);
|
||||
if (ftty < 0)
|
||||
return "open(\"/dev/tty\", O_RDWR | O_NOCTTY | O_CLOEXEC) failed";
|
||||
|
||||
if (!isatty(STDIN_FILENO))
|
||||
{
|
||||
if (ftty < 0)
|
||||
ftty = open("/dev/tty", O_RDWR | O_NOCTTY | O_CLOEXEC);
|
||||
fin = ftty;
|
||||
}
|
||||
if (!isatty(STDOUT_FILENO))
|
||||
{
|
||||
if (ftty < 0)
|
||||
ftty = open("/dev/tty", O_RDWR | O_NOCTTY | O_CLOEXEC);
|
||||
fout = ftty;
|
||||
if(tcgetattr(ftty, &oldTerm) == -1)
|
||||
return "tcgetattr(STDIN_FILENO, &oldTerm) failed";
|
||||
|
||||
struct termios newTerm = oldTerm;
|
||||
newTerm.c_lflag &= (tcflag_t) ~(ICANON | ECHO);
|
||||
if(tcsetattr(ftty, TCSAFLUSH, &newTerm) == -1)
|
||||
return "tcsetattr(STDIN_FILENO, TCSAFLUSH, &newTerm)";
|
||||
atexit(restoreTerm);
|
||||
}
|
||||
|
||||
struct termios oldTerm;
|
||||
if(tcgetattr(fin, &oldTerm) == -1)
|
||||
return "tcgetattr(STDIN_FILENO, &oldTerm) failed";
|
||||
|
||||
struct termios newTerm = oldTerm;
|
||||
newTerm.c_lflag &= (tcflag_t) ~(ICANON | ECHO);
|
||||
if(tcsetattr(fin, TCSAFLUSH, &newTerm) == -1)
|
||||
return "tcsetattr(STDIN_FILENO, TCSAFLUSH, &newTerm)";
|
||||
|
||||
ffWriteFDData(fout, strlen(request), request);
|
||||
ffWriteFDData(ftty, strlen(request), request);
|
||||
|
||||
//Give the terminal some time to respond
|
||||
if(poll(&(struct pollfd) { .fd = fin, .events = POLLIN }, 1, FF_IO_TERM_RESP_WAIT_MS) <= 0)
|
||||
{
|
||||
tcsetattr(fin, TCSANOW, &oldTerm);
|
||||
if(poll(&(struct pollfd) { .fd = ftty, .events = POLLIN }, 1, FF_IO_TERM_RESP_WAIT_MS) <= 0)
|
||||
return "poll() timeout or failed";
|
||||
}
|
||||
|
||||
char buffer[512];
|
||||
ssize_t bytesRead = read(fin, buffer, sizeof(buffer) - 1);
|
||||
|
||||
tcsetattr(fin, TCSANOW, &oldTerm);
|
||||
ssize_t bytesRead = read(ftty, buffer, sizeof(buffer) - 1);
|
||||
|
||||
if(bytesRead <= 0)
|
||||
return "read(STDIN_FILENO, buffer, sizeof(buffer) - 1) failed";
|
||||
|
||||
@@ -37,6 +37,11 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs*
|
||||
moduleArgs->keyWidth = (uint32_t) yyjson_get_uint(val);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "keyIcon"))
|
||||
{
|
||||
ffStrbufSetS(&moduleArgs->keyIcon, yyjson_get_str(val));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,6 +55,8 @@ void ffJsonConfigGenerateModuleArgsConfig(yyjson_mut_doc* doc, yyjson_mut_val* m
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "keyColor", &moduleArgs->keyColor);
|
||||
if (moduleArgs->keyWidth != defaultModuleArgs->keyWidth)
|
||||
yyjson_mut_obj_add_uint(doc, module, "keyWidth", moduleArgs->keyWidth);
|
||||
if (!ffStrbufEqual(&defaultModuleArgs->keyIcon, &moduleArgs->keyIcon))
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "keyIcon", &moduleArgs->keyIcon);
|
||||
}
|
||||
|
||||
const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[])
|
||||
|
||||
@@ -8,6 +8,7 @@ static FFModuleBaseInfo* B[] = {
|
||||
(void*) &instance.config.modules.battery,
|
||||
(void*) &instance.config.modules.bios,
|
||||
(void*) &instance.config.modules.bluetooth,
|
||||
(void*) &instance.config.modules.bluetoothRadio,
|
||||
(void*) &instance.config.modules.board,
|
||||
(void*) &instance.config.modules.bootmgr,
|
||||
(void*) &instance.config.modules.break_,
|
||||
|
||||
+25
-28
@@ -50,20 +50,29 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const
|
||||
ffOptionParseColor(value, &result->outputColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "key-color"))
|
||||
else if(ffStrStartsWithIgnCase(subKey, "key-"))
|
||||
{
|
||||
if(value == NULL)
|
||||
const char* subKey2 = subKey + strlen("key-");
|
||||
if(ffStrEqualsIgnCase(subKey2, "color"))
|
||||
{
|
||||
fprintf(stderr, "Error: usage: %s <str>\n", argumentKey);
|
||||
exit(477);
|
||||
if(value == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error: usage: %s <str>\n", argumentKey);
|
||||
exit(477);
|
||||
}
|
||||
ffOptionParseColor(value, &result->keyColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey2, "width"))
|
||||
{
|
||||
result->keyWidth = ffOptionParseUInt32(argumentKey, value);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey2, "icon"))
|
||||
{
|
||||
ffOptionParseString(argumentKey, value, &result->keyIcon);
|
||||
return true;
|
||||
}
|
||||
ffOptionParseColor(value, &result->keyColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "key-width"))
|
||||
{
|
||||
result->keyWidth = ffOptionParseUInt32(argumentKey, value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -197,6 +206,11 @@ void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer)
|
||||
else FF_APPEND_COLOR_PROP_COND(title, colorTitle)
|
||||
else FF_APPEND_COLOR_PROP_COND(output, colorOutput)
|
||||
else FF_APPEND_COLOR_PROP_COND(separator, colorSeparator)
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Error: invalid color code found: %s\n", value);
|
||||
exit(479);
|
||||
}
|
||||
}
|
||||
ffStrbufAppendC(buffer, *value);
|
||||
++value;
|
||||
@@ -205,20 +219,3 @@ void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer)
|
||||
#undef FF_APPEND_COLOR_PROP_COND
|
||||
}
|
||||
}
|
||||
|
||||
void ffOptionInitModuleArg(FFModuleArgs* args)
|
||||
{
|
||||
ffStrbufInit(&args->key);
|
||||
ffStrbufInit(&args->keyColor);
|
||||
ffStrbufInit(&args->outputFormat);
|
||||
ffStrbufInit(&args->outputColor);
|
||||
args->keyWidth = 0;
|
||||
}
|
||||
|
||||
void ffOptionDestroyModuleArg(FFModuleArgs* args)
|
||||
{
|
||||
ffStrbufDestroy(&args->key);
|
||||
ffStrbufDestroy(&args->keyColor);
|
||||
ffStrbufDestroy(&args->outputFormat);
|
||||
ffStrbufDestroy(&args->outputColor);
|
||||
}
|
||||
|
||||
+28
-2
@@ -45,10 +45,19 @@ static inline void ffOptionInitModuleBaseInfo(
|
||||
baseInfo->generateJsonConfig = (__typeof__(baseInfo->generateJsonConfig)) generateJsonConfig;
|
||||
}
|
||||
|
||||
typedef enum FFModuleKeyType
|
||||
{
|
||||
FF_MODULE_KEY_TYPE_NONE = 0,
|
||||
FF_MODULE_KEY_TYPE_STRING = 1 << 0,
|
||||
FF_MODULE_KEY_TYPE_ICON = 1 << 1,
|
||||
FF_MODULE_KEY_TYPE_BOTH = FF_MODULE_KEY_TYPE_STRING | FF_MODULE_KEY_TYPE_ICON,
|
||||
} FFModuleKeyType;
|
||||
|
||||
typedef struct FFModuleArgs
|
||||
{
|
||||
FFstrbuf key;
|
||||
FFstrbuf keyColor;
|
||||
FFstrbuf keyIcon;
|
||||
FFstrbuf outputFormat;
|
||||
FFstrbuf outputColor;
|
||||
uint32_t keyWidth;
|
||||
@@ -73,5 +82,22 @@ static inline void ffOptionParseColor(const char* value, FFstrbuf* buffer)
|
||||
ffStrbufClear(buffer);
|
||||
ffOptionParseColorNoClear(value, buffer);
|
||||
}
|
||||
void ffOptionInitModuleArg(FFModuleArgs* args);
|
||||
void ffOptionDestroyModuleArg(FFModuleArgs* args);
|
||||
|
||||
static inline void ffOptionInitModuleArg(FFModuleArgs* args, const char* icon)
|
||||
{
|
||||
ffStrbufInit(&args->key);
|
||||
ffStrbufInit(&args->keyColor);
|
||||
ffStrbufInitStatic(&args->keyIcon, icon);
|
||||
ffStrbufInit(&args->outputFormat);
|
||||
ffStrbufInit(&args->outputColor);
|
||||
args->keyWidth = 0;
|
||||
}
|
||||
|
||||
static inline void ffOptionDestroyModuleArg(FFModuleArgs* args)
|
||||
{
|
||||
ffStrbufDestroy(&args->key);
|
||||
ffStrbufDestroy(&args->keyColor);
|
||||
ffStrbufDestroy(&args->keyIcon);
|
||||
ffStrbufDestroy(&args->outputFormat);
|
||||
ffStrbufDestroy(&args->outputColor);
|
||||
}
|
||||
|
||||
+29
-13
@@ -11,8 +11,10 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
return;
|
||||
|
||||
//This is used as a magic value for hiding keys
|
||||
if (!(moduleArgs && ffStrbufEqualS(&moduleArgs->key, " ")))
|
||||
if (!(moduleArgs && ffStrbufEqualS(&moduleArgs->key, " ")) && instance.config.display.keyType != FF_MODULE_KEY_TYPE_NONE)
|
||||
{
|
||||
ffPrintCharTimes(' ', instance.config.display.keyPaddingLeft);
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
@@ -25,21 +27,35 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
ffPrintColor(&instance.config.display.colorKeys);
|
||||
}
|
||||
|
||||
//NULL check is required for modules with custom keys, e.g. disk with the folder path
|
||||
if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0)
|
||||
bool hasIcon = false;
|
||||
if (instance.config.display.keyType & FF_MODULE_KEY_TYPE_ICON && moduleArgs && moduleArgs->keyIcon.length > 0)
|
||||
{
|
||||
fputs(moduleName, stdout);
|
||||
|
||||
if(moduleIndex > 0)
|
||||
printf(" %hhu", moduleIndex);
|
||||
ffStrbufWriteTo(&moduleArgs->keyIcon, stdout);
|
||||
hasIcon = true;
|
||||
}
|
||||
else
|
||||
|
||||
if (instance.config.display.keyType & FF_MODULE_KEY_TYPE_STRING)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 1, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex, "index"},
|
||||
}));
|
||||
ffStrbufWriteTo(&key, stdout);
|
||||
if(hasIcon)
|
||||
putchar(' ');
|
||||
|
||||
//NULL check is required for modules with custom keys, e.g. disk with the folder path
|
||||
if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0)
|
||||
{
|
||||
fputs(moduleName, stdout);
|
||||
|
||||
if(moduleIndex > 0)
|
||||
printf(" %hhu", moduleIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 2, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex, "index"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &moduleArgs->keyIcon, "icon"},
|
||||
}));
|
||||
ffStrbufWriteTo(&key, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#if __has_include(<pthread_np.h>)
|
||||
#if FF_HAVE_PTHREAD_NP
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
#define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
@@ -51,7 +51,7 @@
|
||||
static inline void ffThreadDetach(FFThreadType thread) { pthread_detach(thread); }
|
||||
static inline bool ffThreadJoin(FFThreadType thread, FF_MAYBE_UNUSED uint32_t timeout)
|
||||
{
|
||||
#if (defined(__linux__) && !defined(__ANDROID__)) || __has_include(<pthread_np.h>)
|
||||
#if HAVE_TIMEDJOIN_NP
|
||||
if (timeout > 0)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
@@ -505,6 +505,27 @@
|
||||
"type": "num"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "key-padding-left",
|
||||
"desc": "Set the left padding of keys to <num> characters",
|
||||
"arg": {
|
||||
"type": "num"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "key-type",
|
||||
"desc": "Set whether to show icon before string keys",
|
||||
"arg": {
|
||||
"type": "enum",
|
||||
"enum": {
|
||||
"none": "Disable keys",
|
||||
"string": "Show string",
|
||||
"icon": "Show icon (requires newest nerd font)",
|
||||
"both": "Show both icon and string"
|
||||
},
|
||||
"default": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "bright-color",
|
||||
"desc": "Set if the keys, title and ASCII logo should be printed in bright color",
|
||||
@@ -1637,6 +1658,14 @@
|
||||
},
|
||||
"pseudo": true
|
||||
},
|
||||
{
|
||||
"long": "<module>-key-icon",
|
||||
"desc": "Set the icon to be displayed by \"--key-type icon\"",
|
||||
"arg": {
|
||||
"type": "string"
|
||||
},
|
||||
"pseudo": true
|
||||
},
|
||||
{
|
||||
"long": "<module>-output-color",
|
||||
"desc": "Override the global \"--color-output\" option for each specific module",
|
||||
|
||||
@@ -61,13 +61,17 @@ static void detectBluetoothValue(FFDBusData* dbus, DBusMessageIter* iter, FFBlue
|
||||
dbus->lib->ffdbus_message_iter_next(&dictIter);
|
||||
|
||||
if(ffStrEquals(deviceProperty, "Address"))
|
||||
ffDBusGetValue(dbus, &dictIter, &device->address);
|
||||
ffDBusGetString(dbus, &dictIter, &device->address);
|
||||
else if(ffStrEquals(deviceProperty, "Name"))
|
||||
ffDBusGetValue(dbus, &dictIter, &device->name);
|
||||
ffDBusGetString(dbus, &dictIter, &device->name);
|
||||
else if(ffStrEquals(deviceProperty, "Icon"))
|
||||
ffDBusGetValue(dbus, &dictIter, &device->type);
|
||||
ffDBusGetString(dbus, &dictIter, &device->type);
|
||||
else if(ffStrEquals(deviceProperty, "Percentage"))
|
||||
ffDBusGetByte(dbus, &dictIter, &device->battery);
|
||||
{
|
||||
uint32_t percentage;
|
||||
if (ffDBusGetUint(dbus, &dictIter, &percentage))
|
||||
device->battery = (uint8_t) percentage;
|
||||
}
|
||||
else if(ffStrEquals(deviceProperty, "Connected"))
|
||||
ffDBusGetBool(dbus, &dictIter, &device->connected);
|
||||
}
|
||||
@@ -86,8 +90,8 @@ static void detectBluetoothProperty(FFDBusData* dbus, DBusMessageIter* iter, FFB
|
||||
const char* propertyType;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(&dictIter, &propertyType);
|
||||
|
||||
if(strstr(propertyType, "Device") == NULL && strstr(propertyType, "Battery") == NULL)
|
||||
return; //We don't care about other properties
|
||||
if(!ffStrContains(propertyType, ".Device") && !ffStrContains(propertyType, ".Battery"))
|
||||
return; // We don't care about other properties
|
||||
|
||||
dbus->lib->ffdbus_message_iter_next(&dictIter);
|
||||
|
||||
@@ -97,11 +101,10 @@ static void detectBluetoothProperty(FFDBusData* dbus, DBusMessageIter* iter, FFB
|
||||
DBusMessageIter arrayIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(&dictIter, &arrayIter);
|
||||
|
||||
while(true)
|
||||
do
|
||||
{
|
||||
detectBluetoothValue(dbus, &arrayIter, device);
|
||||
FF_DBUS_ITER_CONTINUE(dbus, &arrayIter);
|
||||
}
|
||||
} while (dbus->lib->ffdbus_message_iter_next(&arrayIter));
|
||||
}
|
||||
|
||||
static void detectBluetoothObject(FFlist* devices, FFDBusData* dbus, DBusMessageIter* iter)
|
||||
@@ -118,8 +121,8 @@ static void detectBluetoothObject(FFlist* devices, FFDBusData* dbus, DBusMessage
|
||||
const char* objectPath;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(&dictIter, &objectPath);
|
||||
|
||||
//We don't want adapter objects
|
||||
if(strstr(objectPath, "dev_") == NULL)
|
||||
// We don't want adapter objects
|
||||
if(!ffStrContains(objectPath, "/dev_"))
|
||||
return;
|
||||
|
||||
dbus->lib->ffdbus_message_iter_next(&dictIter);
|
||||
@@ -137,11 +140,10 @@ static void detectBluetoothObject(FFlist* devices, FFDBusData* dbus, DBusMessage
|
||||
device->battery = 0;
|
||||
device->connected = false;
|
||||
|
||||
while(true)
|
||||
do
|
||||
{
|
||||
detectBluetoothProperty(dbus, &arrayIter, device);
|
||||
FF_DBUS_ITER_CONTINUE(dbus, &arrayIter);
|
||||
}
|
||||
} while (dbus->lib->ffdbus_message_iter_next(&arrayIter));
|
||||
|
||||
if(device->name.length == 0)
|
||||
{
|
||||
@@ -160,11 +162,10 @@ static void detectBluetoothRoot(FFlist* devices, FFDBusData* dbus, DBusMessageIt
|
||||
DBusMessageIter arrayIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(iter, &arrayIter);
|
||||
|
||||
while(true)
|
||||
do
|
||||
{
|
||||
detectBluetoothObject(devices, dbus, &arrayIter);
|
||||
FF_DBUS_ITER_CONTINUE(dbus, &arrayIter);
|
||||
}
|
||||
} while (dbus->lib->ffdbus_message_iter_next(&arrayIter));
|
||||
}
|
||||
|
||||
static const char* detectBluetooth(FFlist* devices)
|
||||
@@ -174,7 +175,7 @@ static const char* detectBluetooth(FFlist* devices)
|
||||
if(error)
|
||||
return error;
|
||||
|
||||
DBusMessage* managedObjects = ffDBusGetMethodReply(&dbus, "org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
|
||||
DBusMessage* managedObjects = ffDBusGetMethodReply(&dbus, "org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", NULL);
|
||||
if(!managedObjects)
|
||||
return "Failed to call GetManagedObjects";
|
||||
|
||||
|
||||
@@ -15,43 +15,35 @@ const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothResult */)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindNextDevice)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindDeviceClose)
|
||||
|
||||
BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = {
|
||||
BLUETOOTH_DEVICE_INFO btdi = {
|
||||
.dwSize = sizeof(btdi)
|
||||
};
|
||||
HBLUETOOTH_DEVICE_FIND hFind = ffBluetoothFindFirstDevice(&(BLUETOOTH_DEVICE_SEARCH_PARAMS) {
|
||||
.fReturnConnected = TRUE,
|
||||
.fReturnRemembered = TRUE,
|
||||
.fReturnAuthenticated = TRUE,
|
||||
.fReturnUnknown = TRUE,
|
||||
.dwSize = sizeof(btsp)
|
||||
};
|
||||
|
||||
BLUETOOTH_DEVICE_INFO btdi = {
|
||||
.dwSize = sizeof(btdi)
|
||||
};
|
||||
HBLUETOOTH_DEVICE_FIND hFind = ffBluetoothFindFirstDevice(&btsp, &btdi);
|
||||
.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS)
|
||||
}, &btdi);
|
||||
if(!hFind)
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_MORE_ITEMS)
|
||||
return "No Bluetooth devices found";
|
||||
else
|
||||
return "BluetoothFindFirstDevice() failed";
|
||||
return "BluetoothFindFirstDevice() failed";
|
||||
}
|
||||
|
||||
do {
|
||||
FFBluetoothResult* device = ffListAdd(devices);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInit(&device->address);
|
||||
ffStrbufInit(&device->type);
|
||||
device->battery = 0;
|
||||
device->connected = !!btdi.fConnected;
|
||||
|
||||
ffStrbufSetWS(&device->name, btdi.szName);
|
||||
|
||||
ffStrbufAppendF(&device->address, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
ffStrbufInitWS(&device->name, btdi.szName);
|
||||
ffStrbufInitF(&device->address, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
btdi.Address.rgBytes[0],
|
||||
btdi.Address.rgBytes[1],
|
||||
btdi.Address.rgBytes[2],
|
||||
btdi.Address.rgBytes[3],
|
||||
btdi.Address.rgBytes[4],
|
||||
btdi.Address.rgBytes[5]);
|
||||
ffStrbufInit(&device->type);
|
||||
device->battery = 0;
|
||||
device->connected = !!btdi.fConnected;
|
||||
|
||||
//https://btprodspecificationrefs.blob.core.windows.net/assigned-numbers/Assigned%20Number%20Types/Assigned%20Numbers.pdf
|
||||
|
||||
if(BitTest(&btdi.ulClassofDevice, 13))
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
#include "bluetoothradio.h"
|
||||
|
||||
// https://github.com/ziglang/zig/blob/a84951465b409495095a9598db0cae745f34fa7b/lib/libc/include/any-windows-any/bthdef.h#L187-L236
|
||||
|
||||
#define BTH_MFG_ERICSSON 0
|
||||
#define BTH_MFG_NOKIA 1
|
||||
#define BTH_MFG_INTEL 2
|
||||
#define BTH_MFG_IBM 3
|
||||
#define BTH_MFG_TOSHIBA 4
|
||||
#define BTH_MFG_3COM 5
|
||||
#define BTH_MFG_MICROSOFT 6
|
||||
#define BTH_MFG_LUCENT 7
|
||||
#define BTH_MFG_MOTOROLA 8
|
||||
#define BTH_MFG_INFINEON 9
|
||||
#define BTH_MFG_CSR 10
|
||||
#define BTH_MFG_SILICONWAVE 11
|
||||
#define BTH_MFG_DIGIANSWER 12
|
||||
#define BTH_MFG_TI 13
|
||||
#define BTH_MFG_PARTHUS 14
|
||||
#define BTH_MFG_BROADCOM 15
|
||||
#define BTH_MFG_MITEL 16
|
||||
#define BTH_MFG_WIDCOMM 17
|
||||
#define BTH_MFG_ZEEVO 18
|
||||
#define BTH_MFG_ATMEL 19
|
||||
#define BTH_MFG_MITSIBUSHI 20
|
||||
#define BTH_MFG_RTX_TELECOM 21
|
||||
#define BTH_MFG_KC_TECHNOLOGY 22
|
||||
#define BTH_MFG_NEWLOGIC 23
|
||||
#define BTH_MFG_TRANSILICA 24
|
||||
#define BTH_MFG_ROHDE_SCHWARZ 25
|
||||
#define BTH_MFG_TTPCOM 26
|
||||
#define BTH_MFG_SIGNIA 27
|
||||
#define BTH_MFG_CONEXANT 28
|
||||
#define BTH_MFG_QUALCOMM 29
|
||||
#define BTH_MFG_INVENTEL 30
|
||||
#define BTH_MFG_AVM_BERLIN 31
|
||||
#define BTH_MFG_BANDSPEED 32
|
||||
#define BTH_MFG_MANSELLA 33
|
||||
#define BTH_MFG_NEC 34
|
||||
#define BTH_MFG_WAVEPLUS_TECHNOLOGY_CO 35
|
||||
#define BTH_MFG_ALCATEL 36
|
||||
#define BTH_MFG_PHILIPS_SEMICONDUCTOR 37
|
||||
#define BTH_MFG_C_TECHNOLOGIES 38
|
||||
#define BTH_MFG_OPEN_INTERFACE 39
|
||||
#define BTH_MFG_RF_MICRO_DEVICES 40
|
||||
#define BTH_MFG_HITACHI 41
|
||||
#define BTH_MFG_SYMBOL_TECHNOLOGIES 42
|
||||
#define BTH_MFG_TENOVIS 43
|
||||
#define BTH_MFG_MACRONIX_INTERNATIONAL 44
|
||||
#define BTH_MFG_MARVELL 72
|
||||
#define BTH_MFG_APPLE 76
|
||||
#define BTH_MFG_NORDIC_SEMICONDUCTORS_ASA 89
|
||||
#define BTH_MFG_ARUBA_NETWORKS 283
|
||||
#define BTH_MFG_INTERNAL_USE 65535
|
||||
|
||||
const char* ffBluetoothRadioGetVendor(uint32_t manufacturerId)
|
||||
{
|
||||
switch (manufacturerId)
|
||||
{
|
||||
case BTH_MFG_ERICSSON: return "Ericsson";
|
||||
case BTH_MFG_NOKIA: return "Nokia";
|
||||
case BTH_MFG_INTEL: return "Intel";
|
||||
case BTH_MFG_IBM: return "IBM";
|
||||
case BTH_MFG_TOSHIBA: return "Toshiba";
|
||||
case BTH_MFG_3COM: return "3Com";
|
||||
case BTH_MFG_MICROSOFT: return "Microsoft";
|
||||
case BTH_MFG_LUCENT: return "Lucent";
|
||||
case BTH_MFG_MOTOROLA: return "Motorola";
|
||||
case BTH_MFG_INFINEON: return "Infineon";
|
||||
case BTH_MFG_CSR: return "CSR";
|
||||
case BTH_MFG_SILICONWAVE: return "Silicon-Wave";
|
||||
case BTH_MFG_DIGIANSWER: return "Digi-Answer";
|
||||
case BTH_MFG_TI: return "Ti";
|
||||
case BTH_MFG_PARTHUS: return "Parthus";
|
||||
case BTH_MFG_BROADCOM: return "Broadcom";
|
||||
case BTH_MFG_MITEL: return "Mitel";
|
||||
case BTH_MFG_WIDCOMM: return "Widcomm";
|
||||
case BTH_MFG_ZEEVO: return "Zeevo";
|
||||
case BTH_MFG_ATMEL: return "Atmel";
|
||||
case BTH_MFG_MITSIBUSHI: return "Mitsubishi";
|
||||
case BTH_MFG_RTX_TELECOM: return "RTX Telecom";
|
||||
case BTH_MFG_KC_TECHNOLOGY: return "KC Technology";
|
||||
case BTH_MFG_NEWLOGIC: return "Newlogic";
|
||||
case BTH_MFG_TRANSILICA: return "Transilica";
|
||||
case BTH_MFG_ROHDE_SCHWARZ: return "Rohde-Schwarz";
|
||||
case BTH_MFG_TTPCOM: return "TTPCom";
|
||||
case BTH_MFG_SIGNIA: return "Signia";
|
||||
case BTH_MFG_CONEXANT: return "Conexant";
|
||||
case BTH_MFG_QUALCOMM: return "Qualcomm";
|
||||
case BTH_MFG_INVENTEL: return "Inventel";
|
||||
case BTH_MFG_AVM_BERLIN: return "AVM Berlin";
|
||||
case BTH_MFG_BANDSPEED: return "Bandspeed";
|
||||
case BTH_MFG_MANSELLA: return "Mansella";
|
||||
case BTH_MFG_NEC: return "NEC";
|
||||
case BTH_MFG_WAVEPLUS_TECHNOLOGY_CO: return "Waveplus";
|
||||
case BTH_MFG_ALCATEL: return "Alcatel";
|
||||
case BTH_MFG_PHILIPS_SEMICONDUCTOR: return "Philips Semiconductors";
|
||||
case BTH_MFG_C_TECHNOLOGIES: return "C Technologies";
|
||||
case BTH_MFG_OPEN_INTERFACE: return "Open Interface";
|
||||
case BTH_MFG_RF_MICRO_DEVICES: return "RF Micro Devices";
|
||||
case BTH_MFG_HITACHI: return "Hitachi";
|
||||
case BTH_MFG_SYMBOL_TECHNOLOGIES: return "Symbol Technologies";
|
||||
case BTH_MFG_TENOVIS: return "Tenovis";
|
||||
case BTH_MFG_MACRONIX_INTERNATIONAL: return "Macronix International";
|
||||
case BTH_MFG_MARVELL: return "Marvell";
|
||||
case BTH_MFG_APPLE: return "Apple";
|
||||
case BTH_MFG_NORDIC_SEMICONDUCTORS_ASA: return "Nordic Semiconductor ASA";
|
||||
case BTH_MFG_ARUBA_NETWORKS: return "Aruba Networks";
|
||||
case BTH_MFG_INTERNAL_USE: return "Internal Use";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFBluetoothRadioResult
|
||||
{
|
||||
FFstrbuf name;
|
||||
FFstrbuf address;
|
||||
FFstrbuf vendor;
|
||||
int32_t lmpVersion;
|
||||
int32_t lmpSubversion;
|
||||
bool enabled;
|
||||
bool discoverable;
|
||||
bool connectable;
|
||||
} FFBluetoothRadioResult;
|
||||
|
||||
const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */);
|
||||
const char* ffBluetoothRadioGetVendor(uint32_t manufacturerId);
|
||||
@@ -0,0 +1,69 @@
|
||||
#include "bluetoothradio.h"
|
||||
#include "common/processing.h"
|
||||
|
||||
#import <IOBluetooth/IOBluetooth.h>
|
||||
|
||||
// For some reason the official declaration of IOBluetoothHostController don't include property `controllers`
|
||||
@interface IOBluetoothHostController()
|
||||
+ (id)controllers;
|
||||
@end
|
||||
|
||||
const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothResult */)
|
||||
{
|
||||
NSArray<IOBluetoothHostController*>* ctrls = IOBluetoothHostController.controllers;
|
||||
if(!ctrls)
|
||||
return "IOBluetoothHostController.controllers returns nil";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) {
|
||||
"system_profiler",
|
||||
"SPBluetoothDataType",
|
||||
"-xml",
|
||||
"-detailLevel",
|
||||
"basic",
|
||||
NULL
|
||||
}) != NULL)
|
||||
return "Starting `system_profiler SPBluetoothDataType -xml -detailLevel basic` failed";
|
||||
|
||||
NSArray* arr = [NSPropertyListSerialization propertyListWithData:[NSData dataWithBytes:buffer.chars length:buffer.length]
|
||||
options:NSPropertyListImmutable
|
||||
format:nil
|
||||
error:nil];
|
||||
if (!arr || !arr.count)
|
||||
return "system_profiler SPBluetoothDataType returned an empty array";
|
||||
|
||||
for (IOBluetoothHostController* ctrl in ctrls)
|
||||
{
|
||||
FFBluetoothRadioResult* device = ffListAdd(devices);
|
||||
ffStrbufInitS(&device->name, ctrl.nameAsString.UTF8String);
|
||||
ffStrbufInitS(&device->address, ctrl.addressAsString.UTF8String);
|
||||
ffStrbufInitStatic(&device->vendor, "Apple");
|
||||
device->lmpVersion = INT_MIN;
|
||||
device->lmpSubversion = INT_MIN;
|
||||
device->enabled = ctrl.powerState == kBluetoothHCIPowerStateON;
|
||||
device->discoverable = false;
|
||||
device->connectable = true;
|
||||
|
||||
for (NSDictionary* itemDict in arr[0][@"_items"])
|
||||
{
|
||||
NSDictionary* props = itemDict[@"controller_properties"];
|
||||
if (!props) continue;
|
||||
|
||||
if (![ctrl.addressAsString isEqualToString:props[@"controller_address"]]) continue;
|
||||
|
||||
NSString* services = props[@"controller_supportedServices"];
|
||||
if ([services containsString:@" LEA "])
|
||||
device->lmpVersion = -11;
|
||||
else if ([services containsString:@" GATT "])
|
||||
device->lmpVersion = -6;
|
||||
|
||||
device->discoverable = ![props[@"controller_discoverable"] isEqualToString:@"attrib_off"];
|
||||
ffStrbufSetS(&device->vendor, ((NSString*) props[@"controller_vendorID"]).UTF8String);
|
||||
ffStrbufSubstrAfterFirstC(&device->vendor, '(');
|
||||
ffStrbufTrimRight(&device->vendor, ')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
#include "bluetoothradio.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#ifdef FF_HAVE_DBUS
|
||||
#include "common/dbus.h"
|
||||
|
||||
/* Example dbus reply, striped to only the relevant parts:
|
||||
array [ //root
|
||||
dict entry(
|
||||
object path "/org/bluez/hci0"
|
||||
array [
|
||||
dict entry(
|
||||
string "org.bluez.Adapter1"
|
||||
array [
|
||||
dict entry(
|
||||
string "Address"
|
||||
variant string "XX:XX:XX:XX:XX:XX"
|
||||
)
|
||||
dict entry(
|
||||
string "Name"
|
||||
variant string "xxxxxxxx"
|
||||
)
|
||||
dict entry(
|
||||
string "Powered"
|
||||
variant boolean true
|
||||
)
|
||||
dict entry(
|
||||
string "PowerState"
|
||||
variant string "on"
|
||||
)
|
||||
dict entry(
|
||||
string "Manufacturer"
|
||||
variant uint16 2
|
||||
)
|
||||
dict entry(
|
||||
string "Version"
|
||||
variant byte 12
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
*/
|
||||
|
||||
static void detectBluetoothValue(FFDBusData* dbus, DBusMessageIter* iter, FFBluetoothRadioResult* device)
|
||||
{
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY)
|
||||
return;
|
||||
|
||||
DBusMessageIter dictIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(iter, &dictIter);
|
||||
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_STRING)
|
||||
return;
|
||||
|
||||
const char* deviceProperty;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(&dictIter, &deviceProperty);
|
||||
|
||||
dbus->lib->ffdbus_message_iter_next(&dictIter);
|
||||
|
||||
if(ffStrEquals(deviceProperty, "Address"))
|
||||
ffDBusGetString(dbus, &dictIter, &device->address);
|
||||
else if(ffStrEquals(deviceProperty, "Alias"))
|
||||
ffDBusGetString(dbus, &dictIter, &device->name);
|
||||
else if(ffStrEquals(deviceProperty, "Manufacturer"))
|
||||
{
|
||||
uint32_t vendorId;
|
||||
if (ffDBusGetUint(dbus, &dictIter, &vendorId))
|
||||
ffStrbufSetStatic(&device->vendor, ffBluetoothRadioGetVendor(vendorId));
|
||||
}
|
||||
else if(ffStrEquals(deviceProperty, "Version"))
|
||||
ffDBusGetUint(dbus, &dictIter, (uint32_t*) &device->lmpVersion);
|
||||
else if(ffStrEquals(deviceProperty, "Powered"))
|
||||
ffDBusGetBool(dbus, &dictIter, &device->enabled);
|
||||
else if(ffStrEquals(deviceProperty, "Discoverable"))
|
||||
ffDBusGetBool(dbus, &dictIter, &device->discoverable);
|
||||
else if(ffStrEquals(deviceProperty, "Pairable"))
|
||||
ffDBusGetBool(dbus, &dictIter, &device->connectable);
|
||||
}
|
||||
|
||||
static void detectBluetoothProperty(FFDBusData* dbus, DBusMessageIter* iter, FFBluetoothRadioResult* device)
|
||||
{
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY)
|
||||
return;
|
||||
|
||||
DBusMessageIter dictIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(iter, &dictIter);
|
||||
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_STRING)
|
||||
return;
|
||||
|
||||
const char* propertyType;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(&dictIter, &propertyType);
|
||||
|
||||
if(!ffStrContains(propertyType, ".Adapter"))
|
||||
return; //We don't care about other properties
|
||||
|
||||
dbus->lib->ffdbus_message_iter_next(&dictIter);
|
||||
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_ARRAY)
|
||||
return;
|
||||
|
||||
DBusMessageIter arrayIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(&dictIter, &arrayIter);
|
||||
|
||||
do
|
||||
{
|
||||
detectBluetoothValue(dbus, &arrayIter, device);
|
||||
} while (dbus->lib->ffdbus_message_iter_next(&arrayIter));
|
||||
}
|
||||
|
||||
static void detectBluetoothObject(FFlist* devices, FFDBusData* dbus, DBusMessageIter* iter)
|
||||
{
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY)
|
||||
return;
|
||||
|
||||
DBusMessageIter dictIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(iter, &dictIter);
|
||||
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_OBJECT_PATH)
|
||||
return;
|
||||
|
||||
const char* objectPath;
|
||||
dbus->lib->ffdbus_message_iter_get_basic(&dictIter, &objectPath);
|
||||
|
||||
//We want adapter objects
|
||||
if(!ffStrStartsWith(objectPath, "/org/bluez/hci") || ffStrContains(objectPath, "/dev_"))
|
||||
return;
|
||||
|
||||
dbus->lib->ffdbus_message_iter_next(&dictIter);
|
||||
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_ARRAY)
|
||||
return;
|
||||
|
||||
DBusMessageIter arrayIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(&dictIter, &arrayIter);
|
||||
|
||||
FFBluetoothRadioResult* device = ffListAdd(devices);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInit(&device->address);
|
||||
ffStrbufInitStatic(&device->vendor, "Unknown");
|
||||
device->lmpVersion = INT_MIN;
|
||||
device->lmpSubversion = INT_MIN;
|
||||
device->enabled = false;
|
||||
|
||||
do
|
||||
{
|
||||
detectBluetoothProperty(dbus, &arrayIter, device);
|
||||
} while (dbus->lib->ffdbus_message_iter_next(&arrayIter));
|
||||
|
||||
if(device->name.length == 0)
|
||||
{
|
||||
ffStrbufDestroy(&device->name);
|
||||
ffStrbufDestroy(&device->address);
|
||||
--devices->length;
|
||||
}
|
||||
}
|
||||
|
||||
static void detectBluetoothRoot(FFlist* devices, FFDBusData* dbus, DBusMessageIter* iter)
|
||||
{
|
||||
if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
|
||||
return;
|
||||
|
||||
DBusMessageIter arrayIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(iter, &arrayIter);
|
||||
|
||||
do
|
||||
{
|
||||
detectBluetoothObject(devices, dbus, &arrayIter);
|
||||
} while (dbus->lib->ffdbus_message_iter_next(&arrayIter));
|
||||
}
|
||||
|
||||
static const char* detectBluetooth(FFlist* devices)
|
||||
{
|
||||
FFDBusData dbus;
|
||||
const char* error = ffDBusLoadData(DBUS_BUS_SYSTEM, &dbus);
|
||||
if(error)
|
||||
return error;
|
||||
|
||||
DBusMessage* managedObjects = ffDBusGetMethodReply(&dbus, "org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", NULL);
|
||||
if(!managedObjects)
|
||||
return "Failed to call GetManagedObjects";
|
||||
|
||||
DBusMessageIter rootIter;
|
||||
if(!dbus.lib->ffdbus_message_iter_init(managedObjects, &rootIter))
|
||||
{
|
||||
dbus.lib->ffdbus_message_unref(managedObjects);
|
||||
return "Failed to get root iterator of GetManagedObjects";
|
||||
}
|
||||
|
||||
detectBluetoothRoot(devices, &dbus, &rootIter);
|
||||
|
||||
dbus.lib->ffdbus_message_unref(managedObjects);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
|
||||
{
|
||||
#ifdef FF_HAVE_DBUS
|
||||
return detectBluetooth(devices);
|
||||
#else
|
||||
return "Fastfetch was compiled without DBus support";
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "bluetoothradio.h"
|
||||
|
||||
const char* ffDetectBluetoothRadio(FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothRadioResult */)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
#include "bluetoothradio.h"
|
||||
#include "common/library.h"
|
||||
#include "common/io/io.h"
|
||||
#include "util/windows/unicode.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <bluetoothapis.h>
|
||||
#include <winioctl.h>
|
||||
|
||||
// #include <bthioctl.h>
|
||||
|
||||
#define BTH_IOCTL_BASE 0
|
||||
#define BTH_CTL(id) CTL_CODE(FILE_DEVICE_BLUETOOTH, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_BTH_GET_LOCAL_INFO BTH_CTL(BTH_IOCTL_BASE+0x00)
|
||||
#define LMP_LE_SUPPORTED(x) ((x >> 38) & 1)
|
||||
|
||||
typedef struct _BTH_RADIO_INFO
|
||||
{
|
||||
// Supported LMP features of the radio. Use LMP_XXX() to extract
|
||||
// the desired bits.
|
||||
ULONGLONG lmpSupportedFeatures;
|
||||
|
||||
// Manufacturer ID (possibly BTH_MFG_XXX)
|
||||
USHORT mfg;
|
||||
|
||||
// LMP subversion
|
||||
USHORT lmpSubversion;
|
||||
|
||||
// LMP version
|
||||
UCHAR lmpVersion;
|
||||
} __attribute__((__packed__)) BTH_RADIO_INFO;
|
||||
|
||||
typedef struct _BTH_LOCAL_RADIO_INFO
|
||||
{
|
||||
// Local BTH_ADDR, class of device, and radio name
|
||||
BTH_DEVICE_INFO localInfo;
|
||||
|
||||
// Combo of LOCAL_RADIO_XXX values
|
||||
ULONG flags;
|
||||
|
||||
// HCI revision, see core spec
|
||||
USHORT hciRevision;
|
||||
|
||||
// HCI version, see core spec
|
||||
UCHAR hciVersion;
|
||||
|
||||
// More information about the local radio (LMP, MFG)
|
||||
BTH_RADIO_INFO radioInfo;
|
||||
} __attribute__((__packed__)) BTH_LOCAL_RADIO_INFO;
|
||||
static_assert(sizeof(BTH_LOCAL_RADIO_INFO) == 292, "BTH_LOCAL_RADIO_INFO should be 292 bytes");
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wpointer-sign"
|
||||
|
||||
const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
|
||||
{
|
||||
// Actually bluetoothapis.dll, but it's missing on Windows 7
|
||||
FF_LIBRARY_LOAD(bluetoothapis, NULL, "dlopen bthprops.cpl failed", "bthprops.cpl", 1)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindFirstRadio)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindNextRadio)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindRadioClose)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothIsConnectable)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothIsDiscoverable)
|
||||
|
||||
HANDLE hRadio = NULL;
|
||||
HBLUETOOTH_DEVICE_FIND hFind = ffBluetoothFindFirstRadio(&(BLUETOOTH_FIND_RADIO_PARAMS) {
|
||||
.dwSize = sizeof(BLUETOOTH_FIND_RADIO_PARAMS)
|
||||
}, &hRadio);
|
||||
if(!hFind)
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_MORE_ITEMS)
|
||||
return "No Bluetooth radios found or service disabled";
|
||||
else
|
||||
return "BluetoothFindFirstRadio() failed";
|
||||
}
|
||||
|
||||
do {
|
||||
BTH_LOCAL_RADIO_INFO blri;
|
||||
DWORD returned;
|
||||
if (!DeviceIoControl(hRadio, IOCTL_BTH_GET_LOCAL_INFO, NULL, 0, &blri, sizeof(blri), &returned, NULL))
|
||||
continue;
|
||||
|
||||
FFBluetoothRadioResult* device = ffListAdd(devices);
|
||||
ffStrbufInitS(&device->name, blri.localInfo.name);
|
||||
|
||||
BLUETOOTH_ADDRESS_STRUCT addr = { .ullLong = blri.localInfo.address };
|
||||
ffStrbufInitF(&device->address, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
addr.rgBytes[0],
|
||||
addr.rgBytes[1],
|
||||
addr.rgBytes[2],
|
||||
addr.rgBytes[3],
|
||||
addr.rgBytes[4],
|
||||
addr.rgBytes[5]);
|
||||
|
||||
device->lmpVersion = blri.radioInfo.lmpVersion;
|
||||
device->lmpSubversion = blri.radioInfo.lmpSubversion;
|
||||
ffStrbufInitStatic(&device->vendor, ffBluetoothRadioGetVendor(blri.radioInfo.mfg));
|
||||
device->enabled = true;
|
||||
device->connectable = ffBluetoothIsConnectable(hRadio);
|
||||
device->discoverable = ffBluetoothIsDiscoverable(hRadio);
|
||||
} while (ffBluetoothFindNextRadio(hFind, &hRadio));
|
||||
|
||||
ffBluetoothFindRadioClose(hFind);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -5,13 +5,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if __has_include(<linux/videodev2.h>)
|
||||
#if FF_HAVE_LINUX_VIDEODEV2
|
||||
#include <linux/videodev2.h>
|
||||
#endif
|
||||
|
||||
const char* ffDetectCamera(FFlist* result)
|
||||
{
|
||||
#if __has_include(<linux/videodev2.h>)
|
||||
#if FF_HAVE_LINUX_VIDEODEV2
|
||||
char path[] = "/dev/videoN";
|
||||
|
||||
for (uint32_t i = 0; i <= 9; ++i)
|
||||
|
||||
@@ -44,7 +44,7 @@ static const char* detectFrequency(FFCPUResult* cpu)
|
||||
return "\"pmgr\" should conform to \"AppleARMIODevice\"";
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFDataRef freqProperty = (CFDataRef) IORegistryEntryCreateCFProperty(entryDevice, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, kNilOptions);
|
||||
if (CFGetTypeID(freqProperty) != CFDataGetTypeID())
|
||||
if (!freqProperty || CFGetTypeID(freqProperty) != CFDataGetTypeID())
|
||||
return "\"voltage-states5-sram\" in \"pmgr\" is not found";
|
||||
|
||||
// voltage-states5-sram stores supported <frequency / voltage> pairs of pcores from the lowest to the highest
|
||||
|
||||
@@ -13,18 +13,64 @@
|
||||
#ifdef __ANDROID__
|
||||
#include "common/settings.h"
|
||||
|
||||
static void detectQualcomm(FFCPUResult* cpu)
|
||||
{
|
||||
if (ffStrbufEqualS(&cpu->name, "SM8635"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8s Gen 3 [SM8635]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM8650-AC"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8 Gen 3 for Galaxy [SM8650-AC]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM8650"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8 Gen 3 [SM8650]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM8550-AC"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8 Gen 2 for Galaxy [SM8550-AC]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM8550"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8 Gen 2 [SM8550]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM8475"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8+ Gen 1 [SM8475]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM8450"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8 Gen 1 [SM8450]");
|
||||
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM7675"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 7+ Gen 3 [SM7675]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM7550"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 7 Gen 3 [SM7550]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM7475"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 7+ Gen 2 [SM7550]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM7435"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 7s Gen 2 [SM7435]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM7450"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 7 Gen 1 [SM7450]");
|
||||
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM6375-AC"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 6s Gen 3 [SM6375-AC]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM6450"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 6 Gen 1 [SM6450]");
|
||||
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM4635"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 4s Gen 2 [SM4635]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM4450"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 4 Gen 2 [SM4450]");
|
||||
else if (ffStrbufEqualS(&cpu->name, "SM4375"))
|
||||
ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 4 Gen 1 [SM4375]");
|
||||
}
|
||||
|
||||
static void detectAndroid(FFCPUResult* cpu)
|
||||
{
|
||||
if (cpu->name.length == 0)
|
||||
{
|
||||
ffSettingsGetAndroidProperty("ro.soc.model", &cpu->name);
|
||||
ffStrbufClear(&cpu->vendor); // We usually detect the vendor of CPU core as ARM, but instead we want the vendor of SOC
|
||||
if (ffSettingsGetAndroidProperty("ro.soc.model", &cpu->name))
|
||||
ffStrbufClear(&cpu->vendor); // We usually detect the vendor of CPU core as ARM, but instead we want the vendor of SOC
|
||||
else if(ffSettingsGetAndroidProperty("ro.mediatek.platform", &cpu->name))
|
||||
ffStrbufSetStatic(&cpu->vendor, "MTK");
|
||||
}
|
||||
if (cpu->vendor.length == 0)
|
||||
{
|
||||
if (!ffSettingsGetAndroidProperty("ro.soc.manufacturer", &cpu->vendor))
|
||||
ffSettingsGetAndroidProperty("ro.product.product.manufacturer", &cpu->vendor);
|
||||
}
|
||||
|
||||
if (ffStrbufEqualS(&cpu->vendor, "QTI") && ffStrbufStartsWithS(&cpu->name, "SM"))
|
||||
detectQualcomm(cpu);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
|
||||
FFDisk* disk = ffListAdd(disks);
|
||||
|
||||
disk->bytesTotal = fs->f_blocks * fs->f_bsize;
|
||||
disk->bytesTotal = (uint64_t)fs->f_blocks * fs->f_bsize;
|
||||
disk->bytesFree = (uint64_t)fs->f_bfree * fs->f_bsize;
|
||||
disk->bytesAvailable = (uint64_t)fs->f_bavail * fs->f_bsize;
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
@@ -82,25 +82,25 @@ static bool detectWithGetprop(FFDisplayServerResult* ds)
|
||||
if (ffSettingsGetAndroidProperty("persist.sys.miui_resolution", &buffer) &&
|
||||
ffStrbufContainC(&buffer, ','))
|
||||
{
|
||||
// 1440,3200,560 => width,height,ppi
|
||||
// 1440,3200,560 => width,height,densityDpi
|
||||
uint32_t width = (uint32_t) ffStrbufToUInt(&buffer, 0);
|
||||
ffStrbufSubstrAfterFirstC(&buffer, ',');
|
||||
uint32_t height = (uint32_t) ffStrbufToUInt(&buffer, 0);
|
||||
ffStrbufSubstrAfterFirstC(&buffer, ',');
|
||||
uint32_t ppi = (uint32_t) ffStrbufToUInt(&buffer, 0);
|
||||
double scaleFactor = (double) ffStrbufToUInt(&buffer, 0) / 160.;
|
||||
return ffdsAppendDisplay(ds,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(uint32_t) (width / scaleFactor + .5),
|
||||
(uint32_t) (height / scaleFactor + .5),
|
||||
0,
|
||||
0,
|
||||
FF_DISPLAY_TYPE_BUILTIN,
|
||||
false,
|
||||
0,
|
||||
(uint32_t) (width / ppi * 25.4),
|
||||
(uint32_t) (height / ppi * 25.4)
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
{
|
||||
const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
|
||||
if (!(time.flags & kCVTimeIsIndefinite))
|
||||
refreshRate = time.timeScale / (double) time.timeValue + 0.5; //59.97...
|
||||
refreshRate = time.timeScale / (double) time.timeValue; //59.97...
|
||||
CVDisplayLinkRelease(link);
|
||||
}
|
||||
}
|
||||
@@ -86,21 +86,15 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
);
|
||||
if (display)
|
||||
{
|
||||
// Shitty code
|
||||
uint8_t bitDepth = 0;
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef desc = CFCopyDescription(mode);
|
||||
CFRange start = CFStringFind(desc, CFSTR("BitsPerSample = "), 0);
|
||||
if (start.location != kCFNotFound)
|
||||
// https://stackoverflow.com/a/33519316/9976392
|
||||
// Also shitty, but better than parsing `CFCopyDescription(mode)`
|
||||
CFDictionaryRef dict = (CFDictionaryRef) *((int64_t *)mode + 2);
|
||||
if (CFGetTypeID(dict) == CFDictionaryGetTypeID())
|
||||
{
|
||||
for (CFIndex idx = start.location + start.length; idx < CFStringGetLength(desc); ++idx)
|
||||
{
|
||||
UniChar ch = CFStringGetCharacterAtIndex(desc, idx);
|
||||
if (!ffCharIsDigit((char) ch))
|
||||
break;
|
||||
bitDepth = (uint8_t) (bitDepth * 10 + (ch - '0'));
|
||||
}
|
||||
int32_t bitDepth;
|
||||
ffCfDictGetInt(dict, kCGDisplayBitsPerSample, &bitDepth);
|
||||
display->bitDepth = (uint8_t) bitDepth;
|
||||
}
|
||||
display->bitDepth = bitDepth;
|
||||
}
|
||||
CGDisplayModeRelease(mode);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,48 @@
|
||||
#include "common/settings.h"
|
||||
#endif
|
||||
|
||||
static void getWMProtocolNameFromEnv(FFDisplayServerResult* result)
|
||||
{
|
||||
const char* env = getenv("XDG_SESSION_TYPE");
|
||||
if(env)
|
||||
{
|
||||
if(ffStrEqualsIgnCase(env, "wayland"))
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND);
|
||||
else if(ffStrEqualsIgnCase(env, "x11") || ffStrEqualsIgnCase(env, "xorg"))
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
|
||||
else if(ffStrEqualsIgnCase(env, "tty"))
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_TTY);
|
||||
else
|
||||
ffStrbufSetS(&result->wmProtocolName, env);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(getenv("WAYLAND_DISPLAY") != NULL || getenv("WAYLAND_SOCKET") != NULL)
|
||||
{
|
||||
ffStrbufSetStatic(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND);
|
||||
return;
|
||||
}
|
||||
|
||||
if(getenv("DISPLAY") != NULL) // XWayland also set this
|
||||
{
|
||||
ffStrbufSetStatic(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
|
||||
return;
|
||||
}
|
||||
|
||||
env = getenv("TERM");
|
||||
if(ffStrSet(env) && ffStrEqualsIgnCase(env, "linux"))
|
||||
{
|
||||
ffStrbufSetStatic(&result->wmProtocolName, FF_WM_PROTOCOL_TTY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
{
|
||||
if (instance.config.general.dsForceDrm == FF_DS_FORCE_DRM_TYPE_FALSE)
|
||||
getWMProtocolNameFromEnv(ds);
|
||||
|
||||
if (!ffStrbufEqualS(&ds->wmProtocolName, FF_WM_PROTOCOL_TTY) &&instance.config.general.dsForceDrm == FF_DS_FORCE_DRM_TYPE_FALSE)
|
||||
{
|
||||
//We try wayland as our preferred display server, as it supports the most features.
|
||||
//This method can't detect the name of our WM / DE
|
||||
@@ -57,8 +96,11 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
}
|
||||
#endif
|
||||
|
||||
//This fills in missing information about WM / DE by using env vars and iterating processes
|
||||
ffdsDetectWMDE(ds);
|
||||
if(!ffStrbufEqualS(&ds->wmProtocolName, FF_WM_PROTOCOL_TTY))
|
||||
{
|
||||
//This fills in missing information about WM / DE by using env vars and iterating processes
|
||||
ffdsDetectWMDE(ds);
|
||||
}
|
||||
}
|
||||
|
||||
bool ffdsMatchDrmConnector(const char* connName, FFstrbuf* edidName)
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
bool ffdsMatchDrmConnector(const char* connName, FFstrbuf* edidName);
|
||||
|
||||
const char* ffdsConnectWlroots(FFDisplayServerResult* result);
|
||||
void ffdsConnectWayland(FFDisplayServerResult* result);
|
||||
const char* ffdsConnectWayland(FFDisplayServerResult* result);
|
||||
|
||||
void ffdsConnectXcbRandr(FFDisplayServerResult* result);
|
||||
void ffdsConnectXcb(FFDisplayServerResult* result);
|
||||
|
||||
@@ -220,6 +220,8 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
|
||||
if (nDevices < 0)
|
||||
return "drmGetDevices() failed";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
|
||||
|
||||
for (int iDev = 0; iDev < nDevices; ++iDev)
|
||||
{
|
||||
drmDevice* dev = devices[iDev];
|
||||
@@ -228,6 +230,13 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
|
||||
continue;
|
||||
|
||||
const char* path = dev->nodes[DRM_NODE_PRIMARY];
|
||||
|
||||
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;
|
||||
|
||||
FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
continue;
|
||||
@@ -292,7 +301,8 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
|
||||
}
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
|
||||
|
||||
ffStrbufClear(&name);
|
||||
|
||||
for (int iProp = 0; iProp < conn->count_props; ++iProp)
|
||||
{
|
||||
|
||||
@@ -122,7 +122,7 @@ void ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* regist
|
||||
display.edidName.length
|
||||
? &display.edidName
|
||||
// Try ignoring `eDP-1-unknown`, where `unknown` is localized
|
||||
: display.description.length && !(ffStrbufStartsWithS(&display.description, display.name.chars) && display.description.chars[display.name.length] == '-')
|
||||
: display.description.length && !ffStrbufContain(&display.description, &display.name)
|
||||
? &display.description
|
||||
: &display.name,
|
||||
display.type,
|
||||
|
||||
@@ -22,14 +22,27 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result)
|
||||
{
|
||||
struct ucred ucred;
|
||||
socklen_t len = sizeof(struct ucred);
|
||||
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1)
|
||||
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1 || ucred.pid <= 0)
|
||||
return false;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY procPath = ffStrbufCreate();
|
||||
ffStrbufAppendF(&procPath, "/proc/%d/cmdline", ucred.pid); //We check the cmdline for the process name, because it is not trimmed.
|
||||
ffReadFileBuffer(procPath.chars, &result->wmProcessName);
|
||||
if (!ffReadFileBuffer(procPath.chars, &result->wmProcessName))
|
||||
return false;
|
||||
|
||||
// #1135: wl-restart is a special case
|
||||
const char* filename = strrchr(result->wmProcessName.chars, '/');
|
||||
if (filename)
|
||||
filename++;
|
||||
else
|
||||
filename = result->wmProcessName.chars;
|
||||
|
||||
if (ffStrEquals(filename, "wl-restart"))
|
||||
ffStrbufSubstrAfterFirstC(&result->wmProcessName, '\0');
|
||||
|
||||
ffStrbufSubstrBeforeFirstC(&result->wmProcessName, '\0'); //Trim the arguments
|
||||
ffStrbufSubstrAfterLastC(&result->wmProcessName, '/'); //Trim the path
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
@@ -69,27 +82,93 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
|
||||
}
|
||||
}
|
||||
|
||||
bool detectWayland(FFDisplayServerResult* result)
|
||||
void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const char *name)
|
||||
{
|
||||
WaylandDisplay* display = data;
|
||||
if (display->id) return;
|
||||
|
||||
display->type = ffdsGetDisplayType(name);
|
||||
if (!display->edidName.length)
|
||||
ffdsMatchDrmConnector(name, &display->edidName);
|
||||
display->id = ffWaylandGenerateIdFromName(name);
|
||||
ffStrbufAppendS(&display->name, name);
|
||||
}
|
||||
|
||||
void ffWaylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED void* output, const char* description)
|
||||
{
|
||||
WaylandDisplay* display = data;
|
||||
if (display->description.length) return;
|
||||
|
||||
while (*description == ' ') ++description;
|
||||
if (!ffStrEquals(description, "Unknown Display") && !ffStrContains(description, "(null)"))
|
||||
ffStrbufAppendS(&display->description, description);
|
||||
}
|
||||
|
||||
uint32_t ffWaylandHandleRotation(WaylandDisplay* display)
|
||||
{
|
||||
uint32_t rotation;
|
||||
switch(display->transform)
|
||||
{
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
||||
case WL_OUTPUT_TRANSFORM_90:
|
||||
rotation = 90;
|
||||
break;
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
||||
case WL_OUTPUT_TRANSFORM_180:
|
||||
rotation = 180;
|
||||
break;
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
||||
case WL_OUTPUT_TRANSFORM_270:
|
||||
rotation = 270;
|
||||
break;
|
||||
default:
|
||||
rotation = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(rotation)
|
||||
{
|
||||
case 90:
|
||||
case 270: {
|
||||
int32_t temp = display->width;
|
||||
display->width = display->height;
|
||||
display->height = temp;
|
||||
|
||||
temp = display->physicalWidth;
|
||||
display->physicalWidth = display->physicalHeight;
|
||||
display->physicalHeight = temp;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return rotation;
|
||||
}
|
||||
|
||||
const char* ffdsConnectWayland(FFDisplayServerResult* result)
|
||||
{
|
||||
if (getenv("XDG_RUNTIME_DIR") == NULL)
|
||||
return "Wayland requires $XDG_RUNTIME_DIR being set";
|
||||
|
||||
FF_LIBRARY_LOAD(wayland, &instance.config.library.libWayland, false, "libwayland-client" FF_LIBRARY_EXTENSION, 1)
|
||||
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_connect, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_get_fd, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_proxy_marshal_constructor, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_disconnect, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_registry_interface, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_display_connect)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_display_get_fd)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_proxy_marshal_constructor)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_display_disconnect)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_registry_interface)
|
||||
|
||||
WaylandData data = {};
|
||||
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_marshal_constructor_versioned, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_add_listener, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_destroy, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_display_roundtrip, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_output_interface, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(wayland, data, wl_proxy_marshal_constructor_versioned)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(wayland, data, wl_proxy_add_listener)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(wayland, data, wl_proxy_destroy)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(wayland, data, wl_display_roundtrip)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(wayland, data, wl_output_interface)
|
||||
|
||||
data.display = ffwl_display_connect(NULL);
|
||||
if(data.display == NULL)
|
||||
return false;
|
||||
return "wl_display_connect returned NULL";
|
||||
|
||||
waylandDetectWM(ffwl_display_get_fd(data.display), result);
|
||||
|
||||
@@ -97,7 +176,7 @@ bool detectWayland(FFDisplayServerResult* result)
|
||||
if(registry == NULL)
|
||||
{
|
||||
ffwl_display_disconnect(data.display);
|
||||
return false;
|
||||
return "wl_display_get_registry returned NULL";
|
||||
}
|
||||
|
||||
data.result = result;
|
||||
@@ -192,97 +271,15 @@ bool detectWayland(FFDisplayServerResult* result)
|
||||
//We successfully connected to wayland and detected the display.
|
||||
//So we can set set the session type to wayland.
|
||||
//This is used as an indicator that we are running wayland by the x11 backends.
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND);
|
||||
return true;
|
||||
ffStrbufSetStatic(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const char *name)
|
||||
#else
|
||||
|
||||
const char* ffdsConnectWayland(FF_MAYBE_UNUSED FFDisplayServerResult* result)
|
||||
{
|
||||
WaylandDisplay* display = data;
|
||||
if (display->id) return;
|
||||
|
||||
display->type = ffdsGetDisplayType(name);
|
||||
if (!display->edidName.length)
|
||||
ffdsMatchDrmConnector(name, &display->edidName);
|
||||
display->id = ffWaylandGenerateIdFromName(name);
|
||||
ffStrbufAppendS(&display->name, name);
|
||||
return "Fastfetch was compiled without Wayland support";
|
||||
}
|
||||
|
||||
void ffWaylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED void* output, const char* description)
|
||||
{
|
||||
WaylandDisplay* display = data;
|
||||
if (display->description.length) return;
|
||||
|
||||
while (*description == ' ') ++description;
|
||||
if (!ffStrEquals(description, "Unknown Display") && !ffStrContains(description, "(null)"))
|
||||
ffStrbufAppendS(&display->description, description);
|
||||
}
|
||||
|
||||
uint32_t ffWaylandHandleRotation(WaylandDisplay* display)
|
||||
{
|
||||
uint32_t rotation;
|
||||
switch(display->transform)
|
||||
{
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
||||
case WL_OUTPUT_TRANSFORM_90:
|
||||
rotation = 90;
|
||||
break;
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
||||
case WL_OUTPUT_TRANSFORM_180:
|
||||
rotation = 180;
|
||||
break;
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
||||
case WL_OUTPUT_TRANSFORM_270:
|
||||
rotation = 270;
|
||||
break;
|
||||
default:
|
||||
rotation = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(rotation)
|
||||
{
|
||||
case 90:
|
||||
case 270: {
|
||||
int32_t temp = display->width;
|
||||
display->width = display->height;
|
||||
display->height = temp;
|
||||
|
||||
temp = display->physicalWidth;
|
||||
display->physicalWidth = display->physicalHeight;
|
||||
display->physicalHeight = temp;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return rotation;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ffdsConnectWayland(FFDisplayServerResult* result)
|
||||
{
|
||||
//Wayland requires this to be set
|
||||
if(getenv("XDG_RUNTIME_DIR") == NULL)
|
||||
return;
|
||||
|
||||
#ifdef FF_HAVE_WAYLAND
|
||||
if(detectWayland(result))
|
||||
return;
|
||||
#endif
|
||||
|
||||
const char* xdgSessionType = getenv("XDG_SESSION_TYPE");
|
||||
|
||||
//If XDG_SESSION_TYPE is set, and doesn't contain "wayland", we are probably not running in a wayland session.
|
||||
if(xdgSessionType != NULL && !ffStrEqualsIgnCase(xdgSessionType, "wayland"))
|
||||
return;
|
||||
|
||||
//If XDG_SESSION_TYPE is not set, check if WAYLAND_DISPLAY or WAYLAND_SOCKET is set.
|
||||
//If not, there is no indicator for a wayland session
|
||||
if(xdgSessionType == NULL && getenv("WAYLAND_DISPLAY") == NULL && getenv("WAYLAND_SOCKET") == NULL)
|
||||
return;
|
||||
|
||||
//We are probably running a wayland compositor at this point,
|
||||
//but fastfetch was compiled without the required library, or loading the library failed.
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ static void waylandHandleZwlrHead(void *data, FF_MAYBE_UNUSED struct zwlr_output
|
||||
rotation,
|
||||
display.edidName.length
|
||||
? &display.edidName
|
||||
: display.description.length
|
||||
: display.description.length && !ffStrbufContain(&display.description, &display.name)
|
||||
? &display.description
|
||||
: &display.name,
|
||||
display.type,
|
||||
|
||||
@@ -240,38 +240,6 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name)
|
||||
}
|
||||
}
|
||||
|
||||
static void getWMProtocolNameFromEnv(FFDisplayServerResult* result)
|
||||
{
|
||||
//This is only called if all connection attempts to a display server failed
|
||||
//We don't need to check for wayland here, as the wayland code will always set the protocol name to wayland
|
||||
|
||||
const char* env = getenv("XDG_SESSION_TYPE");
|
||||
if(ffStrSet(env))
|
||||
{
|
||||
if(ffStrEqualsIgnCase(env, "x11"))
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
|
||||
else if(ffStrEqualsIgnCase(env, "tty"))
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_TTY);
|
||||
else
|
||||
ffStrbufSetS(&result->wmProtocolName, env);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
env = getenv("DISPLAY");
|
||||
if(ffStrSet(env))
|
||||
{
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
|
||||
return;
|
||||
}
|
||||
|
||||
env = getenv("TERM");
|
||||
if(ffStrSet(env) && ffStrEqualsIgnCase(env, "linux"))
|
||||
{
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_TTY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* getFromProcesses(FFDisplayServerResult* result)
|
||||
{
|
||||
@@ -396,15 +364,6 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
|
||||
|
||||
void ffdsDetectWMDE(FFDisplayServerResult* result)
|
||||
{
|
||||
//If all connections failed, use the environment variables to detect protocol name
|
||||
if(result->wmProtocolName.length == 0)
|
||||
getWMProtocolNameFromEnv(result);
|
||||
|
||||
//We don't want to detect anything in TTY
|
||||
//This can't happen if a connection succeeded, so we don't need to clear wmProcessName
|
||||
if(ffStrbufIgnCaseCompS(&result->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
|
||||
return;
|
||||
|
||||
const char* env = parseEnv();
|
||||
|
||||
if(result->wmProcessName.length > 0)
|
||||
|
||||
@@ -7,6 +7,7 @@ const char* FF_GPU_VENDOR_NAME_APPLE = "Apple";
|
||||
const char* FF_GPU_VENDOR_NAME_AMD = "AMD";
|
||||
const char* FF_GPU_VENDOR_NAME_INTEL = "Intel";
|
||||
const char* FF_GPU_VENDOR_NAME_NVIDIA = "NVIDIA";
|
||||
const char* FF_GPU_VENDOR_NAME_MTHREADS = "Moore Threads";
|
||||
const char* FF_GPU_VENDOR_NAME_QUALCOMM = "Qualcomm";
|
||||
const char* FF_GPU_VENDOR_NAME_MTK = "MTK";
|
||||
const char* FF_GPU_VENDOR_NAME_VMWARE = "VMware";
|
||||
@@ -24,6 +25,7 @@ const char* ffGetGPUVendorString(unsigned vendorId)
|
||||
case 0x1002: case 0x1022: return FF_GPU_VENDOR_NAME_AMD;
|
||||
case 0x8086: case 0x8087: case 0x03e7: return FF_GPU_VENDOR_NAME_INTEL;
|
||||
case 0x0955: case 0x10de: case 0x12d2: return FF_GPU_VENDOR_NAME_NVIDIA;
|
||||
case 0x1ed5: return FF_GPU_VENDOR_NAME_MTHREADS;
|
||||
case 0x5143: return FF_GPU_VENDOR_NAME_QUALCOMM;
|
||||
case 0x14c3: return FF_GPU_VENDOR_NAME_MTK;
|
||||
case 0x15ad: return FF_GPU_VENDOR_NAME_VMWARE;
|
||||
@@ -56,6 +58,7 @@ const char* detectByOpenGL(FFlist* gpus)
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
gpu->dedicated = gpu->shared = (FFGPUMemory){0, 0};
|
||||
gpu->deviceId = 0;
|
||||
|
||||
@@ -70,6 +73,8 @@ const char* detectByOpenGL(FFlist* gpus)
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
|
||||
else if (ffStrbufContainS(&gpu->name, "NVIDIA"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
|
||||
else if (ffStrbufContainS(&gpu->name, "MTT"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_MTHREADS);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
#define FF_GPU_CORE_COUNT_UNSET -1
|
||||
#define FF_GPU_VMEM_SIZE_UNSET ((uint64_t)-1)
|
||||
#define FF_GPU_FREQUENCY_UNSET 0
|
||||
#define FF_GPU_CORE_USAGE_UNSET (0/0.0)
|
||||
|
||||
extern const char* FF_GPU_VENDOR_NAME_APPLE;
|
||||
extern const char* FF_GPU_VENDOR_NAME_AMD;
|
||||
extern const char* FF_GPU_VENDOR_NAME_INTEL;
|
||||
extern const char* FF_GPU_VENDOR_NAME_NVIDIA;
|
||||
extern const char* FF_GPU_VENDOR_NAME_MTHREADS;
|
||||
extern const char* FF_GPU_VENDOR_NAME_VMWARE;
|
||||
extern const char* FF_GPU_VENDOR_NAME_PARALLEL;
|
||||
extern const char* FF_GPU_VENDOR_NAME_MICROSOFT;
|
||||
@@ -35,6 +37,7 @@ typedef struct FFGPUResult
|
||||
uint32_t frequency; // Maximum time clock frequency in MHz
|
||||
FFGPUMemory dedicated;
|
||||
FFGPUMemory shared;
|
||||
double coreUsage;
|
||||
uint64_t deviceId; // Used internally, may be uninitialized
|
||||
} FFGPUResult;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ static const char* detectFrequency(FFGPUResult* gpu)
|
||||
return "\"pmgr\" should conform to \"AppleARMIODevice\"";
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFDataRef freqProperty = (CFDataRef) IORegistryEntryCreateCFProperty(entryDevice, CFSTR("voltage-states9-sram"), kCFAllocatorDefault, kNilOptions);
|
||||
if (CFGetTypeID(freqProperty) != CFDataGetTypeID())
|
||||
if (!freqProperty || CFGetTypeID(freqProperty) != CFDataGetTypeID())
|
||||
return "\"voltage-states9-sram\" in \"pmgr\" is not found";
|
||||
|
||||
// voltage-states5-sram stores supported <frequency / voltage> pairs of gpu from the lowest to the highest
|
||||
@@ -76,8 +76,12 @@ static const char* detectFrequency(FFGPUResult* gpu)
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
|
||||
{
|
||||
FF_IOOBJECT_AUTO_RELEASE io_iterator_t iterator = IO_OBJECT_NULL;
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching(kIOAcceleratorClassName), &iterator) != kIOReturnSuccess)
|
||||
return "IOServiceGetMatchingServices() failed";
|
||||
{
|
||||
CFMutableDictionaryRef matches = IOServiceMatching(kIOAcceleratorClassName);
|
||||
CFDictionaryAddValue(matches, CFSTR("IOMatchCategory"), CFSTR(kIOAcceleratorClassName));
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL, matches, &iterator) != kIOReturnSuccess)
|
||||
return "IOServiceGetMatchingServices() failed";
|
||||
}
|
||||
|
||||
io_registry_entry_t registryEntry;
|
||||
while ((registryEntry = IOIteratorNext(iterator)) != IO_OBJECT_NULL)
|
||||
@@ -103,6 +107,31 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
|
||||
if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) // For Apple
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
|
||||
gpu->coreUsage = 0.0/0.0;
|
||||
CFDictionaryRef perfStatistics = NULL;
|
||||
uint64_t vramUsed = 0, vramTotal = 0;
|
||||
if (ffCfDictGetDict(properties, CFSTR("PerformanceStatistics"), &perfStatistics) == NULL)
|
||||
{
|
||||
int64_t utilization;
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("Device Utilization %"), &utilization) == NULL)
|
||||
gpu->coreUsage = (double) utilization;
|
||||
else if (ffCfDictGetInt64(perfStatistics, CFSTR("GPU Core Utilization"), &utilization) == NULL)
|
||||
gpu->coreUsage = (double) utilization / 10000000.; // Nvidia?
|
||||
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("Alloc system memory"), (int64_t*) &vramTotal) == NULL)
|
||||
{
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("In use system memory"), (int64_t*) &vramUsed) != NULL)
|
||||
vramTotal = 0;
|
||||
}
|
||||
else if (ffCfDictGetInt64(perfStatistics, CFSTR("vramUsedBytes"), (int64_t*) &vramTotal) == NULL)
|
||||
{
|
||||
if (ffCfDictGetInt64(perfStatistics, CFSTR("vramFreeBytes"), (int64_t*) &vramUsed) == NULL)
|
||||
vramTotal += vramUsed;
|
||||
else
|
||||
vramTotal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ffStrbufInit(&gpu->name);
|
||||
//IOAccelerator returns model / vendor-id properties for Apple Silicon, but not for Intel Iris GPUs.
|
||||
//Still needs testing for AMD's
|
||||
@@ -123,7 +152,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
|
||||
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
int vendorId;
|
||||
if(!ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId))
|
||||
if(ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId) == NULL)
|
||||
{
|
||||
const char* vendorStr = ffGetGPUVendorString((unsigned) vendorId);
|
||||
ffStrbufAppendS(&gpu->vendor, vendorStr);
|
||||
@@ -136,6 +165,17 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
|
||||
if (vendorStr == FF_GPU_VENDOR_NAME_APPLE)
|
||||
detectFrequency(gpu);
|
||||
#endif
|
||||
|
||||
if (gpu->type == FF_GPU_TYPE_INTEGRATED)
|
||||
{
|
||||
gpu->shared.total = vramTotal;
|
||||
gpu->shared.used = vramUsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpu->dedicated.total = vramTotal;
|
||||
gpu->dedicated.used = vramUsed;
|
||||
}
|
||||
}
|
||||
|
||||
gpu->temperature = options->temp ? detectGpuTemp(&gpu->name) : FF_GPU_TEMP_UNSET;
|
||||
|
||||
@@ -44,17 +44,6 @@ const char* ffGpuDetectMetal(FFlist* gpus)
|
||||
|
||||
gpu->type = device.hasUnifiedMemory ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE;
|
||||
#endif
|
||||
|
||||
if (gpu->type == FF_GPU_TYPE_INTEGRATED)
|
||||
{
|
||||
gpu->shared.total = device.recommendedMaxWorkingSetSize;
|
||||
gpu->shared.used = device.currentAllocatedSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpu->dedicated.total = device.recommendedMaxWorkingSetSize;
|
||||
gpu->dedicated.used = device.currentAllocatedSize;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
|
||||
ffStrbufInit(&gpu->platformApi);
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->deviceId = ((uint64_t) pc->pc_sel.pc_domain << 6) | ((uint64_t) pc->pc_sel.pc_bus << 4) | ((uint64_t) pc->pc_sel.pc_dev << 2) | pc->pc_sel.pc_func;
|
||||
@@ -92,10 +93,29 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
|
||||
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
|
||||
.type = &gpu->type,
|
||||
.frequency = &gpu->frequency,
|
||||
.coreUsage = &gpu->coreUsage,
|
||||
.name = options->driverSpecific ? &gpu->name : NULL,
|
||||
}, "libnvidia-ml.so");
|
||||
}
|
||||
|
||||
if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET)
|
||||
gpu->type = gpu->dedicated.total > (uint64_t)1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
|
||||
if (gpu->type == FF_GPU_TYPE_UNKNOWN)
|
||||
{
|
||||
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA)
|
||||
{
|
||||
if (ffStrbufStartsWithIgnCaseS(&gpu->name, "GeForce") ||
|
||||
ffStrbufStartsWithIgnCaseS(&gpu->name, "Quadro") ||
|
||||
ffStrbufStartsWithIgnCaseS(&gpu->name, "Tesla"))
|
||||
gpu->type = FF_GPU_TYPE_DISCRETE;
|
||||
}
|
||||
else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_MTHREADS)
|
||||
{
|
||||
if (ffStrbufStartsWithIgnCaseS(&gpu->name, "MTT "))
|
||||
gpu->type = FF_GPU_TYPE_DISCRETE;
|
||||
}
|
||||
else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_INTEL)
|
||||
{
|
||||
gpu->type = ffStrbufStartsWithIgnCaseS(&gpu->name, "Arc ") ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,63 @@ typedef struct FFGpuDriverResult
|
||||
double* temp;
|
||||
FFGPUMemory* memory;
|
||||
uint32_t* coreCount;
|
||||
double* coreUsage;
|
||||
FFGPUType* type;
|
||||
uint32_t* frequency;
|
||||
FFstrbuf* name;
|
||||
} FFGpuDriverResult;
|
||||
|
||||
const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
|
||||
const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
|
||||
const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
|
||||
const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
|
||||
|
||||
FF_MAYBE_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName)
|
||||
{
|
||||
if (vendor == FF_GPU_VENDOR_NAME_NVIDIA)
|
||||
{
|
||||
*pDetectFn = ffDetectNvidiaGpuInfo;
|
||||
#ifdef _WIN32
|
||||
*pDllName = "nvml.dll";
|
||||
#else
|
||||
*pDllName = "libnvidia-ml.so";
|
||||
#endif
|
||||
}
|
||||
else if (vendor == FF_GPU_VENDOR_NAME_MTHREADS)
|
||||
{
|
||||
*pDetectFn = ffDetectMthreadsGpuInfo;
|
||||
#ifdef _WIN32
|
||||
*pDllName = "mtml.dll";
|
||||
#else
|
||||
*pDllName = "libmtml.so";
|
||||
#endif
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if (vendor == FF_GPU_VENDOR_NAME_INTEL)
|
||||
{
|
||||
*pDetectFn = ffDetectIntelGpuInfo;
|
||||
#ifdef _WIN64
|
||||
*pDllName = "ControlLib.dll";
|
||||
#else
|
||||
*pDllName = "ControlLib32.dll";
|
||||
#endif
|
||||
}
|
||||
else if (vendor == FF_GPU_VENDOR_NAME_AMD)
|
||||
{
|
||||
*pDetectFn = ffDetectAmdGpuInfo;
|
||||
#ifdef _WIN64
|
||||
*pDllName = "amd_ags_x64.dll";
|
||||
#else
|
||||
*pDllName = "amd_ags_x86.dll";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
*pDetectFn = NULL;
|
||||
*pDllName = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+112
-32
@@ -7,29 +7,90 @@
|
||||
#include "common/properties.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_STR_INDIR(x) #x
|
||||
#define FF_STR(x) FF_STR_INDIR(x)
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#if __has_include(<drm/drm.h>)
|
||||
#include <drm/drm.h>
|
||||
#define FF_HAVE_DRM_H 1
|
||||
#elif __has_include(<libdrm/drm.h>)
|
||||
#include <libdrm/drm.h>
|
||||
#define FF_HAVE_DRM_H 1
|
||||
#endif
|
||||
|
||||
#if FF_HAVE_DRM_H
|
||||
#if __aarch64__ && FF_HAVE_DRM
|
||||
#include <drm.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if __aarch64__ && __has_include(<drm/asahi_drm.h>)
|
||||
#include <drm/asahi_drm.h>
|
||||
#define FF_HAVE_ASAHI_DRM_H 1
|
||||
#if __has_include(<drm/asahi_drm.h>)
|
||||
#include <drm/asahi_drm.h>
|
||||
#else
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
/* Copyright (C) The Asahi Linux Contributors */
|
||||
#define DRM_ASAHI_GET_PARAMS 0x00
|
||||
#define DRM_ASAHI_MAX_CLUSTERS 32
|
||||
struct drm_asahi_params_global
|
||||
{
|
||||
__u32 unstable_uabi_version;
|
||||
__u32 pad0;
|
||||
|
||||
__u64 feat_compat;
|
||||
__u64 feat_incompat;
|
||||
|
||||
__u32 gpu_generation;
|
||||
__u32 gpu_variant;
|
||||
__u32 gpu_revision;
|
||||
__u32 chip_id;
|
||||
|
||||
__u32 num_dies;
|
||||
__u32 num_clusters_total;
|
||||
__u32 num_cores_per_cluster;
|
||||
__u32 num_frags_per_cluster;
|
||||
__u32 num_gps_per_cluster;
|
||||
__u32 num_cores_total_active;
|
||||
__u64 core_masks[DRM_ASAHI_MAX_CLUSTERS];
|
||||
|
||||
__u32 vm_page_size;
|
||||
__u32 pad1;
|
||||
__u64 vm_user_start;
|
||||
__u64 vm_user_end;
|
||||
__u64 vm_shader_start;
|
||||
__u64 vm_shader_end;
|
||||
|
||||
__u32 max_syncs_per_submission;
|
||||
__u32 max_commands_per_submission;
|
||||
__u32 max_commands_in_flight;
|
||||
__u32 max_attachments;
|
||||
|
||||
__u32 timer_frequency_hz;
|
||||
__u32 min_frequency_khz;
|
||||
__u32 max_frequency_khz;
|
||||
__u32 max_power_mw;
|
||||
|
||||
__u32 result_render_size;
|
||||
__u32 result_compute_size;
|
||||
};
|
||||
|
||||
struct drm_asahi_get_params
|
||||
{
|
||||
/** @extensions: Pointer to the first extension struct, if any */
|
||||
__u64 extensions;
|
||||
|
||||
/** @param: Parameter group to fetch (MBZ) */
|
||||
__u32 param_group;
|
||||
|
||||
/** @pad: MBZ */
|
||||
__u32 pad;
|
||||
|
||||
/** @value: User pointer to write parameter struct */
|
||||
__u64 pointer;
|
||||
|
||||
/** @value: Size of user buffer, max size supported on return */
|
||||
__u64 size;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
DRM_IOCTL_ASAHI_GET_PARAMS = DRM_IOWR(DRM_COMMAND_BASE + DRM_ASAHI_GET_PARAMS, struct drm_asahi_get_params),
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define FF_STR_INDIR(x) #x
|
||||
#define FF_STR(x) FF_STR_INDIR(x)
|
||||
|
||||
static bool pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey)
|
||||
{
|
||||
uint32_t pciDirLength = pciDir->length;
|
||||
@@ -45,6 +106,17 @@ static bool pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer
|
||||
ffStrbufSetNS(&gpu->driver, (uint32_t) (resultLength - (slash - pathBuf)), slash);
|
||||
}
|
||||
|
||||
if (ffStrbufEqualS(&gpu->driver, "nvidia"))
|
||||
{
|
||||
if (ffReadFileBuffer("/proc/driver/nvidia/version", buffer))
|
||||
{
|
||||
if (ffStrbufContainS(buffer, " Open "))
|
||||
ffStrbufAppendS(&gpu->driver, " (open source)");
|
||||
else
|
||||
ffStrbufAppendS(&gpu->driver, " (proprietary)");
|
||||
}
|
||||
}
|
||||
|
||||
if (instance.config.general.detectVersion)
|
||||
{
|
||||
ffStrbufAppendS(pciDir, "/module/version");
|
||||
@@ -212,14 +284,6 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
if (sscanf(pPciPath, "%" SCNx32 ":%" SCNx32 ":%" SCNx32 ".%" SCNx32, &pciDomain, &pciBus, &pciDevice, &pciFunc) != 4)
|
||||
return "Invalid PCI device path";
|
||||
|
||||
ffStrbufAppendS(deviceDir, "/enable");
|
||||
if (ffReadFileBuffer(deviceDir->chars, buffer))
|
||||
{
|
||||
if (!ffStrbufStartsWithC(buffer, '1'))
|
||||
return "GPU disabled";
|
||||
}
|
||||
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
|
||||
ffStrbufInitStatic(&gpu->vendor, ffGetGPUVendorString((uint16_t) vendorId));
|
||||
ffStrbufInit(&gpu->name);
|
||||
@@ -279,11 +343,13 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
pciDetectIntelSpecific(gpu, deviceDir, buffer);
|
||||
ffStrbufSubstrBefore(deviceDir, drmDirPathLength);
|
||||
}
|
||||
else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA)
|
||||
else
|
||||
{
|
||||
if (options->temp || options->driverSpecific)
|
||||
__typeof__(&ffDetectNvidiaGpuInfo) detectFn;
|
||||
const char* soName;
|
||||
if (getDriverSpecificDetectionFn(gpu->vendor.chars, &detectFn, &soName) && (options->temp || options->driverSpecific))
|
||||
{
|
||||
ffDetectNvidiaGpuInfo(&(FFGpuDriverCondition) {
|
||||
detectFn(&(FFGpuDriverCondition) {
|
||||
.type = FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID,
|
||||
.pciBusId = {
|
||||
.domain = pciDomain,
|
||||
@@ -295,23 +361,35 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
.temp = options->temp ? &gpu->temperature : NULL,
|
||||
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
|
||||
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
|
||||
.coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL,
|
||||
.type = &gpu->type,
|
||||
.frequency = options->driverSpecific ? &gpu->frequency : NULL,
|
||||
}, "libnvidia-ml.so");
|
||||
.name = options->driverSpecific ? &gpu->name : NULL,
|
||||
}, soName);
|
||||
}
|
||||
|
||||
if (gpu->type == FF_GPU_TYPE_UNKNOWN)
|
||||
{
|
||||
if (ffStrbufStartsWithIgnCaseS(&gpu->name, "GeForce") ||
|
||||
ffStrbufStartsWithIgnCaseS(&gpu->name, "Quadro") ||
|
||||
ffStrbufStartsWithIgnCaseS(&gpu->name, "Tesla"))
|
||||
gpu->type = FF_GPU_TYPE_DISCRETE;
|
||||
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA)
|
||||
{
|
||||
if (ffStrbufStartsWithIgnCaseS(&gpu->name, "GeForce") ||
|
||||
ffStrbufStartsWithIgnCaseS(&gpu->name, "Quadro") ||
|
||||
ffStrbufStartsWithIgnCaseS(&gpu->name, "Tesla"))
|
||||
gpu->type = FF_GPU_TYPE_DISCRETE;
|
||||
}
|
||||
else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_MTHREADS)
|
||||
{
|
||||
if (ffStrbufStartsWithIgnCaseS(&gpu->name, "MTT "))
|
||||
gpu->type = FF_GPU_TYPE_DISCRETE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if __aarch64__
|
||||
|
||||
FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, const char* drmKey)
|
||||
{
|
||||
uint32_t index = ffStrbufFirstIndexS(buffer, "apple,agx-t");
|
||||
@@ -326,13 +404,14 @@ FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, F
|
||||
ffStrbufInitF(&gpu->platformApi, "DRM (%s)", drmKey);
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
gpu->type = FF_GPU_TYPE_INTEGRATED;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
|
||||
pciDetectDriver(gpu, drmDir, buffer, drmKey);
|
||||
|
||||
#if FF_HAVE_ASAHI_DRM_H
|
||||
#if FF_HAVE_DRM
|
||||
ffStrbufSetS(buffer, "/dev/dri/");
|
||||
ffStrbufAppendS(buffer, drmKey);
|
||||
FF_AUTO_CLOSE_FD int fd = open(buffer->chars, O_RDONLY);
|
||||
@@ -354,6 +433,7 @@ FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, F
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char* drmDetectGPUs(const FFGPUOptions* options, FFlist* gpus)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
#include "gpu_driver_specific.h"
|
||||
|
||||
#include "common/library.h"
|
||||
#include "mtml.h"
|
||||
|
||||
struct FFMtmlData
|
||||
{
|
||||
FF_LIBRARY_SYMBOL(mtmlDeviceGetBrand)
|
||||
FF_LIBRARY_SYMBOL(mtmlDeviceGetIndex)
|
||||
FF_LIBRARY_SYMBOL(mtmlDeviceGetName)
|
||||
FF_LIBRARY_SYMBOL(mtmlDeviceGetPciInfo)
|
||||
FF_LIBRARY_SYMBOL(mtmlDeviceGetUUID)
|
||||
FF_LIBRARY_SYMBOL(mtmlDeviceInitGpu)
|
||||
FF_LIBRARY_SYMBOL(mtmlDeviceInitMemory)
|
||||
FF_LIBRARY_SYMBOL(mtmlGpuGetMaxClock)
|
||||
FF_LIBRARY_SYMBOL(mtmlGpuGetTemperature)
|
||||
FF_LIBRARY_SYMBOL(mtmlGpuGetUtilization)
|
||||
FF_LIBRARY_SYMBOL(mtmlLibraryCountDevice)
|
||||
FF_LIBRARY_SYMBOL(mtmlLibraryInitDeviceByIndex)
|
||||
FF_LIBRARY_SYMBOL(mtmlLibraryInitDeviceByPciSbdf)
|
||||
FF_LIBRARY_SYMBOL(mtmlLibraryInitSystem)
|
||||
FF_LIBRARY_SYMBOL(mtmlMemoryGetTotal)
|
||||
FF_LIBRARY_SYMBOL(mtmlMemoryGetUsed)
|
||||
FF_LIBRARY_SYMBOL(mtmlMemoryGetUtilization)
|
||||
FF_LIBRARY_SYMBOL(mtmlLibraryShutDown)
|
||||
|
||||
bool inited;
|
||||
MtmlLibrary *lib;
|
||||
MtmlSystem *sys;
|
||||
} mtmlData;
|
||||
|
||||
static void shutdownMtml()
|
||||
{
|
||||
mtmlData.ffmtmlLibraryShutDown(mtmlData.lib);
|
||||
}
|
||||
|
||||
const char *ffDetectMthreadsGpuInfo(const FFGpuDriverCondition *cond, FFGpuDriverResult result, const char *soName)
|
||||
{
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
|
||||
if (!mtmlData.inited)
|
||||
{
|
||||
mtmlData.inited = true;
|
||||
FF_LIBRARY_LOAD(libmtml, NULL, "dlopen mtml failed", soName, 1);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libmtml, mtmlLibraryInit)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetBrand)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetIndex)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetName)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetPciInfo)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetUUID)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceInitGpu)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceInitMemory)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlGpuGetMaxClock)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlGpuGetTemperature)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlGpuGetUtilization)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlLibraryCountDevice)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlLibraryInitDeviceByIndex)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlLibraryInitDeviceByPciSbdf)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlLibraryInitSystem)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlMemoryGetTotal)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlMemoryGetUsed)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlMemoryGetUtilization)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlLibraryShutDown)
|
||||
|
||||
if (ffmtmlLibraryInit(&mtmlData.lib) != MTML_SUCCESS)
|
||||
{
|
||||
mtmlData.ffmtmlLibraryInitSystem = NULL;
|
||||
return "mtmlLibraryInit failed";
|
||||
}
|
||||
if (mtmlData.ffmtmlLibraryInitSystem(mtmlData.lib, &mtmlData.sys) != MTML_SUCCESS)
|
||||
{
|
||||
mtmlData.ffmtmlLibraryShutDown(mtmlData.lib);
|
||||
mtmlData.ffmtmlLibraryInitSystem = NULL;
|
||||
return "mtmlLibraryInitSystem failed";
|
||||
}
|
||||
atexit(shutdownMtml);
|
||||
libmtml = NULL; // don't close mtml
|
||||
}
|
||||
|
||||
if (mtmlData.ffmtmlLibraryInitSystem == NULL)
|
||||
return "loading mtml library failed";
|
||||
|
||||
MtmlDevice *device = NULL;
|
||||
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);
|
||||
|
||||
MtmlReturn ret = mtmlData.ffmtmlLibraryInitDeviceByPciSbdf(mtmlData.lib, pciBusIdStr, &device);
|
||||
if (ret != MTML_SUCCESS)
|
||||
return "mtmlLibraryInitDeviceByPciSbdf() failed";
|
||||
}
|
||||
else if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID)
|
||||
{
|
||||
uint32_t count;
|
||||
if (mtmlData.ffmtmlLibraryCountDevice(mtmlData.lib, &count) != MTML_SUCCESS)
|
||||
return "mtmlLibraryCountDevice() failed";
|
||||
|
||||
for (uint32_t i = 0; i < count; i++, device = NULL)
|
||||
{
|
||||
if (mtmlData.ffmtmlLibraryInitDeviceByIndex(mtmlData.lib, i, &device) != MTML_SUCCESS)
|
||||
continue;
|
||||
|
||||
MtmlPciInfo pciInfo;
|
||||
if (mtmlData.ffmtmlDeviceGetPciInfo(device, &pciInfo) != MTML_SUCCESS)
|
||||
continue;
|
||||
|
||||
if (pciInfo.pciDeviceId != ((cond->pciDeviceId.deviceId << 16u) | cond->pciDeviceId.vendorId) ||
|
||||
pciInfo.pciSubsystemId != cond->pciDeviceId.subSystemId)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
if (!device)
|
||||
return "Device not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Unknown condition type";
|
||||
}
|
||||
|
||||
MtmlBrandType brand;
|
||||
if (mtmlData.ffmtmlDeviceGetBrand(device, &brand) == MTML_SUCCESS)
|
||||
{
|
||||
switch (brand)
|
||||
{
|
||||
case MTML_BRAND_MTT:
|
||||
*result.type = FF_GPU_TYPE_DISCRETE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.temp)
|
||||
{
|
||||
MtmlGpu *gpu = NULL;
|
||||
if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS)
|
||||
{
|
||||
uint32_t value;
|
||||
if (mtmlData.ffmtmlGpuGetTemperature(gpu, &value) == MTML_SUCCESS)
|
||||
*result.temp = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.memory)
|
||||
{
|
||||
MtmlMemory *mem = NULL;
|
||||
if (mtmlData.ffmtmlDeviceInitMemory(device, &mem) == MTML_SUCCESS)
|
||||
{
|
||||
unsigned long long total;
|
||||
if (mtmlData.ffmtmlMemoryGetTotal(mem, &total) == MTML_SUCCESS)
|
||||
result.memory->total = total;
|
||||
|
||||
unsigned long long used;
|
||||
if (mtmlData.ffmtmlMemoryGetUsed(mem, &used) == MTML_SUCCESS)
|
||||
result.memory->used = used;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.frequency)
|
||||
{
|
||||
MtmlGpu *gpu = NULL;
|
||||
if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS)
|
||||
{
|
||||
uint32_t clockMHz;
|
||||
if (mtmlData.ffmtmlGpuGetMaxClock(gpu, &clockMHz) == MTML_SUCCESS)
|
||||
*result.frequency = clockMHz;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.coreUsage)
|
||||
{
|
||||
MtmlGpu *gpu = NULL;
|
||||
if (mtmlData.ffmtmlDeviceInitGpu(device, &gpu) == MTML_SUCCESS)
|
||||
{
|
||||
unsigned int utilization;
|
||||
if (mtmlData.ffmtmlGpuGetUtilization(gpu, &utilization) == MTML_SUCCESS)
|
||||
*result.coreUsage = utilization;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.name)
|
||||
{
|
||||
char name[MTML_DEVICE_NAME_BUFFER_SIZE];
|
||||
if (mtmlData.ffmtmlDeviceGetName(device, name, sizeof(name)) == MTML_SUCCESS)
|
||||
ffStrbufSetS(result.name, name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
#else
|
||||
|
||||
FF_UNUSED(cond, result, soName);
|
||||
return "dlopen is disabled";
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -12,7 +12,9 @@ struct FFNvmlData {
|
||||
FF_LIBRARY_SYMBOL(nvmlDeviceGetMemoryInfo_v2)
|
||||
FF_LIBRARY_SYMBOL(nvmlDeviceGetNumGpuCores)
|
||||
FF_LIBRARY_SYMBOL(nvmlDeviceGetMaxClockInfo)
|
||||
FF_LIBRARY_SYMBOL(nvmlDeviceGetUtilizationRates)
|
||||
FF_LIBRARY_SYMBOL(nvmlDeviceGetBrand)
|
||||
FF_LIBRARY_SYMBOL(nvmlDeviceGetName)
|
||||
|
||||
bool inited;
|
||||
} nvmlData;
|
||||
@@ -35,7 +37,9 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetMemoryInfo_v2)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetNumGpuCores)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetMaxClockInfo)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetUtilizationRates)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetBrand)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetName)
|
||||
|
||||
if (ffnvmlInit_v2() != NVML_SUCCESS)
|
||||
{
|
||||
@@ -124,6 +128,20 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
|
||||
if (result.frequency)
|
||||
nvmlData.ffnvmlDeviceGetMaxClockInfo(device, NVML_CLOCK_GRAPHICS, result.frequency);
|
||||
|
||||
if (result.coreUsage)
|
||||
{
|
||||
nvmlUtilization_t utilization;
|
||||
if (nvmlData.ffnvmlDeviceGetUtilizationRates(device, &utilization) == NVML_SUCCESS)
|
||||
*result.coreUsage = utilization.gpu;
|
||||
}
|
||||
|
||||
if (result.name)
|
||||
{
|
||||
char name[NVML_DEVICE_NAME_V2_BUFFER_SIZE];
|
||||
if (nvmlData.ffnvmlDeviceGetName(device, name, sizeof(name)) == NVML_SUCCESS)
|
||||
ffStrbufSetS(result.name, name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
#else
|
||||
|
||||
@@ -59,6 +59,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
|
||||
ffStrbufInit(&gpu->platformApi);
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->deviceId = 0;
|
||||
|
||||
+96
-104
@@ -3,140 +3,118 @@
|
||||
#include "util/windows/unicode.h"
|
||||
#include "util/windows/registry.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#define INITGUID
|
||||
#include <windows.h>
|
||||
#include <setupapi.h>
|
||||
#include <devguid.h>
|
||||
|
||||
static int isGpuNameEqual(const FFGPUResult* gpu, const FFstrbuf* name)
|
||||
static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
|
||||
{
|
||||
return ffStrbufEqual(&gpu->name, name);
|
||||
if(*hdev)
|
||||
SetupDiDestroyDeviceInfoList(*hdev);
|
||||
}
|
||||
|
||||
static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName)
|
||||
{
|
||||
if (vendor == FF_GPU_VENDOR_NAME_NVIDIA)
|
||||
{
|
||||
*pDetectFn = ffDetectNvidiaGpuInfo;
|
||||
*pDllName = "nvml.dll";
|
||||
}
|
||||
else if (vendor == FF_GPU_VENDOR_NAME_INTEL)
|
||||
{
|
||||
*pDetectFn = ffDetectIntelGpuInfo;
|
||||
#ifdef _WIN64
|
||||
*pDllName = "ControlLib.dll";
|
||||
#else
|
||||
*pDllName = "ControlLib32.dll";
|
||||
#endif
|
||||
}
|
||||
else if (vendor == FF_GPU_VENDOR_NAME_AMD)
|
||||
{
|
||||
*pDetectFn = ffDetectAmdGpuInfo;
|
||||
#ifdef _WIN64
|
||||
*pDllName = "amd_ags_x64.dll";
|
||||
#else
|
||||
*pDllName = "amd_ags_x86.dll";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
*pDetectFn = NULL;
|
||||
*pDllName = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#define FF_EMPTY_GUID_STR L"{00000000-0000-0000-0000-000000000000}"
|
||||
#define FF_GUID_STRLEN (sizeof(FF_EMPTY_GUID_STR) / sizeof(wchar_t) - 1)
|
||||
|
||||
const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus)
|
||||
{
|
||||
DISPLAY_DEVICEW displayDevice = { .cb = sizeof(displayDevice) };
|
||||
wchar_t regDirectxKey[MAX_PATH] = L"SOFTWARE\\Microsoft\\DirectX\\{";
|
||||
const uint32_t regDirectxKeyPrefixLength = (uint32_t) wcslen(regDirectxKey);
|
||||
wchar_t regControlVideoKey[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\{";
|
||||
const uint32_t regControlVideoKeyPrefixLength = (uint32_t) wcslen(regControlVideoKey);
|
||||
const uint32_t deviceKeyPrefixLength = strlen("\\Registry\\Machine\\") + regControlVideoKeyPrefixLength;
|
||||
HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) =
|
||||
SetupDiGetClassDevsW(&GUID_DEVCLASS_DISPLAY, NULL, NULL, DIGCF_PRESENT);
|
||||
|
||||
for (DWORD i = 0; EnumDisplayDevicesW(NULL, i, &displayDevice, 0); ++i)
|
||||
if(hdev == INVALID_HANDLE_VALUE)
|
||||
return "SetupDiGetClassDevsW(&GUID_DEVCLASS_DISPLAY) failed";
|
||||
|
||||
wchar_t regDirectxKey[] = L"SOFTWARE\\Microsoft\\DirectX\\" FF_EMPTY_GUID_STR;
|
||||
const uint32_t regDirectxKeyPrefixLength = (uint32_t) strlen("SOFTWARE\\Microsoft\\DirectX\\");
|
||||
wchar_t regControlVideoKey[] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\" FF_EMPTY_GUID_STR L"\\0000";
|
||||
const uint32_t regControlVideoKeyPrefixLength = (uint32_t) strlen("SYSTEM\\CurrentControlSet\\Control\\Video\\");
|
||||
|
||||
SP_DEVINFO_DATA did = { .cbSize = sizeof(did) };
|
||||
for (DWORD idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); ++idev)
|
||||
{
|
||||
if (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue;
|
||||
wchar_t hardwareId[256];
|
||||
if (!SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_HARDWAREID, NULL, (PBYTE) hardwareId, sizeof(hardwareId), NULL))
|
||||
continue;
|
||||
|
||||
const uint32_t deviceKeyLength = (uint32_t) wcslen(displayDevice.DeviceKey);
|
||||
if (__builtin_expect(deviceKeyLength == 100, true))
|
||||
wchar_t videoId[39];
|
||||
{
|
||||
if (wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// DeviceKey can be empty. See #484
|
||||
FF_STRBUF_AUTO_DESTROY gpuName = ffStrbufCreateWS(displayDevice.DeviceString);
|
||||
if (ffListContains(gpus, &gpuName, (void*) isGpuNameEqual)) continue;
|
||||
FF_HKEY_AUTO_DESTROY hKey = SetupDiOpenDevRegKey(hdev, &did, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE);
|
||||
if (!hKey) continue;
|
||||
DWORD videoIdLength = sizeof(videoId);
|
||||
if (RegGetValueW(hKey, NULL, L"VideoID", RRF_RT_REG_SZ, NULL, videoId, &videoIdLength) != ERROR_SUCCESS || videoIdLength != (FF_GUID_STRLEN + 1) * sizeof(wchar_t))
|
||||
continue;
|
||||
}
|
||||
|
||||
// See: https://download.nvidia.com/XFree86/Linux-x86_64/545.23.06/README/supportedchips.html
|
||||
// displayDevice.DeviceID = MatchingDeviceId "PCI\\VEN_10DE&DEV_2782&SUBSYS_513417AA&REV_A1"
|
||||
wmemcpy(regControlVideoKey + regControlVideoKeyPrefixLength, videoId, FF_GUID_STRLEN);
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regControlVideoKey, &hKey, NULL)) continue;
|
||||
|
||||
unsigned vendorId = 0, deviceId = 0, subSystemId = 0, revId = 0;
|
||||
swscanf(displayDevice.DeviceID, L"PCI\\VEN_%x&DEV_%x&SUBSYS_%x&REV_%x", &vendorId, &deviceId, &subSystemId, &revId);
|
||||
swscanf(hardwareId, L"PCI\\VEN_%x&DEV_%x&SUBSYS_%x&REV_%x", &vendorId, &deviceId, &subSystemId, &revId);
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
|
||||
ffStrbufInitStatic(&gpu->vendor, ffGetGPUVendorString(vendorId));
|
||||
ffStrbufInitWS(&gpu->name, displayDevice.DeviceString);
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
ffStrbufInitStatic(&gpu->platformApi, "Direct3D");
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->deviceId = 0;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
|
||||
if (deviceKeyLength == 100 && displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{')
|
||||
if (!ffRegReadStrbuf(hKey, L"DriverDesc", &gpu->name, NULL)) // faster, for some reason
|
||||
{
|
||||
wmemcpy(regControlVideoKey + regControlVideoKeyPrefixLength, displayDevice.DeviceKey + deviceKeyPrefixLength, strlen("00000000-0000-0000-0000-000000000000}\\0000"));
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regControlVideoKey, &hKey, NULL)) continue;
|
||||
wchar_t name[256];
|
||||
if (SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_DEVICEDESC, NULL, (PBYTE) name, sizeof(name), NULL))
|
||||
ffStrbufSetWS(&gpu->name, name);
|
||||
}
|
||||
ffRegReadStrbuf(hKey, L"DriverVersion", &gpu->driver, NULL);
|
||||
|
||||
ffRegReadStrbuf(hKey, L"DriverVersion", &gpu->driver, NULL);
|
||||
wmemcpy(regDirectxKey + regDirectxKeyPrefixLength, videoId, FF_GUID_STRLEN);
|
||||
FF_HKEY_AUTO_DESTROY hDirectxKey = NULL;
|
||||
if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regDirectxKey, &hDirectxKey, NULL))
|
||||
{
|
||||
uint64_t dedicatedVideoMemory = 0;
|
||||
if(ffRegReadUint64(hDirectxKey, L"DedicatedVideoMemory", &dedicatedVideoMemory, NULL))
|
||||
gpu->type = dedicatedVideoMemory >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
|
||||
|
||||
wmemcpy(regDirectxKey + regDirectxKeyPrefixLength, displayDevice.DeviceKey + deviceKeyPrefixLength, strlen("00000000-0000-0000-0000-000000000000}"));
|
||||
FF_HKEY_AUTO_DESTROY hDirectxKey = NULL;
|
||||
if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regDirectxKey, &hDirectxKey, NULL))
|
||||
uint64_t dedicatedSystemMemory, sharedSystemMemory;
|
||||
if(ffRegReadUint64(hDirectxKey, L"DedicatedSystemMemory", &dedicatedSystemMemory, NULL) &&
|
||||
ffRegReadUint64(hDirectxKey, L"SharedSystemMemory", &sharedSystemMemory, NULL))
|
||||
{
|
||||
uint64_t dedicatedVideoMemory = 0;
|
||||
if(ffRegReadUint64(hDirectxKey, L"DedicatedVideoMemory", &dedicatedVideoMemory, NULL))
|
||||
gpu->type = dedicatedVideoMemory >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
|
||||
|
||||
uint64_t dedicatedSystemMemory, sharedSystemMemory;
|
||||
if(ffRegReadUint64(hDirectxKey, L"DedicatedSystemMemory", &dedicatedSystemMemory, NULL) &&
|
||||
ffRegReadUint64(hDirectxKey, L"SharedSystemMemory", &sharedSystemMemory, NULL))
|
||||
{
|
||||
gpu->dedicated.total = dedicatedVideoMemory + dedicatedSystemMemory;
|
||||
gpu->shared.total = sharedSystemMemory;
|
||||
}
|
||||
|
||||
ffRegReadUint64(hDirectxKey, L"AdapterLuid", &gpu->deviceId, NULL);
|
||||
|
||||
uint32_t featureLevel = 0;
|
||||
if(ffRegReadUint(hDirectxKey, L"MaxD3D12FeatureLevel", &featureLevel, NULL) && featureLevel)
|
||||
ffStrbufSetF(&gpu->platformApi, "Direct3D 12.%u", (featureLevel & 0x0F00) >> 8);
|
||||
else if(ffRegReadUint(hDirectxKey, L"MaxD3D11FeatureLevel", &featureLevel, NULL) && featureLevel)
|
||||
ffStrbufSetF(&gpu->platformApi, "Direct3D 11.%u", (featureLevel & 0x0F00) >> 8);
|
||||
}
|
||||
else if (!ffRegReadUint64(hKey, L"HardwareInformation.qwMemorySize", &gpu->dedicated.total, NULL))
|
||||
{
|
||||
uint32_t vmem = 0;
|
||||
if (ffRegReadUint(hKey, L"HardwareInformation.MemorySize", &vmem, NULL))
|
||||
gpu->dedicated.total = vmem;
|
||||
gpu->type = gpu->dedicated.total > 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
|
||||
gpu->dedicated.total = dedicatedVideoMemory + dedicatedSystemMemory;
|
||||
gpu->shared.total = sharedSystemMemory;
|
||||
}
|
||||
|
||||
if (gpu->vendor.length == 0)
|
||||
{
|
||||
ffRegReadStrbuf(hKey, L"ProviderName", &gpu->vendor, NULL);
|
||||
if (ffStrbufContainS(&gpu->vendor, "Intel"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
|
||||
else if (ffStrbufContainS(&gpu->vendor, "NVIDIA"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
|
||||
else if (ffStrbufContainS(&gpu->vendor, "AMD") || ffStrbufContainS(&gpu->vendor, "ATI"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
|
||||
}
|
||||
ffRegReadUint64(hDirectxKey, L"AdapterLuid", &gpu->deviceId, NULL);
|
||||
|
||||
uint32_t featureLevel = 0;
|
||||
if(ffRegReadUint(hDirectxKey, L"MaxD3D12FeatureLevel", &featureLevel, NULL) && featureLevel)
|
||||
ffStrbufSetF(&gpu->platformApi, "Direct3D 12.%u", (featureLevel & 0x0F00) >> 8);
|
||||
else if(ffRegReadUint(hDirectxKey, L"MaxD3D11FeatureLevel", &featureLevel, NULL) && featureLevel)
|
||||
ffStrbufSetF(&gpu->platformApi, "Direct3D 11.%u", (featureLevel & 0x0F00) >> 8);
|
||||
}
|
||||
else if (!ffRegReadUint64(hKey, L"HardwareInformation.qwMemorySize", &gpu->dedicated.total, NULL))
|
||||
{
|
||||
uint32_t vmem = 0;
|
||||
if (ffRegReadUint(hKey, L"HardwareInformation.MemorySize", &vmem, NULL))
|
||||
gpu->dedicated.total = vmem;
|
||||
gpu->type = gpu->dedicated.total > 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
|
||||
}
|
||||
|
||||
if (gpu->vendor.length == 0)
|
||||
{
|
||||
ffRegReadStrbuf(hKey, L"ProviderName", &gpu->vendor, NULL);
|
||||
if (ffStrbufContainS(&gpu->vendor, "Intel"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
|
||||
else if (ffStrbufContainS(&gpu->vendor, "NVIDIA"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
|
||||
else if (ffStrbufContainS(&gpu->vendor, "AMD") || ffStrbufContainS(&gpu->vendor, "ATI"))
|
||||
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
|
||||
}
|
||||
|
||||
__typeof__(&ffDetectNvidiaGpuInfo) detectFn;
|
||||
@@ -144,23 +122,37 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
|
||||
|
||||
if (getDriverSpecificDetectionFn(gpu->vendor.chars, &detectFn, &dllName) && (options->temp || options->driverSpecific))
|
||||
{
|
||||
if (vendorId && deviceId && subSystemId)
|
||||
uint32_t pciBus, pciAddr;
|
||||
if (SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_BUSNUMBER, NULL, (PBYTE) &pciBus, sizeof(pciBus), NULL) &&
|
||||
SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_ADDRESS, NULL, (PBYTE) &pciAddr, sizeof(pciAddr), NULL))
|
||||
{
|
||||
uint32_t pciDev = (pciAddr >> 16) & 0xFFFF;
|
||||
uint32_t pciFunc = pciAddr & 0xFFFF;
|
||||
|
||||
detectFn(
|
||||
&(FFGpuDriverCondition) {
|
||||
.type = FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID | FF_GPU_DRIVER_CONDITION_TYPE_LUID,
|
||||
.type = FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID
|
||||
| (gpu->deviceId > 0 ? FF_GPU_DRIVER_CONDITION_TYPE_LUID : 0)
|
||||
| FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID,
|
||||
.pciDeviceId = {
|
||||
.deviceId = deviceId,
|
||||
.vendorId = vendorId,
|
||||
.subSystemId = subSystemId,
|
||||
.revId = revId,
|
||||
},
|
||||
.pciBusId = {
|
||||
.domain = 0,
|
||||
.bus = pciBus,
|
||||
.device = pciDev,
|
||||
.func = pciFunc,
|
||||
},
|
||||
.luid = gpu->deviceId,
|
||||
},
|
||||
(FFGpuDriverResult) {
|
||||
.temp = options->temp ? &gpu->temperature : NULL,
|
||||
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
|
||||
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
|
||||
.coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL,
|
||||
.type = &gpu->type,
|
||||
.frequency = options->driverSpecific ? &gpu->frequency : NULL,
|
||||
},
|
||||
|
||||
@@ -71,8 +71,10 @@ const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FF
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
ffStrbufInitS(&gpu->name, desc);
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
gpu->deviceId = 0;
|
||||
ffStrbufInitStatic(&gpu->platformApi, "DXCore");
|
||||
|
||||
ffStrbufInit(&gpu->driver);
|
||||
@@ -119,8 +121,10 @@ const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FF
|
||||
.temp = options->temp ? &gpu->temperature : NULL,
|
||||
.memory = options->driverSpecific ? &gpu->dedicated : NULL,
|
||||
.coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL,
|
||||
.coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL,
|
||||
.type = &gpu->type,
|
||||
.frequency = options->driverSpecific ? &gpu->frequency : NULL,
|
||||
.name = options->driverSpecific ? &gpu->name : NULL,
|
||||
}, "/usr/lib/wsl/lib/libnvidia-ml.so");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
|
||||
// DISCLAIMER:
|
||||
// THIS FILE IS CREATED FROM SCRATCH, BY READING THE OFFICIAL MTML API
|
||||
// DOCUMENTATION REFERENCED BELOW, IN ORDER TO MAKE FASTFETCH MIT COMPLIANT.
|
||||
|
||||
#define MTML_API __attribute__((visibility("default")))
|
||||
#define MTML_DEVICE_PCI_SBDF_BUFFER_SIZE 32
|
||||
#define MTML_DEVICE_NAME_BUFFER_SIZE 32
|
||||
#define MTML_DEVICE_UUID_BUFFER_SIZE 48
|
||||
|
||||
/**
|
||||
* Return values for MTML API calls.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MTML_SUCCESS = 0,
|
||||
} MtmlReturn;
|
||||
|
||||
/**
|
||||
* The brand of the device.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MTML_BRAND_MTT = 0, //!< MTT series.
|
||||
MTML_BRAND_UNKNOWN, //!< An unknown brand.
|
||||
|
||||
// Keep this on the last line.
|
||||
MTML_BRAND_COUNT //!< The number of brands.
|
||||
} MtmlBrandType;
|
||||
|
||||
typedef struct MtmlLibrary MtmlLibrary;
|
||||
typedef struct MtmlSystem MtmlSystem;
|
||||
typedef struct MtmlDevice MtmlDevice;
|
||||
typedef struct MtmlGpu MtmlGpu;
|
||||
typedef struct MtmlMemory MtmlMemory;
|
||||
|
||||
/**
|
||||
* PCI information about a device.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char sbdf[MTML_DEVICE_PCI_SBDF_BUFFER_SIZE]; //!< The tuple segment:bus:device.function PCI identifier (& NULL terminator).
|
||||
unsigned int segment; //!< The PCI segment group(domain) on which the device's bus resides, 0 to 0xffffffff.
|
||||
unsigned int bus; //!< The bus on which the device resides, 0 to 0xff.
|
||||
unsigned int device; //!< The device ID on the bus, 0 to 31.
|
||||
unsigned int pciDeviceId; //!< The combined 16-bit device ID and 16-bit vendor ID.
|
||||
unsigned int pciSubsystemId; //!< The 32-bit sub system device ID.
|
||||
unsigned int busWidth; //!< @deprecated This value set to zero.
|
||||
float pciMaxSpeed; //!< The maximum link speed (transfer rate per lane) of the device. The unit is GT/s.
|
||||
float pciCurSpeed; //!< The current link speed (transfer rate per lane) of the device. The unit is GT/s.
|
||||
unsigned int pciMaxWidth; //!< The maximum link width of the device.
|
||||
unsigned int pciCurWidth; //!< The current link width of the device.
|
||||
unsigned int pciMaxGen; //!< The maximum supported generation of the device.
|
||||
unsigned int pciCurGen; //!< The current generation of the device.
|
||||
int rsvd[6]; //!< Reserved for future extension.
|
||||
} MtmlPciInfo;
|
||||
|
||||
// Retrieves the brand of a device.
|
||||
MtmlReturn MTML_API mtmlDeviceGetBrand(const MtmlDevice *dev, MtmlBrandType *type);
|
||||
// Retrieves the index associated with the specified device.
|
||||
MtmlReturn MTML_API mtmlDeviceGetIndex(const MtmlDevice *dev, unsigned int *index);
|
||||
// Retrieves the name of a device.
|
||||
MtmlReturn MTML_API mtmlDeviceGetName(const MtmlDevice *dev, char *name, unsigned int length);
|
||||
// Retrieves the PCI attributes of a device.
|
||||
MtmlReturn MTML_API mtmlDeviceGetPciInfo(const MtmlDevice *dev, MtmlPciInfo *pci);
|
||||
/**
|
||||
* Retrieves the UUID of a specified device. The UUID is a hexadecimal string in the
|
||||
* form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where each 'x' is an ASCII character that represents a hexadecimal
|
||||
* digit. The UUID is globally unique for every single device thus can be used to identify different devices
|
||||
* physically.
|
||||
*/
|
||||
MtmlReturn MTML_API mtmlDeviceGetUUID(const MtmlDevice *dev, char *uuid, unsigned int length);
|
||||
// Initializes a GPU opaque object to represent a specific graphic core on the target device that is designated by its index.
|
||||
MtmlReturn MTML_API mtmlDeviceInitGpu(const MtmlDevice *dev, MtmlGpu **gpu);
|
||||
// Initializes a memory opaque object to represent the memory on the target device.
|
||||
MtmlReturn MTML_API mtmlDeviceInitMemory(const MtmlDevice *dev, MtmlMemory **mem);
|
||||
|
||||
// Retrieves the maximum supported clock speed for the device's graphic core.
|
||||
MtmlReturn MTML_API mtmlGpuGetMaxClock(const MtmlGpu *gpu, unsigned int *clockMhz);
|
||||
// Retrieves the current temperature readings for the device's graphic core, in degrees Celsius.
|
||||
MtmlReturn MTML_API mtmlGpuGetTemperature(const MtmlGpu *gpu, unsigned int *temp);
|
||||
// Retrieves the current utilization rate for the device's graphic core.
|
||||
MtmlReturn MTML_API mtmlGpuGetUtilization(const MtmlGpu *gpu, unsigned int *utilization);
|
||||
|
||||
// Retrieves the number of devices that can be accessed by the library opaque object.
|
||||
MtmlReturn MTML_API mtmlLibraryCountDevice(const MtmlLibrary *lib, unsigned int *count);
|
||||
/**
|
||||
* Initializes a device opaque object to represent a device that is designated by its index.
|
||||
* The index ranges from (0) to (deviceCount - 1), where deviceCount is retrieved from \ref mtmlLibraryCountDevice().
|
||||
*/
|
||||
MtmlReturn MTML_API mtmlLibraryInit(MtmlLibrary **lib);
|
||||
/**
|
||||
* Initializes a device opaque object to represent a device that is designated by its index.
|
||||
* The index ranges from (0) to (deviceCount - 1), where deviceCount is retrieved from \ref mtmlLibraryCountDevice().
|
||||
*/
|
||||
MtmlReturn MTML_API mtmlLibraryInitDeviceByIndex(const MtmlLibrary *lib, unsigned int index, MtmlDevice **dev);
|
||||
/**
|
||||
* Initializes a device opaque object to represent a device that is designated by its PCI Sbdf.
|
||||
* The PCI Sbdf format like 00000000:3a:00.0 refer to \ref MtmlPciInfo::sbdf.
|
||||
*/
|
||||
MtmlReturn MTML_API mtmlLibraryInitDeviceByPciSbdf(const MtmlLibrary *lib, const char *pciSbdf, MtmlDevice **dev);
|
||||
// Initializes a MtmlSystem opaque pointer that is bound to a library opaque object.
|
||||
MtmlReturn MTML_API mtmlLibraryInitSystem(const MtmlLibrary *lib, MtmlSystem **sys);
|
||||
/**
|
||||
* Shuts down the library opaque object that is previously initialized by \ref mtmlLibraryInit() and releases its resources.
|
||||
* The \a lib pointer cannot be used anymore after this function returns.
|
||||
*/
|
||||
MtmlReturn MTML_API mtmlLibraryShutDown(MtmlLibrary *lib);
|
||||
|
||||
// Retrieves the amount of total memory available on the device, in bytes.
|
||||
MtmlReturn MTML_API mtmlMemoryGetTotal(const MtmlMemory *mem, unsigned long long *total);
|
||||
// Retrieves the amount of used memory on the device, in bytes.
|
||||
MtmlReturn MTML_API mtmlMemoryGetUsed(const MtmlMemory *mem, unsigned long long *used);
|
||||
// Retrieves the current memory utilization rate for the device.
|
||||
MtmlReturn MTML_API mtmlMemoryGetUtilization(const MtmlMemory *mem, unsigned int *utilization);
|
||||
@@ -7,6 +7,7 @@
|
||||
// https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceStructs.html
|
||||
#define NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE 32
|
||||
#define NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE 16
|
||||
#define NVML_DEVICE_NAME_V2_BUFFER_SIZE 96
|
||||
|
||||
typedef enum { NVML_SUCCESS = 0 } nvmlReturn_t;
|
||||
typedef struct nvmlDevice_t* nvmlDevice_t;
|
||||
@@ -94,6 +95,16 @@ typedef enum {
|
||||
NVML_BRAND_COUNT,
|
||||
} nvmlBrandType_t;
|
||||
|
||||
// https://docs.nvidia.com/deploy/nvml-api/structnvmlUtilization__t.html#structnvmlUtilization__t
|
||||
// Utilization information for a device.
|
||||
typedef struct
|
||||
{
|
||||
// Percent of time over the past second during which one or more kernels was executing on the GPU
|
||||
unsigned int gpu;
|
||||
// Percent of time over the past second during which global (device) memory was being read or written
|
||||
unsigned int memory;
|
||||
} nvmlUtilization_t;
|
||||
|
||||
// https://docs.nvidia.com/deploy/nvml-api/group__nvmlInitializationAndCleanup.html#group__nvmlInitializationAndCleanup
|
||||
// Initialize NVML, but don't initialize any GPUs yet
|
||||
nvmlReturn_t nvmlInit_v2(void);
|
||||
@@ -119,3 +130,7 @@ extern nvmlReturn_t nvmlDeviceGetNumGpuCores(nvmlDevice_t device, unsigned int*
|
||||
extern nvmlReturn_t nvmlDeviceGetMaxClockInfo(nvmlDevice_t device, nvmlClockType_t type, unsigned int* clock);
|
||||
// Retrieves the brand of this device
|
||||
extern nvmlReturn_t nvmlDeviceGetBrand(nvmlDevice_t device, nvmlBrandType_t* type);
|
||||
// Retrieves the current utilization rates for the device
|
||||
extern nvmlReturn_t nvmlDeviceGetUtilizationRates(nvmlDevice_t device, nvmlUtilization_t *utilization);
|
||||
// Retrieves the name of this device.
|
||||
extern nvmlReturn_t nvmlDeviceGetName(nvmlDevice_t device, char *name, unsigned int length);
|
||||
|
||||
@@ -35,13 +35,12 @@ static const char* getSshdVersion(FFstrbuf* version)
|
||||
{
|
||||
const char* error = ffProcessAppendStdErr(version, (char* const[]) {
|
||||
"sshd",
|
||||
"-qv",
|
||||
"-V",
|
||||
NULL
|
||||
});
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
// unknown option -- v
|
||||
// OpenSSH_9.0p1, OpenSSL 3.0.9 30 May 2023...
|
||||
ffStrbufSubstrBeforeFirstC(version, ',');
|
||||
ffStrbufSubstrAfterFirstC(version, '_');
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
#include "common/dbus.h"
|
||||
#include "common/library.h"
|
||||
|
||||
#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
|
||||
{ \
|
||||
if(!(dbus)->lib->ffdbus_message_iter_next(iterator)) \
|
||||
break; \
|
||||
continue; \
|
||||
}
|
||||
|
||||
static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResult* result)
|
||||
{
|
||||
DBusMessage* reply = ffDBusGetProperty(data, busName, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player", "Metadata");
|
||||
@@ -61,13 +68,13 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul
|
||||
data->lib->ffdbus_message_iter_next(&dictIterator);
|
||||
|
||||
if(ffStrEquals(key, "xesam:title"))
|
||||
ffDBusGetValue(data, &dictIterator, &result->song);
|
||||
ffDBusGetString(data, &dictIterator, &result->song);
|
||||
else if(ffStrEquals(key, "xesam:album"))
|
||||
ffDBusGetValue(data, &dictIterator, &result->album);
|
||||
ffDBusGetString(data, &dictIterator, &result->album);
|
||||
else if(ffStrEquals(key, "xesam:artist"))
|
||||
ffDBusGetValue(data, &dictIterator, &result->artist);
|
||||
ffDBusGetString(data, &dictIterator, &result->artist);
|
||||
else if(ffStrEquals(key, "xesam:url"))
|
||||
ffDBusGetValue(data, &dictIterator, &result->url);
|
||||
ffDBusGetString(data, &dictIterator, &result->url);
|
||||
|
||||
if(result->song.length > 0 && result->artist.length > 0 && result->album.length > 0 && result->url.length > 0)
|
||||
break;
|
||||
@@ -85,6 +92,8 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul
|
||||
return false;
|
||||
}
|
||||
|
||||
ffDBusGetPropertyString(data, busName, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player", "PlaybackStatus", &result->status);
|
||||
|
||||
//Set short bus name
|
||||
ffStrbufAppendS(&result->playerId, busName + sizeof(FF_DBUS_MPRIS_PREFIX) - 1);
|
||||
|
||||
@@ -119,7 +128,7 @@ static void getBestBus(FFDBusData* data, FFMediaResult* result)
|
||||
getBusProperties(data, FF_DBUS_MPRIS_PREFIX"plasma-browser-integration", result)
|
||||
) return;
|
||||
|
||||
DBusMessage* reply = ffDBusGetMethodReply(data, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames");
|
||||
DBusMessage* reply = ffDBusGetMethodReply(data, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames", NULL);
|
||||
if(reply == NULL)
|
||||
return;
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result)
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
gpu->deviceId = (size_t) deviceID;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
|
||||
if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VERSION, sizeof(buffer), buffer, NULL) == CL_SUCCESS)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ static inline void wrapIoDestroyPlugInInterface(IOCFPlugInInterface*** pluginInf
|
||||
if (*pluginInf)
|
||||
IODestroyPlugInInterface(*pluginInf);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const char* detectSsdTemp(io_service_t entryPhysical, double* temp)
|
||||
{
|
||||
@@ -82,10 +82,12 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
device->temperature = FF_PHYSICALDISK_TEMP_UNSET;
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFBooleanRef removable = IORegistryEntryCreateCFProperty(entryPartition, CFSTR(kIOMediaRemovableKey), kCFAllocatorDefault, kNilOptions);
|
||||
device->type |= CFBooleanGetValue(removable) ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED;
|
||||
if (removable)
|
||||
device->type |= CFBooleanGetValue(removable) ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED;
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFBooleanRef writable = IORegistryEntryCreateCFProperty(entryPartition, CFSTR(kIOMediaWritableKey), kCFAllocatorDefault, kNilOptions);
|
||||
device->type |= CFBooleanGetValue(writable) ? FF_PHYSICALDISK_TYPE_READWRITE : FF_PHYSICALDISK_TYPE_READONLY;
|
||||
if (writable)
|
||||
device->type |= CFBooleanGetValue(writable) ? FF_PHYSICALDISK_TYPE_READWRITE : FF_PHYSICALDISK_TYPE_READONLY;
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef bsdName = IORegistryEntryCreateCFProperty(entryPartition, CFSTR(kIOBSDNameKey), kCFAllocatorDefault, kNilOptions);
|
||||
if (bsdName)
|
||||
@@ -125,7 +127,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
if (options->temp)
|
||||
{
|
||||
FF_CFTYPE_AUTO_RELEASE CFBooleanRef nvmeSMARTCapable = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyNVMeSMARTCapableKey), kCFAllocatorDefault, kNilOptions);
|
||||
|
||||
@@ -23,6 +23,12 @@ static inline const char* getVendorString(unsigned vendorId)
|
||||
|
||||
void FFPhysicalMemoryUpdateVendorString(FFPhysicalMemoryResult* device)
|
||||
{
|
||||
if (ffStrbufEqualS(&device->vendor, "Unknown"))
|
||||
{
|
||||
ffStrbufClear(&device->vendor);
|
||||
return;
|
||||
}
|
||||
|
||||
char vendorIdStr[5];
|
||||
if (ffStrbufStartsWithS(&device->vendor, "0x"))
|
||||
{
|
||||
|
||||
@@ -75,10 +75,10 @@ const char* ffDetectPhysicalMemory(FFlist* result)
|
||||
if (!data)
|
||||
return "Memory device is not found in SMBIOS data";
|
||||
|
||||
for (; data->Header.Type == FF_SMBIOS_TYPE_MEMORY_DEVICE;
|
||||
data = (const FFSmbiosMemoryDevice*) ffSmbiosNextEntry(&data->Header))
|
||||
for (; data->Header.Type < FF_SMBIOS_TYPE_END_OF_TABLE;
|
||||
data = (const FFSmbiosMemoryDevice*) ffSmbiosNextEntry(&data->Header))
|
||||
{
|
||||
if (data->Size == 0) continue;
|
||||
if (data->Header.Type != FF_SMBIOS_TYPE_MEMORY_DEVICE || data->Size == 0) continue;
|
||||
|
||||
const char* strings = (const char*) data + data->Header.Length;
|
||||
|
||||
|
||||
@@ -72,193 +72,6 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont)
|
||||
ffStrbufAppendS(&terminalFont->error, "Couldn't find Font in "FASTFETCH_TARGET_DIR_ETC"/vconsole.conf");
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
|
||||
#include "common/library.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char* detectWTProfile(yyjson_val* profile, FFstrbuf* name, double* size)
|
||||
{
|
||||
yyjson_val* font = yyjson_obj_get(profile, "font");
|
||||
if (!font)
|
||||
return "yyjson_obj_get(profile, \"font\"); failed";
|
||||
|
||||
if (!yyjson_is_obj(font))
|
||||
return "yyjson_is_obj(font) returns false";
|
||||
|
||||
if (name->length == 0)
|
||||
{
|
||||
yyjson_val* pface = yyjson_obj_get(font, "face");
|
||||
if(yyjson_is_str(pface))
|
||||
ffStrbufAppendS(name, unsafe_yyjson_get_str(pface));
|
||||
}
|
||||
|
||||
if (*size < 0)
|
||||
{
|
||||
yyjson_val* psize = yyjson_obj_get(font, "size");
|
||||
if (yyjson_is_num(psize))
|
||||
*size = yyjson_get_num(psize);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void wrapYyjsonFree(yyjson_doc** doc)
|
||||
{
|
||||
assert(doc);
|
||||
if (*doc)
|
||||
yyjson_doc_free(*doc);
|
||||
}
|
||||
|
||||
static const char* detectFromWTImpl(FFstrbuf* content, FFstrbuf* name, double* size)
|
||||
{
|
||||
yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, NULL);
|
||||
if (!doc)
|
||||
return "Failed to parse WT JSON config file";
|
||||
|
||||
yyjson_val* const root = yyjson_doc_get_root(doc);
|
||||
assert(root);
|
||||
|
||||
yyjson_val* profiles = yyjson_obj_get(root, "profiles");
|
||||
if (!profiles)
|
||||
return "yyjson_obj_get(root, \"profiles\") failed";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY wtProfileId = ffStrbufCreateS(getenv("WT_PROFILE_ID"));
|
||||
ffStrbufTrim(&wtProfileId, '\'');
|
||||
if (wtProfileId.length > 0)
|
||||
{
|
||||
yyjson_val* list = yyjson_obj_get(profiles, "list");
|
||||
if (yyjson_is_arr(list))
|
||||
{
|
||||
yyjson_val* profile;
|
||||
size_t idx, max;
|
||||
yyjson_arr_foreach(list, idx, max, profile)
|
||||
{
|
||||
yyjson_val* guid = yyjson_obj_get(profile, "guid");
|
||||
|
||||
if(ffStrbufEqualS(&wtProfileId, yyjson_get_str(guid)))
|
||||
{
|
||||
detectWTProfile(profile, name, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yyjson_val* defaults = yyjson_obj_get(profiles, "defaults");
|
||||
if (defaults)
|
||||
detectWTProfile(defaults, name, size);
|
||||
|
||||
if(name->length == 0)
|
||||
ffStrbufSetS(name, "Cascadia Mono");
|
||||
if(*size < 0)
|
||||
*size = 12;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
//https://learn.microsoft.com/en-us/windows/terminal/install#settings-json-file
|
||||
FF_STRBUF_AUTO_DESTROY json = ffStrbufCreate();
|
||||
const char* error = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
if(terminalExe && terminalExe->length > 0 && !ffStrbufEqualS(terminalExe, "Windows Terminal"))
|
||||
{
|
||||
char jsonPath[MAX_PATH + 1];
|
||||
strncpy(jsonPath, terminalExe->chars, ffStrbufLastIndexC(terminalExe, '\\') + 1);
|
||||
char* pathEnd = jsonPath + strlen(jsonPath);
|
||||
strncpy(pathEnd, ".portable", sizeof(jsonPath) - (size_t) (pathEnd - jsonPath) - 1);
|
||||
|
||||
if(ffPathExists(jsonPath, FF_PATHTYPE_ANY))
|
||||
{
|
||||
strncpy(pathEnd, "settings\\settings.json", sizeof(jsonPath) - (size_t) (pathEnd - jsonPath) - 1);
|
||||
if(!ffAppendFileBuffer(jsonPath, &json))
|
||||
error = "Error reading Windows Terminal portable settings JSON file";
|
||||
}
|
||||
else if(SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, jsonPath)))
|
||||
{
|
||||
size_t remaining = sizeof(jsonPath) - strlen(jsonPath) - 1;
|
||||
if(ffStrbufContainIgnCaseS(terminalExe, "_8wekyb3d8bbwe\\"))
|
||||
{
|
||||
// Microsoft Store version
|
||||
if(ffStrbufContainIgnCaseS(terminalExe, ".WindowsTerminalPreview_"))
|
||||
{
|
||||
// Preview version
|
||||
strncat(jsonPath, "\\Packages\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\LocalState\\settings.json", remaining);
|
||||
if(!ffAppendFileBuffer(jsonPath, &json))
|
||||
error = "Error reading Windows Terminal Preview settings JSON file";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stable version
|
||||
strncat(jsonPath, "\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json", remaining);
|
||||
if(!ffAppendFileBuffer(jsonPath, &json))
|
||||
error = "Error reading Windows Terminal settings JSON file";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strncat(jsonPath, "\\Microsoft\\Windows Terminal\\settings.json", remaining);
|
||||
if(!ffAppendFileBuffer(jsonPath, &json))
|
||||
error = "Error reading Windows Terminal settings JSON file";
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
FF_UNUSED(terminalExe);
|
||||
#endif
|
||||
|
||||
if(!error && json.length == 0)
|
||||
{
|
||||
error = ffProcessAppendStdOut(&json, (char* const[]) {
|
||||
"cmd.exe",
|
||||
"/c",
|
||||
//print the file content directly, so we don't need to handle the difference of Windows and POSIX path
|
||||
"if exist %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json "
|
||||
"( type %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json ) "
|
||||
"else if exist %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\LocalState\\settings.json "
|
||||
"( type %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\LocalState\\settings.json ) "
|
||||
"else if exist \"%LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json\" "
|
||||
"( type %LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json ) "
|
||||
"else ( call )",
|
||||
NULL
|
||||
});
|
||||
}
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, error);
|
||||
return;
|
||||
}
|
||||
ffStrbufTrimRight(&json, '\n');
|
||||
if(json.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "Cannot find file \"settings.json\"");
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
|
||||
double size = -1;
|
||||
error = detectFromWTImpl(&json, &name, &size);
|
||||
|
||||
if(error)
|
||||
ffStrbufAppendS(&terminalFont->error, error);
|
||||
else
|
||||
{
|
||||
char sizeStr[16];
|
||||
snprintf(sizeStr, sizeof(sizeStr), "%g", size);
|
||||
ffFontInitValues(&terminalFont->font, name.chars, sizeStr);
|
||||
}
|
||||
}
|
||||
|
||||
#endif //defined(_WIN32) || defined(__linux__)
|
||||
|
||||
static bool queryKittyTerm(const char* query, FFstrbuf* res)
|
||||
{
|
||||
// https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233
|
||||
@@ -322,34 +135,6 @@ FF_MAYBE_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResul
|
||||
return true;
|
||||
}
|
||||
|
||||
static void detectTerminator(FFTerminalFontResult* result)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY useSystemFont = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
|
||||
FFpropquery fontQuery[] = {
|
||||
{"use_system_font =", &useSystemFont},
|
||||
{"font =", &fontName},
|
||||
};
|
||||
|
||||
if(!ffParsePropFileConfigValues("terminator/config", 2, fontQuery))
|
||||
{
|
||||
ffStrbufAppendS(&result->error, "Couldn't read Terminator config file");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ffStrbufIgnCaseEqualS(&useSystemFont, "True"))
|
||||
{
|
||||
ffFontInitCopy(&result->font, "System");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fontName.length == 0)
|
||||
ffFontInitValues(&result->font, "mono", "8");
|
||||
else
|
||||
ffFontInitPango(&result->font, fontName.chars);
|
||||
}
|
||||
|
||||
static bool detectWezterm(const FFstrbuf* exe, FFTerminalFontResult* result)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY cli = ffStrbufCreateCopy(exe);
|
||||
@@ -442,8 +227,6 @@ static bool detectTerminalFontCommon(const FFTerminalResult* terminal, FFTermina
|
||||
{
|
||||
if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "alacritty"))
|
||||
detectAlacritty(terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "terminator"))
|
||||
detectTerminator(terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "wezterm-gui"))
|
||||
detectWezterm(&terminal->exe, terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "tabby"))
|
||||
@@ -460,13 +243,6 @@ static bool detectTerminalFontCommon(const FFTerminalResult* terminal, FFTermina
|
||||
detectTTY(terminalFont);
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
//Used by both Linux (WSL) and Windows
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "Windows Terminal") ||
|
||||
ffStrbufIgnCaseEqualS(&terminal->processName, "WindowsTerminal.exe"))
|
||||
detectFromWindowsTerminal(&terminal->exe, terminalFont);
|
||||
#endif
|
||||
|
||||
else
|
||||
return false;
|
||||
|
||||
|
||||
@@ -379,6 +379,30 @@ static void detectWarp(FFTerminalFontResult* terminalFont)
|
||||
}
|
||||
}
|
||||
|
||||
static void detectTerminator(FFTerminalFontResult* result)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY useSystemFont = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
|
||||
if(!ffParsePropFileConfigValues("terminator/config", 2, (FFpropquery[]) {
|
||||
{"use_system_font =", &useSystemFont},
|
||||
{"font =", &fontName},
|
||||
}) || ffStrbufIgnCaseEqualS(&useSystemFont, "True"))
|
||||
{
|
||||
FF_AUTO_FREE const char* fontName = getSystemMonospaceFont();
|
||||
if(ffStrSet(fontName))
|
||||
ffFontInitPango(&result->font, fontName);
|
||||
else
|
||||
ffStrbufAppendS(&result->error, "Couldn't get system monospace font name from GSettings / DConf");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fontName.length == 0)
|
||||
ffFontInitValues(&result->font, "Mono", "10");
|
||||
else
|
||||
ffFontInitPango(&result->font, fontName.chars);
|
||||
}
|
||||
|
||||
static void detectWestonTerminal(FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate();
|
||||
@@ -426,4 +450,6 @@ void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFo
|
||||
detectWarp(terminalFont);
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "weston-terminal"))
|
||||
detectWestonTerminal(terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "terminator"))
|
||||
detectTerminator(terminalFont);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,184 @@
|
||||
#include "common/properties.h"
|
||||
#include "common/library.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/processing.h"
|
||||
#include "common/properties.h"
|
||||
#include "detection/terminalshell/terminalshell.h"
|
||||
#include "terminalfont.h"
|
||||
#include "util/windows/unicode.h"
|
||||
#include "terminalfont.h"
|
||||
|
||||
#include <shlobj.h>
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char* detectWTProfile(yyjson_val* profile, FFstrbuf* name, double* size)
|
||||
{
|
||||
yyjson_val* font = yyjson_obj_get(profile, "font");
|
||||
if (!font)
|
||||
return "yyjson_obj_get(profile, \"font\"); failed";
|
||||
|
||||
if (!yyjson_is_obj(font))
|
||||
return "yyjson_is_obj(font) returns false";
|
||||
|
||||
if (name->length == 0)
|
||||
{
|
||||
yyjson_val* pface = yyjson_obj_get(font, "face");
|
||||
if(yyjson_is_str(pface))
|
||||
ffStrbufAppendS(name, unsafe_yyjson_get_str(pface));
|
||||
}
|
||||
|
||||
if (*size < 0)
|
||||
{
|
||||
yyjson_val* psize = yyjson_obj_get(font, "size");
|
||||
if (yyjson_is_num(psize))
|
||||
*size = yyjson_get_num(psize);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void wrapYyjsonFree(yyjson_doc** doc)
|
||||
{
|
||||
assert(doc);
|
||||
if (*doc)
|
||||
yyjson_doc_free(*doc);
|
||||
}
|
||||
|
||||
static const char* detectFromWTImpl(FFstrbuf* content, FFstrbuf* name, double* size)
|
||||
{
|
||||
yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, NULL);
|
||||
if (!doc)
|
||||
return "Failed to parse WT JSON config file";
|
||||
|
||||
yyjson_val* const root = yyjson_doc_get_root(doc);
|
||||
assert(root);
|
||||
|
||||
yyjson_val* profiles = yyjson_obj_get(root, "profiles");
|
||||
if (!profiles)
|
||||
return "yyjson_obj_get(root, \"profiles\") failed";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY wtProfileId = ffStrbufCreateS(getenv("WT_PROFILE_ID"));
|
||||
ffStrbufTrim(&wtProfileId, '\'');
|
||||
if (wtProfileId.length > 0)
|
||||
{
|
||||
yyjson_val* list = yyjson_obj_get(profiles, "list");
|
||||
if (yyjson_is_arr(list))
|
||||
{
|
||||
yyjson_val* profile;
|
||||
size_t idx, max;
|
||||
yyjson_arr_foreach(list, idx, max, profile)
|
||||
{
|
||||
yyjson_val* guid = yyjson_obj_get(profile, "guid");
|
||||
|
||||
if(ffStrbufEqualS(&wtProfileId, yyjson_get_str(guid)))
|
||||
{
|
||||
detectWTProfile(profile, name, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yyjson_val* defaults = yyjson_obj_get(profiles, "defaults");
|
||||
if (defaults)
|
||||
detectWTProfile(defaults, name, size);
|
||||
|
||||
if(name->length == 0)
|
||||
ffStrbufSetS(name, "Cascadia Mono");
|
||||
if(*size < 0)
|
||||
*size = 12;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
//https://learn.microsoft.com/en-us/windows/terminal/install#settings-json-file
|
||||
FF_STRBUF_AUTO_DESTROY json = ffStrbufCreate();
|
||||
const char* error = NULL;
|
||||
|
||||
if(terminalExe && terminalExe->length > 0 && !ffStrbufEqualS(terminalExe, "Windows Terminal"))
|
||||
{
|
||||
char jsonPath[MAX_PATH + 1];
|
||||
strncpy(jsonPath, terminalExe->chars, ffStrbufLastIndexC(terminalExe, '\\') + 1);
|
||||
char* pathEnd = jsonPath + strlen(jsonPath);
|
||||
strncpy(pathEnd, ".portable", sizeof(jsonPath) - (size_t) (pathEnd - jsonPath) - 1);
|
||||
|
||||
if(ffPathExists(jsonPath, FF_PATHTYPE_ANY))
|
||||
{
|
||||
strncpy(pathEnd, "settings\\settings.json", sizeof(jsonPath) - (size_t) (pathEnd - jsonPath) - 1);
|
||||
if(!ffAppendFileBuffer(jsonPath, &json))
|
||||
error = "Error reading Windows Terminal portable settings JSON file";
|
||||
}
|
||||
else if(SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, jsonPath)))
|
||||
{
|
||||
size_t remaining = sizeof(jsonPath) - strlen(jsonPath) - 1;
|
||||
if(ffStrbufContainIgnCaseS(terminalExe, "_8wekyb3d8bbwe\\"))
|
||||
{
|
||||
// Microsoft Store version
|
||||
if(ffStrbufContainIgnCaseS(terminalExe, ".WindowsTerminalPreview_"))
|
||||
{
|
||||
// Preview version
|
||||
strncat(jsonPath, "\\Packages\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\LocalState\\settings.json", remaining);
|
||||
if(!ffAppendFileBuffer(jsonPath, &json))
|
||||
error = "Error reading Windows Terminal Preview settings JSON file";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stable version
|
||||
strncat(jsonPath, "\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json", remaining);
|
||||
if(!ffAppendFileBuffer(jsonPath, &json))
|
||||
error = "Error reading Windows Terminal settings JSON file";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strncat(jsonPath, "\\Microsoft\\Windows Terminal\\settings.json", remaining);
|
||||
if(!ffAppendFileBuffer(jsonPath, &json))
|
||||
error = "Error reading Windows Terminal settings JSON file";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!error && json.length == 0)
|
||||
{
|
||||
error = ffProcessAppendStdOut(&json, (char* const[]) {
|
||||
"cmd.exe",
|
||||
"/c",
|
||||
//print the file content directly, so we don't need to handle the difference of Windows and POSIX path
|
||||
"if exist %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json "
|
||||
"( type %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json ) "
|
||||
"else if exist %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\LocalState\\settings.json "
|
||||
"( type %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\\LocalState\\settings.json ) "
|
||||
"else if exist \"%LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json\" "
|
||||
"( type %LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json ) "
|
||||
"else ( call )",
|
||||
NULL
|
||||
});
|
||||
}
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, error);
|
||||
return;
|
||||
}
|
||||
ffStrbufTrimRight(&json, '\n');
|
||||
if(json.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "Cannot find file \"settings.json\"");
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate();
|
||||
double size = -1;
|
||||
error = detectFromWTImpl(&json, &name, &size);
|
||||
|
||||
if(error)
|
||||
ffStrbufAppendS(&terminalFont->error, error);
|
||||
else
|
||||
{
|
||||
char sizeStr[16];
|
||||
snprintf(sizeStr, sizeof(sizeStr), "%g", size);
|
||||
ffFontInitValues(&terminalFont->font, name.chars, sizeStr);
|
||||
}
|
||||
}
|
||||
|
||||
static void detectMintty(FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
@@ -87,7 +261,10 @@ static void detectConEmu(FFTerminalFontResult* terminalFont)
|
||||
|
||||
void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
if(ffStrbufIgnCaseEqualS(&terminal->processName, "mintty"))
|
||||
if(ffStrbufIgnCaseEqualS(&terminal->processName, "Windows Terminal") ||
|
||||
ffStrbufIgnCaseEqualS(&terminal->processName, "WindowsTerminal.exe"))
|
||||
detectFromWindowsTerminal(&terminal->exe, terminalFont);
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "mintty"))
|
||||
detectMintty(terminalFont);
|
||||
else if(ffStrbufIgnCaseEqualS(&terminal->processName, "conhost.exe"))
|
||||
detectConhost(terminalFont);
|
||||
|
||||
@@ -200,28 +200,6 @@ static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version)
|
||||
NULL
|
||||
}) == NULL;
|
||||
}
|
||||
#else
|
||||
static bool getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY command = ffStrbufCreate();
|
||||
ffStrbufAppendS(&command, "printf \"%s\" \"$");
|
||||
ffStrbufAppendTransformS(&command, exeName, toupper);
|
||||
ffStrbufAppendS(&command, "_VERSION\"");
|
||||
|
||||
if (ffProcessAppendStdOut(version, (char* const[]) {
|
||||
"env",
|
||||
"-i",
|
||||
exe->chars,
|
||||
"-c",
|
||||
command.chars,
|
||||
NULL
|
||||
}) != NULL)
|
||||
return false;
|
||||
|
||||
ffStrbufSubstrBeforeFirstC(version, '(');
|
||||
ffStrbufRemoveStrings(version, 2, (const char*[]) { "-release", "release" });
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
|
||||
@@ -261,9 +239,9 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
|
||||
return getShellVersionWinPowerShell(exe, version);
|
||||
|
||||
return getFileVersion(exe->chars, version);
|
||||
#else
|
||||
return getShellVersionGeneric(exe, exeName, version);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FF_MAYBE_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version)
|
||||
|
||||
@@ -42,7 +42,6 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
|
||||
ffStrbufEqualS(&result->processName, "sudo") ||
|
||||
ffStrbufEqualS(&result->processName, "su") ||
|
||||
ffStrbufEqualS(&result->processName, "strace") ||
|
||||
ffStrbufEqualS(&result->processName, "sshd") ||
|
||||
ffStrbufEqualS(&result->processName, "gdb") ||
|
||||
ffStrbufEqualS(&result->processName, "lldb") ||
|
||||
ffStrbufEqualS(&result->processName, "lldb-mi") ||
|
||||
@@ -51,7 +50,7 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
|
||||
ffStrbufEqualS(&result->processName, "perf") ||
|
||||
ffStrbufEqualS(&result->processName, "guake-wrapped") ||
|
||||
ffStrbufEqualS(&result->processName, "time") ||
|
||||
ffStrbufEqualS(&result->processName, "hyfetch") || //when hyfetch uses fastfetch as backend
|
||||
ffStrbufContainS(&result->processName, "hyfetch") || //when hyfetch uses fastfetch as backend
|
||||
ffStrbufEqualS(&result->processName, "clifm") || //https://github.com/leo-arch/clifm/issues/289
|
||||
ffStrbufEqualS(&result->processName, "valgrind") ||
|
||||
ffStrbufEqualS(&result->processName, "fastfetch") || //994
|
||||
@@ -102,7 +101,6 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
|
||||
ffStrbufEqualS(&result->processName, "oil.ovm") ||
|
||||
ffStrbufEqualS(&result->processName, "xonsh") || // works in Linux but not in macOS because kernel returns `Python` in this case
|
||||
ffStrbufEqualS(&result->processName, "login") ||
|
||||
ffStrbufEqualS(&result->processName, "sshd") ||
|
||||
ffStrbufEqualS(&result->processName, "clifm") || // https://github.com/leo-arch/clifm/issues/289
|
||||
ffStrbufEqualS(&result->processName, "chezmoi") || // #762
|
||||
#ifdef __linux__
|
||||
@@ -314,6 +312,8 @@ static void setTerminalInfoDetails(FFTerminalResult* result)
|
||||
ffStrbufInitStatic(&result->prettyName, "tmux");
|
||||
else if(ffStrbufStartsWithS(&result->processName, "screen-"))
|
||||
ffStrbufInitStatic(&result->prettyName, "screen");
|
||||
else if(ffStrbufEqualS(&result->processName, "sshd") || ffStrbufStartsWithS(&result->processName, "sshd-"))
|
||||
ffStrbufInitCopy(&result->prettyName, &result->tty);
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ static uint32_t getShellInfo(FFShellResult* result, uint32_t pid)
|
||||
if(
|
||||
ffStrbufIgnCaseEqualS(&result->prettyName, "sudo") ||
|
||||
ffStrbufIgnCaseEqualS(&result->prettyName, "su") ||
|
||||
ffStrbufIgnCaseEqualS(&result->prettyName, "sshd") ||
|
||||
ffStrbufIgnCaseEqualS(&result->prettyName, "gdb") ||
|
||||
ffStrbufIgnCaseEqualS(&result->prettyName, "lldb") ||
|
||||
ffStrbufIgnCaseEqualS(&result->prettyName, "python") || // python on windows generates shim executables
|
||||
@@ -155,7 +154,7 @@ static bool getTerminalFromEnv(FFTerminalResult* result)
|
||||
}
|
||||
|
||||
//SSH
|
||||
if(getenv("SSH_CONNECTION") != NULL)
|
||||
if(getenv("SSH_TTY") != NULL)
|
||||
term = getenv("SSH_TTY");
|
||||
|
||||
//Windows Terminal
|
||||
@@ -315,6 +314,11 @@ static void setTerminalInfoDetails(FFTerminalResult* result)
|
||||
ffStrbufSetStatic(&result->prettyName, "Windows Explorer");
|
||||
else if(ffStrbufEqualS(&result->prettyName, "wezterm-gui"))
|
||||
ffStrbufSetStatic(&result->prettyName, "WezTerm");
|
||||
else if(ffStrbufIgnCaseEqualS(&result->prettyName, "sshd") || ffStrbufStartsWithIgnCaseS(&result->prettyName, "sshd-"))
|
||||
{
|
||||
const char* tty = getenv("SSH_TTY");
|
||||
if (tty) ffStrbufSetS(&result->prettyName, tty);
|
||||
}
|
||||
}
|
||||
|
||||
bool fftsGetTerminalVersion(FFstrbuf* processName, FFstrbuf* exe, FFstrbuf* version);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "users.h"
|
||||
|
||||
#if __has_include(<utmpx.h>)
|
||||
#if FF_HAVE_UTMPX
|
||||
#include <utmpx.h>
|
||||
#else
|
||||
//for Android compatibility
|
||||
|
||||
@@ -237,6 +237,7 @@ static const char* detectVulkan(FFVulkanResult* result)
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->temperature = FF_GPU_TEMP_UNSET;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
|
||||
next:
|
||||
continue;
|
||||
|
||||
@@ -12,7 +12,7 @@ struct FFWifiConnection
|
||||
{
|
||||
FFstrbuf status;
|
||||
FFstrbuf ssid;
|
||||
FFstrbuf macAddress;
|
||||
FFstrbuf bssid;
|
||||
FFstrbuf protocol;
|
||||
FFstrbuf security;
|
||||
double signalQuality; // Percentage
|
||||
|
||||
@@ -37,7 +37,7 @@ const char* ffDetectWifi(FFlist* result)
|
||||
ffStrbufInit(&item->inf.status);
|
||||
ffStrbufInit(&item->conn.status);
|
||||
ffStrbufInit(&item->conn.ssid);
|
||||
ffStrbufInit(&item->conn.macAddress);
|
||||
ffStrbufInit(&item->conn.bssid);
|
||||
ffStrbufInit(&item->conn.protocol);
|
||||
ffStrbufInit(&item->conn.security);
|
||||
item->conn.signalQuality = 0.0/0.0;
|
||||
@@ -53,12 +53,12 @@ const char* ffDetectWifi(FFlist* result)
|
||||
|
||||
if(!ffStrbufEqualS(&item->inf.status, "COMPLETED"))
|
||||
return NULL;
|
||||
|
||||
|
||||
double rssi = yyjson_get_num(yyjson_obj_get(root, "rssi"));
|
||||
item->conn.signalQuality = rssi >= -50 ? 100 : rssi <= -100 ? 0 : (rssi + 100) * 2;
|
||||
|
||||
|
||||
ffStrbufAppendS(&item->inf.description, yyjson_get_str(yyjson_obj_get(root, "ip")));
|
||||
ffStrbufAppendS(&item->conn.macAddress, yyjson_get_str(yyjson_obj_get(root, "bssid")));
|
||||
ffStrbufAppendS(&item->conn.bssid, yyjson_get_str(yyjson_obj_get(root, "bssid")));
|
||||
ffStrbufAppendS(&item->conn.ssid, yyjson_get_str(yyjson_obj_get(root, "ssid")));
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -6,21 +6,17 @@
|
||||
struct Apple80211; // https://code.google.com/archive/p/iphone-wireless/wikis/Apple80211.wiki
|
||||
|
||||
// 0 is successful; < 0 is failure
|
||||
int Apple80211Open(struct Apple80211 **handle) __attribute__((weak_import));
|
||||
int Apple80211BindToInterface(struct Apple80211 *handle, CFStringRef interface) __attribute__((weak_import));
|
||||
int Apple80211GetInfoCopy(struct Apple80211 *handle, CFDictionaryRef *info) __attribute__((weak_import));
|
||||
int Apple80211Close(struct Apple80211 *handle) __attribute__((weak_import));
|
||||
|
||||
static NSDictionary* getWifiInfoByApple80211(NSString* ifName)
|
||||
@interface CWInterface()
|
||||
@property (readonly) struct Apple80211* device;
|
||||
@end
|
||||
|
||||
static NSDictionary* getWifiInfoByApple80211(CWInterface* inf)
|
||||
{
|
||||
if (!Apple80211Open || !Apple80211BindToInterface || !Apple80211GetInfoCopy || !Apple80211Close) return NULL;
|
||||
|
||||
struct Apple80211* handle = NULL;
|
||||
if (Apple80211Open(&handle) < 0) return NULL;
|
||||
if (Apple80211BindToInterface(handle, (__bridge CFStringRef)ifName) < 0) return NULL;
|
||||
CFDictionaryRef result;
|
||||
if (Apple80211GetInfoCopy(handle, &result) < 0) return NULL;
|
||||
Apple80211Close(handle);
|
||||
if (!Apple80211GetInfoCopy) return NULL;
|
||||
CFDictionaryRef result = NULL;
|
||||
if (Apple80211GetInfoCopy(inf.device, &result) < 0) return NULL;
|
||||
return CFBridgingRelease(result);
|
||||
}
|
||||
|
||||
@@ -37,7 +33,7 @@ const char* ffDetectWifi(FFlist* result)
|
||||
ffStrbufInit(&item->inf.status);
|
||||
ffStrbufInit(&item->conn.status);
|
||||
ffStrbufInit(&item->conn.ssid);
|
||||
ffStrbufInit(&item->conn.macAddress);
|
||||
ffStrbufInit(&item->conn.bssid);
|
||||
ffStrbufInit(&item->conn.protocol);
|
||||
ffStrbufInit(&item->conn.security);
|
||||
item->conn.signalQuality = 0.0/0.0;
|
||||
@@ -57,15 +53,15 @@ const char* ffDetectWifi(FFlist* result)
|
||||
|
||||
if (inf.ssid) // https://developer.apple.com/forums/thread/732431
|
||||
ffStrbufAppendS(&item->conn.ssid, inf.ssid.UTF8String);
|
||||
else if (apple || (apple = getWifiInfoByApple80211(inf.interfaceName)))
|
||||
else if (apple || (apple = getWifiInfoByApple80211(inf)))
|
||||
ffStrbufAppendS(&item->conn.ssid, [[apple valueForKey:@"SSID_STR"] UTF8String]);
|
||||
else
|
||||
ffStrbufSetStatic(&item->conn.ssid, "<unknown ssid>"); // https://developer.apple.com/forums/thread/732431
|
||||
|
||||
if (inf.bssid)
|
||||
ffStrbufAppendS(&item->conn.macAddress, inf.bssid.UTF8String);
|
||||
else if (apple || (apple = getWifiInfoByApple80211(inf.interfaceName)))
|
||||
ffStrbufAppendS(&item->conn.macAddress, [[apple valueForKey:@"BSSID"] UTF8String]);
|
||||
ffStrbufAppendS(&item->conn.bssid, inf.bssid.UTF8String);
|
||||
else if (apple || (apple = getWifiInfoByApple80211(inf)))
|
||||
ffStrbufAppendS(&item->conn.bssid, [[apple valueForKey:@"BSSID"] UTF8String]);
|
||||
|
||||
switch(inf.activePHYMode)
|
||||
{
|
||||
@@ -152,7 +148,7 @@ const char* ffDetectWifi(FFlist* result)
|
||||
break;
|
||||
case kCWSecurityUnknown:
|
||||
// Sonoma...
|
||||
if (apple || (apple = getWifiInfoByApple80211(inf.interfaceName)))
|
||||
if (apple || (apple = getWifiInfoByApple80211(inf)))
|
||||
{
|
||||
NSDictionary* authType = [apple valueForKey:@"AUTH_TYPE"];
|
||||
if (authType)
|
||||
|
||||
@@ -28,7 +28,7 @@ const char* ffDetectWifi(FFlist* result)
|
||||
ffStrbufInit(&item->inf.status);
|
||||
ffStrbufInit(&item->conn.status);
|
||||
ffStrbufInit(&item->conn.ssid);
|
||||
ffStrbufInit(&item->conn.macAddress);
|
||||
ffStrbufInit(&item->conn.bssid);
|
||||
ffStrbufInit(&item->conn.protocol);
|
||||
ffStrbufInit(&item->conn.security);
|
||||
item->conn.signalQuality = 0.0/0.0;
|
||||
@@ -42,7 +42,7 @@ const char* ffDetectWifi(FFlist* result)
|
||||
if (ibssid < item->conn.ssid.length)
|
||||
{
|
||||
ibssid += (uint32_t) strlen(" bssid ");
|
||||
ffStrbufSetS(&item->conn.macAddress, item->conn.ssid.chars + ibssid);
|
||||
ffStrbufSetS(&item->conn.bssid, item->conn.ssid.chars + ibssid);
|
||||
}
|
||||
|
||||
ffStrbufSubstrBeforeFirstC(&item->conn.ssid, ' ');
|
||||
|
||||
+226
-260
@@ -1,184 +1,95 @@
|
||||
#include "wifi.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef FF_HAVE_LIBNM
|
||||
|
||||
#include "common/dbus.h"
|
||||
#include "common/processing.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/library.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <glib.h>
|
||||
#define NM_NO_INCLUDE_EXTRA_HEADERS 1
|
||||
#include <NetworkManager.h>
|
||||
#include <net/if.h>
|
||||
|
||||
//https://developer-old.gnome.org/libnm/stable/libnm-nm-dbus-interface.html
|
||||
#ifndef NM_VERSION_1_26
|
||||
#define NM_802_11_AP_SEC_KEY_MGMT_OWE 0x00000800
|
||||
#define NM_802_11_AP_SEC_KEY_MGMT_OWE_TM 0x00001000
|
||||
#endif
|
||||
#ifdef FF_HAVE_DBUS
|
||||
// https://people.freedesktop.org/~lkundrak/nm-docs/nm-dbus-types.html#NM80211ApFlags
|
||||
typedef enum {
|
||||
NM_802_11_AP_FLAGS_NONE = 0x00000000,
|
||||
NM_802_11_AP_FLAGS_PRIVACY = 0x00000001,
|
||||
NM_802_11_AP_FLAGS_WPS = 0x00000002,
|
||||
NM_802_11_AP_FLAGS_WPS_PBC = 0x00000004,
|
||||
NM_802_11_AP_FLAGS_WPS_PIN = 0x00000008,
|
||||
} NM80211ApFlags;
|
||||
|
||||
static const char* detectWifiWithLibnm(FFlist* result)
|
||||
// https://people.freedesktop.org/~lkundrak/nm-docs/nm-dbus-types.html#NM80211ApSecurityFlags
|
||||
typedef enum {
|
||||
NM_802_11_AP_SEC_NONE = 0x00000000,
|
||||
NM_802_11_AP_SEC_PAIR_WEP40 = 0x00000001,
|
||||
NM_802_11_AP_SEC_PAIR_WEP104 = 0x00000002,
|
||||
NM_802_11_AP_SEC_PAIR_TKIP = 0x00000004,
|
||||
NM_802_11_AP_SEC_PAIR_CCMP = 0x00000008,
|
||||
NM_802_11_AP_SEC_GROUP_WEP40 = 0x00000010,
|
||||
NM_802_11_AP_SEC_GROUP_WEP104 = 0x00000020,
|
||||
NM_802_11_AP_SEC_GROUP_TKIP = 0x00000040,
|
||||
NM_802_11_AP_SEC_GROUP_CCMP = 0x00000080,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_SAE = 0x00000400,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_OWE = 0x00000800,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_OWE_TM = 0x00001000,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192 = 0x00002000,
|
||||
} NM80211ApSecurityFlags;
|
||||
|
||||
static const char* detectWifiWithNm(FFWifiResult* item, FFstrbuf* buffer)
|
||||
{
|
||||
FF_LIBRARY_LOAD(nm, &instance.config.library.libnm, "dlopen libnm failed", "libnm" FF_LIBRARY_EXTENSION, 0);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_client_new);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_client_get_devices);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_device_get_iface);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_device_get_state);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_device_wifi_get_type);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_device_wifi_get_active_access_point);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_access_point_get_ssid);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_utils_ssid_to_utf8);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_access_point_get_bssid);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_access_point_get_strength);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_access_point_get_max_bitrate);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_access_point_get_flags);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_access_point_get_wpa_flags);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, nm_access_point_get_rsn_flags);
|
||||
FFDBusData dbus;
|
||||
const char* error = ffDBusLoadData(DBUS_BUS_SYSTEM, &dbus);
|
||||
if(error)
|
||||
return error;
|
||||
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, g_type_check_instance_is_a);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, g_bytes_get_size);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, g_bytes_get_data);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, g_free);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(nm, g_object_unref);
|
||||
|
||||
NMClient* client = ffnm_client_new(NULL, NULL);
|
||||
if(!client)
|
||||
return "Could not create NMClient";
|
||||
|
||||
/* Get all devices managed by NetworkManager */
|
||||
const GPtrArray* devices = ffnm_client_get_devices(client);
|
||||
|
||||
/* Go through the array and process Wi-Fi devices */
|
||||
for (guint i = 0; i < devices->len; i++)
|
||||
{
|
||||
NMDevice *device = g_ptr_array_index(devices, i);
|
||||
if (!({
|
||||
GTypeInstance *inst = (GTypeInstance*) device;
|
||||
GType type = ffnm_device_wifi_get_type();
|
||||
gboolean return_value;
|
||||
if (!inst)
|
||||
return_value = FALSE;
|
||||
else if (inst->g_class && inst->g_class->g_type == type)
|
||||
return_value = TRUE;
|
||||
else
|
||||
return_value = ffg_type_check_instance_is_a (inst, type);
|
||||
return_value;
|
||||
}) //NM_IS_DEVICE_WIFI(device)
|
||||
)
|
||||
continue;
|
||||
DBusMessage* device = ffDBusGetMethodReply(&dbus, "org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager", "org.freedesktop.NetworkManager", "GetDeviceByIpIface", item->inf.description.chars);
|
||||
if(!device)
|
||||
return "Failed to call GetDeviceByIpIface";
|
||||
|
||||
FFWifiResult* item = (FFWifiResult*) ffListAdd(result);
|
||||
ffStrbufInit(&item->inf.description);
|
||||
ffStrbufInit(&item->inf.status);
|
||||
ffStrbufInit(&item->conn.status);
|
||||
ffStrbufInit(&item->conn.ssid);
|
||||
ffStrbufInit(&item->conn.macAddress);
|
||||
ffStrbufInit(&item->conn.protocol);
|
||||
ffStrbufInit(&item->conn.security);
|
||||
item->conn.signalQuality = 0.0/0.0;
|
||||
item->conn.rxRate = 0.0/0.0;
|
||||
item->conn.txRate = 0.0/0.0;
|
||||
|
||||
ffStrbufAppendS(&item->inf.description, ffnm_device_get_iface(device));
|
||||
NMDeviceState state = ffnm_device_get_state(device);
|
||||
switch(state)
|
||||
ffStrbufClear(buffer);
|
||||
DBusMessageIter rootIter;
|
||||
if(!dbus.lib->ffdbus_message_iter_init(device, &rootIter) || !ffDBusGetString(&dbus, &rootIter, buffer))
|
||||
{
|
||||
case NM_DEVICE_STATE_UNKNOWN:
|
||||
ffStrbufSetStatic(&item->inf.status, "Unknown");
|
||||
break;
|
||||
case NM_DEVICE_STATE_UNMANAGED:
|
||||
ffStrbufSetStatic(&item->inf.status, "Unmanaged");
|
||||
break;
|
||||
case NM_DEVICE_STATE_UNAVAILABLE:
|
||||
ffStrbufSetStatic(&item->inf.status, "Unavailable");
|
||||
break;
|
||||
case NM_DEVICE_STATE_DISCONNECTED:
|
||||
ffStrbufSetStatic(&item->inf.status, "Disconnected");
|
||||
break;
|
||||
case NM_DEVICE_STATE_PREPARE:
|
||||
ffStrbufSetStatic(&item->inf.status, "Prepare");
|
||||
break;
|
||||
case NM_DEVICE_STATE_CONFIG:
|
||||
ffStrbufSetStatic(&item->inf.status, "Config");
|
||||
break;
|
||||
case NM_DEVICE_STATE_NEED_AUTH:
|
||||
ffStrbufSetStatic(&item->inf.status, "Need auth");
|
||||
break;
|
||||
case NM_DEVICE_STATE_IP_CONFIG:
|
||||
ffStrbufSetStatic(&item->inf.status, "IP config");
|
||||
break;
|
||||
case NM_DEVICE_STATE_IP_CHECK:
|
||||
ffStrbufSetStatic(&item->inf.status, "IP check");
|
||||
break;
|
||||
case NM_DEVICE_STATE_SECONDARIES:
|
||||
ffStrbufSetStatic(&item->inf.status, "Secondaries");
|
||||
break;
|
||||
case NM_DEVICE_STATE_ACTIVATED:
|
||||
ffStrbufSetStatic(&item->inf.status, "Activated");
|
||||
break;
|
||||
case NM_DEVICE_STATE_DEACTIVATING:
|
||||
ffStrbufSetStatic(&item->inf.status, "Deactivating");
|
||||
break;
|
||||
case NM_DEVICE_STATE_FAILED:
|
||||
ffStrbufSetStatic(&item->inf.status, "Failed");
|
||||
break;
|
||||
dbus.lib->ffdbus_message_unref(device);
|
||||
return "Failed to get device path";
|
||||
}
|
||||
if(state != NM_DEVICE_STATE_ACTIVATED)
|
||||
continue;
|
||||
dbus.lib->ffdbus_message_unref(device);
|
||||
}
|
||||
|
||||
NMAccessPoint* ap = ffnm_device_wifi_get_active_access_point((NMDeviceWifi *) device);
|
||||
if (!ap)
|
||||
continue;
|
||||
if (item->conn.txRate != item->conn.txRate)
|
||||
{
|
||||
uint32_t bitrate;
|
||||
if (ffDBusGetPropertyUint(&dbus, "org.freedesktop.NetworkManager", buffer->chars, "org.freedesktop.NetworkManager.Device.Wireless", "Bitrate", &bitrate))
|
||||
item->conn.txRate = bitrate / 1000.;
|
||||
}
|
||||
|
||||
ffStrbufSetStatic(&item->conn.status, "Connected");
|
||||
FF_STRBUF_AUTO_DESTROY apPath = ffStrbufCreate();
|
||||
if (!ffDBusGetPropertyString(&dbus, "org.freedesktop.NetworkManager", buffer->chars, "org.freedesktop.NetworkManager.Device.Wireless", "ActiveAccessPoint", &apPath))
|
||||
return "Failed to get active access point path";
|
||||
|
||||
GBytes* activeSsid = ffnm_access_point_get_ssid(ap);
|
||||
if (activeSsid)
|
||||
{
|
||||
char* ssid = ffnm_utils_ssid_to_utf8(ffg_bytes_get_data(activeSsid, NULL), ffg_bytes_get_size(activeSsid));
|
||||
ffStrbufAppendS(&item->conn.ssid, ssid);
|
||||
ffg_free(ssid);
|
||||
}
|
||||
if (!item->conn.status.length)
|
||||
ffStrbufSetStatic(&item->conn.status, "connected");
|
||||
|
||||
ffStrbufAppendS(&item->conn.macAddress, ffnm_access_point_get_bssid(ap));
|
||||
item->conn.signalQuality = ffnm_access_point_get_strength(ap);
|
||||
item->conn.rxRate = ffnm_access_point_get_max_bitrate(ap);
|
||||
if (!item->conn.ssid.length)
|
||||
ffDBusGetPropertyString(&dbus, "org.freedesktop.NetworkManager", apPath.chars, "org.freedesktop.NetworkManager.AccessPoint", "Ssid", &item->conn.ssid);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate();
|
||||
if(!ffProcessAppendStdOut(&output, (char* const[]){
|
||||
"iw",
|
||||
"dev",
|
||||
item->inf.description.chars,
|
||||
"link",
|
||||
NULL
|
||||
}))
|
||||
{
|
||||
if(ffParsePropLines(output.chars, "rx bitrate: ", &item->conn.protocol))
|
||||
{
|
||||
sscanf(item->conn.protocol.chars, "%lf", &item->conn.rxRate);
|
||||
}
|
||||
if(ffParsePropLines(output.chars, "tx bitrate: ", &item->conn.protocol))
|
||||
{
|
||||
if(ffStrbufContainS(&item->conn.protocol, " HE-MCS "))
|
||||
ffStrbufSetStatic(&item->conn.protocol, "802.11ax (Wi-Fi 6)");
|
||||
else if(ffStrbufContainS(&item->conn.protocol, " VHT-MCS "))
|
||||
ffStrbufSetStatic(&item->conn.protocol, "802.11ac (Wi-Fi 5)");
|
||||
else if(ffStrbufContainS(&item->conn.protocol, " MCS "))
|
||||
ffStrbufSetStatic(&item->conn.protocol, "802.11n (Wi-Fi 4)");
|
||||
else
|
||||
ffStrbufClear(&item->conn.protocol);
|
||||
if (!item->conn.bssid.length)
|
||||
ffDBusGetPropertyString(&dbus, "org.freedesktop.NetworkManager", apPath.chars, "org.freedesktop.NetworkManager.AccessPoint", "HwAddress", &item->conn.bssid);
|
||||
|
||||
sscanf(item->conn.protocol.chars, "%lf", &item->conn.txRate);
|
||||
}
|
||||
}
|
||||
|
||||
NM80211ApFlags flags = ffnm_access_point_get_flags(ap);
|
||||
NM80211ApSecurityFlags wpaFlags = ffnm_access_point_get_wpa_flags(ap);
|
||||
NM80211ApSecurityFlags rsnFlags = ffnm_access_point_get_rsn_flags(ap);
|
||||
if (item->conn.signalQuality != item->conn.signalQuality)
|
||||
{
|
||||
uint32_t strengthPercent;
|
||||
if (ffDBusGetPropertyUint(&dbus, "org.freedesktop.NetworkManager", apPath.chars, "org.freedesktop.NetworkManager.AccessPoint", "Strength", &strengthPercent))
|
||||
item->conn.signalQuality = strengthPercent;
|
||||
}
|
||||
|
||||
NM80211ApFlags flags;
|
||||
NM80211ApSecurityFlags wpaFlags, rsnFlags;
|
||||
if (ffDBusGetPropertyUint(&dbus, "org.freedesktop.NetworkManager", apPath.chars, "org.freedesktop.NetworkManager.AccessPoint", "Flags", &flags) &&
|
||||
ffDBusGetPropertyUint(&dbus, "org.freedesktop.NetworkManager", apPath.chars, "org.freedesktop.NetworkManager.AccessPoint", "WpaFlags", &wpaFlags) &&
|
||||
ffDBusGetPropertyUint(&dbus, "org.freedesktop.NetworkManager", apPath.chars , "org.freedesktop.NetworkManager.AccessPoint", "RsnFlags", &rsnFlags))
|
||||
{
|
||||
if ((flags & NM_802_11_AP_FLAGS_PRIVACY) && (wpaFlags == NM_802_11_AP_SEC_NONE)
|
||||
&& (rsnFlags == NM_802_11_AP_SEC_NONE))
|
||||
ffStrbufAppendS(&item->conn.security, "WEP/");
|
||||
@@ -205,36 +116,167 @@ static const char* detectWifiWithLibnm(FFlist* result)
|
||||
ffStrbufTrimRight(&item->conn.security, '/');
|
||||
}
|
||||
|
||||
ffg_object_unref(client);
|
||||
return NULL;
|
||||
}
|
||||
#endif // FF_HAVE_DBUS
|
||||
|
||||
static const char* detectWifiWithIw(FFWifiResult* item, FFstrbuf* buffer)
|
||||
{
|
||||
const char* error = NULL;
|
||||
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate();
|
||||
if((error = ffProcessAppendStdOut(&output, (char* const[]){
|
||||
"iw",
|
||||
"dev",
|
||||
item->inf.description.chars,
|
||||
"link",
|
||||
NULL
|
||||
})))
|
||||
return error;
|
||||
|
||||
if(output.length == 0)
|
||||
return "iw command execution failed";
|
||||
|
||||
if(!ffParsePropLines(output.chars, "Connected to ", &item->conn.bssid))
|
||||
{
|
||||
ffStrbufAppendS(&item->conn.status, "disconnected");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ffStrbufAppendS(&item->conn.status, "connected");
|
||||
ffStrbufSubstrBeforeFirstC(&item->conn.bssid, ' ');
|
||||
ffStrbufUpperCase(&item->conn.bssid);
|
||||
|
||||
ffParsePropLines(output.chars, "SSID: ", &item->conn.ssid);
|
||||
|
||||
ffStrbufClear(buffer);
|
||||
if(ffParsePropLines(output.chars, "signal: ", buffer))
|
||||
{
|
||||
int level = (int) ffStrbufToSInt(buffer, INT_MAX);
|
||||
if (level != INT_MAX)
|
||||
item->conn.signalQuality = level >= -50 ? 100 : level <= -100 ? 0 : (level + 100) * 2;
|
||||
}
|
||||
|
||||
ffStrbufClear(buffer);
|
||||
if(ffParsePropLines(output.chars, "rx bitrate: ", buffer))
|
||||
item->conn.rxRate = ffStrbufToDouble(buffer);
|
||||
|
||||
ffStrbufClear(buffer);
|
||||
if(ffParsePropLines(output.chars, "tx bitrate: ", buffer))
|
||||
{
|
||||
item->conn.txRate = ffStrbufToDouble(buffer);
|
||||
|
||||
if(ffStrbufContainS(buffer, " HE-MCS "))
|
||||
ffStrbufSetStatic(&item->conn.protocol, "802.11ax (Wi-Fi 6)");
|
||||
else if(ffStrbufContainS(buffer, " VHT-MCS "))
|
||||
ffStrbufSetStatic(&item->conn.protocol, "802.11ac (Wi-Fi 5)");
|
||||
else if(ffStrbufContainS(buffer, " MCS "))
|
||||
ffStrbufSetStatic(&item->conn.protocol, "802.11n (Wi-Fi 4)");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if __has_include(<linux/wireless.h>)
|
||||
#define FF_DETECT_WIFI_WITH_IOCTLS
|
||||
|
||||
#if FF_HAVE_LINUX_WIRELESS
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/wireless.h> //TODO: Don't depend on kernel headers
|
||||
#include <linux/wireless.h>
|
||||
|
||||
static const char* detectWifiWithIoctls(FFlist* result)
|
||||
static const char* detectWifiWithIoctls(FFWifiResult* item)
|
||||
{
|
||||
FF_AUTO_CLOSE_FD int sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if(sock < 0)
|
||||
return "socket() failed";
|
||||
|
||||
struct iwreq iwr;
|
||||
strncpy(iwr.ifr_name, item->inf.description.chars, IFNAMSIZ);
|
||||
ffStrbufEnsureFree(&item->conn.ssid, IW_ESSID_MAX_SIZE);
|
||||
iwr.u.essid.pointer = (caddr_t) item->conn.ssid.chars;
|
||||
iwr.u.essid.length = IW_ESSID_MAX_SIZE + 1;
|
||||
iwr.u.essid.flags = 0;
|
||||
if(ioctl(sock, SIOCGIWESSID, &iwr) >= 0)
|
||||
{
|
||||
ffStrbufSetStatic(&item->conn.status, "connected");
|
||||
ffStrbufRecalculateLength(&item->conn.ssid);
|
||||
}
|
||||
|
||||
if(ioctl(sock, SIOCGIWNAME, &iwr) >= 0 && !ffStrEqualsIgnCase(iwr.u.name, "IEEE 802.11"))
|
||||
{
|
||||
if(ffStrStartsWithIgnCase(iwr.u.name, "IEEE "))
|
||||
ffStrbufSetS(&item->conn.protocol, iwr.u.name + strlen("IEEE "));
|
||||
else
|
||||
ffStrbufSetS(&item->conn.protocol, iwr.u.name);
|
||||
}
|
||||
|
||||
if(ioctl(sock, SIOCGIWAP, &iwr) >= 0)
|
||||
{
|
||||
for(int i = 0; i < 6; ++i)
|
||||
ffStrbufAppendF(&item->conn.bssid, "%.2X:", (uint8_t) iwr.u.ap_addr.sa_data[i]);
|
||||
ffStrbufTrimRight(&item->conn.bssid, '-');
|
||||
}
|
||||
|
||||
if(ioctl(sock, SIOCGIWRATE, &iwr) >= 0)
|
||||
item->conn.txRate = iwr.u.bitrate.value / 1000000.;
|
||||
|
||||
struct iw_statistics stats;
|
||||
iwr.u.data.pointer = &stats;
|
||||
iwr.u.data.length = sizeof(stats);
|
||||
iwr.u.data.flags = 0;
|
||||
|
||||
if(ioctl(sock, SIOCGIWSTATS, &iwr) >= 0)
|
||||
{
|
||||
int8_t level = (int8_t) stats.qual.level; // https://stackoverflow.com/questions/18079771/wireless-h-how-do-i-print-out-the-signal-level
|
||||
item->conn.signalQuality = level >= -50 ? 100 : level <= -100 ? 0 : (level + 100) * 2;
|
||||
}
|
||||
|
||||
//FIXME: doesn't work
|
||||
struct iw_encode_ext iwe;
|
||||
iwr.u.data.pointer = &iwe;
|
||||
iwr.u.data.length = sizeof(iwe);
|
||||
iwr.u.data.flags = 0;
|
||||
if(ioctl(sock, SIOCGIWENCODEEXT, &iwr) >= 0)
|
||||
{
|
||||
switch(iwe.alg)
|
||||
{
|
||||
case IW_ENCODE_ALG_WEP:
|
||||
ffStrbufAppendS(&item->conn.security, "WEP");
|
||||
break;
|
||||
case IW_ENCODE_ALG_TKIP:
|
||||
ffStrbufAppendS(&item->conn.security, "TKIP");
|
||||
break;
|
||||
case IW_ENCODE_ALG_CCMP:
|
||||
ffStrbufAppendS(&item->conn.security, "CCMP");
|
||||
break;
|
||||
case IW_ENCODE_ALG_PMK:
|
||||
ffStrbufAppendS(&item->conn.security, "PMK");
|
||||
break;
|
||||
case IW_ENCODE_ALG_AES_CMAC:
|
||||
ffStrbufAppendS(&item->conn.security, "CMAC");
|
||||
break;
|
||||
default:
|
||||
ffStrbufAppendF(&item->conn.security, "Unknown (%d)", (int) iwe.alg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif // FF_HAVE_LINUX_WIRELESS
|
||||
|
||||
const char* ffDetectWifi(FF_MAYBE_UNUSED FFlist* result)
|
||||
{
|
||||
struct if_nameindex* infs = if_nameindex();
|
||||
if(!infs)
|
||||
return "if_nameindex() failed";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
for(struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i)
|
||||
{
|
||||
ffStrbufSetF(&path, "/sys/class/net/%s/phy80211", i->if_name);
|
||||
if(!ffPathExists(path.chars, FF_PATHTYPE_DIRECTORY))
|
||||
ffStrbufSetF(&buffer, "/sys/class/net/%s/phy80211", i->if_name);
|
||||
if(!ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY))
|
||||
continue;
|
||||
|
||||
FFWifiResult* item = (FFWifiResult*)ffListAdd(result);
|
||||
@@ -242,109 +284,33 @@ static const char* detectWifiWithIoctls(FFlist* result)
|
||||
ffStrbufInit(&item->inf.status);
|
||||
ffStrbufInit(&item->conn.status);
|
||||
ffStrbufInit(&item->conn.ssid);
|
||||
ffStrbufInit(&item->conn.macAddress);
|
||||
ffStrbufInit(&item->conn.bssid);
|
||||
ffStrbufInit(&item->conn.protocol);
|
||||
ffStrbufInit(&item->conn.security);
|
||||
item->conn.signalQuality = 0.0/0.0;
|
||||
item->conn.rxRate = 0.0/0.0;
|
||||
item->conn.txRate = 0.0/0.0;
|
||||
|
||||
ffStrbufSetF(&path, "/sys/class/net/%s/operstate", i->if_name);
|
||||
if (!ffAppendFileBuffer(path.chars, &item->inf.status))
|
||||
ffStrbufSetF(&buffer, "/sys/class/net/%s/operstate", i->if_name);
|
||||
if (!ffAppendFileBuffer(buffer.chars, &item->inf.status))
|
||||
continue;
|
||||
|
||||
ffStrbufTrimRightSpace(&item->inf.status);
|
||||
if (!ffStrbufEqualS(&item->inf.status, "up"))
|
||||
continue;
|
||||
|
||||
FF_AUTO_CLOSE_FD int sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if(sock < 0)
|
||||
continue;
|
||||
|
||||
struct iwreq iwr;
|
||||
strncpy(iwr.ifr_name, i->if_name, IFNAMSIZ);
|
||||
ffStrbufEnsureFree(&item->conn.ssid, IW_ESSID_MAX_SIZE);
|
||||
iwr.u.essid.pointer = (caddr_t) item->conn.ssid.chars;
|
||||
iwr.u.essid.length = IW_ESSID_MAX_SIZE + 1;
|
||||
iwr.u.essid.flags = 0;
|
||||
if(ioctl(sock, SIOCGIWESSID, &iwr) >= 0)
|
||||
ffStrbufRecalculateLength(&item->conn.ssid);
|
||||
|
||||
if(ioctl(sock, SIOCGIWNAME, &iwr) >= 0 && !ffStrEqualsIgnCase(iwr.u.name, "IEEE 802.11"))
|
||||
if (detectWifiWithIw(item, &buffer) != NULL)
|
||||
{
|
||||
if(ffStrStartsWithIgnCase(iwr.u.name, "IEEE "))
|
||||
ffStrbufSetS(&item->conn.protocol, iwr.u.name + strlen("IEEE "));
|
||||
else
|
||||
ffStrbufSetS(&item->conn.protocol, iwr.u.name);
|
||||
#ifdef FF_HAVE_LINUX_WIRELESS
|
||||
detectWifiWithIoctls(item);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(ioctl(sock, SIOCGIWAP, &iwr) >= 0)
|
||||
{
|
||||
for(int i = 0; i < 6; ++i)
|
||||
ffStrbufAppendF(&item->conn.macAddress, "%.2X-", (uint8_t) iwr.u.ap_addr.sa_data[i]);
|
||||
ffStrbufTrimRight(&item->conn.macAddress, '-');
|
||||
}
|
||||
|
||||
struct iw_statistics stats;
|
||||
iwr.u.data.pointer = &stats;
|
||||
iwr.u.data.length = sizeof(stats);
|
||||
iwr.u.data.flags = 0;
|
||||
|
||||
if(ioctl(sock, SIOCGIWSTATS, &iwr) >= 0)
|
||||
{
|
||||
int8_t level = (int8_t) stats.qual.level; // https://stackoverflow.com/questions/18079771/wireless-h-how-do-i-print-out-the-signal-level
|
||||
item->conn.signalQuality = level >= -50 ? 100 : level <= -100 ? 0 : (level + 100) * 2;
|
||||
}
|
||||
|
||||
//FIXME: doesn't work
|
||||
struct iw_encode_ext iwe;
|
||||
iwr.u.data.pointer = &iwe;
|
||||
iwr.u.data.length = sizeof(iwe);
|
||||
iwr.u.data.flags = 0;
|
||||
if(ioctl(sock, SIOCGIWENCODEEXT, &iwr) >= 0)
|
||||
{
|
||||
struct iw_encode_ext* iwe = iwr.u.data.pointer;
|
||||
switch(iwe->alg)
|
||||
{
|
||||
case IW_ENCODE_ALG_WEP:
|
||||
ffStrbufAppendS(&item->conn.security, "WEP");
|
||||
break;
|
||||
case IW_ENCODE_ALG_TKIP:
|
||||
ffStrbufAppendS(&item->conn.security, "TKIP");
|
||||
break;
|
||||
case IW_ENCODE_ALG_CCMP:
|
||||
ffStrbufAppendS(&item->conn.security, "CCMP");
|
||||
break;
|
||||
case IW_ENCODE_ALG_PMK:
|
||||
ffStrbufAppendS(&item->conn.security, "PMK");
|
||||
break;
|
||||
case IW_ENCODE_ALG_AES_CMAC:
|
||||
ffStrbufAppendS(&item->conn.security, "CMAC");
|
||||
break;
|
||||
default:
|
||||
ffStrbufAppendF(&item->conn.security, "Unknown (%d)", (int) iwe->alg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef FF_HAVE_DBUS
|
||||
detectWifiWithNm(item, &buffer);
|
||||
#endif
|
||||
}
|
||||
if_freenameindex(infs);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const char* ffDetectWifi(FF_MAYBE_UNUSED FFlist* result)
|
||||
{
|
||||
#ifdef FF_HAVE_LIBNM
|
||||
detectWifiWithLibnm(result);
|
||||
if(result->length) // NetworkManager not enabled? #811
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
#ifdef FF_DETECT_WIFI_WITH_IOCTLS
|
||||
return detectWifiWithIoctls(result);
|
||||
#endif
|
||||
|
||||
return "linux/wireless.h not found during compilation";
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ const char* ffDetectWifi(FFlist* result)
|
||||
ffStrbufInit(&item->inf.status);
|
||||
ffStrbufInit(&item->conn.status);
|
||||
ffStrbufInit(&item->conn.ssid);
|
||||
ffStrbufInit(&item->conn.macAddress);
|
||||
ffStrbufInit(&item->conn.bssid);
|
||||
ffStrbufInit(&item->conn.protocol);
|
||||
ffStrbufInit(&item->conn.security);
|
||||
item->conn.signalQuality = 0.0/0.0;
|
||||
@@ -107,8 +107,8 @@ const char* ffDetectWifi(FFlist* result)
|
||||
(const char *)connInfo->wlanAssociationAttributes.dot11Ssid.ucSSID);
|
||||
|
||||
for (size_t i = 0; i < sizeof(connInfo->wlanAssociationAttributes.dot11Bssid); i++)
|
||||
ffStrbufAppendF(&item->conn.macAddress, "%.2X-", connInfo->wlanAssociationAttributes.dot11Bssid[i]);
|
||||
ffStrbufTrimRight(&item->conn.macAddress, '-');
|
||||
ffStrbufAppendF(&item->conn.bssid, "%.2X-", connInfo->wlanAssociationAttributes.dot11Bssid[i]);
|
||||
ffStrbufTrimRight(&item->conn.bssid, '-');
|
||||
|
||||
switch (connInfo->wlanAssociationAttributes.dot11PhyType)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/${c2}o${c3}.
|
||||
${c1} :${c2}sssso${c3}-
|
||||
${c1} :${c2}ossssssso${c3}:
|
||||
${c1} /${c2}ssssssssssso${c3}+
|
||||
${c1} -+${c2}ssssssssssssssso${c3}+
|
||||
${c1} //${c2}osssssssssssssso${c3}+-
|
||||
`+++++++++++++++-`
|
||||
/${c2}o${c3}.
|
||||
${c1} /${c2}sssso${c3}-
|
||||
${c1} /${c2}ossssssso${c3}:
|
||||
${c1} /${c2}ssssssssssso${c3}+
|
||||
${c1} /${c2}ssssssssssssssso${c3}+
|
||||
${c1}//${c2}osssssssssssssso${c3}+-
|
||||
`+++++++++++++++-`
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
$1###########################-
|
||||
$1###############################
|
||||
$1=#########**************#########
|
||||
$1########## ########
|
||||
$1########## ########
|
||||
$1########## ########
|
||||
$1########## ########
|
||||
$1########## ########
|
||||
$1########## $2. $1########
|
||||
$1########## $2+=. $1:#####
|
||||
$1+#########+=========- $2%%%* $1=#
|
||||
$1#####################* $2%%%%#
|
||||
$1-#####################* $2%%%%%.
|
||||
$2```````
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user