Compare commits

..

103 Commits

Author SHA1 Message Date
李通洲 15c72c04af Release: 1.11.1
Update changelog too
2023-05-28 00:17:57 +08:00
李通洲 b797246607 DisplayServer (Apple): use FF_AUTO_FREE 2023-05-28 00:17:57 +08:00
李通洲 d54bb4fd16 Windows: use ffStrbufInitWS 2023-05-28 00:17:57 +08:00
李通洲 0a946e3976 Disk (Windows): improve performance 2023-05-28 00:17:57 +08:00
李通洲 a339f00d83 Windows: fix potential memory curruption bug in unicode.c
Also add ffStrbufInitWS
2023-05-28 00:17:57 +08:00
李通洲 de15866c9a TerminalShell (Windows): print clink version 2023-05-28 00:17:57 +08:00
李通洲 24ee87720e TerminalShell: code refactoring 2023-05-28 00:17:57 +08:00
李通洲 7310b3ed09 TerminalShel (Windows): detect Tabby version with exe file version 2023-05-28 00:17:57 +08:00
李通洲 bb6cdc7bb0 Settings (Linux): fix memleaks reported by LeakSanitizer 2023-05-28 00:17:57 +08:00
李通洲 4a2d20fb74 TerminalFont: support Tabby 2023-05-28 00:17:57 +08:00
李通洲 b136b86300 TerminalShell: support Tabby terminal version detection 2023-05-28 00:17:57 +08:00
李通洲 d4a7ae8b34 Sound (macOS): detecting volume more aggressively 2023-05-28 00:17:57 +08:00
李通洲 04da7cebdb Logo: add macOS small version 2023-05-28 00:17:57 +08:00
李通洲 ccb227e694 TerminalShell: fix iTerm being detected as iTermServer-* sometimes 2023-05-28 00:17:57 +08:00
李通洲 9c7b868227 TerminalShell: support xonsh 2023-05-28 00:17:57 +08:00
李通洲 f333937b35 Swap (Windows): fix compiler warnings 2023-05-28 00:17:57 +08:00
李通洲 e4f6f15d70 Vulkan: try fixing #456 2023-05-28 00:17:57 +08:00
李通洲 5ae8ef1cb3 Swap: split module code from memory.c 2023-05-28 00:17:57 +08:00
李通洲 d863652e1b CMake(Windows): remove USE_WIN_NTAPI option 2023-05-28 00:17:57 +08:00
李通洲 ac540d73b7 Network: drop module 2023-05-28 00:17:57 +08:00
Edward Piper 37b9da7337 Fix EndeavourOS logo again 2023-05-28 00:17:57 +08:00
李通洲 93c0dbde0d DisplayServer (Windows): code simplification 2023-05-28 00:17:57 +08:00
李通洲 aa236b4da0 OpenCL: split detection code 2023-05-28 00:17:57 +08:00
李通洲 2fd3643632 Doc: document Network module 2023-05-28 00:17:57 +08:00
李通洲 24f9247c54 LocalIP: simplify loop interface detection 2023-05-28 00:17:57 +08:00
李通洲 d312b752a1 Network (FreeBSD): add dirty support 2023-05-28 00:17:57 +08:00
李通洲 1b476757a0 Network: code refactor & bug fixes 2023-05-28 00:17:57 +08:00
李通洲 c78a8f6317 Network (Linux): add support 2023-05-28 00:17:57 +08:00
李通洲 24c3788055 Network (Windows): add support 2023-05-28 00:17:57 +08:00
李通洲 a644762a60 Network (macOS): init 2023-05-28 00:17:57 +08:00
Linus Dierheimer 3185d92fb5 --pipe: don't print white color blocks
Fixes #450
2023-05-28 00:17:57 +08:00
李通洲 2c629bc821 FFstrbuf: remove FF_STRBUF_CREATE macro 2023-05-28 00:17:57 +08:00
李通洲 1a6c38bc26 CpuUsage: code refactor 2023-05-28 00:17:57 +08:00
李通洲 589f9aa8f3 Processes: code refactor 2023-05-28 00:17:57 +08:00
tdtooke 70e5d0b235 Update builtin.c 2023-05-28 00:17:57 +08:00
tdtooke aa81d80578 Update builtin.c 2023-05-28 00:17:57 +08:00
KingKrouch 7bc6676680 Update Windows 11 ASCII
Reason being that the original ASCII art as shown in Windows Terminal has random portions using "*" and "(" as opposed to "/".
2023-05-28 00:17:57 +08:00
Linus Dierheimer ab9b10824f Fix flatpak package count
Fix user package count
Show runtime packages too
Fixes #441
2023-05-28 00:17:57 +08:00
Linus Dierheimer f5931e80e7 Fix a new compile warning 2023-05-28 00:17:57 +08:00
Linus Dierheimer bf4f86b4f6 Remove leftover comment 2023-05-28 00:17:57 +08:00
李通洲 7f59f22cf4 Font: code refactor 2023-05-28 00:17:57 +08:00
李通洲 14f4817381 Doc: update changelog 2023-05-28 00:17:57 +08:00
李通洲 e821468bb0 Gamepad: fix copy-and-paste errors 2023-05-28 00:17:57 +08:00
李通洲 d9315d2332 Doc: update changelog 2023-05-28 00:17:57 +08:00
李通洲 a2b4be388e Logo: add SteamOS (#439) 2023-05-28 00:17:57 +08:00
李通洲 35e06642f9 Gamepad (Windows): change the name of Pro Controller 2023-05-28 00:17:57 +08:00
李通洲 92de3e4f30 Windows: fix compiling with imagemagick enabled 2023-05-28 00:17:57 +08:00
Carter Li 81a4be498b Merge pull request #437 from LinusDierheimer/dev
Release 1.11.0
2023-03-25 14:42:07 +08:00
李通洲 56477f5ea6 GPU: be more careful to concat strings 2023-03-25 14:19:58 +08:00
李通洲 ca05e2e905 GPU: add option --gpu-force-vulkan 2023-03-25 13:24:28 +08:00
李通洲 a524302ea7 GPU (Windows): use a faster implementation 2023-03-25 13:04:44 +08:00
李通洲 945b5f1b15 Parsing: make it able to print 1.00 GB 2023-03-25 12:53:08 +08:00
李通洲 ccb0f853db Deps: revert changes of JSON parse library
Let's not make the change before fastfetch 2.0
2023-03-25 10:00:35 +08:00
李通洲 b8f1b0d6aa Release 1.11.0 2023-03-25 01:08:32 +08:00
李通洲 aa7d5bd704 Chore: add myself to FUNDING.yml 2023-03-25 00:50:40 +08:00
李通洲 9ee4c08790 Gamepad (Windows): detect gamepad name by productId
Also improve performance
2023-03-25 00:50:40 +08:00
李通洲 725d2f2612 Windows: fix <Windows.h> header mess 2023-03-25 00:50:40 +08:00
李通洲 4d5ad691f3 Doc: update changelog for flatpak-user support 2023-03-24 23:41:06 +08:00
李通洲 b2f3bf3461 Packages (Linux): support flatpak-user
Fixes #436
2023-03-24 17:47:03 +08:00
李通洲 44c389d29f Doc: document --display-compact-type 2023-03-23 15:09:47 +08:00
李通洲 ac8e03419e DisplayServer (Windows): correct resolution for vertical modes 2023-03-22 23:43:52 +08:00
李通洲 babb836f91 DisplayServer: detect display type ( builtin or external ) 2023-03-22 21:33:46 +08:00
李通洲 95e0a5ee95 DisplayServer: fix programming errors 2023-03-22 20:41:21 +08:00
李通洲 642a0c78cc Display: add options --display-detect-name and --display-precise-refresh-rate 2023-03-22 16:51:06 +08:00
李通洲 1ac90584cb Display: add option --display-compact-mode 2023-03-22 16:19:39 +08:00
李通洲 ccef5de86e Display (macOS, Windows): support display name detection 2023-03-22 16:04:48 +08:00
李通洲 e526ec9c32 Brightness: tidy 2023-03-22 15:44:59 +08:00
李通洲 b15e68658f FFstrbuf: make ffStrbufInit inlinable; add ffStrbufInitMove 2023-03-22 15:35:22 +08:00
李通洲 dcd0f8d3f6 DisplayServer (Windows): support precise refresh rate 2023-03-22 14:59:24 +08:00
李通洲 b3da6b0e89 CPU (Windows): try improving performance 2023-03-21 15:27:34 +08:00
李通洲 ff8c761de0 Doc: add changelog for new cursor features 2023-03-20 14:09:35 +08:00
李通洲 e6258acb55 Cursor (macOS): add support 2023-03-20 14:09:35 +08:00
李通洲 ecafed8fd5 Cursor (Windows): support cursor size detection 2023-03-20 10:29:06 +08:00
李通洲 73f99b1298 Doc: update changelog 2023-03-20 10:18:20 +08:00
Carter Li 7a6ed854ec Merge pull request #435 from regulargvy13/patch-1
Small update for nobara logo
2023-03-18 22:05:36 +08:00
regulargvy13 e923d78016 Small update for nobara logo
The last line in nobara logo was missing just a few spaces, so I added them, and now it's in proper shape :)
2023-03-18 00:46:46 +01:00
李通洲 615b2f72ae GPU (Linux): don't exit if libpci is failed to init
* Fixes #433
* Ref https://github.com/pciutils/pciutils/issues/136
2023-03-13 17:46:24 +08:00
李通洲 9773349253 Chassis: fix wrong module args used when printing 2023-03-10 13:54:27 +08:00
李通洲 fc57fa5415 Doc: document foot terminal support
Fix #431
2023-03-09 14:05:01 +08:00
李通洲 bdd9d46517 TerminalFont: support foot terminal 2023-03-09 14:02:08 +08:00
李通洲 013499f7a2 Terminal: support foot version detection 2023-03-09 14:01:59 +08:00
李通洲 c4416379bb Packages (Linux): support linuxbrew (Homebrew for Linux) 2023-03-08 15:02:58 +08:00
李通洲 c0c07e7dc9 TerminalFont: optimise JSON related code 2023-03-07 00:54:56 +08:00
李通洲 38ec3718ce CI: fix Windows artifacts 2023-03-06 11:22:57 +08:00
李通洲 e2e3561443 TerminalFont: migrate to json-c to prevent from 3rd lib code embedding 2023-03-04 12:17:16 +08:00
李通洲 199f2fc0cd Wifi (Linux): fix compiling with musl (#429) 2023-03-04 09:46:21 +08:00
李通洲 c944b2f599 DateTime: correct format as yyyy-MM-dd 2023-03-04 00:49:07 +08:00
李通洲 fdd0d47762 TerminalFont: migrate cJSON to yyjson
yyjson provides faster JSON parsing and supports JSON with comments ( which is allowed in WT config file )
https://github.com/ibireme/yyjson
2023-03-04 00:47:39 +08:00
李通洲 e5f851dcbb DisplayServer (Windows): fix scaled resolution detection 2023-03-04 00:41:32 +08:00
李通洲 78cb2781e6 Brightness (macOS): display monitor names 2023-03-01 15:40:18 +08:00
李通洲 ef9b5c57b1 DisplayServer (macOS): change process names 2023-02-27 11:29:10 +08:00
Carter Li 52eacd7140 Merge pull request #428 from LinusDierheimer/dev
Release: 1.10.3
2023-02-25 17:34:53 +08:00
李通洲 b19d8d6700 Release: 1.10.3 2023-02-25 16:06:16 +08:00
李通洲 6b0add44ee Init: print threads for --list-features if supported 2023-02-25 15:29:12 +08:00
李通洲 b66338494f CMake: fix compile error on Windows 2023-02-25 13:31:36 +08:00
李通洲 47cec48a49 GPU (Windows): fix uninited variables 2023-02-25 13:31:36 +08:00
李通洲 09ccbca79c WmTheme (Apple): don't depend on displayserver detection 2023-02-25 13:31:36 +08:00
李通洲 4f28ae62a7 Font: don't depend on displayserver detection on Windows and macOS. 2023-02-25 13:31:36 +08:00
李通洲 e953ea6542 Android: enable mutltithreading public-ip / weather detection 2023-02-24 17:48:20 +08:00
李通洲 de72c98a28 Init: don't create detection thread for displayserver on Windows / macOS
Displayserver (mainly resolutions) detection is cheap on win / mac, but creating an detection thread is unnecessary
2023-02-24 17:48:20 +08:00
李通洲 7f15f91bd3 Temps (Windows): dirty support
Note: https://stackoverflow.com/a/17083409
2023-02-23 21:31:33 +08:00
李通洲 c570c5bf97 IO: use FF_AUTO_CLOSE_FD 2023-02-23 13:58:39 +08:00
李通洲 52c304ecae IO (Linux): add detailed error messages for ffProcessAppendStdOut 2023-02-23 13:32:12 +08:00
119 changed files with 1808 additions and 1247 deletions
+1 -1
View File
@@ -1 +1 @@
github: LinusDierheimer
github: [LinusDierheimer, CarterLi]
+5 -5
View File
@@ -21,12 +21,12 @@ jobs:
uses: actions/checkout@v3
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libcjson-dev libnm-dev libpulse-dev
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libcjson-dev
- name: configure project
env:
CC: ${{ matrix.compiler }}
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBCJSON=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} .
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} -DENABLE_JSONC=${{ matrix.enableFeatures }} .
- name: build project
run: cmake --build .
@@ -53,7 +53,7 @@ jobs:
uses: actions/checkout@v3
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libcjson-dev libnm-dev libpulse-dev
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libcjson-dev
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
@@ -183,7 +183,7 @@ jobs:
with:
msystem: CLANG64
update: true
install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd mingw-w64-clang-x86_64-cjson
- name: print msys version
run: uname -a
@@ -244,7 +244,7 @@ jobs:
with:
msystem: CLANG32
update: true
install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-cjson mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd
install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd mingw-w64-clang-i686-cjson
- name: print msys version
run: uname -a
+56
View File
@@ -1,3 +1,59 @@
# 1.11.1
Features:
* Support xonsh detection (TerminalShell)
* Support Tabby version / terminal font detection (TerminalFont)
Bugfixes:
* Fix name of Pro Controller (Gamepad, Windows)
* Fix compile error with imagemagick enabled (Windows)
* Fix copy-and-paste errors (Gamepad)
* Flatpak: Fix user package count
* Flatpak: Count runtime packages too (#441)
* Fix flatpak package count (#441)
* Don't print white color blocks with `--pipe` (#450)
* Fix iTerm being detected as iTermServer-* sometimes
* Fix sound device volume being incorrectly detected as muted sometimes (Sound)
* Fix memleaks reported by LeakSanitizer (Linux)
* Fix potential memory curruption bug in unicode.c (Windows)
Logo:
* Update Windows 11 ASCII logo to look more visually consistent (#445)
* Add another font color index to arch icon (#446)
* Add SteamOS
* Add macOS small / small2
# 1.11.0
Features:
* Support linuxbrew (Packages, Linux)
* Support foot terminal (#431, Linux)
* Support cursor size detection on Windows (Cursor, Windows)
* Support cursor detection on macOS (Cursor, macOS)
* Support display name, display type and decimal refresh rate detection (Display, macOS / Windows)
* Support `--display-compact-type` to display multiple resolutions in one line (Display)
* Support flatpak-user (Packages, Linux, #436)
* Support `--gpu-force-vulkan` to force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations` (GPU)
Bugfixes:
* Fix date time format
* Fix compiling with musl (Wifi, Linux, #429)
* Don't exit if libpci is failed to init (GPU, Linux, #433)
* Names of most well-known gamepads are correctly printed instead of `Wireless Controller` on Windows
Logo:
* Small update for nobara logo (#435, @regulargvy13)
# 1.10.3
Bugfixes:
* Fix uninitialized variables (GPU, Windows)
* Fix compiling errors (Windows)
Improvements:
* Improve preformance (WmTheme amd Font, Windows and macOS)
* Enable nonblocking public-ip / weather detection (Android)
# 1.10.2
Bugfixes:
+33 -26
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 1.10.2
VERSION 1.11.1
LANGUAGES C
DESCRIPTION "Fast system information tool"
HOMEPAGE_URL "https://github.com/LinusDierheimer/fastfetch"
@@ -67,13 +67,12 @@ cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32" OFF)
cmake_dependent_option(ENABLE_LIBCJSON "Enable libcjson" ON "LINUX OR WIN32" OFF)
cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND AND NOT ANDROID" OFF)
cmake_dependent_option(ENABLE_LIBCJSON "Enable libcjson" ON "LINUX OR WIN32" OFF)
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
cmake_dependent_option(ENABLE_BUFFER "Enable stdout buffer" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
cmake_dependent_option(USE_WIN_NTAPI "Allow using internal NTAPI" ON "WIN32" OFF)
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
@@ -117,7 +116,11 @@ if(NOT WIN32)
set(FASTFETCH_FLAGS_DEBUG "${FASTFETCH_FLAGS_DEBUG} -fsanitize=address -fsanitize=undefined")
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG} -rdynamic")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}")
if(NOT WIN32)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -rdynamic")
endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
include(CheckIPOSupported)
@@ -244,6 +247,7 @@ set(LIBFASTFETCH_SRC
src/detection/host/host.c
src/detection/locale/locale.c
src/detection/media/media.c
src/detection/opencl/opencl.c
src/detection/os/os.c
src/detection/packages/packages.c
src/detection/terminalfont/terminalfont.c
@@ -292,6 +296,7 @@ set(LIBFASTFETCH_SRC
src/modules/separator.c
src/modules/shell.c
src/modules/sound.c
src/modules/swap.c
src/modules/media.c
src/modules/terminal.c
src/modules/terminalfont.c
@@ -458,7 +463,7 @@ elseif(APPLE)
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_apple.c
src/detection/cpuUsage/cpuUsage_apple.c
src/detection/cursor/cursor_nosupport.c
src/detection/cursor/cursor_apple.m
src/detection/disk/disk_apple.m
src/detection/disk/disk_bsd.c
src/detection/displayserver/displayserver_apple.c
@@ -504,21 +509,22 @@ elseif(WIN32)
src/detection/disk/disk_windows.c
src/detection/displayserver/displayserver_windows.c
src/detection/font/font_windows.c
src/detection/gpu/gpu_windows.cpp
src/detection/gpu/gpu_windows.c
src/detection/host/host_windows.c
src/detection/localip/localip_windows.c
src/detection/gamepad/gamepad_windows.cpp
src/detection/gamepad/gamepad_windows.c
src/detection/media/media_nosupport.c
src/detection/memory/memory_windows.c
src/detection/opengl/opengl_windows.c
src/detection/os/os_windows.cpp
src/detection/packages/packages_windows.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_windows.cpp
src/detection/processes/processes_windows.c
src/detection/sound/sound_windows.cpp
src/detection/swap/swap_windows.cpp
src/detection/swap/swap_windows.c
src/detection/terminalfont/terminalfont_windows.c
src/detection/terminalshell/terminalshell_windows.cpp
src/detection/terminalshell/terminalshell_windows.c
src/detection/temps/temps_windows.cpp
src/detection/uptime/uptime_windows.c
src/detection/users/users_windows.c
src/detection/wifi/wifi_windows.c
@@ -537,6 +543,9 @@ add_library(libfastfetch OBJECT
)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
if(WIN32)
target_compile_definitions(libfastfetch PUBLIC WIN32_LEAN_AND_MEAN=1)
endif()
CHECK_INCLUDE_FILE("utmpx.h" HAVE_UTMPX_H)
if(HAVE_UTMPX_H)
@@ -663,10 +672,6 @@ ff_lib_enable(OPENCL
"OpenCL"
"OpenCL"
)
ff_lib_enable(LIBCJSON
"libcjson"
"CJson"
)
ff_lib_enable(LIBNM
"libnm"
"libnm"
@@ -679,6 +684,10 @@ ff_lib_enable(PULSE
"libpulse"
"Pulse"
)
ff_lib_enable(LIBCJSON
"libcjson"
"CJson"
)
if(ENABLE_THREADS)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS)
@@ -693,17 +702,19 @@ endif()
if(APPLE)
target_link_libraries(libfastfetch
PRIVATE "-framework Cocoa"
PRIVATE "-framework CoreFoundation"
PRIVATE "-framework CoreAudio"
PRIVATE "-framework CoreVideo"
PRIVATE "-framework CoreWLAN"
PRIVATE "-framework IOBluetooth"
PRIVATE "-framework IOKit"
PRIVATE "-framework OpenGL"
PRIVATE "-framework OpenCL"
PRIVATE "-framework Cocoa"
PRIVATE "-framework CoreWLAN"
PRIVATE "-framework CoreAudio"
PRIVATE "-framework CoreVideo"
PRIVATE "-framework IOBluetooth"
PRIVATE "-weak_framework MediaRemote -F /System/Library/PrivateFrameworks"
PRIVATE "-framework SystemConfiguration"
PRIVATE "-weak_framework CoreDisplay"
PRIVATE "-weak_framework DisplayServices -F /System/Library/PrivateFrameworks"
PRIVATE "-weak_framework MediaRemote -F /System/Library/PrivateFrameworks"
)
elseif(WIN32)
target_compile_definitions(libfastfetch PRIVATE -D_WIN32_WINNT=0x0601)
@@ -719,14 +730,10 @@ elseif(WIN32)
PRIVATE "ntdll"
PRIVATE "version"
PRIVATE "setupapi"
PRIVATE "dxgi"
PRIVATE "dinput8"
PRIVATE "hid"
PRIVATE "wtsapi32"
PRIVATE "powrprof"
)
if(USE_WIN_NTAPI)
target_compile_definitions(libfastfetch PRIVATE FF_USE_WIN_NTAPI)
endif()
endif()
target_include_directories(libfastfetch
+2 -2
View File
@@ -94,7 +94,7 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa
##### Builtin logos
```
AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Fedora, FreeBSD, Garuda, Gentoo, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, Ubuntu, Vanilla, Void, Windows, Windows 11, Windows 8, Zorin
AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Fedora, FreeBSD, Garuda, Gentoo, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, SteamOS, Ubuntu, Vanilla, Void, Windows, Windows 11, Windows 8, Zorin
```
##### Package managers
@@ -114,7 +114,7 @@ Budgie, Cinnamon, Gnome, KDE Plasma, LXQt, Mate, XFCE4
##### Terminal fonts
```
Alacritty, Apple Terminal, ConEmu, Deepin Terminal, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, mintty, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal
Alacritty, Apple Terminal, ConEmu, Deepin Terminal, foot, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, mintty, Tabby, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal
```
## Building
+4
View File
@@ -182,6 +182,8 @@ __fastfetch_completion()
"--cpu-temp"
"--gpu-temp"
"--battery-temp"
"--display-detect-name"
"--display-precise-refresh-rate"
"--localip-show-ipv4"
"--localip-show-ipv6"
"--localip-show-loop"
@@ -199,6 +201,7 @@ __fastfetch_completion()
"--disk-show-subvolumes"
"--gpu-hide-integrated"
"--gpu-hide-discrete"
"--gpu-force-vulkan"
"--disk-show-unknown"
"--bluetooth-show-disconnected"
)
@@ -224,6 +227,7 @@ __fastfetch_completion()
"--color"
"--color-keys"
"--color-title"
"--display-compact-type"
"--separator"
"-s"
"--structure"
+1 -1
View File
@@ -3,7 +3,7 @@
--kernel-format Sysname: {}; Release: {}; Version: {}
--uptime-format Days: {}; Hours: {}; Minutes: {}; Seconds: {}
--processes-format Count: {}
--packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {}
--packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak-system: {}; flatpak-user: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {}
--shell-format Process name: {}; Process path: {}; Process exe: {}; Process version: {}; User path: {}; User exe: {}; User version: {}
--display-format Width: {}; Height: {}; Refresh rate: {}; ScaledWith: {}; ScaledHeight: {}
--de-format Process name: {}; Pretty name: {}; Version: {}
+19 -23
View File
@@ -8,9 +8,8 @@
#include <unistd.h>
#include <sys/stat.h>
#ifdef _WIN32
#include <wincon.h>
#include <windows.h>
#include <locale.h>
#include <shlobj.h>
#include "util/windows/unicode.h"
#else
#include <signal.h>
@@ -145,6 +144,7 @@ static void defaultConfig(FFinstance* instance)
instance->config.cpuTemp = false;
instance->config.gpuTemp = false;
instance->config.gpuForceVulkan = false;
instance->config.batteryTemp = false;
instance->config.gpuHideIntegrated = false;
@@ -161,6 +161,10 @@ static void defaultConfig(FFinstance* instance)
instance->config.diskShowUnknown = false;
instance->config.diskShowSubvolumes = false;
instance->config.displayCompactType = FF_DISPLAY_COMPACT_TYPE_NONE;
instance->config.displayDetectName = false;
instance->config.displayPreciseRefreshRate = false;
instance->config.bluetoothShowDisconnected = false;
instance->config.soundType = FF_SOUND_TYPE_MAIN;
@@ -212,42 +216,29 @@ void ffInitInstance(FFinstance* instance)
defaultConfig(instance);
}
#ifdef FF_HAVE_THREADS
FF_THREAD_ENTRY_DECL_WRAPPER(ffConnectDisplayServer, FFinstance*)
#if !(defined(__APPLE__) || defined(_WIN32))
#if defined(FF_HAVE_THREADS) && !(defined(__APPLE__) || defined(_WIN32) || defined(__ANDROID__))
#include "detection/gtk_qt/gtk_qt.h"
#define FF_DETECT_QT_GTK 1
#define FF_START_DETECTION_THREADS
FF_THREAD_ENTRY_DECL_WRAPPER(ffConnectDisplayServer, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectQt, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK2, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK3, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK4, FFinstance*)
#endif //!(defined(__APPLE__) || defined(_WIN32))
#endif //FF_HAVE_THREADS
void startDetectionThreads(FFinstance* instance)
{
#ifdef FF_HAVE_THREADS
ffThreadDetach(ffThreadCreate(ffConnectDisplayServerThreadMain, instance));
#ifdef FF_DETECT_QT_GTK
ffThreadDetach(ffThreadCreate(ffDetectQtThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK2ThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK3ThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK4ThreadMain, instance));
#endif
#else
FF_UNUSED(instance);
#endif
}
#endif //FF_HAVE_THREADS
static volatile bool ffDisableLinewrap = true;
static volatile bool ffHideCursor = true;
@@ -268,7 +259,7 @@ static void resetConsole()
BOOL WINAPI consoleHandler(DWORD signal)
{
FF_UNUSED(signal);
resetConsole();
resetConsole();
exit(0);
}
#else
@@ -282,8 +273,10 @@ static void exitSignalHandler(int signal)
void ffStart(FFinstance* instance)
{
if(instance->config.multithreading)
startDetectionThreads(instance);
#ifdef FF_START_DETECTION_THREADS
if(instance->config.multithreading)
startDetectionThreads(instance);
#endif
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
@@ -450,6 +443,9 @@ void ffDestroyInstance(FFinstance* instance)
void ffListFeatures()
{
fputs(
#ifdef FF_HAVE_THREADS
"threads\n"
#endif
#ifdef FF_HAVE_LIBPCI
"libpci\n"
#endif
+30
View File
@@ -7,6 +7,7 @@
#ifdef _WIN32
#include <fileapi.h>
#include <handleapi.h>
#include <io.h>
typedef HANDLE FFNativeFD;
#else
@@ -101,4 +102,33 @@ static inline void ffUnsuppressIO(bool* suppressed)
void ffListFilesRecursively(const char* path);
static inline bool wrapClose(FFNativeFD* pfd)
{
assert(pfd);
#ifndef WIN32
if (*pfd < 0)
return false;
close(*pfd);
#else
// https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
if (*pfd == NULL || *pfd == INVALID_HANDLE_VALUE)
return false;
CloseHandle(*pfd);
#endif
return true;
}
#define FF_AUTO_CLOSE_FD __attribute__((__cleanup__(wrapClose)))
static inline bool wrapFclose(FILE** pfile)
{
assert(pfile);
if (!*pfile)
return false;
fclose(*pfile);
return true;
}
#define FF_AUTO_CLOSE_FILE __attribute__((__cleanup__(wrapFclose)))
#endif // FF_INCLUDED_common_io_io
+6 -18
View File
@@ -27,7 +27,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC;
int openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
int fd = open(fileName, openFlagsModes, openFlagsRights);
int FF_AUTO_CLOSE_FD fd = open(fileName, openFlagsModes, openFlagsRights);
if(fd == -1)
{
createSubfolders(fileName);
@@ -36,11 +36,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
return false;
}
bool ret = write(fd, data, dataSize) != -1;
close(fd);
return ret;
return write(fd, data, dataSize) > 0;
}
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer)
@@ -77,28 +73,20 @@ bool ffAppendFDBuffer(int fd, FFstrbuf* buffer)
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
{
int fd = open(fileName, O_RDONLY);
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY);
if(fd == -1)
return -1;
ssize_t readed = ffReadFDData(fd, dataSize, data);
close(fd);
return readed;
return ffReadFDData(fd, dataSize, data);
}
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
{
int fd = open(fileName, O_RDONLY);
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY);
if(fd == -1)
return false;
bool ret = ffAppendFDBuffer(fd, buffer);
close(fd);
return ret;
return ffAppendFDBuffer(fd, buffer);
}
bool ffPathExists(const char* path, FFPathType type)
+7 -21
View File
@@ -2,7 +2,7 @@
static void createSubfolders(const char* fileName)
{
FFstrbuf path;
FF_STRBUF_AUTO_DESTROY path;
ffStrbufInit(&path);
while(*fileName != '\0')
@@ -12,13 +12,11 @@ static void createSubfolders(const char* fileName)
CreateDirectoryA(path.chars, NULL);
++fileName;
}
ffStrbufDestroy(&path);
}
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
{
HANDLE handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE FF_AUTO_CLOSE_FD handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
{
createSubfolders(fileName);
@@ -28,11 +26,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
}
DWORD written;
bool ret = !!WriteFile(handle, data, (DWORD)dataSize, &written, NULL);
CloseHandle(handle);
return ret;
return !!WriteFile(handle, data, (DWORD)dataSize, &written, NULL);
}
bool ffAppendFDBuffer(HANDLE handle, FFstrbuf* buffer)
@@ -69,28 +63,20 @@ bool ffAppendFDBuffer(HANDLE handle, FFstrbuf* buffer)
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
{
HANDLE handle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE FF_AUTO_CLOSE_FD handle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
return -1;
ssize_t readed = ffReadFDData(handle, dataSize, data);
CloseHandle(handle);
return readed;
return ffReadFDData(handle, dataSize, data);
}
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
{
HANDLE handle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE FF_AUTO_CLOSE_FD handle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
return false;
bool ret = ffAppendFDBuffer(handle, buffer);
CloseHandle(handle);
return ret;
return ffAppendFDBuffer(handle, buffer);
}
bool ffPathExists(const char* path, FFPathType type)
+1 -1
View File
@@ -65,7 +65,7 @@ static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, uint8_t p
long double size = (long double) bytes;
uint8_t counter = 0;
while(size > base && counter < prefixesLength - 1)
while(size >= base && counter < prefixesLength - 1)
{
size /= base;
counter++;
+2
View File
@@ -3,6 +3,8 @@
#ifndef FF_INCLUDED_parsing_h
#define FF_INCLUDED_parsing_h
#include "fastfetch.h"
#include <stdint.h>
typedef struct FFVersion
+15 -4
View File
@@ -30,9 +30,20 @@ const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
//Parent
close(pipes[1]);
waitpid(childPid, NULL, 0);
bool ok = ffAppendFDBuffer(pipes[0], buffer);
close(pipes[0]);
return ok ? NULL : "ffAppendFDBuffer() failed";
int FF_AUTO_CLOSE_FD childPipeFd = pipes[0];
int status = -1;
if(waitpid(childPid, &status, 0) < 0)
return "waitpid(childPid, &status, 0) failed";
if (!WIFEXITED(status))
return "WIFEXITED(status) == false";
if(WEXITSTATUS(status) == 901)
return "WEXITSTATUS(status) == 901 ( execvp failed )";
if(!ffAppendFDBuffer(childPipeFd, buffer))
return "ffAppendFDBuffer(childPipeFd, buffer) failed";
return NULL;
}
-1
View File
@@ -1,7 +1,6 @@
#include "fastfetch.h"
#include "common/processing.h"
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
+2 -2
View File
@@ -166,10 +166,10 @@ bool ffParsePropFileListValues(const FFlist* list, const char* relativeFile, uin
FFstrbuf baseDir;
ffStrbufInitA(&baseDir, 64);
for(uint32_t i = 0; i < list->length; i++)
FF_LIST_FOR_EACH(FFstrbuf, dirPrefix, *list)
{
//We need to copy the dir each time, because it used by multiple threads, so we can't directly write to it.
ffStrbufSet(&baseDir, ffListGet(list, i));
ffStrbufSet(&baseDir, dirPrefix);
ffStrbufAppendS(&baseDir, relativeFile);
if(ffParsePropFileValues(baseDir.chars, numQueries, queries))
+17 -8
View File
@@ -57,23 +57,31 @@ typedef enum FFInitState
typedef struct GVariantGetters
{
FF_LIBRARY_SYMBOL(g_variant_get_string)
FF_LIBRARY_SYMBOL(g_variant_dup_string)
FF_LIBRARY_SYMBOL(g_variant_get_boolean)
FF_LIBRARY_SYMBOL(g_variant_get_int32)
FF_LIBRARY_SYMBOL(g_variant_unref)
} GVariantGetters;
static FFvariant getGVariantValue(GVariant* variant, FFvarianttype type, const GVariantGetters* variantGetters)
{
FFvariant result;
if(variant == NULL)
return FF_VARIANT_NULL;
result = FF_VARIANT_NULL;
else if(type == FF_VARIANT_TYPE_STRING)
return (FFvariant) {.strValue = variantGetters->ffg_variant_get_string(variant, NULL)};
result = (FFvariant) {.strValue = variantGetters->ffg_variant_dup_string(variant, NULL)}; // Dup string, so that variant itself can be freed
else if(type == FF_VARIANT_TYPE_BOOL)
return (FFvariant) {.boolValue = (bool) variantGetters->ffg_variant_get_boolean(variant), .boolValueSet = true};
result = (FFvariant) {.boolValue = (bool) variantGetters->ffg_variant_get_boolean(variant), .boolValueSet = true};
else if(type == FF_VARIANT_TYPE_INT)
return (FFvariant) {.intValue = variantGetters->ffg_variant_get_int32(variant)};
result = (FFvariant) {.intValue = variantGetters->ffg_variant_get_int32(variant)};
else
return FF_VARIANT_NULL;
result = FF_VARIANT_NULL;
if(variant)
variantGetters->ffg_variant_unref(variant);
return result;
}
typedef struct GSettingsData
@@ -102,9 +110,10 @@ static const GSettingsData* getGSettingsData(const FFinstance* instance)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_source_get_default)
#define data data.variantGetters
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_string)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_dup_string)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_boolean)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_int32)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_unref);
#undef data
data.schemaSource = data.ffg_settings_schema_source_get_default();
@@ -169,7 +178,7 @@ static const DConfData* getDConfData(const FFinstance* instance)
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_new)
#define data data.variantGetters
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_string)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_dup_string)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_boolean)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_int32)
#undef data
+1 -1
View File
@@ -20,7 +20,7 @@
}
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static __stdcall unsigned fn ## ThreadMain (void* data) { fn((paramType)data); return 0; }
static inline void ffThreadDetach(FFThreadType thread) { CloseHandle(thread); }
static inline void ffThreadJoin(FFThreadType thread) { WaitForSingleObject(thread, INFINITE); }
static inline void ffThreadJoin(FFThreadType thread) { WaitForSingleObject(thread, 0xffffffff /*INFINITE*/); }
#else
#include <pthread.h>
#define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+25 -1
View File
@@ -219,6 +219,13 @@
#--gpu-hide-integrated
#--gpu-hide-discrete
# GPU detection options
# Forces using vulkan to detect GPUs
# which support video memory usage detection with `--allow-slow-operations`
# Must be either true or false
# Default is false.
#--gpu-force-vulkan
# Shell option
# Sets if shell version should be detected and printed
# Must be either true or false
@@ -253,6 +260,24 @@
# Default is false.
#--bluetooth-show-disconnected false
# Display compact output option
# Sets if all displays should be printed in one line
# Must be either original (print pixel resolution) or scaled (print scaled resolution)
# Default is none.
#--display-compact-type none
# Display detect name option
# Sets if display name should be detected and printed (if supported)
# Must be either true of false
# Default is false.
#--display-detect-name none
# Display precise refresh rate option
# Sets if decimal refresh rates should not be rounded into integers when printing
# Must be either true (keep decimals) of false (round into integers)
# Default is false.
#--display-precise-refresh-rate false
# Sound show all option
# Sets if all sound devices should be printed
# Must be either main, active or all. Default is main
@@ -429,6 +454,5 @@
#--lib-osmesa /usr/lib/libOSMesa.so
#--lib-opencl /usr/lib/libOpenCL.so
#--lib-cjson /usr/lib/libcjson.so
#--lib-cjson /usr/lib/libasound.so
#--lib-freetype /data/data/com.termux/files/usr/lib
#--lib-pulse /usr/lib/libpulse.so
+4
View File
@@ -113,10 +113,14 @@ Module specific options:
--disk-show-subvolumes <?value>: Set if subvolumes should be printed. Default is false
--disk-show-unknown <?value>: Set if unknown (unable to detect sizes) volumes should be printed. Default is false
--bluetooth-show-disconnected: <?value>: Set if disconnected bluetooth devices should be printed. Default is false
--display-compact-type: <?string>: Set if all displays should be printed in one line. Default is none
--display-detect-name: <?value>: Set if display name should be detected and printed (if supported). Default is false
--display-precise-refresh-rate: <?value>:Set if decimal refresh rates should not be rounded into integers when printing
--sound-type: <value>: Set what type of sound devices should be printed. Should be either main, active or all. Default is main
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
--gpu-force-vulkan <?value>: Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`. Default is false
--gpu-hide-integrated <?value>: Hide integrated GPU if supported. Default is false
--gpu-hide-discrete <?value>: Hide discrete GPU if supported. Default is false
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
+12 -14
View File
@@ -2,24 +2,22 @@
#include "util/windows/unicode.h"
#include "util/mallocHelper.h"
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <setupapi.h>
#include <batclass.h>
#include <devguid.h>
#include <winternl.h>
#include <powrprof.h>
#ifdef FF_USE_WIN_NTAPI
NTSYSCALLAPI
NTSTATUS
NTAPI
NtPowerInformation(
IN POWER_INFORMATION_LEVEL InformationLevel,
IN PVOID InputBuffer OPTIONAL,
IN ULONG InputBufferLength,
OUT PVOID OutputBuffer OPTIONAL,
IN ULONG OutputBufferLength);
#define CallNtPowerInformation NtPowerInformation
#endif
NTSYSCALLAPI
NTSTATUS
NTAPI
NtPowerInformation(
IN POWER_INFORMATION_LEVEL InformationLevel,
IN PVOID InputBuffer OPTIONAL,
IN ULONG InputBufferLength,
OUT PVOID OutputBuffer OPTIONAL,
IN ULONG OutputBufferLength);
static inline void wrapCloseHandle(HANDLE* handle)
{
@@ -146,7 +144,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
else
{
SYSTEM_BATTERY_STATE info;
if (NT_SUCCESS(CallNtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
{
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
ffStrbufInit(&battery->modelName);
@@ -1,6 +1,7 @@
#include "bluetooth.h"
#include "util/windows/unicode.h"
#include <windows.h>
#include <bluetoothapis.h>
#pragma GCC diagnostic push
+22 -4
View File
@@ -1,8 +1,10 @@
#include "brightness.h"
#include "util/apple/cf_helpers.h"
#include <CoreGraphics/CoreGraphics.h>
extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float *brightness) __attribute__((weak_import));
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import));
const char* ffDetectBrightness(FFlist* result)
{
@@ -22,11 +24,27 @@ const char* ffDetectBrightness(FFlist* result)
continue;
FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result);
if(CGDisplayIsBuiltin(screen))
ffStrbufInitS(&display->name, "built-in");
else
ffStrbufInitF(&display->name, "external-%u", (unsigned) screen);
display->value = brightness * 100;
ffStrbufInit(&display->name);
if(CoreDisplay_DisplayCreateInfoDictionary)
{
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen);
if(displayInfo)
{
CFDictionaryRef productNames;
if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames))
{
if(!ffCfDictGetString(productNames, CFSTR("en_US"), &display->name))
continue;
}
}
}
if(CGDisplayIsBuiltin(screen))
ffStrbufAppendS(&display->name, "built-in");
else
ffStrbufAppendF(&display->name, "external-%u", (unsigned) screen);
}
return NULL;
+14 -7
View File
@@ -1,4 +1,5 @@
#include "cpu.h"
#include "detection/temps/temps_windows.h"
#include "util/windows/registry.h"
#include "util/mallocHelper.h"
@@ -14,25 +15,28 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
{
DWORD length = 0;
GetLogicalProcessorInformationEx(RelationProcessorCore, NULL, &length);
GetLogicalProcessorInformationEx(RelationAll, NULL, &length);
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
pLogicalInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);
if(pLogicalInfo && GetLogicalProcessorInformationEx(RelationProcessorCore, pLogicalInfo, &length))
if(pProcessorInfo && GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length))
{
for(
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pLogicalInfo;
(uint8_t*)ptr < ((uint8_t*)pLogicalInfo) + length;
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pProcessorInfo;
(uint8_t*)ptr < ((uint8_t*)pProcessorInfo) + length;
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((uint8_t*)ptr) + ptr->Size)
)
{
if(ptr->Relationship == RelationProcessorCore)
++cpu->coresPhysical;
else if(ptr->Relationship == RelationGroup)
{
cpu->coresOnline += ptr->Group.GroupInfo->ActiveProcessorCount;
cpu->coresLogical += ptr->Group.GroupInfo->MaximumProcessorCount;
}
}
}
}
cpu->coresOnline = (uint16_t)GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
cpu->coresLogical = (uint16_t)GetMaximumProcessorCount(ALL_PROCESSOR_GROUPS);
FF_HKEY_AUTO_DESTROY hKey;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL))
@@ -46,4 +50,7 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL);
ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL);
if(instance->config.cpuTemp)
ffDetectSmbiosTemp(&cpu->temperature, NULL);
}
-25
View File
@@ -1,8 +1,6 @@
#include "fastfetch.h"
#include "cpuUsage.h"
#ifdef FF_USE_WIN_NTAPI
#include "util/mallocHelper.h"
#include <ntstatus.h>
@@ -37,26 +35,3 @@ const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll)
return NULL;
}
#else
#include <processthreadsapi.h>
static inline uint64_t fileTimeToUint64(const FILETIME* ft) {
return (((uint64_t)ft->dwHighDateTime) << 32) | ((uint64_t)ft->dwLowDateTime);
}
const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll)
{
FILETIME idleTime, kernelTime, userTime;
if(!GetSystemTimes(&idleTime, &kernelTime, &userTime))
return "GetSystemTimes() failed";
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getsystemtimes
// `kernelTime` also includes the amount of time the system has been idle.
*totalAll = fileTimeToUint64(&userTime) + fileTimeToUint64(&kernelTime);
*inUseAll = *totalAll - fileTimeToUint64(&idleTime);
return NULL;
}
#endif
+52
View File
@@ -0,0 +1,52 @@
#include "cursor.h"
#import <Foundation/Foundation.h>
static void appendColor(FFstrbuf* str, NSDictionary* color)
{
int r = (int) (((NSNumber*) [color valueForKey:@"red"]).doubleValue * 255);
int g = (int) (((NSNumber*) [color valueForKey:@"green"]).doubleValue * 255);
int b = (int) (((NSNumber*) [color valueForKey:@"blue"]).doubleValue * 255);
int a = (int) (((NSNumber*) [color valueForKey:@"alpha"]).doubleValue * 255);
if (r == 255 && g == 255 && b == 255 && a == 255)
ffStrbufAppendS(str, "White");
else if (r == 0 && g == 0 && b == 0 && a == 255)
ffStrbufAppendS(str, "Black");
else
ffStrbufAppendF(str, "#%02X%02X%02X%02X", r, g, b, a);
}
void ffDetectCursor(const FFinstance* instance, FFCursorResult* result)
{
NSError* error;
NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/com.apple.universalaccess.plist", instance->state.platform.homeDir.chars];
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName]
error:&error];
if(error)
{
ffStrbufAppendS(&result->error, error.localizedDescription.UTF8String);
return;
}
NSDictionary* color;
ffStrbufAppendS(&result->theme, "Fill - ");
if ((color = [dict valueForKey:@"cursorFill"]))
appendColor(&result->theme, color);
else
ffStrbufAppendS(&result->theme, "Black");
ffStrbufAppendS(&result->theme, ", Outline - ");
if ((color = [dict valueForKey:@"cursorOutline"]))
appendColor(&result->theme, color);
else
ffStrbufAppendS(&result->theme, "White");
NSNumber* mouseDriverCursorSize = [dict valueForKey:@"mouseDriverCursorSize"];
if (mouseDriverCursorSize)
ffStrbufAppendF(&result->size, "%d", (int) (mouseDriverCursorSize.doubleValue * 32));
else
ffStrbufAppendS(&result->size, "32");
}
+19 -12
View File
@@ -1,12 +1,19 @@
#include "cursor.h"
#include "util/windows/registry.h"
void ffDetectCursor(const FFinstance* instance, FFCursorResult* result)
{
FF_UNUSED(instance);
FF_HKEY_AUTO_DESTROY hKey;
if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Cursors", &hKey, &result->error))
ffRegReadStrbuf(hKey, NULL, &result->theme, &result->error);
}
#include "cursor.h"
#include "util/windows/registry.h"
void ffDetectCursor(const FFinstance* instance, FFCursorResult* result)
{
FF_UNUSED(instance);
FF_HKEY_AUTO_DESTROY hKey;
if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Cursors", &hKey, &result->error))
{
if (!ffRegReadStrbuf(hKey, NULL, &result->theme, &result->error))
return;
uint32_t cursorBaseSize;
ffRegReadUint(hKey, L"CursorBaseSize", &cursorBaseSize, &result->error);
ffStrbufAppendF(&result->size, "%u", (unsigned) cursorBaseSize);
}
}
-3
View File
@@ -25,9 +25,6 @@ static bool isPhysicalDevice(FFstrbuf* device)
if(!S_ISBLK(deviceStat.st_mode))
return false;
//Ignore all devices that are not physical devices
//DrvFs is a filesystem plugin to WSL that was designed to support interop between WSL and the Windows filesystem.
if(ffStrbufEqualS(device, "drvfs"))
return true;
+24 -24
View File
@@ -1,36 +1,31 @@
#include "disk.h"
#include "util/windows/unicode.h"
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include <assert.h>
void ffDetectDisksImpl(FFDiskResult* disks)
{
uint32_t length = GetLogicalDriveStringsA(0, NULL);
if(length == 0)
{
ffStrbufAppendS(&disks->error, "GetLogicalDriveStringsA failed");
return;
}
char* buf = malloc(length + 1);
GetLogicalDriveStringsA(length, buf);
wchar_t buf[MAX_PATH + 1];
uint32_t length = GetLogicalDriveStringsW(sizeof(buf) / sizeof(*buf), buf);
assert(length < sizeof(buf) / sizeof(*buf));
for(uint32_t i = 0; i < length; i++)
{
const char* mountpoint = buf + i;
const wchar_t* mountpoint = buf + i;
UINT driveType = GetDriveTypeA(mountpoint);
UINT driveType = GetDriveTypeW(mountpoint);
if(driveType == DRIVE_NO_ROOT_DIR)
{
i += (uint32_t)strlen(mountpoint);
i += (uint32_t)wcslen(mountpoint);
continue;
}
FFDisk* disk = ffListAdd(&disks->disks);
ffStrbufInitS(&disk->mountpoint, mountpoint);
ffStrbufInitWS(&disk->mountpoint, mountpoint);
uint64_t bytesFree;
if(!GetDiskFreeSpaceExA(mountpoint, NULL, (PULARGE_INTEGER)&disk->bytesTotal, (PULARGE_INTEGER)&bytesFree))
if(!GetDiskFreeSpaceExW(mountpoint, NULL, (PULARGE_INTEGER)&disk->bytesTotal, (PULARGE_INTEGER)&bytesFree))
{
disk->bytesTotal = 0;
bytesFree = 0;
@@ -44,20 +39,27 @@ void ffDetectDisksImpl(FFDiskResult* disks)
else
disk->type = FF_DISK_TYPE_HIDDEN;
ffStrbufInitA(&disk->filesystem, MAX_PATH + 1);
ffStrbufInitA(&disk->name, MAX_PATH + 1);
ffStrbufInit(&disk->filesystem);
ffStrbufInit(&disk->name);
wchar_t diskName[MAX_PATH + 1], diskFileSystem[MAX_PATH + 1];
//https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa#remarks
UINT errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
GetVolumeInformationA(mountpoint,
disk->name.chars, disk->name.allocated, //Volume name
BOOL result = GetVolumeInformationW(mountpoint,
diskName, sizeof(diskName) / sizeof(*diskName), //Volume name
NULL, //Serial number
NULL, //Max component length
NULL, //File system flags
disk->filesystem.chars, disk->filesystem.allocated
diskFileSystem, sizeof(diskFileSystem) / sizeof(*diskFileSystem)
);
SetErrorMode(errorMode);
ffStrbufRecalculateLength(&disk->name);
ffStrbufRecalculateLength(&disk->filesystem);
if(result)
{
ffStrbufSetWS(&disk->filesystem, diskFileSystem);
ffStrbufSetWS(&disk->name, diskName);
}
//TODO: implement
disk->filesUsed = 0;
@@ -65,6 +67,4 @@ void ffDetectDisksImpl(FFDiskResult* disks)
i += disk->mountpoint.length;
}
free(buf);
}
+11 -19
View File
@@ -1,25 +1,15 @@
#include "displayserver.h"
#include "detection/internal.h"
uint32_t ffdsParseRefreshRate(int32_t refreshRate)
{
if(refreshRate <= 0)
return 0;
int remainder = refreshRate % 5;
if(remainder >= 3)
refreshRate += (5 - remainder);
else
refreshRate -= remainder;
//All other typicall refresh rates are dividable by 5
if(refreshRate == 145)
refreshRate = 144;
return (uint32_t) refreshRate;
}
bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate, uint32_t scaledWidth, uint32_t scaledHeight)
bool ffdsAppendDisplay(
FFDisplayServerResult* result,
uint32_t width,
uint32_t height,
double refreshRate,
uint32_t scaledWidth,
uint32_t scaledHeight,
FFstrbuf* name,
FFDisplayType type)
{
if(width == 0 || height == 0)
return false;
@@ -30,6 +20,8 @@ bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t h
display->refreshRate = refreshRate;
display->scaledWidth = scaledWidth;
display->scaledHeight = scaledHeight;
ffStrbufInitMove(&display->name, name);
display->type = type;
return true;
}
+18 -4
View File
@@ -34,13 +34,21 @@
#define FF_WM_PROTOCOL_X11 "X11"
#define FF_WM_PROTOCOL_WAYLAND "Wayland"
typedef enum FFDisplayType {
FF_DISPLAY_TYPE_UNKNOWN,
FF_DISPLAY_TYPE_BUILTIN,
FF_DISPLAY_TYPE_EXTERNAL,
} FFDisplayType;
typedef struct FFDisplayResult
{
uint32_t width;
uint32_t height;
uint32_t refreshRate;
double refreshRate;
uint32_t scaledWidth;
uint32_t scaledHeight;
FFstrbuf name;
FFDisplayType type;
} FFDisplayResult;
typedef struct FFDisplayServerResult
@@ -56,8 +64,14 @@ typedef struct FFDisplayServerResult
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance);
//Used internal
uint32_t ffdsParseRefreshRate(int32_t refreshRate);
bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate, uint32_t scaledWidth, uint32_t scaledHeight);
bool ffdsAppendDisplay(
FFDisplayServerResult* result,
uint32_t width,
uint32_t height,
double refreshRate,
uint32_t scaledWidth,
uint32_t scaledHeight,
FFstrbuf* name,
FFDisplayType type);
#endif
@@ -1,5 +1,7 @@
#include "displayserver.h"
#include "common/sysctl.h"
#include "util/apple/cf_helpers.h"
#include "util/mallocHelper.h"
#include <stdlib.h>
#include <ctype.h>
@@ -8,7 +10,9 @@
#include <CoreGraphics/CGDirectDisplay.h>
#include <CoreVideo/CVDisplayLink.h>
static void detectDisplays(FFDisplayServerResult* ds)
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import));
static void detectDisplays(FFDisplayServerResult* ds, bool detectName)
{
CGDirectDisplayID screens[128];
uint32_t screenCount;
@@ -36,12 +40,27 @@ static void detectDisplays(FFDisplayServerResult* ds)
}
}
FF_STRBUF_AUTO_DESTROY name;
ffStrbufInit(&name);
if(detectName && CoreDisplay_DisplayCreateInfoDictionary)
{
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen);
if(displayInfo)
{
CFDictionaryRef productNames;
if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames))
ffCfDictGetString(productNames, CFSTR("en_US"), &name);
}
}
ffdsAppendDisplay(ds,
(uint32_t)CGDisplayModeGetPixelWidth(mode),
(uint32_t)CGDisplayModeGetPixelHeight(mode),
(uint32_t)refreshRate,
refreshRate,
(uint32_t)CGDisplayModeGetWidth(mode),
(uint32_t)CGDisplayModeGetHeight(mode)
(uint32_t)CGDisplayModeGetHeight(mode),
&name,
CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL
);
CGDisplayModeRelease(mode);
}
@@ -55,7 +74,7 @@ static void detectWMPlugin(FFstrbuf* name)
u_int requestLength = sizeof(request) / sizeof(*request);
size_t length = 0;
struct kinfo_proc* processes = ffSysctlGetData(request, requestLength, &length);
FF_AUTO_FREE struct kinfo_proc* processes = ffSysctlGetData(request, requestLength, &length);
if(processes == NULL)
return;
@@ -76,15 +95,13 @@ static void detectWMPlugin(FFstrbuf* name)
name->chars[0] = (char) toupper(name->chars[0]);
break;
}
free(processes);
}
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance)
{
FF_UNUSED(instance);
ffStrbufInitS(&ds->wmProcessName, "quartz");
ffStrbufInitS(&ds->wmProcessName, "WindowServer");
ffStrbufInitS(&ds->wmPrettyName, "Quartz Compositor");
ffStrbufInit(&ds->wmProtocolName);
@@ -99,9 +116,9 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
ffStrbufInit(&ds->deProcessName);
ffStrbufInit(&ds->dePrettyName);
ffStrbufInit(&ds->deVersion);
ffStrbufAppendS(&ds->deProcessName, "aqua");
ffStrbufInit(&ds->deProcessName);
ffStrbufAppendS(&ds->dePrettyName, "Aqua");
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4);
detectDisplays(ds);
detectDisplays(ds, instance->config.displayDetectName);
}
@@ -1,33 +1,101 @@
#include "displayserver.h"
#include "detection/os/os.h"
#include "util/windows/unicode.h"
#include <dwmapi.h>
#include <WinUser.h>
typedef struct
static void detectDisplays(FFDisplayServerResult* ds, bool detectName)
{
WCHAR* deviceName;
uint32_t width;
uint32_t height;
} DataBundle;
DISPLAYCONFIG_PATH_INFO paths[128];
uint32_t pathCount = sizeof(paths) / sizeof(paths[0]);
DISPLAYCONFIG_MODE_INFO modes[256];
uint32_t modeCount = sizeof(modes) / sizeof(modes[0]);
static CALLBACK WINBOOL enumMonitorProc(HMONITOR hMonitor, FF_MAYBE_UNUSED HDC hDC, FF_MAYBE_UNUSED LPRECT rc, LPARAM lparam)
{
MONITORINFOEXW mi = { .cbSize = sizeof(mi) };
DataBundle* data = (DataBundle*) lparam;
if(GetMonitorInfoW(hMonitor, (MONITORINFO *)&mi) && wcscmp(mi.szDevice, data->deviceName) == 0)
if (QueryDisplayConfig(
QDC_ONLY_ACTIVE_PATHS,
&pathCount,
paths,
&modeCount,
modes,
NULL) == ERROR_SUCCESS)
{
data->width = (uint32_t) mi.rcMonitor.right;
data->height = (uint32_t) mi.rcMonitor.bottom;
return FALSE;
for (uint32_t i = 0; i < pathCount; ++i)
{
DISPLAYCONFIG_PATH_INFO* path = &paths[i];
DISPLAYCONFIG_SOURCE_DEVICE_NAME sourceName = {
.header = {
.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME,
.size = sizeof(sourceName),
.adapterId = path->sourceInfo.adapterId,
.id = path->sourceInfo.id,
},
};
uint32_t scaledWidth = 0, scaledHeight = 0;
if (DisplayConfigGetDeviceInfo(&sourceName.header) == ERROR_SUCCESS)
{
HDC hdc = CreateICW(sourceName.viewGdiDeviceName, NULL, NULL, NULL);
scaledWidth = (uint32_t) GetDeviceCaps(hdc, HORZRES);
scaledHeight = (uint32_t) GetDeviceCaps(hdc, VERTRES);
DeleteDC(hdc);
}
FF_STRBUF_AUTO_DESTROY name;
ffStrbufInit(&name);
if (detectName)
{
DISPLAYCONFIG_TARGET_DEVICE_NAME targetName = {
.header = {
.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME,
.size = sizeof(targetName),
.adapterId = path->targetInfo.adapterId,
.id = path->targetInfo.id,
},
};
if(DisplayConfigGetDeviceInfo(&targetName.header) == ERROR_SUCCESS)
{
if (targetName.flags.friendlyNameFromEdid)
ffStrbufSetWS(&name, targetName.monitorFriendlyDeviceName);
else
{
ffStrbufSetWS(&name, targetName.monitorDevicePath);
ffStrbufSubstrAfterFirstC(&name, '#');
ffStrbufSubstrBeforeFirstC(&name, '#');
}
}
}
uint32_t width = modes[path->sourceInfo.modeInfoIdx].sourceMode.width;
uint32_t height = modes[path->sourceInfo.modeInfoIdx].sourceMode.height;
if (path->targetInfo.rotation == DISPLAYCONFIG_ROTATION_ROTATE90 ||
path->targetInfo.rotation == DISPLAYCONFIG_ROTATION_ROTATE270)
{
uint32_t temp = width;
width = height;
height = temp;
}
ffdsAppendDisplay(ds,
width,
height,
path->targetInfo.refreshRate.Numerator / (double) path->targetInfo.refreshRate.Denominator,
scaledWidth,
scaledHeight,
&name,
path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL ||
path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED ||
path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED
? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL
);
}
}
return TRUE;
}
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance)
{
FF_UNUSED(instance);
BOOL enabled;
if(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled == TRUE)
{
@@ -45,23 +113,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
ffStrbufInit(&ds->deVersion);
ffListInit(&ds->displays, sizeof(FFDisplayResult));
DISPLAY_DEVICEW displayDevice = { .cb = sizeof(DISPLAY_DEVICEW) };
for(DWORD devNum = 0; EnumDisplayDevicesW(NULL, devNum, &displayDevice, 0) != 0; ++devNum)
{
if(!(displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE))
continue;
DEVMODEW devMode = { .dmSize = sizeof(DEVMODEW) };
if(EnumDisplaySettingsW(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode) == 0)
continue;
DataBundle data = {
.deviceName = displayDevice.DeviceName,
.width = 0,
.height = 0,
};
EnumDisplayMonitors(NULL, NULL, enumMonitorProc, (LPARAM)&data);
ffdsAppendDisplay(ds, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmDisplayFrequency, data.width, data.height);
}
detectDisplays(ds, instance->config.displayDetectName);
//https://github.com/hykilpikonna/hyfetch/blob/master/neofetch#L2067
const FFOSResult* os = ffDetectOS(instance);
+4 -2
View File
@@ -123,9 +123,11 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
ffdsAppendDisplay(wldata->result,
(uint32_t) display.width,
(uint32_t) display.height,
ffdsParseRefreshRate(display.refreshRate / 1000),
display.refreshRate / 1000.0,
(uint32_t) (display.width / display.scale),
(uint32_t) (display.height / display.scale)
(uint32_t) (display.height / display.scale),
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
ffThreadMutexUnlock(&mutex);
+17 -10
View File
@@ -112,13 +112,14 @@ void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result)
while(iterator.rem > 0)
{
ffdsAppendDisplay(
result,
ffdsAppendDisplay(result,
(uint32_t) iterator.data->width_in_pixels,
(uint32_t) iterator.data->height_in_pixels,
0,
(uint32_t) iterator.data->width_in_pixels,
(uint32_t) iterator.data->height_in_pixels
(uint32_t) iterator.data->height_in_pixels,
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
ffxcb_screen_next(&iterator);
}
@@ -174,9 +175,7 @@ typedef struct XcbRandrData
static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* modeInfo)
{
uint32_t refreshRate = ffdsParseRefreshRate((int32_t) (
modeInfo->dot_clock / (uint32_t) (modeInfo->htotal * modeInfo->vtotal)
));
double refreshRate = (double) modeInfo->dot_clock / (double) (modeInfo->htotal * modeInfo->vtotal);
return ffdsAppendDisplay(
data->result,
@@ -184,7 +183,9 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo
(uint32_t) modeInfo->height,
refreshRate == 0 ? data->defaultRefreshRate : refreshRate,
(uint32_t) modeInfo->width,
(uint32_t) modeInfo->height
(uint32_t) modeInfo->height,
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
}
@@ -221,7 +222,9 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc)
(uint32_t) crtcInfoReply->height,
data->defaultRefreshRate,
(uint32_t) crtcInfoReply->width,
(uint32_t) crtcInfoReply->height
(uint32_t) crtcInfoReply->height,
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
free(crtcInfoReply);
@@ -266,7 +269,9 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
(uint32_t) monitor->height,
data->defaultRefreshRate,
(uint32_t) monitor->width,
(uint32_t) monitor->height
(uint32_t) monitor->height,
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
}
@@ -326,7 +331,9 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
(uint32_t) screen->height_in_pixels,
data->defaultRefreshRate,
(uint32_t) screen->width_in_pixels,
(uint32_t) screen->height_in_pixels
(uint32_t) screen->height_in_pixels,
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
}
+17 -10
View File
@@ -77,13 +77,14 @@ void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result)
for(int i = 0; i < ScreenCount(display); i++)
{
Screen* screen = ScreenOfDisplay(display, i);
ffdsAppendDisplay(
result,
ffdsAppendDisplay(result,
(uint32_t) WidthOfScreen(screen),
(uint32_t) HeightOfScreen(screen),
0,
(uint32_t) WidthOfScreen(screen),
(uint32_t) HeightOfScreen(screen)
(uint32_t) HeightOfScreen(screen),
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
}
@@ -133,9 +134,7 @@ typedef struct XrandrData
static bool xrandrHandleModeInfo(XrandrData* data, XRRModeInfo* modeInfo)
{
uint32_t refreshRate = ffdsParseRefreshRate((int32_t) (
modeInfo->dotClock / (modeInfo->hTotal * modeInfo->vTotal)
));
double refreshRate = (double) modeInfo->dotClock / (double) (modeInfo->hTotal * modeInfo->vTotal);
return ffdsAppendDisplay(
data->result,
@@ -143,7 +142,9 @@ static bool xrandrHandleModeInfo(XrandrData* data, XRRModeInfo* modeInfo)
(uint32_t) modeInfo->height,
refreshRate == 0 ? data->defaultRefreshRate : refreshRate,
(uint32_t) modeInfo->width,
(uint32_t) modeInfo->height
(uint32_t) modeInfo->height,
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
}
@@ -174,7 +175,9 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc)
(uint32_t) crtcInfo->height,
data->defaultRefreshRate,
(uint32_t) crtcInfo->width,
(uint32_t) crtcInfo->height
(uint32_t) crtcInfo->height,
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
data->ffXRRFreeCrtcInfo(crtcInfo);
@@ -210,7 +213,9 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
(uint32_t) monitorInfo->height,
data->defaultRefreshRate,
(uint32_t) monitorInfo->width,
(uint32_t) monitorInfo->height
(uint32_t) monitorInfo->height,
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
}
@@ -264,7 +269,9 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
(uint32_t) HeightOfScreen(screen),
data->defaultRefreshRate,
(uint32_t) WidthOfScreen(screen),
(uint32_t) HeightOfScreen(screen)
(uint32_t) HeightOfScreen(screen),
NULL,
FF_DISPLAY_TYPE_UNKNOWN
);
}
+1
View File
@@ -9,6 +9,7 @@ static void detectFont(const FFinstance* instance, FFFontResult* font)
for(uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i)
ffStrbufInit(&font->fonts[i]);
ffStrbufInit(&font->display);
ffDetectFontImpl(instance, font);
+1
View File
@@ -18,6 +18,7 @@ typedef struct FFFontResult
* Other: Unset, Unset, Unset, Unset
*/
FFstrbuf fonts[FF_DETECT_FONT_NUM_FONTS];
FFstrbuf display;
} FFFontResult;
const FFFontResult* ffDetectFont(const FFinstance* instance);
+18
View File
@@ -4,6 +4,23 @@
#import <AppKit/NSFont.h>
static void generateString(FFFontResult* font)
{
if(font->fonts[0].length > 0)
{
ffStrbufAppend(&font->display, &font->fonts[0]);
ffStrbufAppendS(&font->display, " [System]");
if(font->fonts[1].length > 0)
ffStrbufAppendS(&font->display, ", ");
}
if(font->fonts[1].length > 0)
{
ffStrbufAppend(&font->display, &font->fonts[1]);
ffStrbufAppendS(&font->display, " [User]");
}
}
void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
{
FF_UNUSED(instance);
@@ -11,4 +28,5 @@ void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
ffStrbufAppendS(&result->fonts[1], [NSFont userFontOfSize:12].familyName.UTF8String);
ffStrbufAppendS(&result->fonts[2], [NSFont monospacedSystemFontOfSize:12 weight:400].familyName.UTF8String);
ffStrbufAppendS(&result->fonts[3], [NSFont userFixedPitchFontOfSize:12].familyName.UTF8String);
generateString(result);
}
+26
View File
@@ -1,9 +1,33 @@
#include "common/font.h"
#include "common/parsing.h"
#include "detection/displayserver/displayserver.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "font.h"
static void generateString(FFFontResult* font)
{
ffParseGTK(&font->display, &font->fonts[1], &font->fonts[2], &font->fonts[3]);
if(font->fonts[0].length > 0)
{
if(font->display.length > 0)
ffStrbufAppendS(&font->display, ", ");
ffStrbufAppend(&font->display, &font->fonts[0]);
ffStrbufAppendS(&font->display, " [QT]");
}
}
void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
{
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
{
ffStrbufAppendS(&result->error, "Font isn't supported in TTY");
return;
}
FFfont qt;
ffFontInitQt(&qt, ffDetectQt(instance)->font.chars);
ffStrbufAppend(&result->fonts[0], &qt.pretty);
@@ -23,4 +47,6 @@ void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
ffFontInitPango(&gtk4, ffDetectGTK4(instance)->font.chars);
ffStrbufAppend(&result->fonts[3], &gtk4.pretty);
ffFontDestroy(&gtk4);
generateString(result);
}
+23 -1
View File
@@ -1,7 +1,27 @@
#include "font.h"
#include "util/windows/unicode.h"
#include <winuser.h>
#include <windows.h>
static void generateString(FFFontResult* font)
{
const char* types[] = { "Caption", "Menu", "Message", "Status" };
for(uint32_t i = 0; i < sizeof(types) / sizeof(types[0]); ++i)
{
if(i == 0 || !ffStrbufEqual(&font->fonts[i - 1], &font->fonts[i]))
{
if(i > 0)
ffStrbufAppendS(&font->display, "], ");
ffStrbufAppendF(&font->display, "%s [%s", font->fonts[i].chars, types[i]);
}
else
{
ffStrbufAppendS(&font->display, " / ");
ffStrbufAppendS(&font->display, types[i]);
}
}
ffStrbufAppendC(&font->display, ']');
}
void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
{
@@ -19,4 +39,6 @@ void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
if(fonts[i]->lfHeight < 0)
ffStrbufAppendF(&result->fonts[i], " (%dpt)", (int)-fonts[i]->lfHeight);
}
generateString(result);
}
+138
View File
@@ -0,0 +1,138 @@
#include "gamepad.h"
#include "common/io/io.h"
#include "util/mallocHelper.h"
#include "util/windows/unicode.h"
#include <windows.h>
#include <hidsdi.h>
static const char* detectKnownGamepad(uint32_t vendorId, uint32_t productId)
{
switch (vendorId)
{
// Nintendo
case 0x057E:
{
switch (productId)
{
case 0x2006: return "Nintendo Switch Joycon L";
case 0x2007: return "Nintendo Switch Joycon R";
case 0x2009: return "Nintendo Switch Pro Controller";
case 0x200E: return "Nintendo Switch Charging Grip";
case 0x2017: return "Nintendo Switch SNES Controller";
default: return NULL;
}
}
// Sony
case 0x054C:
{
switch (productId)
{
case 0x0268: return "Sony Playstation 3 Controller";
case 0x05C4: return "Sony DualShock 4 Gen1";
case 0x09CC: return "Sony DualShock 4 Gen2";
case 0x0BA0: return "Sony PS4 Controller USB receiver";
case 0x0CE6: return "Sony DualSense";
default: return NULL;
}
}
// Microsoft
case 0x045E:
{
switch (productId)
{
case 0x02E0: return "Microsoft X-Box One S pad (Wireless)";
case 0x02FD: return "Microsoft X-Box One S pad (Wireless, 2016 FW)";
case 0x0B05: return "Microsoft X-Box One Elite Series 2 pad (Wireless)";
case 0x0B13: return "Microsoft X-Box Series X (Wireless)";
case 0x028E: return "Microsoft XBox 360";
case 0x028F: return "Microsoft XBox 360 v2";
case 0x02A1: return "Microsoft XBox 360";
case 0x0291: return "Microsoft XBox 360 USB receiver";
case 0x02A0: return "Microsoft XBox 360 Big Button IR";
case 0x02DD: return "Microsoft XBox One";
case 0xB326: return "Microsoft XBox One Firmware 2015";
case 0x02E3: return "Microsoft XBox One Elite";
case 0x02FF: return "Microsoft XBox One Elite";
case 0x02EA: return "Microsoft XBox One S";
default: return NULL;
}
}
// Logitech
case 0x046D:
{
switch (productId)
{
case 0xC216: return "Logitech F310, DirectInput";
case 0xC218: return "Logitech F510, DirectInput";
case 0xC219: return "Logitech F710, DirectInput";
case 0xC21D: return "Logitech F310";
case 0xC21E: return "Logitech F510";
case 0xC21F: return "Logitech F710";
default: return NULL;
}
}
default: return NULL;
}
}
const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFGamepadDevice */)
{
UINT nDevices = 0;
if (GetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST)))
return "GetRawInputDeviceList(NULL) failed";
if (nDevices == 0)
return "No HID devices found";
RAWINPUTDEVICELIST* FF_AUTO_FREE pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices);
if ((nDevices = GetRawInputDeviceList(pRawInputDeviceList, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT) -1)
return "GetRawInputDeviceList(pRawInputDeviceList) failed";
for (UINT i = 0; i < nDevices; ++i) {
if (pRawInputDeviceList[i].dwType != 2) continue;
HANDLE hDevice = pRawInputDeviceList[i].hDevice;
RID_DEVICE_INFO rdi;
UINT rdiSize = sizeof(rdi);
if (GetRawInputDeviceInfoW(hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) == (UINT) -1)
continue;
if (rdi.hid.usUsagePage != 1 || rdi.hid.usUsage != 5) // Gamepad
continue;
WCHAR devName[MAX_PATH] = L"";
UINT nameSize = MAX_PATH;
if (GetRawInputDeviceInfoW(hDevice, RIDI_DEVICENAME, devName, &nameSize) == (UINT) -1)
continue;
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
ffStrbufInitWS(&device->identifier, devName);
ffStrbufInit(&device->name);
const char* knownGamepad = detectKnownGamepad(rdi.hid.dwVendorId, rdi.hid.dwProductId);
if (knownGamepad)
ffStrbufSetS(&device->name, knownGamepad);
else
{
wchar_t displayName[126];
HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hHidFile && HidD_GetProductString(hHidFile, displayName, sizeof(wchar_t) * 126))
ffStrbufSetWS(&device->name, displayName);
else
ffStrbufSetF(&device->name, "Unknown gamepad %4X-%4X", rdi.hid.dwVendorId, rdi.hid.dwProductId);
}
}
return NULL;
}
-32
View File
@@ -1,32 +0,0 @@
extern "C" {
#include "gamepad.h"
}
#include <initguid.h>
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
CALLBACK BOOL DIEnumDevicesCallback(LPCDIDEVICEINSTANCEA lpddi, LPVOID pvRef)
{
FFlist* devices = (FFlist*) pvRef;
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
ffStrbufInitF(&device->identifier, "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
lpddi->guidInstance.Data1, lpddi->guidInstance.Data2, lpddi->guidInstance.Data3,
lpddi->guidInstance.Data4[0], lpddi->guidInstance.Data4[1], lpddi->guidInstance.Data4[2], lpddi->guidInstance.Data4[3],
lpddi->guidInstance.Data4[4], lpddi->guidInstance.Data4[5], lpddi->guidInstance.Data4[6], lpddi->guidInstance.Data4[7]);
ffStrbufInitS(&device->name, lpddi->tszInstanceName);
return DIENUM_CONTINUE;
}
extern "C"
const char* ffDetectGamepad(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFGamepadDevice */)
{
IDirectInput8A* dinput;
if (!SUCCEEDED(DirectInput8Create(GetModuleHandleW(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8A, (void**)&dinput, NULL)))
return "DirectInput8Create() failed";
dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, DIEnumDevicesCallback, devices, DIEDFL_ATTACHEDONLY);
dinput->Release();
return NULL;
}
+1 -1
View File
@@ -36,7 +36,7 @@ const FFlist* ffDetectGPU(const FFinstance* instance)
{
FF_DETECTION_INTERNAL_GUARD(FFlist,
ffListInit(&result, sizeof(FFGPUResult));
if(ffDetectGPUImpl(&result, instance) != NULL)
if(instance->config.gpuForceVulkan || ffDetectGPUImpl(&result, instance) != NULL)
{
const FFVulkanResult* vulkan = ffDetectVulkan(instance);
result = vulkan->gpus;
+1 -1
View File
@@ -29,7 +29,6 @@ typedef struct FFGPUMemory
typedef struct FFGPUResult
{
uint64_t id;
FFGpuType type;
FFstrbuf vendor;
FFstrbuf name;
@@ -38,6 +37,7 @@ typedef struct FFGPUResult
int coreCount;
FFGPUMemory dedicated;
FFGPUMemory shared;
uint32_t vulkanDeviceId; // Only used for vulkan
} FFGPUResult;
const FFlist* ffDetectGPU(const FFinstance* instance);
-1
View File
@@ -60,7 +60,6 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
FFGPUResult* gpu = ffListAdd(gpus);
gpu->id = 0;
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
gpu->type = FF_GPU_TYPE_UNKNOWN;
+37 -6
View File
@@ -10,6 +10,7 @@
#include <string.h>
#include <unistd.h>
#include <pci/pci.h>
#include <setjmp.h>
typedef struct PCIData
{
@@ -35,11 +36,11 @@ static void pciDetectVendorName(FFGPUResult* gpu, PCIData* pci, struct pci_dev*
pci->ffpci_lookup_name(pci->access, gpu->vendor.chars, (int) gpu->vendor.allocated, PCI_LOOKUP_VENDOR, device->vendor_id);
ffStrbufRecalculateLength(&gpu->vendor);
if(ffStrbufFirstIndexS(&gpu->vendor, "AMD") < gpu->vendor.length || ffStrbufFirstIndexS(&gpu->vendor, "ATI") < gpu->vendor.length)
if(ffStrbufContainS(&gpu->vendor, "AMD") || ffStrbufContainS(&gpu->vendor, "ATI"))
ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
else if(ffStrbufFirstIndexS(&gpu->vendor, "Intel") < gpu->vendor.length)
else if(ffStrbufContainS(&gpu->vendor, "Intel"))
ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
else if(ffStrbufFirstIndexS(&gpu->vendor, "NVIDIA") < gpu->vendor.length)
else if(ffStrbufContainS(&gpu->vendor, "NVIDIA"))
ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
}
@@ -199,8 +200,7 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
FFGPUResult* gpu = ffListAdd(results);
gpu->id = 0;
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
ffStrbufInit(&gpu->vendor);
pciDetectVendorName(gpu, pci, device);
@@ -220,6 +220,30 @@ static void pciHandleDevice(const FFinstance* instance, FFlist* results, PCIData
pciDetectTemperatur(gpu, device);
}
jmp_buf pciInitJmpBuf;
static void __attribute__((__noreturn__))
handlePciInitError(FF_MAYBE_UNUSED char *msg, ...)
{
longjmp(pciInitJmpBuf, 1);
}
// https://github.com/pciutils/pciutils/blob/bca0412843fa650c749128ade03f35ab3e8fe2b9/lib/init.c#L186
static void __attribute__((__noreturn__))
handlePciGenericError(char *msg, ...)
{
va_list args;
va_start(args, msg);
fputs("pcilib: ", stderr);
vfprintf(stderr, msg, args);
va_end(args);
fputc('\n', stderr);
exit(1);
}
static void handlePciWarning(FF_MAYBE_UNUSED char *msg, ...)
{
// noop
}
static const char* pciDetectGPUs(const FFinstance* instance, FFlist* gpus)
{
PCIData pci;
@@ -240,7 +264,14 @@ static const char* pciDetectGPUs(const FFinstance* instance, FFlist* gpus)
#endif
pci.access = ffpci_alloc();
ffpci_init(pci.access);
pci.access->warning = handlePciWarning;
pci.access->error = handlePciInitError;
if(setjmp(pciInitJmpBuf) == 0) // https://github.com/pciutils/pciutils/issues/136
ffpci_init(pci.access);
else
return "pcilib: Cannot find any working access method.";
pci.access->error = handlePciGenericError; // set back to generic error so we don't mess up error handling in other places
ffpci_scan_bus(pci.access);
struct pci_dev* device = pci.access->devices;
+57
View File
@@ -0,0 +1,57 @@
#include "gpu.h"
#include "util/windows/unicode.h"
#include "util/windows/registry.h"
#include <inttypes.h>
const char* ffDetectGPUImpl(FFlist* gpus, FF_MAYBE_UNUSED const FFinstance* instance)
{
DISPLAY_DEVICEW displayDevice = {.cb = sizeof(displayDevice) };
wchar_t regKey[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Control\\Video\\{";
const uint32_t regKeyPrefixLength = strlen("SYSTEM\\CurrentControlSet\\Control\\Video\\{");
const uint32_t deviceKeyPrefixLength = strlen("\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\{");
for (DWORD i = 0; EnumDisplayDevicesW(NULL, i, &displayDevice, 0); ++i)
{
if (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue;
const uint32_t deviceKeyLength = (uint32_t) wcslen(displayDevice.DeviceKey);
if (wmemcmp(&displayDevice.DeviceKey[deviceKeyLength - 4], L"0000", 4) != 0) continue;
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
ffStrbufInit(&gpu->vendor);
ffStrbufInitWS(&gpu->name, displayDevice.DeviceString);
ffStrbufInit(&gpu->driver);
gpu->temperature = FF_GPU_TEMP_UNSET;
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->type = FF_GPU_TYPE_UNKNOWN;
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
if (deviceKeyLength == 100 && displayDevice.DeviceKey[deviceKeyPrefixLength - 1] == '{')
{
wmemcpy(regKey + regKeyPrefixLength, displayDevice.DeviceKey + deviceKeyPrefixLength, 100 - regKeyPrefixLength + 1);
FF_HKEY_AUTO_DESTROY hKey = NULL;
if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, regKey, &hKey, NULL)) continue;
ffRegReadStrbuf(hKey, L"DriverVersion", &gpu->driver, NULL);
ffRegReadStrbuf(hKey, L"ProviderName", &gpu->vendor, NULL);
if(ffStrbufContainS(&gpu->vendor, "AMD") || ffStrbufContainS(&gpu->vendor, "ATI"))
ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
else if(ffStrbufContainS(&gpu->vendor, "Intel"))
ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
else if(ffStrbufContainS(&gpu->vendor, "NVIDIA"))
ffStrbufSetS(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
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;
}
}
return NULL;
}
-172
View File
@@ -1,172 +0,0 @@
extern "C" {
#include "gpu.h"
#include "util/windows/unicode.h"
#include "util/windows/registry.h"
}
#include "util/windows/wmi.hpp"
#include <dxgi.h>
#include <wchar.h>
#include <inttypes.h>
static const char* detectWithRegistry(FFlist* gpus)
{
// Ref: https://github.com/lptstr/winfetch/pull/155
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\DirectX", &hKey, nullptr))
return "Open \"HKLM\\SOFTWARE\\Microsoft\\DirectX\" failed";
uint64_t lastSeen;
if(!ffRegReadUint64(hKey, L"LastSeen", &lastSeen, nullptr))
return "Read \"HKLM\\SOFTWARE\\Microsoft\\DirectX\\LastSeen\" failed";
DWORD index = 0;
wchar_t subKeyName[64];
while(true)
{
DWORD subKeySize = sizeof(subKeyName) / sizeof(*subKeyName);
if(RegEnumKeyExW(hKey, index++, subKeyName, &subKeySize, nullptr, nullptr, nullptr, nullptr) != ERROR_SUCCESS)
break;
FF_HKEY_AUTO_DESTROY hSubKey = NULL;
if(!ffRegOpenKeyForRead(hKey, subKeyName, &hSubKey, nullptr))
continue;
uint64_t adapterLastSeen;
if(!ffRegReadUint64(hSubKey, L"LastSeen", &adapterLastSeen, nullptr) || lastSeen != adapterLastSeen)
continue;
uint32_t softwareAdapter;
if(!ffRegReadUint(hSubKey, L"SoftwareAdapter", &softwareAdapter, nullptr) || softwareAdapter)
continue;
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
ffStrbufInit(&gpu->vendor);
ffStrbufInit(&gpu->name);
ffStrbufInit(&gpu->driver);
gpu->temperature = FF_GPU_TEMP_UNSET;
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->type = FF_GPU_TYPE_UNKNOWN;
gpu->id = 0;
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
ffRegReadUint64(hSubKey, L"AdapterLuid", &gpu->id, nullptr);
ffRegReadStrbuf(hSubKey, L"Description", &gpu->name, nullptr);
uint32_t vendorId;
if(ffRegReadUint(hSubKey, L"VendorId", &vendorId, nullptr))
ffStrbufAppendS(&gpu->vendor, ffGetGPUVendorString(vendorId));
uint64_t dedicatedVideoMemory = 0;
if(ffRegReadUint64(hSubKey, L"DedicatedVideoMemory", &dedicatedVideoMemory, nullptr))
gpu->type = dedicatedVideoMemory >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
uint64_t dedicatedSystemMemory, sharedSystemMemory;
if(ffRegReadUint64(hSubKey, L"DedicatedSystemMemory", &dedicatedSystemMemory, nullptr) &&
ffRegReadUint64(hSubKey, L"SharedSystemMemory", &sharedSystemMemory, nullptr))
{
gpu->dedicated.total = dedicatedVideoMemory + dedicatedSystemMemory;
gpu->shared.total = sharedSystemMemory;
}
uint64_t driverVersion;
if(ffRegReadUint64(hSubKey, L"DriverVersion", &driverVersion, nullptr))
{
ffStrbufSetF(&gpu->driver, "%" PRIu64 ".%" PRIu64 ".%" PRIu64 ".%" PRIu64,
(driverVersion >> 48) & 0xFFFF,
(driverVersion >> 32) & 0xFFFF,
(driverVersion >> 16) & 0xFFFF,
(driverVersion >> 0) & 0xFFFF);
}
}
return nullptr;
}
static const char* detectWithDxgi(FFlist* gpus)
{
IDXGIFactory1* pFactory;
if(FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)(&pFactory))))
return "CreateDXGIFactory1() failed";
for(unsigned iAdapter = 0;; ++iAdapter)
{
IDXGIAdapter1* adapter;
if(FAILED(pFactory->EnumAdapters1(iAdapter, &adapter)))
break;
DXGI_ADAPTER_DESC1 desc;
if(FAILED(adapter->GetDesc1(&desc)) || (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE))
continue;
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
gpu->dedicated.total = gpu->dedicated.total = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
ffStrbufInit(&gpu->vendor);
ffStrbufAppendS(&gpu->vendor, ffGetGPUVendorString(desc.VendorId));
gpu->id = (uint64_t&)desc.AdapterLuid;
ffStrbufInit(&gpu->name);
ffStrbufSetWS(&gpu->name, desc.Description);
ffStrbufInit(&gpu->driver);
gpu->type = desc.DedicatedVideoMemory >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
gpu->dedicated.total = desc.DedicatedVideoMemory + desc.DedicatedSystemMemory;
gpu->shared.total = desc.SharedSystemMemory;
adapter->Release();
gpu->temperature = FF_GPU_TEMP_UNSET;
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
}
pFactory->Release();
return nullptr;
}
static const char* detectMemoryUsage(FFlist* gpus)
{
FFWmiQuery query(L"SELECT Name, DedicatedUsage, SharedUsage FROM Win32_PerfRawData_GPUPerformanceCounters_GPUAdapterMemory", nullptr);
if(!query)
return "Query WMI service failed";
FF_STRBUF_AUTO_DESTROY name;
ffStrbufInit(&name);
while(FFWmiRecord record = query.next())
{
record.getString(L"Name", &name); // luid_0x00000000_0x000146E8_phys_0
assert(name.length == strlen("luid_0x00000000_0x000146E8_phys_0"));
ffStrbufSubstrBefore(&name, strlen("luid_0x00000000_0x000146E8")); // luid_0x00000000_0x000146E8
ffStrbufSubstrAfter(&name, strlen("luid_0x00000000_0x") - 1); // 000146E8
uint64_t luid = strtoull(name.chars, nullptr, 16);
FF_LIST_FOR_EACH(FFGPUResult, gpu, *gpus)
{
if (gpu->id != luid) continue;
record.getUnsigned(L"DedicatedUsage", &gpu->dedicated.used);
record.getUnsigned(L"SharedUsage", &gpu->shared.used);
break;
}
}
return nullptr;
}
extern "C"
const char* ffDetectGPUImpl(FFlist* gpus, FF_MAYBE_UNUSED const FFinstance* instance)
{
const char* error = detectWithRegistry(gpus);
if (error)
error = detectWithDxgi(gpus);
if (!error && gpus->length > 0 && instance->config.allowSlowOperations)
detectMemoryUsage(gpus);
return error;
}
+2 -6
View File
@@ -2,14 +2,10 @@
#include <string.h>
#include <ctype.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#ifdef __FreeBSD__
#include <sys/socket.h> // FreeBSD needs this for AF_INET
#endif
static void addNewIp(FFlist* list, const char* name, const char* addr, bool ipv6)
{
@@ -31,7 +27,7 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results)
continue;
// loop back
if (strncmp(ifa->ifa_name, "lo", 2) == 0 && (ifa->ifa_name[2] == '\0' || isdigit(ifa->ifa_name[2])) && !instance->config.localIpShowLoop)
if ((ifa->ifa_flags & IFF_LOOPBACK) && !instance->config.localIpShowLoop)
continue;
if (instance->config.localIpNamePrefix.length && strncmp(ifa->ifa_name, instance->config.localIpNamePrefix.chars, instance->config.localIpNamePrefix.length) != 0)
+8 -2
View File
@@ -3,8 +3,14 @@
#ifndef FF_INCLUDED_detection_memory_memory
#define FF_INCLUDED_detection_memory_memory
#include "detection/storage.h"
#include "fastfetch.h"
void ffDetectMemory(FFMemoryStorage* result);
typedef struct FFMemoryResult
{
uint64_t bytesUsed;
uint64_t bytesTotal;
} FFMemoryResult;
const char* ffDetectMemory(FFMemoryResult* result);
#endif
+7 -13
View File
@@ -3,31 +3,25 @@
#include <string.h>
#include <mach/mach.h>
#include <sys/sysctl.h>
#include <unistd.h>
void ffDetectMemory(FFMemoryStorage* ram)
const char* ffDetectMemory(FFMemoryResult* ram)
{
size_t length = sizeof(ram->bytesTotal);
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0))
{
ffStrbufAppendS(&ram->error, "Failed to read hw.memsize");
return;
}
return "Failed to read hw.memsize";
uint32_t pagesize;
length = sizeof(pagesize);
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pagesize, &length, NULL, 0))
{
ffStrbufAppendS(&ram->error, "Failed to read hw.pagesize");
return;
}
return "Failed to read hw.pagesize";
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
vm_statistics64_data_t vmstat;
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
{
ffStrbufAppendS(&ram->error, "Failed to read host_statistics64");
return;
}
return "Failed to read host_statistics64";
ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * pagesize;
return NULL;
}
+8 -11
View File
@@ -1,24 +1,21 @@
#include "memory.h"
#include "common/sysctl.h"
void ffDetectMemory(FFMemoryStorage* ram)
const char* ffDetectMemory(FFMemoryResult* ram)
{
uint32_t pageSize = (uint32_t) ffSysctlGetInt("hw.pagesize", 0);
if(pageSize == 0)
{
ffStrbufAppendS(&ram->error, "Failed to read hw.pagesize");
return;
}
uint32_t pageSize;
uint64_t length = sizeof(pageSize);
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pageSize, &length, NULL, 0))
return "Failed to read hw.pagesize";
ram->bytesTotal = (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_page_count", 0) * pageSize;
if(ram->bytesTotal == 0)
{
ffStrbufAppendS(&ram->error, "Failed to read vm.stats.vm.v_page_count");
return;
}
return "Failed to read vm.stats.vm.v_page_count";
ram->bytesUsed = ram->bytesTotal
- (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_free_count", 0) * pageSize
- (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_inactive_count", 0) * pageSize
;
return NULL;
}
+7 -10
View File
@@ -1,18 +1,16 @@
#include "memory.h"
#include "util/mallocHelper.h"
#include <stdlib.h>
#include <string.h>
void ffDetectMemory(FFMemoryStorage* ram)
const char* ffDetectMemory(FFMemoryResult* ram)
{
FILE* meminfo = fopen("/proc/meminfo", "r");
if(meminfo == NULL)
{
ffStrbufAppendS(&ram->error, "Failed to open /proc/meminfo");
return;
}
return "Failed to open /proc/meminfo";
char* line = NULL;
char* FF_AUTO_FREE line = NULL;
size_t len = 0;
uint32_t memTotal = 0,
@@ -32,14 +30,13 @@ void ffDetectMemory(FFMemoryStorage* ram)
sscanf(line, "SReclaimable: %u", &sReclaimable);
}
if(line != NULL)
free(line);
fclose(meminfo);
ram->bytesTotal = memTotal * (uint64_t) 1024;
if(ram->bytesTotal == 0)
ffStrbufAppendS(&ram->error, "Failed to read MemTotal");
return "Failed to read MemTotal";
else
ram->bytesUsed = (memTotal + shmem - memFree - buffers - cached - sReclaimable) * (uint64_t) 1024;
return NULL;
}
+6 -5
View File
@@ -1,15 +1,16 @@
#include "memory.h"
void ffDetectMemory(FFMemoryStorage* ram)
#include <windows.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
MEMORYSTATUSEX statex = {
.dwLength = sizeof(statex),
};
if (!GlobalMemoryStatusEx(&statex))
{
ffStrbufAppendS(&ram->error, "GlobalMemoryStatusEx() failed");
return;
}
return "GlobalMemoryStatusEx() failed";
ram->bytesTotal = statex.ullTotalPhys;
ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys;
return NULL;
}
+102
View File
@@ -0,0 +1,102 @@
#include "detection/opencl/opencl.h"
#if defined(FF_HAVE_OPENCL) || defined(__APPLE__)
#include "common/library.h"
#include "common/parsing.h"
#include "util/stringUtils.h"
#include <string.h>
#define CL_TARGET_OPENCL_VERSION 100
#ifdef FF_HAVE_OPENCL
#include <CL/cl.h>
#else
#include <OpenCL/cl.h>
#endif
typedef struct OpenCLData
{
FF_LIBRARY_SYMBOL(clGetPlatformIDs)
FF_LIBRARY_SYMBOL(clGetDeviceIDs)
FF_LIBRARY_SYMBOL(clGetDeviceInfo)
} OpenCLData;
static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result)
{
cl_platform_id platformID;
cl_uint numPlatforms;
data->ffclGetPlatformIDs(1, &platformID, &numPlatforms);
if(numPlatforms == 0)
return "clGetPlatformIDs returned 0 platforms";
cl_device_id deviceID;
cl_uint numDevices;
data->ffclGetDeviceIDs(platformID, CL_DEVICE_TYPE_GPU, 1, &deviceID, &numDevices);
if(numDevices == 0)
data->ffclGetDeviceIDs(platformID, CL_DEVICE_TYPE_ALL, 1, &deviceID, &numDevices);
if(numDevices == 0)
return "clGetDeviceIDs returned 0 devices";
char version[64];
data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VERSION, sizeof(version), version, NULL);
if(!ffStrSet(version))
return "clGetDeviceInfo returned NULL or empty string";
const char* versionPretty = version;
const char* prefix = "OpenCL ";
if(strncasecmp(version, prefix, sizeof(prefix) - 1) == 0)
versionPretty = version + sizeof(prefix) - 1;
ffStrbufSetS(&result->version, versionPretty);
ffStrbufEnsureFree(&result->device, 128);
data->ffclGetDeviceInfo(deviceID, CL_DEVICE_NAME, result->device.allocated, result->device.chars, NULL);
ffStrbufRecalculateLength(&result->device);
ffStrbufEnsureFree(&result->vendor, 32);
data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VENDOR, result->vendor.allocated, result->vendor.chars, NULL);
ffStrbufRecalculateLength(&result->vendor);
return NULL;
}
#endif // defined(FF_HAVE_OPENCL) || defined(__APPLE__)
const char* ffDetectOpenCL(FFinstance* instance, FFOpenCLResult* result)
{
#ifdef FF_HAVE_OPENCL
OpenCLData data;
FF_LIBRARY_LOAD(opencl, &instance->config.libOpenCL, "dlopen libOpenCL"FF_LIBRARY_EXTENSION" failed",
#ifdef _WIN32
"OpenCL"FF_LIBRARY_EXTENSION, -1,
#endif
"libOpenCL"FF_LIBRARY_EXTENSION, 1
);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetPlatformIDs);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceIDs);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceInfo);
return openCLHandleData(&data, result);
#elif defined(__APPLE__) // FF_HAVE_OPENCL
FF_UNUSED(instance);
OpenCLData data;
data.ffclGetPlatformIDs = clGetPlatformIDs;
data.ffclGetDeviceIDs = clGetDeviceIDs;
data.ffclGetDeviceInfo = clGetDeviceInfo;
return openCLHandleData(&data, result);
#else
FF_UNUSED(instance, result);
return "Fastfetch was build without OpenCL support";
#endif // FF_HAVE_OPENCL
}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#ifndef FF_INCLUDED_detection_opencl_opencl
#define FF_INCLUDED_detection_opencl_opencl
#include "fastfetch.h"
typedef struct FFOpenCLResult
{
FFstrbuf version;
FFstrbuf device;
FFstrbuf vendor;
} FFOpenCLResult;
const char* ffDetectOpenCL(FFinstance* instance, FFOpenCLResult* result);
#endif
-1
View File
@@ -2,7 +2,6 @@
#include "common/printing.h"
#include "opengl.h"
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
#include <GL/gl.h>
#ifndef GL_SHADING_LANGUAGE_VERSION // For WGL
+2 -1
View File
@@ -14,7 +14,8 @@ typedef struct FFPackagesResult
uint32_t dpkg;
uint32_t emerge;
uint32_t eopkg;
uint32_t flatpak;
uint32_t flatpakSystem;
uint32_t flatpakUser;
uint32_t nixDefault;
uint32_t nixSystem;
uint32_t nixUser;
+19 -5
View File
@@ -207,6 +207,19 @@ static uint32_t getSnap(FFstrbuf* baseDir)
return result > 0 ? result - 1 : 0;
}
static uint32_t getFlatpak(FFstrbuf* baseDir, const char* dirname)
{
uint32_t baseDirLength = baseDir->length;
ffStrbufAppendS(baseDir, dirname);
uint32_t result =
getNumElements(baseDir, "/app", DT_DIR) +
getNumElements(baseDir, "/runtime", DT_DIR);
ffStrbufSubstrBefore(baseDir, baseDirLength);
return result;
}
#ifdef FF_HAVE_RPM
#include "common/library.h"
#include <rpm/rpmlib.h>
@@ -258,7 +271,7 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, FFPa
packageCounts->dpkg += getNumStrings(baseDir, "/var/lib/dpkg/status", "Status: ");
packageCounts->emerge += countFilesRecursive(baseDir, "/var/db/pkg", "SIZE");
packageCounts->eopkg += getNumElements(baseDir, "/var/lib/eopkg/package", DT_DIR);
packageCounts->flatpak += getNumElements(baseDir, "/var/lib/flatpak/app", DT_DIR);
packageCounts->flatpakSystem += getFlatpak(baseDir, "/var/lib/flatpak");
packageCounts->nixDefault += getNixPackages(baseDir, "/nix/var/nix/profiles/default");
packageCounts->nixSystem += getNixPackages(baseDir, "/run/current-system");
packageCounts->pacman += getNumElements(baseDir, "/var/lib/pacman/local", DT_DIR);
@@ -266,6 +279,8 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, FFPa
packageCounts->rpm += getSQLite3Int(instance, baseDir, "/var/lib/rpm/rpmdb.sqlite", "SELECT count(blob) FROM Packages");
packageCounts->snap += getSnap(baseDir);
packageCounts->xbps += getXBPS(baseDir, "/var/db/xbps");
packageCounts->brewCask += getNumElements(baseDir, "/home/linuxbrew/.linuxbrew/Caskroom", DT_DIR);
packageCounts->brew += getNumElements(baseDir, "/home/linuxbrew/.linuxbrew/Cellar", DT_DIR);
}
static void getPackageCountsRegular(const FFinstance* instance, FFstrbuf* baseDir, FFPackagesResult* packageCounts)
@@ -314,11 +329,11 @@ static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDi
void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result)
{
FFstrbuf baseDir;
FF_STRBUF_AUTO_DESTROY baseDir;
ffStrbufInitA(&baseDir, 512);
ffStrbufAppendS(&baseDir, FASTFETCH_TARGET_DIR_ROOT);
if(ffStrbufIgnCaseCompS(&(ffDetectOS(instance)->id), "bedrock") == 0)
if(ffStrbufIgnCaseEqualS(&ffDetectOS(instance)->id, "bedrock"))
getPackageCountsBedrock(instance, &baseDir, result);
else
getPackageCountsRegular(instance, &baseDir, result);
@@ -333,6 +348,5 @@ void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result)
ffStrbufSet(&baseDir, &instance->state.platform.homeDir);
result->nixUser = getNixPackages(&baseDir, "/.nix-profile");
ffStrbufDestroy(&baseDir);
result->flatpakUser = getFlatpak(&baseDir, "/.local/share/flatpak");
}
+1 -1
View File
@@ -5,6 +5,6 @@
#include "fastfetch.h"
uint32_t ffDetectProcesses(FFstrbuf* error);
const char* ffDetectProcesses(uint32_t* result);
#endif
+5 -6
View File
@@ -6,15 +6,14 @@
#include <sys/user.h>
#endif
uint32_t ffDetectProcesses(FFstrbuf* error)
const char* ffDetectProcesses(uint32_t* result)
{
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
size_t length;
if(sysctl(request, sizeof(request) / sizeof(*request), NULL, &length, NULL, 0) != 0)
{
ffStrbufAppendS(error, "sysctl() failed");
return 0;
}
return (uint32_t)(length / sizeof(struct kinfo_proc));
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_ALL}) failed";
*result = (uint32_t)(length / sizeof(struct kinfo_proc));
return NULL;
}
+5 -3
View File
@@ -2,10 +2,12 @@
#include <sys/sysinfo.h>
uint32_t ffDetectProcesses(FFstrbuf* error)
const char* ffDetectProcesses(uint32_t* result)
{
struct sysinfo info;
if(sysinfo(&info) != 0)
ffStrbufAppendS(error, "sysinfo() failed");
return (uint32_t) info.procs;
return "sysinfo() failed";
*result = (uint32_t) info.procs;
return NULL;
}
@@ -0,0 +1,27 @@
#include "processes.h"
#include "util/mallocHelper.h"
#include <ntstatus.h>
#include <winternl.h>
const char* ffDetectProcesses(uint32_t* result)
{
ULONG size = 0;
if(NtQuerySystemInformation(SystemProcessInformation, NULL, 0, &size) != STATUS_INFO_LENGTH_MISMATCH)
return "NtQuerySystemInformation(SystemProcessInformation, NULL) failed";
size += sizeof(SystemProcessInformation) * 5; //What if new processes are created during two syscalls?
SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PROCESS_INFORMATION*)malloc(size);
if(!pstart)
return "malloc(size) failed";
if(!NT_SUCCESS(NtQuerySystemInformation(SystemProcessInformation, pstart, size, NULL)))
return "NtQuerySystemInformation(SystemProcessInformation, pstart) failed";
*result = 1; //Init with 1 because we test for ptr->NextEntryOffset
for (SYSTEM_PROCESS_INFORMATION* ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*)((uint8_t*)ptr + ptr->NextEntryOffset))
++*result;
return NULL;
}
@@ -1,64 +0,0 @@
extern "C" {
#include "processes.h"
#include "util/mallocHelper.h"
}
#ifdef FF_USE_WIN_NTAPI
#include <ntstatus.h>
#include <winternl.h>
uint32_t ffDetectProcesses(FFstrbuf* error)
{
ULONG size = 0;
if(NtQuerySystemInformation(SystemProcessInformation, nullptr, 0, &size) != STATUS_INFO_LENGTH_MISMATCH)
{
ffStrbufAppendS(error, "NtQuerySystemInformation(SystemProcessInformation, NULL) failed");
return 0;
}
size += sizeof(SystemProcessInformation) * 5; //What if new processes are created during two syscalls?
SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PROCESS_INFORMATION*)malloc(size);
if(!pstart)
{
ffStrbufAppendF(error, "malloc(%u) failed", (unsigned)size);
return 0;
}
if(!NT_SUCCESS(NtQuerySystemInformation(SystemProcessInformation, pstart, size, nullptr)))
{
ffStrbufAppendS(error, "NtQuerySystemInformation(SystemProcessInformation, pstart) failed");
return 0;
}
uint32_t result = 1; //Init with 1 because we test for ptr->NextEntryOffset
for (auto ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*)((uint8_t*)ptr + ptr->NextEntryOffset))
++result;
return result;
}
#else
#include "util/windows/wmi.hpp"
uint32_t ffDetectProcesses(FFstrbuf* error)
{
FFWmiQuery query(L"SELECT NumberOfProcesses FROM Win32_OperatingSystem", error);
if(!query)
return 0;
if(FFWmiRecord record = query.next())
{
uint64_t result = 0;
record.getUnsigned(L"NumberOfProcesses", &result);
return (uint32_t)result;
}
else
{
ffStrbufAppendS(error, "No Wmi result returned");
return 0;
}
}
#endif
+2
View File
@@ -5,6 +5,8 @@
#include "fastfetch.h"
#define FF_SOUND_VOLUME_UNKNOWN 255
typedef struct FFSoundDevice
{
FFstrbuf identifier;
+29 -1
View File
@@ -44,7 +44,7 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* de
FFSoundDevice* device = (FFSoundDevice*) ffListAdd(devices);
device->main = deviceId == mainDeviceId;
device->active = false;
device->volume = 0;
device->volume = FF_SOUND_VOLUME_UNKNOWN;
ffStrbufInitF(&device->identifier, "%u", (unsigned) deviceId);
ffStrbufInit(&device->name);
@@ -67,6 +67,34 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* de
kAudioObjectPropertyElementMain
}, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError)
device->volume = (uint8_t) (volume * 100 + 0.5);
else
{
// Try detecting volume from channels
uint32_t channels[2];
dataSize = sizeof(channels);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress){
kAudioDevicePropertyPreferredChannelsForStereo,
kAudioObjectPropertyScopeOutput,
kAudioObjectPropertyElementMain
}, 0, NULL, &dataSize, channels) == kAudioHardwareNoError)
{
dataSize = sizeof(volume);
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress){
kAudioDevicePropertyVolumeScalar,
kAudioObjectPropertyScopeOutput,
channels[0]
}, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError)
{
float temp;
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress){
kAudioDevicePropertyVolumeScalar,
kAudioObjectPropertyScopeOutput,
channels[1]
}, 0, NULL, &dataSize, &temp) == kAudioHardwareNoError)
device->volume = (uint8_t) ((volume + temp) / 2 * 100 + 0.5);
}
}
}
}
CFStringRef name;
+2 -4
View File
@@ -62,12 +62,10 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_U
FFSoundDevice* device = (FFSoundDevice*) ffListAdd(devices);
device->main = wcscmp(mainDeviceId, immDeviceId) == 0;
device->active = !!(immState & DEVICE_STATE_ACTIVE);
device->volume = 0;
ffStrbufInit(&device->identifier);
device->volume = FF_SOUND_VOLUME_UNKNOWN;
ffStrbufInitWS(&device->identifier, immDeviceId);
ffStrbufInit(&device->name);
ffStrbufSetWS(&device->identifier, immDeviceId);
{
PROPVARIANT __attribute__((__cleanup__(PropVariantClear))) friendlyName;
PropVariantInit(&friendlyName);
-15
View File
@@ -1,15 +0,0 @@
#pragma once
#ifndef FF_INCLUDED_detection_storage
#define FF_INCLUDED_detection_storage
#include "fastfetch.h"
typedef struct FFMemoryStorage
{
FFstrbuf error;
uint64_t bytesUsed;
uint64_t bytesTotal;
} FFMemoryStorage;
#endif
+8 -2
View File
@@ -3,8 +3,14 @@
#ifndef FF_INCLUDED_detection_swap_swap
#define FF_INCLUDED_detection_swap_swap
#include "detection/storage.h"
#include "fastfetch.h"
void ffDetectSwap(FFMemoryStorage* result);
typedef struct FFSwapResult
{
uint64_t bytesUsed;
uint64_t bytesTotal;
} FFSwapResult;
const char* ffDetectSwap(FFSwapResult* result);
#endif
+3 -5
View File
@@ -3,16 +3,14 @@
#include <mach/mach.h>
#include <sys/sysctl.h>
void ffDetectSwap(FFMemoryStorage* swap)
const char* ffDetectSwap(FFSwapResult* swap)
{
struct xsw_usage xsw;
size_t size = sizeof(xsw);
if(sysctl((int[]){ CTL_VM, VM_SWAPUSAGE }, 2, &xsw, &size, NULL, 0) != 0)
{
ffStrbufAppendS(&swap->error, "Failed to read vm.swapusage");
return;
}
return "Failed to read vm.swapusage";
swap->bytesTotal = xsw.xsu_total;
swap->bytesUsed = xsw.xsu_used;
return NULL;
}
+2 -1
View File
@@ -1,8 +1,9 @@
#include "swap.h"
#include "common/sysctl.h"
void ffDetectSwap(FFMemoryStorage* swap)
const char* ffDetectSwap(FFSwapResult* swap)
{
swap->bytesTotal = (uint64_t)ffSysctlGetInt64("vm.swap_total", 0);
swap->bytesUsed = (uint64_t)ffSysctlGetInt64("vm.swap_reserved", 0);
return NULL;
}
+4 -2
View File
@@ -2,12 +2,14 @@
#include <sys/sysinfo.h>
void ffDetectSwap(FFMemoryStorage* swap)
const char* ffDetectSwap(FFSwapResult* swap)
{
struct sysinfo info;
if(sysinfo(&info) != 0)
ffStrbufAppendS(&swap->error, "sysinfo() failed");
return "sysinfo() failed";
swap->bytesTotal = info.totalswap * (uint64_t) info.mem_unit;
swap->bytesUsed = (info.totalswap - info.freeswap) * (uint64_t) info.mem_unit;
return NULL;
}
+31
View File
@@ -0,0 +1,31 @@
#include "swap.h"
#include "util/mallocHelper.h"
#include <winternl.h>
#include <ntstatus.h>
#include <windows.h>
const char* ffDetectSwap(FFSwapResult* swap)
{
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);
ULONG size = sizeof(SYSTEM_PAGEFILE_INFORMATION);
SYSTEM_PAGEFILE_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PAGEFILE_INFORMATION*)malloc(size);
while(true)
{
NTSTATUS status = NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size);
if(status == STATUS_INFO_LENGTH_MISMATCH)
{
if(!(pstart = (SYSTEM_PAGEFILE_INFORMATION*)realloc(pstart, size)))
return "realloc(pstart, size) failed";
}
else if(!NT_SUCCESS(status))
return "NtQuerySystemInformation(SystemPagefileInformation, size) failed";
break;
}
swap->bytesUsed = (uint64_t)pstart->TotalUsed * sysInfo.dwPageSize;
swap->bytesTotal = (uint64_t)pstart->CurrentSize * sysInfo.dwPageSize;
return NULL;
}
-64
View File
@@ -1,64 +0,0 @@
extern "C" {
#include "swap.h"
#include "util/mallocHelper.h"
}
#ifdef FF_USE_WIN_NTAPI
#include <winternl.h>
#include <ntstatus.h>
extern "C"
void ffDetectSwap(FFMemoryStorage* swap)
{
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);
ULONG size = sizeof(SYSTEM_PAGEFILE_INFORMATION);
SYSTEM_PAGEFILE_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PAGEFILE_INFORMATION*)malloc(size);
while(true)
{
NTSTATUS status = NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size);
if(status == STATUS_INFO_LENGTH_MISMATCH)
{
if(!(pstart = (SYSTEM_PAGEFILE_INFORMATION*)realloc(pstart, size)))
{
ffStrbufAppendF(&swap->error, "realloc(pstart, %lu) failed", size);
return;
}
}
else if(!NT_SUCCESS(status))
{
ffStrbufAppendF(&swap->error, "NtQuerySystemInformation(SystemPagefileInformation, %lu) failed", size);
return;
}
break;
}
swap->bytesUsed = (uint64_t)pstart->TotalUsed * sysInfo.dwPageSize;
swap->bytesTotal = (uint64_t)pstart->CurrentSize * sysInfo.dwPageSize;
}
#else
#include "util/windows/wmi.hpp"
extern "C"
void ffDetectSwapImpl(FFMemoryStorage* swap)
{
FFWmiQuery query(L"SELECT AllocatedBaseSize, CurrentUsage FROM Win32_PageFileUsage", &swap->error);
if(!query)
return;
if(FFWmiRecord record = query.next())
{
//MB
record.getUnsigned(L"AllocatedBaseSize", &swap->bytesTotal);
record.getUnsigned(L"CurrentUsage", &swap->bytesUsed);
swap->bytesTotal *= 1024 * 1024;
swap->bytesUsed *= 1024 * 1024;
}
else
ffStrbufInitS(&swap->error, "No Wmi result returned");
}
#endif
+25
View File
@@ -0,0 +1,25 @@
extern "C"
{
#include "temps_windows.h"
}
#include "util/windows/wmi.hpp"
extern "C"
const char* ffDetectSmbiosTemp(double* current, double* critical)
{
// Requires Administrator priviledges
// https://wutils.com/wmi/root/wmi/msacpi_thermalzonetemperature/#properties
FFWmiQuery query(L"SELECT CurrentTemperature, CriticalTripPoint FROM MSAcpi_ThermalZoneTemperature WHERE Active = TRUE", nullptr, FFWmiNamespace::WMI);
if(!query)
return "Query WMI service failed";
if(FFWmiRecord record = query.next())
{
if (current && record.getReal(L"CurrentTemperature", current)) // In tenth of degrees Kelvin
*current = *current / 10 - 273.15;
if (critical && record.getReal(L"CriticalTripPoint", critical)) // In tenth of degrees Kelvin
*critical = *critical / 10 - 273.15;
}
return "No WMI result returned";
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
#ifndef FF_INCLUDED_detection_temps_windows
#define FF_INCLUDED_detection_temps_windows
const char* ffDetectSmbiosTemp(double* current, double* critical);
#endif
+61 -41
View File
@@ -4,7 +4,8 @@
#include "detection/internal.h"
#include "detection/terminalshell/terminalshell.h"
static void detectAlacritty(const FFinstance* instance, FFTerminalFontResult* terminalFont) {
static void detectAlacritty(const FFinstance* instance, FFTerminalFontResult* terminalFont)
{
FFstrbuf fontName;
ffStrbufInit(&fontName);
@@ -65,6 +66,7 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont)
}
#if defined(_WIN32) || defined(__linux__)
#ifdef FF_HAVE_LIBCJSON
#include "common/library.h"
@@ -84,9 +86,11 @@ typedef struct CJSONData
FF_LIBRARY_SYMBOL(cJSON_GetNumberValue)
FF_LIBRARY_SYMBOL(cJSON_IsArray)
FF_LIBRARY_SYMBOL(cJSON_Delete)
cJSON* root;
} CJSONData;
static const char* detectWTProfile(CJSONData* cjsonData, cJSON* profile, FFstrbuf* name, int* size)
static const char* detectWTProfile(CJSONData* cjsonData, cJSON* profile, FFstrbuf* name, double* size)
{
if(!cjsonData->ffcJSON_IsObject(profile))
return "cJSON_IsObject(profile) returns false";
@@ -105,16 +109,22 @@ static const char* detectWTProfile(CJSONData* cjsonData, cJSON* profile, FFstrbu
{
cJSON* psize = cjsonData->ffcJSON_GetObjectItemCaseSensitive(font, "size");
if(cjsonData->ffcJSON_IsNumber(psize))
*size = (int)cjsonData->ffcJSON_GetNumberValue(psize);
*size = cjsonData->ffcJSON_GetNumberValue(psize);
}
return NULL;
}
static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* content, FFstrbuf* name, int* size)
static inline void wrapCjsonFree(CJSONData* data)
{
CJSONData cjsonData;
assert(data);
if (data->root)
data->ffcJSON_Delete(data->root);
}
FF_LIBRARY_LOAD(libcjson, &instance->config.libcJSON, "dlopen libcjson"FF_LIBRARY_EXTENSION" failed", "libcjson"FF_LIBRARY_EXTENSION, 1)
static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* content, FFstrbuf* name, double* size)
{
FF_LIBRARY_LOAD(libcjson, &instance->config.libcJSON, "dlopen libcjson" FF_LIBRARY_EXTENSION " failed", "libcjson"FF_LIBRARY_EXTENSION, 1)
CJSONData __attribute__((__cleanup__(wrapCjsonFree))) cjsonData = {}; // Make sure cjsonData is destroyed before libcjson is dlclosed
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_Parse, cJSON_Parse@4)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_IsObject, cJSON_IsObject@4)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_GetObjectItemCaseSensitive, cJSON_GetObjectItemCaseSensitive@8)
@@ -125,23 +135,15 @@ static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* conten
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_IsArray, cJSON_IsArray@4)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(libcjson, cjsonData, cJSON_Delete, cJSON_Delete@4)
const char* error = NULL;
cJSON* root = cjsonData.ffcJSON_Parse(content->chars);
cJSON* root = cjsonData.root = cjsonData.ffcJSON_Parse(content->chars);
if(!cjsonData.ffcJSON_IsObject(root))
{
error = "cJSON_Parse() failed";
goto exit;
}
return "cJSON_Parse() failed";
cJSON* profiles = cjsonData.ffcJSON_GetObjectItemCaseSensitive(root, "profiles");
if(!cjsonData.ffcJSON_IsObject(profiles))
{
error = "cJSON_GetObjectItemCaseSensitive(root, \"profiles\") failed";
goto exit;
}
return "cJSON_GetObjectItemCaseSensitive(root, \"profiles\") failed";
FFstrbuf wtProfileId;
FF_STRBUF_AUTO_DESTROY wtProfileId;
ffStrbufInitS(&wtProfileId, getenv("WT_PROFILE_ID"));
ffStrbufTrim(&wtProfileId, '\'');
if(wtProfileId.length > 0)
@@ -165,19 +167,16 @@ static const char* detectFromWTImpl(const FFinstance* instance, FFstrbuf* conten
}
}
}
ffStrbufDestroy(&wtProfileId);
cJSON* defaults = cjsonData.ffcJSON_GetObjectItemCaseSensitive(profiles, "defaults");
detectWTProfile(&cjsonData, defaults, name, size);
if(defaults)
detectWTProfile(&cjsonData, defaults, name, size);
if(name->length == 0)
ffStrbufSetS(name, "Cascadia Mono");
if(*size < 0)
*size = 12;
exit:
cjsonData.ffcJSON_Delete(root);
return error;
return NULL;
}
#ifdef _WIN32
@@ -189,7 +188,7 @@ exit:
static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont)
{
//https://learn.microsoft.com/en-us/windows/terminal/install#settings-json-file
FFstrbuf json;
FF_STRBUF_AUTO_DESTROY json;
ffStrbufInit(&json);
const char* error = NULL;
@@ -250,52 +249,48 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbu
if(error)
{
ffStrbufAppendS(&terminalFont->error, error);
ffStrbufDestroy(&json);
return;
}
ffStrbufTrimRight(&json, '\n');
if(json.length == 0)
{
ffStrbufAppendS(&terminalFont->error, "Cannot find file \"settings.json\"");
ffStrbufDestroy(&json);
return;
}
FFstrbuf name;
FF_STRBUF_AUTO_DESTROY name;
ffStrbufInit(&name);
int size = -1;
double size = -1;
error = detectFromWTImpl(instance, &json, &name, &size);
ffStrbufDestroy(&json);
if(error)
ffStrbufAppendS(&terminalFont->error, error);
else
{
char sizeStr[16];
snprintf(sizeStr, sizeof(sizeStr), "%d", size);
snprintf(sizeStr, sizeof(sizeStr), "%g", size);
ffFontInitValues(&terminalFont->font, name.chars, sizeStr);
}
ffStrbufDestroy(&name);
}
#else
#else //FF_HAVE_CJSON
static void detectFromWindowsTeriminal(const FFinstance* instance, const FFstrbuf* terminalExe, FFTerminalFontResult* terminalFont)
{
FF_UNUSED(instance, terminalExe, terminalFont);
ffStrbufAppendS(&terminalFont->error, "Fastfetch was built without libcjson support");
ffStrbufAppendS(&terminalFont->error, "Fastfetch was built without libcJSON support");
}
#endif
#endif //FF_HAVE_CJSON
#endif //defined(_WIN32) || defined(__linux__)
FF_MAYBE_UNUSED static bool detectKitty(const FFinstance* instance, FFTerminalFontResult* result)
{
FFstrbuf fontName;
FF_STRBUF_AUTO_DESTROY fontName;
ffStrbufInit(&fontName);
FFstrbuf fontSize;
FF_STRBUF_AUTO_DESTROY fontSize;
ffStrbufInit(&fontSize);
FFpropquery fontQuery[] = {
@@ -313,9 +308,6 @@ FF_MAYBE_UNUSED static bool detectKitty(const FFinstance* instance, FFTerminalFo
ffFontInitValues(&result->font, fontName.chars, fontSize.chars);
ffStrbufDestroy(&fontName);
ffStrbufDestroy(&fontSize);
return true;
}
@@ -378,6 +370,32 @@ static bool detectWezterm(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminal
return true;
}
static bool detectTabby(FF_MAYBE_UNUSED const FFinstance* instance, FFTerminalFontResult* result)
{
FF_STRBUF_AUTO_DESTROY fontName;
ffStrbufInit(&fontName);
FF_STRBUF_AUTO_DESTROY fontSize;
ffStrbufInit(&fontSize);
FFpropquery fontQuery[] = {
{"font: ", &fontName},
{"fontSize: ", &fontSize},
};
if(!ffParsePropFileConfigValues(instance, "tabby/config.yaml", 2, fontQuery))
return false;
if(fontName.length == 0)
ffStrbufSetS(&fontName, "monospace");
if(fontSize.length == 0)
ffStrbufSetS(&fontSize, "14");
ffFontInitValues(&result->font, fontName.chars, fontSize.chars);
return true;
}
void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont);
static bool detectTerminalFontCommon(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont)
@@ -388,6 +406,8 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina
detectTerminator(instance, terminalFont);
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "wezterm-gui"))
detectWezterm(instance, terminalFont);
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "tabby"))
detectTabby(instance, terminalFont);
#ifndef _WIN32
else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "kitty"))
@@ -86,7 +86,8 @@ static void detectWarpTerminal(const FFinstance* instance, FFTerminalFontResult*
void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont)
{
if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "iterm.app") == 0)
if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "iterm.app") == 0 ||
ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "iTermServer-"))
detectIterm2(instance, terminalFont);
else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "Apple_Terminal") == 0)
detectAppleTerminal(terminalFont);
@@ -193,6 +193,34 @@ static void detectDeepinTerminal(const FFinstance* instance, FFTerminalFontResul
ffStrbufDestroy(&fontSize);
}
static void detectFootTerminal(const FFinstance* instance, FFTerminalFontResult* terminalFont)
{
FF_STRBUF_AUTO_DESTROY font;
ffStrbufInit(&font);
if (!ffParsePropFileConfig(instance, "foot/foot.ini", "font=", &font) || !ffStrSet(font.chars))
{
ffFontInitValues(&terminalFont->font, "monospace", "8");
return;
}
//Sarasa Term SC Nerd:size=8
uint32_t colon = ffStrbufFirstIndexC(&font, ':');
if(colon == font.length)
{
ffFontInitValues(&terminalFont->font, font.chars, "8");
return;
}
uint32_t equal = ffStrbufNextIndexS(&font, colon, "size=");
font.chars[colon] = 0;
if (equal == font.length)
{
ffFontInitValues(&terminalFont->font, font.chars, "8");
return;
}
ffFontInitValues(&terminalFont->font, font.chars, &font.chars[equal + strlen("size=")]);
}
void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont)
{
if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "konsole") == 0)
@@ -207,4 +235,6 @@ void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalSh
detectFromGSettings(instance, "/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile", terminalFont);
else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "deepin-terminal") == 0)
detectDeepinTerminal(instance, terminalFont);
else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "foot") == 0)
detectFootTerminal(instance, terminalFont);
}
@@ -4,7 +4,7 @@
#include "terminalfont.h"
#include "util/windows/unicode.h"
#include <wincon.h>
#include <windows.h>
static void detectMintty(const FFinstance* instance, FFTerminalFontResult* terminalFont)
{
+26 -4
View File
@@ -5,6 +5,8 @@
#ifdef _WIN32
#include "util/mallocHelper.h"
#include <winver.h>
static bool getFileVersion(const char* exePath, FFstrbuf* version)
@@ -13,7 +15,7 @@ static bool getFileVersion(const char* exePath, FFstrbuf* version)
DWORD size = GetFileVersionInfoSizeA(exePath, &handle);
if(size > 0)
{
void* versionData = malloc(size);
FF_AUTO_FREE void* versionData = malloc(size);
if(GetFileVersionInfoA(exePath, handle, size, versionData))
{
VS_FIXEDFILEINFO* verInfo;
@@ -26,11 +28,9 @@ static bool getFileVersion(const char* exePath, FFstrbuf* version)
(unsigned)(( verInfo->dwFileVersionLS >> 16 ) & 0xffff),
(unsigned)(( verInfo->dwFileVersionLS >> 0 ) & 0xffff)
);
free(versionData);
return true;
}
}
free(versionData);
}
return false;
@@ -136,6 +136,11 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
return getExeVersionGeneral(exe, version); //tcsh 6.24.07 (Astron) 2022-12-21 (aarch64-apple-darwin) options wide,nls,dl,al,kan,sm,rh,color,filec
if(strcasecmp(exeName, "nu") == 0)
return getExeVersionRaw(exe, version); //0.73.0
if(strcasecmp(exeName, "python") == 0 && getenv("XONSH_VERSION"))
{
ffStrbufSetS(version, getenv("XONSH_VERSION"));
return true;
}
#ifdef _WIN32
if(strcasecmp(exeName, "powershell") == 0 || strcasecmp(exeName, "powershell_ise") == 0)
@@ -188,6 +193,16 @@ FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* v
return getExeVersionGeneral(exe, version);
}
FF_MAYBE_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* version)
{
if(!getExeVersionRaw(exe, version)) return false;
//foot version: 1.13.1 -pgo +ime -graphemes -assertions
ffStrbufSubstrAfterFirstS(version, "version: ");
ffStrbufSubstrBeforeFirstC(version, ' ');
return true;
}
#ifdef _WIN32
static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version)
@@ -240,6 +255,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe
if(ffStrbufIgnCaseEqualS(processName, "deepin-terminal"))
return getExeVersionGeneral(exe, version);//deepin-terminal 5.4.36
if(ffStrbufIgnCaseEqualS(processName, "foot"))
return getTerminalVersionFoot(exe, version);
#endif
#ifdef _WIN32
@@ -257,6 +275,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe
if(ffStrbufIgnCaseEqualS(processName, "kitty"))
return getExeVersionGeneral(exe, version); //kitty 0.21.2 created by Kovid Goyal
if (ffStrbufIgnCaseEqualS(processName, "Tabby") && getExeVersionRaw(exe, version))
return true;
#endif
if(ffStrbufStartsWithIgnCaseS(processName, "alacritty"))
@@ -269,7 +290,8 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe
if(termProgram)
{
if(ffStrbufStartsWithIgnCaseS(processName, termProgram) || // processName ends with `.exe` on Windows
(strcmp(termProgram, "vscode") == 0 && ffStrbufStartsWithIgnCaseS(processName, "code"))
(strcmp(termProgram, "vscode") == 0 && ffStrbufStartsWithIgnCaseS(processName, "code")) ||
(strcmp(termProgram, "iTerm.app") == 0 && ffStrbufStartsWithIgnCaseS(processName, "iTermServer-"))
) {
ffStrbufSetS(version, termProgramVersion);
return true;
@@ -148,7 +148,7 @@ static void getTerminalShell(FFTerminalShellResult* result, pid_t pid)
}
//Known shells
if(
if (
strcasecmp(name, "bash") == 0 ||
strcasecmp(name, "zsh") == 0 ||
strcasecmp(name, "ksh") == 0 ||
@@ -158,7 +158,8 @@ static void getTerminalShell(FFTerminalShellResult* result, pid_t pid)
strcasecmp(name, "dash") == 0 ||
strcasecmp(name, "pwsh") == 0 ||
strcasecmp(name, "nu") == 0 ||
strcasecmp(name, "git-shell") == 0
strcasecmp(name, "git-shell") == 0 ||
(strcasecmp(name, "python") == 0 && getenv("XONSH_VERSION"))
) {
if (result->shellProcessName.length == 0)
{
@@ -369,13 +370,15 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance)
ffStrbufInitS(&result.shellPrettyName, "PowerShell");
else if(ffStrbufEqualS(&result.shellProcessName, "nu"))
ffStrbufInitS(&result.shellPrettyName, "nushell");
else if(ffStrbufIgnCaseEqualS(&result.shellProcessName, "python") && getenv("XONSH_VERSION"))
ffStrbufInitS(&result.shellPrettyName, "xonsh");
else
{
// https://github.com/LinusDierheimer/fastfetch/discussions/280#discussioncomment-3831734
ffStrbufInitS(&result.shellPrettyName, result.shellExeName);
}
if(ffStrbufEqualS(&result.terminalProcessName, "iTerm.app"))
if(ffStrbufEqualS(&result.terminalProcessName, "iTerm.app") || ffStrbufStartsWithS(&result.terminalProcessName, "iTermServer-"))
ffStrbufInitS(&result.terminalPrettyName, "iTerm");
else if(ffStrbufEqualS(&result.terminalProcessName, "Apple_Terminal"))
ffStrbufInitS(&result.terminalPrettyName, "Apple Terminal");
@@ -1,19 +1,41 @@
extern "C" {
#include "terminalshell.h"
#include "common/processing.h"
#include "common/thread.h"
#include "util/mallocHelper.h"
}
#include <processthreadsapi.h>
#include <windows.h>
#include <wchar.h>
#include <tlhelp32.h>
#ifdef FF_USE_WIN_NTAPI
#include <ntstatus.h>
#include <winternl.h>
static bool getProductVersion(const wchar_t* filePath, FFstrbuf* version)
{
DWORD handle;
DWORD size = GetFileVersionInfoSizeW(filePath, &handle);
if(size > 0)
{
FF_AUTO_FREE void* versionData = malloc(size);
if(GetFileVersionInfoW(filePath, handle, size, versionData))
{
VS_FIXEDFILEINFO* verInfo;
UINT len;
if(VerQueryValueW(versionData, L"\\", (void**)&verInfo, &len) && len && verInfo->dwSignature == 0xFEEF04BD)
{
ffStrbufAppendF(version, "%u.%u.%u.%u",
(unsigned)(( verInfo->dwProductVersionMS >> 16 ) & 0xffff),
(unsigned)(( verInfo->dwProductVersionMS >> 0 ) & 0xffff),
(unsigned)(( verInfo->dwProductVersionLS >> 16 ) & 0xffff),
(unsigned)(( verInfo->dwProductVersionLS >> 0 ) & 0xffff)
);
return true;
}
}
}
return false;
}
static bool getProcessInfo(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrbuf* exe, const char** exeName)
{
HANDLE hProcess = pid == 0
@@ -59,7 +81,7 @@ static bool getProcessInfo(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrb
static bool getTerminalInfoByEnumeratingChildProcesses(FFTerminalShellResult* result, uint32_t ppid)
{
ULONG size = 0;
if(NtQuerySystemInformation(SystemProcessInformation, nullptr, 0, &size) != STATUS_INFO_LENGTH_MISMATCH)
if(NtQuerySystemInformation(SystemProcessInformation, NULL, 0, &size) != STATUS_INFO_LENGTH_MISMATCH)
return false;
size += sizeof(SystemProcessInformation) * 5; //What if new processes are created during two syscalls?
@@ -68,12 +90,12 @@ static bool getTerminalInfoByEnumeratingChildProcesses(FFTerminalShellResult* re
if(!pstart)
return false;
if(!NT_SUCCESS(NtQuerySystemInformation(SystemProcessInformation, pstart, size, nullptr)))
if(!NT_SUCCESS(NtQuerySystemInformation(SystemProcessInformation, pstart, size, NULL)))
return false;
uint32_t currentProcessId = (uint32_t) GetCurrentProcessId();
for (auto ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*)((uint8_t*)ptr + ptr->NextEntryOffset))
for (SYSTEM_PROCESS_INFORMATION* ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*)((uint8_t*)ptr + ptr->NextEntryOffset))
{
if ((uint32_t)(uintptr_t) ptr->InheritedFromUniqueProcessId != ppid)
continue;
@@ -82,7 +104,7 @@ static bool getTerminalInfoByEnumeratingChildProcesses(FFTerminalShellResult* re
if (pid == currentProcessId)
continue;
if(!getProcessInfo(pid, nullptr, &result->terminalProcessName, &result->terminalExe, &result->terminalExeName))
if(!getProcessInfo(pid, NULL, &result->terminalProcessName, &result->terminalExe, &result->terminalExeName))
return false;
result->terminalPid = pid;
@@ -95,77 +117,7 @@ static bool getTerminalInfoByEnumeratingChildProcesses(FFTerminalShellResult* re
return false;
}
#else
#include "util/windows/wmi.hpp"
#include <inttypes.h>
static bool getProcessInfo(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrbuf* exe, const char** exeName)
{
if(pid == 0)
pid = GetCurrentProcessId();
wchar_t sql[256] = {};
swprintf(sql, 256, L"SELECT %ls %ls ParentProcessId FROM Win32_Process WHERE ProcessId = %" PRIu32,
pname ? L"Name," : L"",
pname ? L"ExecutablePath," : L"",
pid);
FFWmiQuery query(sql);
if(!query)
return false;
if(FFWmiRecord record = query.next())
{
if(ppid)
{
uint64_t value;
record.getUnsigned(L"ParentProcessId", &value);
*ppid = (uint32_t) value;
}
if(pname)
record.getString(L"Name", pname);
if(exe)
record.getString(L"ExecutablePath", exe);
if(exeName)
*exeName = exe->chars + ffStrbufLastIndexC(exe, '\\') + 1;
}
return true;
}
static bool getTerminalInfoByEnumeratingChildProcesses(FFTerminalShellResult* result, uint32_t ppid)
{
wchar_t sql[256] = {};
swprintf(sql, 256, L"SELECT Name, ExecutablePath, ProcessId FROM Win32_Process WHERE ProcessId <> %" PRIu32 " AND ParentProcessId = %" PRIu32,
(uint32_t) GetCurrentProcessId(),
ppid);
FFWmiQuery query(sql);
if(!query)
return false;
if(FFWmiRecord record = query.next())
{
record.getString(L"Name", &result->terminalProcessName);
record.getString(L"ExecutablePath", &result->terminalExe);
result->terminalExeName = result->terminalExe.chars + ffStrbufLastIndexC(&result->terminalExe, '\\') + 1;
uint64_t pid;
record.getUnsigned(L"ProcessId", &pid);
result->terminalPid = (uint32_t) pid;
ffStrbufSet(&result->terminalPrettyName, &result->terminalProcessName);
if(ffStrbufEndsWithIgnCaseS(&result->terminalPrettyName, ".exe"))
ffStrbufSubstrBefore(&result->terminalPrettyName, result->terminalPrettyName.length - 4);
return true;
}
return false;
}
#endif
extern "C" bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version);
bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version);
static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult* result, uint32_t pid)
{
@@ -195,7 +147,7 @@ static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult*
ffStrbufClear(&result->shellProcessName);
ffStrbufClear(&result->shellPrettyName);
ffStrbufClear(&result->shellExe);
result->shellExeName = nullptr;
result->shellExeName = NULL;
return getShellInfo(instance, result, ppid);
}
@@ -225,7 +177,9 @@ static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult*
{
if(wcsncmp(module.szModule, L"clink_dll_", strlen("clink_dll_")) == 0)
{
ffStrbufAppendS(&result->shellPrettyName, "CMD (with Clink)");
ffStrbufAppendS(&result->shellPrettyName, "CMD (with Clink ");
getProductVersion(module.szExePath, &result->shellPrettyName);
ffStrbufAppendC(&result->shellPrettyName, ')');
break;
}
}
@@ -316,23 +270,23 @@ static void getTerminalFromEnv(FFTerminalShellResult* result)
ffStrbufIgnCaseCompS(&result->terminalProcessName, "explorer") != 0
) return;
const char* term = nullptr;
const char* term = NULL;
//SSH
if(getenv("SSH_CONNECTION") != nullptr)
if(getenv("SSH_CONNECTION") != NULL)
term = getenv("SSH_TTY");
//Windows Terminal
if(!term && (
getenv("WT_SESSION") != nullptr ||
getenv("WT_PROFILE_ID") != nullptr
getenv("WT_SESSION") != NULL ||
getenv("WT_PROFILE_ID") != NULL
)) term = "Windows Terminal";
//Alacritty
if(!term && (
getenv("ALACRITTY_SOCKET") != nullptr ||
getenv("ALACRITTY_LOG") != nullptr ||
getenv("ALACRITTY_WINDOW_ID") != nullptr
getenv("ALACRITTY_SOCKET") != NULL ||
getenv("ALACRITTY_LOG") != NULL ||
getenv("ALACRITTY_WINDOW_ID") != NULL
)) term = "Alacritty";
if(!term)
@@ -351,7 +305,7 @@ static void getTerminalFromEnv(FFTerminalShellResult* result)
}
}
extern "C" bool fftsGetTerminalVersion(FFstrbuf* processName, FFstrbuf* exe, FFstrbuf* version);
bool fftsGetTerminalVersion(FFstrbuf* processName, FFstrbuf* exe, FFstrbuf* version);
const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance)
{
@@ -386,7 +340,7 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance)
ffStrbufInit(&result.userShellVersion);
uint32_t ppid;
if(!getProcessInfo(0, &ppid, nullptr, nullptr, nullptr))
if(!getProcessInfo(0, &ppid, NULL, NULL, NULL))
goto exit;
ppid = getShellInfo(instance, &result, ppid);
-1
View File
@@ -1,6 +1,5 @@
#include "uptime.h"
#define WIN32_LEAN_AND_MEAN
#include <sysinfoapi.h>
uint64_t ffDetectUptime()
+1
View File
@@ -1,6 +1,7 @@
#include "users.h"
#include "util/windows/unicode.h"
#include <windows.h>
#include <wtsapi32.h>
void ffDetectUsers(FFlist* users, FFstrbuf* error)
+12 -1
View File
@@ -176,8 +176,17 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu
if(physicalDeviceProperties.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU)
continue;
// #456
FF_LIST_FOR_EACH(FFGPUResult, gpu, result->gpus)
{
if (gpu->vulkanDeviceId == physicalDeviceProperties.properties.deviceID)
goto next;
}
FFGPUResult* gpu = ffListAdd(&result->gpus);
gpu->vulkanDeviceId = physicalDeviceProperties.properties.deviceID;
ffStrbufInit(&gpu->name);
ffStrbufAppendS(&gpu->name, physicalDeviceProperties.properties.deviceName);
@@ -185,7 +194,6 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu
gpu->type = FF_GPU_TYPE_DISCRETE;
else
gpu->type = FF_GPU_TYPE_INTEGRATED;
gpu->id = physicalDeviceProperties.properties.deviceID;
ffStrbufInitS(&gpu->vendor, ffGetGPUVendorString(physicalDeviceProperties.properties.vendorID));
ffStrbufInitS(&gpu->driver, driverProperties.driverInfo);
@@ -216,6 +224,9 @@ static const char* detectVulkan(const FFinstance* instance, FFVulkanResult* resu
//No way to detect those using vulkan
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
next:
continue;
}
//If the highest device version is lower than the instance version, use it as our vulkan version
+1
View File
@@ -207,6 +207,7 @@ static const char* detectWifiWithLibnm(const FFinstance* instance, FFlist* resul
#include <net/if.h>
#include <linux/wireless.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
static const char* detectWifiWithIoctls(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* result)
+2 -2
View File
@@ -2,6 +2,7 @@
#include "common/library.h"
#include "util/windows/unicode.h"
#include <windows.h>
#include <wlanapi.h>
#pragma GCC diagnostic push
@@ -71,7 +72,7 @@ const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* res
WLAN_INTERFACE_INFO* ifInfo = (WLAN_INTERFACE_INFO*)&ifList->InterfaceInfo[index];
FFWifiResult* item = (FFWifiResult*)ffListAdd(result);
ffStrbufInit(&item->inf.description);
ffStrbufInitWS(&item->inf.description, ifInfo->strInterfaceDescription);
ffStrbufInit(&item->inf.status);
ffStrbufInit(&item->conn.status);
ffStrbufInit(&item->conn.ssid);
@@ -82,7 +83,6 @@ const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* res
item->conn.rxRate = 0.0/0.0;
item->conn.txRate = 0.0/0.0;
ffStrbufSetWS(&item->inf.description, ifInfo->strInterfaceDescription);
convertIfStateToString(ifInfo->isState, &item->inf.status);
if(ifInfo->isState != wlan_interface_state_connected)
+1 -22
View File
@@ -1,13 +1,10 @@
#include "fastfetch.h"
#include "detection/displayserver/displayserver.h"
#include "wmtheme.h"
#import <Foundation/Foundation.h>
static bool detectQuartzCompositor(FFinstance* instance, FFstrbuf* themeOrError)
bool ffDetectWmTheme(FF_MAYBE_UNUSED FFinstance* instance, FFstrbuf* themeOrError)
{
FF_UNUSED(instance);
NSError* error;
NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/.GlobalPreferences.plist", instance->state.platform.homeDir.chars];
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName]
@@ -41,21 +38,3 @@ static bool detectQuartzCompositor(FFinstance* instance, FFstrbuf* themeOrError)
ffStrbufAppendF(themeOrError, " (%s)", wmTheme ? wmTheme.UTF8String : "Light");
return true;
}
bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError)
{
const FFDisplayServerResult* wm = ffConnectDisplayServer(instance);
if(wm->wmPrettyName.length == 0)
{
ffStrbufAppendS(themeOrError, "WM Theme needs sucessfull WM detection");
return false;
}
if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, "Quartz Compositor") == 0)
return detectQuartzCompositor(instance, themeOrError);
ffStrbufAppendS(themeOrError, "Unknown WM: ");
ffStrbufAppend(themeOrError, &wm->dePrettyName);
return false;
}
@@ -1,5 +1,4 @@
#include "fastfetch.h"
#include "detection/displayserver/displayserver.h"
#include "wmtheme.h"
bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError)
+24 -6
View File
@@ -137,7 +137,7 @@ static inline void printCommandHelp(const char* command)
}
else if(strcasecmp(command, "packages-format") == 0)
{
constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak), {15} (snap), {16} (brew), {17} (brew-cask), {18} (port), {19} (scoop), {20} (choco)", 20,
constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (port), {20} (scoop), {21} (choco)", 21,
"Number of all packages",
"Number of pacman packages",
"Pacman branch on manjaro",
@@ -151,7 +151,8 @@ static inline void printCommandHelp(const char* command)
"Number of nix-default packages",
"Number of apk packages",
"Number of pkg packages",
"Number of flatpak packages",
"Number of flatpak-system packages",
"Number of flatpak-user packages",
"Number of snap packages",
"Number of brew packages",
"Number of brew-cask packages",
@@ -1246,6 +1247,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
instance->config.cpuTemp = optionParseBoolean(value);
else if(strcasecmp(key, "--gpu-temp") == 0)
instance->config.gpuTemp = optionParseBoolean(value);
else if(strcasecmp(key, "--gpu-force-vulkan") == 0)
instance->config.gpuForceVulkan = optionParseBoolean(value);
else if(strcasecmp(key, "--battery-temp") == 0)
instance->config.batteryTemp = optionParseBoolean(value);
else if(strcasecmp(key, "--gpu-hide-integrated") == 0)
@@ -1268,6 +1271,18 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
instance->config.diskShowSubvolumes = optionParseBoolean(value);
else if(strcasecmp(key, "--disk-show-unknown") == 0)
instance->config.diskShowUnknown = optionParseBoolean(value);
else if(strcasecmp(key, "--display-compact-type") == 0)
{
optionParseEnum(key, value, &instance->config.displayCompactType,
"none", FF_DISPLAY_COMPACT_TYPE_NONE,
"original", FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT,
"scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT,
NULL);
}
else if(strcasecmp(key, "--display-precise-refresh-rate") == 0)
instance->config.displayPreciseRefreshRate = optionParseBoolean(value);
else if(strcasecmp(key, "--display-detect-name") == 0)
instance->config.displayDetectName = optionParseBoolean(value);
else if(strcasecmp(key, "--bluetooth-show-disconnected") == 0)
instance->config.bluetoothShowDisconnected = optionParseBoolean(value);
else if(strcasecmp(key, "--sound-type") == 0)
@@ -1527,11 +1542,14 @@ int main(int argc, const char** argv)
if(ffStrbufContainIgnCaseS(&data.structure, "CPUUsage"))
ffPrepareCPUUsage();
if(ffStrbufContainIgnCaseS(&data.structure, "PublicIp"))
ffPreparePublicIp(&instance);
if(instance.config.multithreading)
{
if(ffStrbufContainIgnCaseS(&data.structure, "PublicIp"))
ffPreparePublicIp(&instance);
if(ffStrbufContainIgnCaseS(&data.structure, "Weather"))
ffPrepareWeather(&instance);
if(ffStrbufContainIgnCaseS(&data.structure, "Weather"))
ffPrepareWeather(&instance);
}
ffStart(&instance);
+13 -1
View File
@@ -41,6 +41,13 @@ typedef enum FFSoundType
FF_SOUND_TYPE_ALL,
} FFSoundType;
typedef enum FFDisplayCompactType
{
FF_DISPLAY_COMPACT_TYPE_NONE = 0,
FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT = 1 << 0,
FF_DISPLAY_COMPACT_TYPE_SCALED_BIT = 1 << 1,
} FFDisplayCompactType;
typedef enum FFLocalIpCompactType
{
FF_LOCALIP_COMPACT_TYPE_NONE,
@@ -185,6 +192,7 @@ typedef struct FFconfig
bool cpuTemp;
bool gpuTemp;
bool gpuForceVulkan;
bool batteryTemp;
bool gpuHideIntegrated;
@@ -201,6 +209,10 @@ typedef struct FFconfig
bool diskShowUnknown;
bool diskShowSubvolumes;
FFDisplayCompactType displayCompactType;
bool displayDetectName;
bool displayPreciseRefreshRate;
bool bluetoothShowDisconnected;
FFstrbuf batteryDir;
@@ -314,7 +326,7 @@ void ffPrintCPU(FFinstance* instance);
void ffPrintCPUUsage(FFinstance* instance);
void ffPrintGPU(FFinstance* instance);
void ffPrintMemory(FFinstance* instance);
void ffPrintSwap(FFinstance* instance); //Also in modules/memory.c
void ffPrintSwap(FFinstance* instance);
void ffPrintDisk(FFinstance* instance);
void ffPrintBattery(FFinstance* instance);
void ffPrintPowerAdapter(FFinstance* instance);
+109 -22
View File
@@ -188,7 +188,7 @@ static const FFlogo* getLogoArch()
FF_LOGO_INIT
FF_LOGO_NAMES("arch", "archlinux", "arch-linux")
FF_LOGO_LINES(
" -`\n"
"$1 -`\n"
" .o+`\n"
" `ooo/\n"
" `+oooo:\n"
@@ -197,9 +197,9 @@ static const FFlogo* getLogoArch()
" `/:-:++oooo+:\n"
" `/++++/+++++++:\n"
" `/++++++++++++++:\n"
" `/+++ooooooooooooo/`\n"
" ./ooosssso++osssssso+`\n"
" .oossssso-````/ossssss+`\n"
" `/+++o$2oooooooo$1oooo/`\n"
" ./$2ooosssso++osssssso$1+`\n"
"$2 .oossssso-````/ossssss+`\n"
" -osssssso. :ssssssso.\n"
" :osssssss/ osssso+++.\n"
" /ossssssss/ +ssssooo/-\n"
@@ -209,6 +209,7 @@ static const FFlogo* getLogoArch()
".` `/";
)
FF_LOGO_COLORS(
"36", //cyan
"36" //cyan
)
FF_LOGO_COLOR_KEYS("36"); //cyan
@@ -734,7 +735,7 @@ static const FFlogo* getLogoEndeavour()
"$2`-////+$1ssssssssssssssssssssssssssso$3++++-\n"
" $2`..-+$1oosssssssssssssssssssssssso$3+++++/`\n"
" $3./++++++++++++++++++++++++++++++/:.\n"
" `:::::::::::::::::::::::::------``"
" `:::::::::::::::::::::::::------``"
)
FF_LOGO_COLORS(
"35", //magenta
@@ -1186,6 +1187,56 @@ static const FFlogo* getLogoMacOS()
FF_LOGO_RETURN
}
static const FFlogo* getLogoMacOSSmall()
{
FF_LOGO_INIT
FF_LOGO_NAMES("macos_small", "mac_small", "apple_small", "darwin_small", "osx_small")
FF_LOGO_LINES(
"$1 .:'\n"
" __ :'__\n"
"$2 .'`__`-'__``.\n"
"$3:__________.-'\n"
"$4:_________:\n"
" :_________`-;\n"
"$5 `.__.-.__.'"
)
FF_LOGO_COLORS(
"32", //green
"33", //yellow
"31", //red
"35", //magenta
"34" //blue
)
FF_LOGO_COLOR_KEYS("33"); //yellow
FF_LOGO_COLOR_TITLE("32"); //green
FF_LOGO_RETURN
}
static const FFlogo* getLogoMacOSSmall2()
{
FF_LOGO_INIT
FF_LOGO_NAMES("macos_small2", "mac_small2", "apple_small2", "darwin_small2", "osx_small2")
FF_LOGO_LINES(
"$1 .:'\n"
" __ :'__\n"
"$2 .'` `-' ``.\n"
"$3: .-'\n"
"$4: :\n"
" : `-;\n"
"$5 `.__.-.__.'"
)
FF_LOGO_COLORS(
"32", //green
"33", //yellow
"31", //red
"35", //magenta
"34" //blue
)
FF_LOGO_COLOR_KEYS("33"); //yellow
FF_LOGO_COLOR_TITLE("32"); //green
FF_LOGO_RETURN
}
static const FFlogo* getLogoManjaro()
{
FF_LOGO_INIT
@@ -1369,23 +1420,23 @@ static const FFlogo* getLogoWindows11()
FF_LOGO_NAMES("Windows 11", "Windows Server 2022")
FF_LOGO_LINES(
"$1\n"
",,**************/ ///////////////()\n"
"****************/ ///////////////((\n"
"***************// //////////////(((\n"
"**************/// ////////////(((((\n"
"************///// /////////((((((((\n"
"*********//////// /////((((((((((((\n"
"*******////////// ///((((((((((((((\n"
"****///////////// (((((((((((((((((\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"\n"
"/////////////(((( (((((((((((((((((\n"
"////////////((((( (((((((((((((((((\n"
"///////////(((((( (((((((((((((((((\n"
"/////////(((((((( (((((((((((((((((\n"
"///////(((((((((( (((((((((((((((((\n"
"////((((((((((((( (((((((((((((((((\n"
"((((((((((((((((( (((((((((((((((((\n"
"((((((((((((((((( (((((((((((((((()"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////\n"
"///////////////// /////////////////"
)
FF_LOGO_COLORS(
"34" //blue
@@ -1605,7 +1656,7 @@ static const FFlogo* getLogoNobara()
"⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n"
"⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠛⠉⠉⠛⠛⢿⣿⣿⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿\n"
"⠘⢿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⠟⠁\n"
"⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠛⠛⠛⠉⠁\n"
" ⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠛⠛⠛⠉⠁\n"
)
FF_LOGO_COLORS(
"37" // white
@@ -2217,6 +2268,39 @@ static const FFlogo* getLogoSolus()
FF_LOGO_RETURN
}
static const FFlogo* getLogoSteamOS()
{
FF_LOGO_INIT
FF_LOGO_NAMES("steamos")
FF_LOGO_LINES(
"$1 .,,,,.\n"
" .,'onNMMMMMNNnn',.\n"
" .'oNMANKMMMMMMMMMMMNNn'.\n"
" .'ANMMMMMMMXKNNWWWPFFWNNMNn.\n"
" ;NNMMMMMMMMMMNWW'' ,.., 'WMMM,\n"
" ;NMMMMV+##+VNWWW' .+;'':+, 'WMW,\n"
",VNNWP+$2######$1+WW, $2+: $1:+, +MMM,\n"
"'$2+#############, +. ,+' $1+NMMM\n"
"$2 '*#########*' '*,,*' $1.+NMMMM.\n"
"$2 `'*###*' ,.,;###$1+WNM,\n"
"$2 .,;;, .;##########$1+W\n"
"$2,',. '; ,+##############'\n"
" '###+. :,. .,; ,###############'\n"
" '####.. `'' .,###############'\n"
" '#####+++################'\n"
" '*##################*'\n"
" ''*##########*''\n"
" ''''''\n"
)
FF_LOGO_COLORS(
"34", //blue
"37" //white
)
FF_LOGO_COLOR_KEYS("34"); //blue
FF_LOGO_COLOR_TITLE("34"); //blue
FF_LOGO_RETURN
}
static const FFlogo* getLogoUbuntu()
{
FF_LOGO_INIT
@@ -2469,6 +2553,8 @@ GetLogoMethod* ffLogoBuiltinGetAll()
getLogoLangitKetujuh,
getLogoLinux,
getLogoMacOS,
getLogoMacOSSmall,
getLogoMacOSSmall2,
getLogoManjaro,
getLogoManjaroSmall,
getLogoMint,
@@ -2503,6 +2589,7 @@ GetLogoMethod* ffLogoBuiltinGetAll()
getLogoSlackware,
getLogoSlackwareSmall,
getLogoSolus,
getLogoSteamOS,
getLogoUbuntu,
getLogoUbuntuOld,
getLogoUbuntuSmall,
+2
View File
@@ -4,6 +4,8 @@
#ifdef __APPLE__
#include <sys/syslimits.h>
#elif _WIN32
#include <windows.h>
#endif
static FFstrbuf base64Encode(FFstrbuf* in)
+5 -9
View File
@@ -7,23 +7,23 @@
void ffPrintBrightness(FFinstance* instance)
{
FFlist result;
FF_LIST_AUTO_DESTROY result;
ffListInit(&result, sizeof(FFBrightnessResult));
const char* error = ffDetectBrightness(&result);
if(error)
{
ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &instance->config.brightness, "%s", error);
goto exit;
return;
}
if(result.length == 0)
{
ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &instance->config.brightness, "No result is detected.");
goto exit;
return;
}
FFstrbuf key;
FF_STRBUF_AUTO_DESTROY key;
ffStrbufInit(&key);
FF_LIST_FOR_EACH(FFBrightnessResult, item, result)
@@ -52,11 +52,7 @@ void ffPrintBrightness(FFinstance* instance)
});
}
ffStrbufClear(&key);
ffStrbufDestroy(&item->name);
}
ffStrbufDestroy(&key);
exit:
ffListDestroy(&result);
}
+2 -2
View File
@@ -18,13 +18,13 @@ void ffPrintChassis(FFinstance* instance)
if(result.chassisType.length == 0)
{
ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.host, "chassis_type is not set by O.E.M.");
ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis, "chassis_type is not set by O.E.M.");
return;
}
if(instance->config.chassis.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.host.key);
ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis.key);
FFstrbuf output;
ffStrbufInitCopy(&output, &result.chassisType);
-6
View File
@@ -5,13 +5,7 @@
void ffPrintColors(FFinstance* instance)
{
if(instance->config.pipe)
{
ffLogoPrintLine(instance);
puts("████████████████████████");
ffLogoPrintLine(instance);
puts("████████████████████████");
return;
}
ffLogoPrintLine(instance);
+1 -2
View File
@@ -21,7 +21,7 @@ void ffPrintCPUUsage(FFinstance* instance)
{
ffPrintLogoAndKey(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsage.key);
FFstrbuf str;
FF_STRBUF_AUTO_DESTROY str;
ffStrbufInit(&str);
if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
ffAppendPercentBar(instance, &str, (uint8_t)percentage, 0, 5, 8);
@@ -32,7 +32,6 @@ void ffPrintCPUUsage(FFinstance* instance)
ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0);
}
ffStrbufPutTo(&str, stdout);
ffStrbufDestroy(&str);
}
else
{
+2 -2
View File
@@ -43,6 +43,6 @@ void ffPrintDateTime(FFinstance* instance)
const FFDateTimeResult* datetime = ffDetectDateTime(instance);
ffPrintLogoAndKey(instance, FF_DATETIME_MODULE_NAME, 0, &instance->config.dateTime.key);
//yyyy-mm-dd hh:mm:ss
printf("%u-%s-%u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars);
//yyyy-MM-dd HH:mm:ss
printf("%u-%s-%02u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars);
}

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