Compare commits

...

61 Commits

Author SHA1 Message Date
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
Carter Li 4f4860eee8 Merge pull request #426 from LinusDierheimer/dev
Release: 1.10.2
2023-02-22 15:58:01 +08:00
李通洲 695e3cc692 Release: 1.10.2 2023-02-22 15:16:54 +08:00
李通洲 e05d9da231 Battery / Wifi: fix missing NULL for ffProcessAppendStdOut 2023-02-22 15:12:37 +08:00
Nanda H Krishna c16f9a9e20 sound_apple.c: handle kAudioObjectPropertyElementMain for macOS < 12 2023-02-22 14:19:22 +08:00
Carter Li 74b1871f18 CI: fix build (#424) 2023-02-21 22:19:17 +08:00
77 changed files with 1003 additions and 527 deletions
+1 -1
View File
@@ -1 +1 @@
github: LinusDierheimer
github: [LinusDierheimer, CarterLi]
+6 -6
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
@@ -281,7 +281,7 @@ jobs:
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-Win32
name: fastfetch-win32
path: ./fastfetch-*-Win32.zip
release:
+37
View File
@@ -1,3 +1,40 @@
# 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:
* Handle `kAudioObjectPropertyElementMain` for macOS **SDK** < 12 (#425, @nandahkrishna)
* Add missing `NULL` for `ffProcessAppendStdOut` (#421)
# 1.10.1
New release for debugging #421
+27 -19
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.1
VERSION 1.11.0
LANGUAGES C
DESCRIPTION "Fast system information tool"
HOMEPAGE_URL "https://github.com/LinusDierheimer/fastfetch"
@@ -67,11 +67,11 @@ 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)
@@ -117,7 +117,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)
@@ -458,7 +462,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,10 +508,10 @@ 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
@@ -519,6 +523,7 @@ elseif(WIN32)
src/detection/swap/swap_windows.cpp
src/detection/terminalfont/terminalfont_windows.c
src/detection/terminalshell/terminalshell_windows.cpp
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 +542,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 +671,6 @@ ff_lib_enable(OPENCL
"OpenCL"
"OpenCL"
)
ff_lib_enable(LIBCJSON
"libcjson"
"CJson"
)
ff_lib_enable(LIBNM
"libnm"
"libnm"
@@ -679,6 +683,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 +701,18 @@ 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 "-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,8 +728,7 @@ elseif(WIN32)
PRIVATE "ntdll"
PRIVATE "version"
PRIVATE "setupapi"
PRIVATE "dxgi"
PRIVATE "dinput8"
PRIVATE "hid"
PRIVATE "wtsapi32"
PRIVATE "powrprof"
)
+1 -1
View File
@@ -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, 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++;
+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[])
+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
+2 -1
View File
@@ -14,7 +14,8 @@ const char* ffDetectBatteryImpl(FF_MAYBE_UNUSED FFinstance* instance, FFlist* re
if(ffProcessAppendStdOut(&buffer, (char* const[]){
FF_TERMUX_API_PATH,
FF_TERMUX_API_PARAM
FF_TERMUX_API_PARAM,
NULL
}))
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
+2 -1
View File
@@ -2,11 +2,12 @@
#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
@@ -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);
}
+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);
}
}
-1
View File
@@ -1,6 +1,5 @@
#include "disk.h"
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
void ffDetectDisksImpl(FFDiskResult* disks)
+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,6 @@
#include "displayserver.h"
#include "common/sysctl.h"
#include "util/apple/cf_helpers.h"
#include <stdlib.h>
#include <ctype.h>
@@ -8,7 +9,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 +39,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);
}
@@ -84,7 +102,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
{
FF_UNUSED(instance);
ffStrbufInitS(&ds->wmProcessName, "quartz");
ffStrbufInitS(&ds->wmProcessName, "WindowServer");
ffStrbufInitS(&ds->wmPrettyName, "Quartz Compositor");
ffStrbufInit(&ds->wmProtocolName);
@@ -99,9 +117,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,5 +1,6 @@
#include "displayserver.h"
#include "detection/os/os.h"
#include "util/windows/unicode.h"
#include <dwmapi.h>
#include <WinUser.h>
@@ -11,23 +12,109 @@ typedef struct
uint32_t height;
} DataBundle;
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;
MONITORINFOEXW mi = { .cbSize = sizeof(mi) };
if(GetMonitorInfoW(hMonitor, (MONITORINFO *)&mi) && wcscmp(mi.szDevice, data->deviceName) == 0)
{
data->width = (uint32_t) mi.rcMonitor.right;
data->height = (uint32_t) mi.rcMonitor.bottom;
data->width = (uint32_t) (mi.rcMonitor.right - mi.rcMonitor.left);
data->height = (uint32_t) (mi.rcMonitor.bottom - mi.rcMonitor.top);
return FALSE;
}
return TRUE;
}
static void detectDisplays(FFDisplayServerResult* ds, bool detectName)
{
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]);
if (QueryDisplayConfig(
QDC_ONLY_ACTIVE_PATHS,
&pathCount,
paths,
&modeCount,
modes,
NULL) == ERROR_SUCCESS)
{
for (uint32_t i = 0; i < pathCount; ++i)
{
DISPLAYCONFIG_PATH_INFO* path = &paths[i];
DataBundle data = {};
DISPLAYCONFIG_SOURCE_DEVICE_NAME sourceName = {
.header = {
.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME,
.size = sizeof(sourceName),
.adapterId = path->sourceInfo.adapterId,
.id = path->sourceInfo.id,
},
};
if (DisplayConfigGetDeviceInfo(&sourceName.header) == ERROR_SUCCESS)
{
data.deviceName = sourceName.viewGdiDeviceName;
EnumDisplayMonitors(NULL, NULL, enumMonitorProc, (LPARAM) &data);
}
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,
data.width,
data.height,
&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
);
}
}
}
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance)
{
FF_UNUSED(instance);
BOOL enabled;
if(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled == TRUE)
{
@@ -45,23 +132,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 = 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 = 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
);
}
+9
View File
@@ -1,9 +1,18 @@
#include "common/font.h"
#include "detection/displayserver/displayserver.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "font.h"
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);
+1 -1
View File
@@ -1,7 +1,7 @@
#include "font.h"
#include "util/windows/unicode.h"
#include <winuser.h>
#include <windows.h>
void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
{
+139
View File
@@ -0,0 +1,139 @@
#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";
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);
ffStrbufInit(&device->identifier);
ffStrbufSetWS(&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
View File
@@ -29,7 +29,6 @@ typedef struct FFGPUMemory
typedef struct FFGPUResult
{
uint64_t id;
FFGpuType type;
FFstrbuf vendor;
FFstrbuf name;
-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;
+59
View File
@@ -0,0 +1,59 @@
#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);
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->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
ffStrbufSetWS(&gpu->name, displayDevice.DeviceString);
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
View File
@@ -1,5 +1,7 @@
#include "memory.h"
#include <windows.h>
void ffDetectMemory(FFMemoryStorage* ram)
{
MEMORYSTATUSEX statex = {
-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;
+5 -4
View File
@@ -258,7 +258,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 += getNumElements(baseDir, "/var/lib/flatpak/app", DT_DIR);
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 +266,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,7 +316,7 @@ 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);
@@ -333,6 +335,5 @@ void ffDetectPackagesImpl(const FFinstance* instance, FFPackagesResult* result)
ffStrbufSet(&baseDir, &instance->state.platform.homeDir);
result->nixUser = getNixPackages(&baseDir, "/.nix-profile");
ffStrbufDestroy(&baseDir);
result->flatpakUser += getNumElements(&baseDir, "/.var/app", DT_DIR);
}
+5
View File
@@ -2,6 +2,11 @@
#include "util/apple/cf_helpers.h"
#include <CoreAudio/CoreAudio.h>
#include <AvailabilityMacros.h>
#ifndef MAC_OS_VERSION_12_0
#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
#endif
const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* devices /* List of FFSoundDevice */)
{
+1
View File
@@ -7,6 +7,7 @@ extern "C" {
#include <winternl.h>
#include <ntstatus.h>
#include <windows.h>
extern "C"
void ffDetectSwap(FFMemoryStorage* swap)
+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
+31 -36
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,44 +249,40 @@ 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)
@@ -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)
{
@@ -188,6 +188,20 @@ 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(ffProcessAppendStdOut(version, (char* const[]){
exe->chars,
"--version",
NULL
})) 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 +254,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
@@ -5,7 +5,7 @@ extern "C" {
#include "util/mallocHelper.h"
}
#include <processthreadsapi.h>
#include <windows.h>
#include <wchar.h>
#include <tlhelp32.h>
-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)
-1
View File
@@ -185,7 +185,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);
+2 -1
View File
@@ -13,7 +13,8 @@ const char* ffDetectWifi(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* res
if(ffProcessAppendStdOut(&buffer, (char* const[]){
FF_TERMUX_API_PATH,
FF_TERMUX_API_PARAM
FF_TERMUX_API_PARAM,
NULL
}))
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
+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)
+1
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
+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);
+12
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;
+1 -1
View File
@@ -1605,7 +1605,7 @@ static const FFlogo* getLogoNobara()
"⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n"
"⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠛⠉⠉⠛⠛⢿⣿⣿⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿\n"
"⠘⢿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⠟⠁\n"
"⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠛⠛⠛⠉⠁\n"
" ⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠛⠛⠛⠉⠁\n"
)
FF_LOGO_COLORS(
"37" // white
+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);
+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);
}
+66 -9
View File
@@ -2,30 +2,83 @@
#include "common/printing.h"
#include "detection/displayserver/displayserver.h"
#define FF_RESOLUTION_MODULE_NAME "Display"
#define FF_RESOLUTION_NUM_FORMAT_ARGS 5
#define FF_DISPLAY_MODULE_NAME "Display"
#define FF_DISPLAY_NUM_FORMAT_ARGS 7
void ffPrintDisplay(FFinstance* instance)
{
#ifdef __ANDROID__
ffPrintError(instance, FF_RESOLUTION_MODULE_NAME, 0, &instance->config.display, "Display detection is not supported on Android");
ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display, "Display detection is not supported on Android");
return;
#endif
const FFDisplayServerResult* dsResult = ffConnectDisplayServer(instance);
if (instance->config.displayCompactType != FF_DISPLAY_COMPACT_TYPE_NONE)
{
ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display.key);
int index = 0;
FF_LIST_FOR_EACH(FFDisplayResult, result, dsResult->displays)
{
if (instance->config.displayCompactType & FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT)
{
if (index++) putchar(' ');
printf("%ix%i", result->width, result->height);
}
if (instance->config.displayCompactType & FF_DISPLAY_COMPACT_TYPE_SCALED_BIT)
{
if (index++) putchar(' ');
printf("%ix%i", result->scaledWidth, result->scaledHeight);
}
ffStrbufDestroy(&result->name);
}
putchar('\n');
return;
}
FF_STRBUF_AUTO_DESTROY key;
ffStrbufInit(&key);
for(uint32_t i = 0; i < dsResult->displays.length; i++)
{
FFDisplayResult* result = ffListGet(&dsResult->displays, i);
uint8_t moduleIndex = dsResult->displays.length == 1 ? 0 : (uint8_t) (i + 1);
const char* displayType = result->type == FF_DISPLAY_TYPE_UNKNOWN ? NULL : result->type == FF_DISPLAY_TYPE_BUILTIN ? "built-in" : "external";
if(instance->config.display.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, FF_RESOLUTION_MODULE_NAME, moduleIndex, &instance->config.display.key);
if(result->name.length || (moduleIndex > 0 && displayType))
{
ffStrbufClear(&key);
if(instance->config.display.key.length == 0)
{
ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, result->name.length ? result->name.chars : displayType);
}
else
{
ffParseFormatString(&key, &instance->config.display.key, 1, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &i},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
{FF_FORMAT_ARG_TYPE_STRING, displayType},
});
}
ffPrintLogoAndKey(instance, key.chars, 0, NULL);
}
else
{
ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &instance->config.display.key);
}
printf("%ix%i", result->width, result->height);
if(result->refreshRate > 0)
printf(" @ %iHz", result->refreshRate);
{
if(instance->config.displayPreciseRefreshRate)
printf(" @ %gHz", ((int) (result->refreshRate * 1000 + 0.5)) / 1000.0);
else
printf(" @ %iHz", (uint32_t) (result->refreshRate + 0.5));
}
if(
result->scaledWidth > 0 && result->scaledWidth != result->width &&
@@ -36,16 +89,20 @@ void ffPrintDisplay(FFinstance* instance)
}
else
{
ffPrintFormat(instance, FF_RESOLUTION_MODULE_NAME, moduleIndex, &instance->config.display, FF_RESOLUTION_NUM_FORMAT_ARGS, (FFformatarg[]) {
ffPrintFormat(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &instance->config.display, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_UINT, &result->width},
{FF_FORMAT_ARG_TYPE_UINT, &result->height},
{FF_FORMAT_ARG_TYPE_UINT, &result->refreshRate},
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate},
{FF_FORMAT_ARG_TYPE_UINT, &result->scaledWidth},
{FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight}
{FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
{FF_FORMAT_ARG_TYPE_STRING, displayType},
});
}
ffStrbufDestroy(&result->name);
}
if(dsResult->displays.length == 0)
ffPrintError(instance, FF_RESOLUTION_MODULE_NAME, 0, &instance->config.display, "Couldn't detect display");
ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display, "Couldn't detect display");
}
-8
View File
@@ -75,14 +75,6 @@ void ffPrintFont(FFinstance* instance)
{
assert(FF_DETECT_FONT_NUM_FONTS == FF_FONT_NUM_FORMAT_ARGS);
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
{
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font, "Font isn't supported in TTY");
return;
}
const FFFontResult* font = ffDetectFont(instance);
if(font->error.length > 0)
+6 -4
View File
@@ -3,7 +3,7 @@
#include "detection/packages/packages.h"
#define FF_PACKAGES_MODULE_NAME "Packages"
#define FF_PACKAGES_NUM_FORMAT_ARGS 20
#define FF_PACKAGES_NUM_FORMAT_ARGS 21
void ffPrintPackages(FFinstance* instance)
{
@@ -23,7 +23,7 @@ void ffPrintPackages(FFinstance* instance)
#define FF_PRINT_PACKAGE_NAME(var, name) \
if(counts->var > 0) \
{ \
printf("%u ("name")", counts->var); \
printf("%u (%s)", counts->var, (name)); \
if((all -= counts->var) > 0) \
printf(", "); \
};
@@ -49,7 +49,8 @@ void ffPrintPackages(FFinstance* instance)
FF_PRINT_PACKAGE_NAME(nixDefault, "nix-default")
FF_PRINT_PACKAGE(apk)
FF_PRINT_PACKAGE(pkg)
FF_PRINT_PACKAGE(flatpak)
FF_PRINT_PACKAGE_NAME(flatpakSystem, counts->flatpakUser ? "flatpak-system" : "flatpak")
FF_PRINT_PACKAGE_NAME(flatpakUser, "flatpak-user")
FF_PRINT_PACKAGE(snap)
FF_PRINT_PACKAGE(brew)
FF_PRINT_PACKAGE_NAME(brewCask, "brew-cask")
@@ -78,7 +79,8 @@ void ffPrintPackages(FFinstance* instance)
{FF_FORMAT_ARG_TYPE_UINT, &counts->nixDefault},
{FF_FORMAT_ARG_TYPE_UINT, &counts->apk},
{FF_FORMAT_ARG_TYPE_UINT, &counts->pkg},
{FF_FORMAT_ARG_TYPE_UINT, &counts->flatpak},
{FF_FORMAT_ARG_TYPE_UINT, &counts->flatpakSystem},
{FF_FORMAT_ARG_TYPE_UINT, &counts->flatpakUser},
{FF_FORMAT_ARG_TYPE_UINT, &counts->snap},
{FF_FORMAT_ARG_TYPE_UINT, &counts->brew},
{FF_FORMAT_ARG_TYPE_UINT, &counts->brewCask},
+14 -1
View File
@@ -3,7 +3,7 @@
#include <ctype.h>
#include <inttypes.h>
static char* CHAR_NULL_PTR = "";
char* CHAR_NULL_PTR = "";
void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate)
{
@@ -22,6 +22,19 @@ void ffStrbufInitCopy(FFstrbuf* strbuf, const FFstrbuf* src)
ffStrbufAppend(strbuf, src);
}
void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src)
{
if (src)
{
strbuf->allocated = src->allocated;
strbuf->chars = src->chars;
strbuf->length = src->length;
ffStrbufInit(src);
}
else
ffStrbufInit(strbuf);
}
void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...)
{
assert(format != NULL);
+7 -2
View File
@@ -14,7 +14,8 @@
#include <assert.h>
#ifdef _WIN32
#include <shlwapi.h>
// #include <shlwapi.h>
__stdcall const char* StrStrIA(const char* lpFirst, const char* lpSrch);
#define strcasestr StrStrIA
#endif
@@ -31,6 +32,7 @@ typedef struct FFstrbuf
void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate);
void ffStrbufInitCopy(FFstrbuf* strbuf, const FFstrbuf* src);
void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src);
void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...);
void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments);
@@ -115,7 +117,10 @@ static inline void ffStrbufSetS(FFstrbuf* strbuf, const char* value)
static inline void ffStrbufInit(FFstrbuf* strbuf)
{
ffStrbufInitA(strbuf, 0);
extern char* CHAR_NULL_PTR;
strbuf->allocated = 0;
strbuf->length = 0;
strbuf->chars = CHAR_NULL_PTR;
}
static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char* str)
-1
View File
@@ -1,7 +1,6 @@
#include "FFPlatform_private.h"
#include "util/stringUtils.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <shlobj.h>
+1 -1
View File
@@ -5,7 +5,7 @@
#include "fastfetch.h"
#include <winreg.h>
#include <windows.h>
static inline void wrapRegCloseKey(HKEY* phKey)
{
+2
View File
@@ -1,5 +1,7 @@
#include "unicode.h"
#include <windows.h>
void ffStrbufSetNWS(FFstrbuf* result, uint32_t length, const wchar_t* source)
{
if(!length)