mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 18:06:11 +02:00
Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3f13bdca9 | |||
| 55444b9c4e | |||
| 2f14d7742e | |||
| 0534882f4e | |||
| ce2f2f4416 | |||
| 5259aeb039 | |||
| e51999edd1 | |||
| 2f96c847b9 | |||
| 32d6436027 | |||
| 7358326a13 | |||
| 434a879538 | |||
| 745a8dda65 | |||
| c40086615f | |||
| fe3d38e542 | |||
| f19a3b5549 | |||
| eb308e1861 | |||
| 9a4e7874d6 | |||
| d78e528527 | |||
| 81f0e4d583 | |||
| 1d9f462071 | |||
| 047dca3849 | |||
| 1f7c6ab70c | |||
| 1c49ae5324 | |||
| 2e82f8294f | |||
| b2ead8735b | |||
| 5e9166847d | |||
| 28c01599d5 | |||
| ce47a82fb5 | |||
| f1b047c32b | |||
| bc6ed4f4a2 | |||
| b1ac31f590 | |||
| 326d83f25b | |||
| 7218164088 | |||
| 6f970c36e3 | |||
| eea4150dbd | |||
| afa736c37d | |||
| 643e632368 | |||
| ffe354ab07 | |||
| f77090070c | |||
| fd5d2c84e8 | |||
| ef6af84ea1 | |||
| f64bf73279 | |||
| 157be8443d | |||
| 154e15e88f | |||
| 159122eb98 | |||
| 7b6e157a4d | |||
| c6eff111cc | |||
| f23384725f | |||
| 970863e7df | |||
| 0b473e3bff | |||
| 5a43adb62b | |||
| 1a4a949dfe | |||
| 069c20be40 | |||
| c7f0172b25 | |||
| 125759dc75 | |||
| f0a10fcc6d | |||
| c70b9cb84e | |||
| 5ebdd9a989 | |||
| 77e0d9dba1 | |||
| 55b9e274b6 | |||
| 67fe1e66b5 | |||
| ea2a26bd57 | |||
| 55b279ab09 | |||
| e5e4c8bf88 | |||
| c888254f70 | |||
| 75323d64f8 | |||
| a0c4f2febd | |||
| 4b714c7057 | |||
| 559bca4223 | |||
| 8ed28673a9 | |||
| ed9639c66b | |||
| 98b9ef74cf | |||
| e6be90614a | |||
| 20c2cdf7ba | |||
| c70787bde9 | |||
| 8835f66b8c | |||
| 2b2ebe0823 | |||
| 3ff3feb0e1 | |||
| ee4bc2302a | |||
| cd4a512291 |
@@ -19,11 +19,6 @@ assignees: ''
|
||||
|
||||
# Often helpful information:
|
||||
|
||||
Output of `fastfetch --version`:
|
||||
```
|
||||
//paste here
|
||||
```
|
||||
|
||||
The content of the configuration file you use (if any)
|
||||
```
|
||||
//paste here
|
||||
@@ -34,7 +29,7 @@ Output of `env NO_CONFIG=1 fastfetch --load-config all --show-errors --stat --mu
|
||||
Note that this output will contain you public IP. If it is not relevant for the issue, feel free to remove it before uploading.
|
||||
|
||||
If you get the following error: `Error: couldn't find config: [...]`, copy the files in [presets](../../presets/) to `/usr/share/fastfetch/presets/` or `~/.local/share/fastfetch/presets/`.
|
||||
If this isn't possible (or too much work) for you, post the output of `env NO_CONFIG=1 fastfetch --show-errors --stat --multithreading false --disable-linewrap false --hide-cursor false`.
|
||||
If this isn't possible (or too much work) for you, post the output of `env NO_CONFIG=1 fastfetch --show-errors --stat --multithreading false --disable-linewrap false --hide-cursor false && fastfetch --version`.
|
||||
-->
|
||||
|
||||
```
|
||||
|
||||
@@ -187,7 +187,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-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
|
||||
install: git mingw-w64-clang-x86_64-7zip 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
|
||||
|
||||
- name: print msys version
|
||||
run: uname -a
|
||||
@@ -222,13 +222,16 @@ jobs:
|
||||
run: ctest
|
||||
|
||||
- name: create zip archive
|
||||
run: zip fastfetch-$(./fastfetch --version-raw)-Win64.zip *.dll fastfetch.exe flashfetch.exe
|
||||
run: 7z a -tzip -mx9 -bd -y fastfetch-$(./fastfetch --version-raw)-Win64.zip *.dll fastfetch.exe flashfetch.exe presets
|
||||
|
||||
- name: create 7z archive
|
||||
run: 7z a -t7z -mx9 -bd -y fastfetch-$(./fastfetch --version-raw)-Win64.7z *.dll fastfetch.exe flashfetch.exe presets
|
||||
|
||||
- name: upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: fastfetch-win64
|
||||
path: ./fastfetch-*-Win64.zip
|
||||
path: ./fastfetch-*-Win64.*
|
||||
|
||||
win32:
|
||||
name: Win32
|
||||
@@ -248,7 +251,7 @@ jobs:
|
||||
with:
|
||||
msystem: CLANG32
|
||||
update: true
|
||||
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
|
||||
install: git mingw-w64-clang-i686-7zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd
|
||||
|
||||
- name: print msys version
|
||||
run: uname -a
|
||||
@@ -280,13 +283,16 @@ jobs:
|
||||
run: ctest
|
||||
|
||||
- name: create zip archive
|
||||
run: zip fastfetch-$(./fastfetch --version-raw)-Win32.zip *.dll fastfetch.exe flashfetch.exe
|
||||
run: 7z a -tzip -mx9 -bd -y fastfetch-$(./fastfetch --version-raw)-Win32.zip *.dll fastfetch.exe flashfetch.exe presets
|
||||
|
||||
- name: create 7z archive
|
||||
run: 7z a -t7z -mx9 -bd -y fastfetch-$(./fastfetch --version-raw)-Win32.7z *.dll fastfetch.exe flashfetch.exe presets
|
||||
|
||||
- name: upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: fastfetch-win32
|
||||
path: ./fastfetch-*-Win32.zip
|
||||
path: ./fastfetch-*-Win32.*
|
||||
|
||||
release:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'fastfetch-cli/fastfetch'
|
||||
|
||||
+65
-2
@@ -1,4 +1,67 @@
|
||||
# 2.0.0 (beta)
|
||||
# 2.0.5
|
||||
|
||||
Bugfixes:
|
||||
* Fix segfault when using libxrandr (#544, Display, Linux)
|
||||
* Don't print 0px (#544, Cursor)
|
||||
|
||||
Features:
|
||||
* Add option `--disk-use-available` (#543)
|
||||
* Add option `--disk-show-readonly`
|
||||
|
||||
# 2.0.4
|
||||
|
||||
Bugfixes:
|
||||
* Fix building on 32-bit FreeBSD (Memory, BSD)
|
||||
* Fix `--file-raw` doesn't work (Logo)
|
||||
|
||||
Features:
|
||||
* Trait `-` as an alias for `/dev/stdin`. Available for `--file`, `--file-raw` and `--raw` (Logo)
|
||||
|
||||
# 2.0.3
|
||||
|
||||
Bugfixes:
|
||||
* Fix typo in config parsing for --color-title (#534)
|
||||
* Fix percent formatting for `--*-format` (#535)
|
||||
* Fix loading presets for homebrew (macOS)
|
||||
|
||||
Features:
|
||||
* Add option `--percent-ndigits`
|
||||
* Add command flag `--config` as an alias of `--load-config`
|
||||
* Windows packages now include presets (Windows)
|
||||
|
||||
# 2.0.2
|
||||
|
||||
Bugfixes:
|
||||
* Workarund [a compiler bug of GCC](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282) (Windows)
|
||||
* Fix presets not detected by file name (#529)
|
||||
|
||||
Logo:
|
||||
* Add Tuxedo OS
|
||||
|
||||
# 2.0.1
|
||||
|
||||
First stable release of Fastfetch V2
|
||||
|
||||
Changes:
|
||||
* Unescape strings only when parsing `.conf` files
|
||||
* Previously: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\: *`. Note the backslashs are unescaped twice (once by shell and once by fastfetch).
|
||||
* Now: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\\: *`
|
||||
* Remove option shortcut `-c` (alias of `--color`), which is more commonly used as alias of `--config`
|
||||
* Rename `--recache` to `--logo-recache` (which is used for regenerate image logo cache). Remove option shortcut `-r` (alias of `--recache`).
|
||||
* Detecting brightness of external displays with DDC/CI is no longer guarded behind `--allow-slow-operations` (Brightness)
|
||||
|
||||
Features:
|
||||
* Add `--key-width` for aligning the left edge of values, supported both for global `--key-width` and specific module `--module-key-width`
|
||||
* Add `--bar-char-elapsed`, `--bar-char-total`, `--bar-width` and `--bar-border` options
|
||||
* Add CMake option `ENABLE_SYSTEM_YYJSON`, which allow building fastfetch with system-provided yyjson (for package managers)
|
||||
* Add new module `Version`, which prints fastfetch version (like `fastfetch --version`)
|
||||
|
||||
Bugfixes:
|
||||
* Fix label detection. Use `--disk-key 'Disk ({2})'` to display it (Disk, Linux)
|
||||
* Fix some module options were not inited
|
||||
* Fix terminal version and font detection on NixOS (Terminal, Linux)
|
||||
|
||||
# 2.0.0-beta
|
||||
|
||||
Fastfetch v2 introduces a new configuration file format: JSON config. Please refer to <https://github.com/fastfetch-cli/fastfetch/wiki/Configuration> for details.
|
||||
|
||||
@@ -32,7 +95,7 @@ Features:
|
||||
* Support iTerm non-ascii font detection (Terminal, macOS)
|
||||
* Add option `--title-color-user`, `--title-color-at` and `--title-color-host` (Title)
|
||||
* Add Exherbo logo and package manager count (Packages, Linux, #503)
|
||||
* Add module `Terminal Size` which prints the number of terminal width and height in charactors and pixels
|
||||
* Add module `Terminal Size` which prints the number of terminal width and height in characters and pixels
|
||||
* Add new option `--temperature-unit`
|
||||
* Better CPU and Host detection for Android (Android)
|
||||
* Support yakuake terminal version & font detection (Terminal, Linux)
|
||||
|
||||
+26
-25
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url & FetchContent
|
||||
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
|
||||
|
||||
project(fastfetch
|
||||
VERSION 2.0.0
|
||||
VERSION 2.0.5
|
||||
LANGUAGES C
|
||||
DESCRIPTION "Fast system information tool"
|
||||
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
|
||||
@@ -36,24 +36,6 @@ endif()
|
||||
|
||||
include(CheckIncludeFile)
|
||||
|
||||
include(FetchContent)
|
||||
function(ff_fetch_dep package repo tag)
|
||||
FetchContent_Declare(
|
||||
"${package}"
|
||||
GIT_REPOSITORY "${repo}"
|
||||
GIT_TAG "${tag}"
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
FetchContent_GetProperties("${package}")
|
||||
if(NOT ${package}_POPULATED)
|
||||
message("-- Fetching dependency ${package}@${tag} from ${repo}")
|
||||
FetchContent_Populate(${package})
|
||||
add_subdirectory(${${package}_SOURCE_DIR} ${${package}_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
ff_fetch_dep(yyjson "https://github.com/ibireme/yyjson" "0.7.0")
|
||||
|
||||
#####################
|
||||
# Configure options #
|
||||
#####################
|
||||
@@ -87,6 +69,7 @@ cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
|
||||
cmake_dependent_option(ENABLE_PCI_MEMORY "Enable detecting GPU memory size with libpci" OFF "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embeded) yyjson library" OFF "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
|
||||
|
||||
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
|
||||
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
|
||||
@@ -228,7 +211,6 @@ fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE)
|
||||
fastfetch_load_text(src/data/config_system.txt DATATEXT_CONFIG_SYSTEM)
|
||||
fastfetch_load_text(src/data/config_user.txt DATATEXT_CONFIG_USER)
|
||||
fastfetch_load_text(src/data/config_user.jsonc DATATEXT_CONFIG_USER_JSONC)
|
||||
fastfetch_load_text(src/data/modules.txt DATATEXT_MODULES)
|
||||
fastfetch_load_text(src/data/help.txt DATATEXT_HELP)
|
||||
fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR)
|
||||
fastfetch_load_text(src/data/help_format.txt DATATEXT_HELP_FORMAT)
|
||||
@@ -270,11 +252,13 @@ file(GENERATE OUTPUT logo_builtin.h CONTENT "${LOGO_BUILTIN_H}")
|
||||
|
||||
set(LIBFASTFETCH_SRC
|
||||
src/common/bar.c
|
||||
src/common/commandoption.c
|
||||
src/common/font.c
|
||||
src/common/format.c
|
||||
src/common/init.c
|
||||
src/common/jsonconfig.c
|
||||
src/common/library.c
|
||||
src/common/modules.c
|
||||
src/common/option.c
|
||||
src/common/parsing.c
|
||||
src/common/printing.c
|
||||
@@ -295,6 +279,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/detection/packages/packages.c
|
||||
src/detection/terminalfont/terminalfont.c
|
||||
src/detection/terminalshell/terminalshell.c
|
||||
src/detection/version/version.c
|
||||
src/detection/vulkan/vulkan.c
|
||||
src/logo/builtin.c
|
||||
src/logo/image/im6.c
|
||||
@@ -350,6 +335,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/modules/title/title.c
|
||||
src/modules/uptime/uptime.c
|
||||
src/modules/users/users.c
|
||||
src/modules/version/version.c
|
||||
src/modules/vulkan/vulkan.c
|
||||
src/modules/wallpaper/wallpaper.c
|
||||
src/modules/weather/weather.c
|
||||
@@ -618,12 +604,29 @@ endif()
|
||||
include(CheckFunctionExists)
|
||||
check_function_exists(wcwidth HAVE_WCWIDTH)
|
||||
if(NOT HAVE_WCWIDTH)
|
||||
list(APPEND LIBFASTFETCH_SRC src/util/wcwidth.c)
|
||||
list(APPEND LIBFASTFETCH_SRC src/3rdparty/mk_wcwidch/wcwidth.c)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SYSTEM_YYJSON)
|
||||
find_package(yyjson)
|
||||
if(yyjson_FOUND)
|
||||
message(STATUS "System provided yyjson is used")
|
||||
else()
|
||||
message(FATAL_ERROR "ENABLE_SYSTEM_YYJSON is set but system provided yyjson is not found")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/3rdparty/yyjson/yyjson.c
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(libfastfetch OBJECT
|
||||
${LIBFASTFETCH_SRC}
|
||||
)
|
||||
if(yyjson_FOUND)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_USE_SYSTEM_YYJSON)
|
||||
target_link_libraries(libfastfetch PRIVATE yyjson)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE)
|
||||
if(WIN32)
|
||||
@@ -822,6 +825,7 @@ elseif(WIN32)
|
||||
)
|
||||
elseif(BSD)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "m"
|
||||
PRIVATE "usbhid"
|
||||
)
|
||||
elseif(ANDROID)
|
||||
@@ -847,7 +851,6 @@ target_include_directories(libfastfetch
|
||||
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE ${CMAKE_DL_LIBS}
|
||||
PRIVATE yyjson
|
||||
)
|
||||
|
||||
######################
|
||||
@@ -862,7 +865,6 @@ target_compile_definitions(fastfetch
|
||||
)
|
||||
target_link_libraries(fastfetch
|
||||
PRIVATE libfastfetch
|
||||
PRIVATE yyjson
|
||||
)
|
||||
|
||||
add_executable(flashfetch
|
||||
@@ -873,7 +875,6 @@ target_compile_definitions(flashfetch
|
||||
)
|
||||
target_link_libraries(flashfetch
|
||||
PRIVATE libfastfetch
|
||||
PRIVATE yyjson
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
# Fastfetch
|
||||
|
||||
[](https://github.com/fastfetch-cli/fastfetch/actions/workflows/ci.yml)
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
[](https://repology.org/project/fastfetch/versions)
|
||||
[](https://repology.org/project/fastfetch/versions)
|
||||
|
||||
Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written mainly in C, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported.
|
||||
|
||||
@@ -96,14 +105,14 @@ All categories not listed here should work without needing a specific implementa
|
||||
|
||||
##### Available Modules
|
||||
```
|
||||
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, Monitor, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme
|
||||
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, Monitor, OpenCL, OpenGL, OS, Packages, Player, Power Adapter, Processes, PublicIP, Separator, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Version, Vulkan, Wallpaper, Weather, Wifi, WM, WMTheme
|
||||
```
|
||||
|
||||
##### Builtin logos
|
||||
|
||||
<!-- `Content of src/logo/builtin.c`.split('\n').map(x => x.trim()).filter(x => x.startsWith('// ')).map(x => x.slice(3)).sort((a,b)=>a.toUpperCase().localeCompare(b.toUpperCase())).join(', ') -->
|
||||
<!-- `Content of src/logo/builtin.c`.split('\n').map(x => x.trim()).filter(x => x.startsWith('// ')).map(x => x.slice(3)).filter(x => x != 'LAST').sort((a, b)=>a.toUpperCase().localeCompare(b.toUpperCase())).join(', ') -->
|
||||
```
|
||||
AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, Dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, GNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, Januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin
|
||||
AerOS, AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, Dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, GNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, Januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, MOS, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, TuxedoOS, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin
|
||||
```
|
||||
|
||||
Run `fastfetch --print-logos` to print them
|
||||
|
||||
+116
-1
@@ -17,6 +17,12 @@
|
||||
"title": "Color of the module key. Left empty to use `display.color.keys`",
|
||||
"$ref": "#/$defs/colors"
|
||||
},
|
||||
"keyWidth": {
|
||||
"title": "Width of the module key. Use 0 to use `display.keyWidth`",
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"default": 0
|
||||
},
|
||||
"format": {
|
||||
"title": "Output format of the module",
|
||||
"type": "string"
|
||||
@@ -155,6 +161,11 @@
|
||||
"title": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol",
|
||||
"default": false
|
||||
},
|
||||
"recache": {
|
||||
"type": "boolean",
|
||||
"title": "If true, regenerate image logo cache",
|
||||
"default": false
|
||||
},
|
||||
"chafa": {
|
||||
"type": "object",
|
||||
"title": "Chafa configuration. See chafa document for details",
|
||||
@@ -221,6 +232,11 @@
|
||||
"title": "Use multiple threads to detect values",
|
||||
"default": true
|
||||
},
|
||||
"thread": {
|
||||
"type": "boolean",
|
||||
"title": "Alias of multithreading",
|
||||
"default": true
|
||||
},
|
||||
"stat": {
|
||||
"type": "boolean",
|
||||
"title": "Show time usage (in ms) for individual modules",
|
||||
@@ -309,6 +325,12 @@
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"keyWidth": {
|
||||
"title": "Align the width of keys to number of characters, 0 to disable",
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"default": 0
|
||||
},
|
||||
"binaryPrefix": {
|
||||
"type": "string",
|
||||
"title": "Set the binary prefix to used when printing bytes",
|
||||
@@ -321,6 +343,8 @@
|
||||
"sizeNdigits": {
|
||||
"type": "integer",
|
||||
"title": "Set the number of digits to keep after the decimal point when formatting sizes",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"default": 2
|
||||
},
|
||||
"sizeMaxPrefix": {
|
||||
@@ -335,13 +359,47 @@
|
||||
"enum": ["CELSIUS", "C", "FAHRENHEIT", "F", "KELVIN", "K"],
|
||||
"default": "C"
|
||||
},
|
||||
"bar": {
|
||||
"type": "object",
|
||||
"title": "Set the bar configuration",
|
||||
"properties": {
|
||||
"charElapsed": {
|
||||
"type": "string",
|
||||
"title": "Set the character to use in elapsed part",
|
||||
"default": "■"
|
||||
},
|
||||
"charTotal": {
|
||||
"type": "string",
|
||||
"title": "Set the character to use in total part",
|
||||
"default": "-"
|
||||
},
|
||||
"border": {
|
||||
"type": "boolean",
|
||||
"title": "Whether to show a border around the bar",
|
||||
"default": true
|
||||
},
|
||||
"width": {
|
||||
"type": "integer",
|
||||
"title": "Set the width of the bar, in number of characters",
|
||||
"minimum": 1,
|
||||
"default": 10
|
||||
}
|
||||
}
|
||||
},
|
||||
"percentType": {
|
||||
"type": "number",
|
||||
"title": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"maximum": 255,
|
||||
"default": 1
|
||||
},
|
||||
"percentNdigits": {
|
||||
"type": "number",
|
||||
"title": "Set the number of digits to keep after the decimal point when formatting percentage numbers",
|
||||
"minimum": 0,
|
||||
"maximum": 9,
|
||||
"default": 0
|
||||
},
|
||||
"noBuffer": {
|
||||
"type": "boolean",
|
||||
"title": "Whether to disable the stdout application buffer",
|
||||
@@ -509,6 +567,7 @@
|
||||
"theme",
|
||||
"uptime",
|
||||
"users",
|
||||
"version",
|
||||
"vulkan",
|
||||
"wallpaper",
|
||||
"weather",
|
||||
@@ -577,6 +636,7 @@
|
||||
"theme",
|
||||
"uptime",
|
||||
"users",
|
||||
"version",
|
||||
"vulkan",
|
||||
"wallpaper",
|
||||
"wm",
|
||||
@@ -590,6 +650,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -617,6 +680,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -640,6 +706,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -663,6 +732,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -716,6 +788,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -736,6 +811,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"title": "Text to print",
|
||||
"type": "string"
|
||||
@@ -772,6 +850,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -803,17 +884,30 @@
|
||||
"title": "Set if subvolumes should be printed",
|
||||
"default": false
|
||||
},
|
||||
"showReadOnly": {
|
||||
"type": "boolean",
|
||||
"title": "Set if read only volumes should be printed",
|
||||
"default": false
|
||||
},
|
||||
"showUnknown": {
|
||||
"type": "boolean",
|
||||
"title": "Set if unknown (unable to detect sizes) volumes should be printed",
|
||||
"default": false
|
||||
},
|
||||
"useAvailable": {
|
||||
"type": "boolean",
|
||||
"title": "Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes",
|
||||
"default": false
|
||||
},
|
||||
"key": {
|
||||
"$ref": "#/$defs/key"
|
||||
},
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -851,6 +945,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -903,6 +1000,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -931,6 +1031,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -961,6 +1064,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1003,6 +1109,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1044,6 +1153,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
@@ -1077,6 +1189,9 @@
|
||||
"keyColor": {
|
||||
"$ref": "#/$defs/keyColor"
|
||||
},
|
||||
"keyWidth": {
|
||||
"$ref": "#/$defs/keyWidth"
|
||||
},
|
||||
"format": {
|
||||
"$ref": "#/$defs/format"
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:Monitor:LM:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:TerminalSize:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors
|
||||
--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:Monitor:LM:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:TerminalSize:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Version:Break:Colors
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"sound",
|
||||
"gamepad",
|
||||
"weather",
|
||||
"version",
|
||||
"break",
|
||||
"colors"
|
||||
]
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"logo": {
|
||||
"type": "small"
|
||||
},
|
||||
"display": {
|
||||
"percentType": 6,
|
||||
"keyWidth": 11,
|
||||
"bar": {
|
||||
"charElapsed": "=",
|
||||
"charTotal": "-",
|
||||
"width": 13
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
"title",
|
||||
"separator",
|
||||
"memory",
|
||||
"swap",
|
||||
"disk",
|
||||
"battery",
|
||||
{
|
||||
"type": "colors",
|
||||
"paddingLeft": 11,
|
||||
"symbol": "circle"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"home": "https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c",
|
||||
"license": "Embed in source",
|
||||
"version": "2007-05-26 (Unicode 5.0)",
|
||||
"author": "Markus Kuhn",
|
||||
"modified": "CarterLi"
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"home": "https://github.com/ibireme/yyjson",
|
||||
"license": "MIT ( embed in source )",
|
||||
"version": "5e3b26d2659287d31e2f8e10f95f95feb7e5ab3a",
|
||||
"author": "ibireme"
|
||||
}
|
||||
Vendored
+9281
File diff suppressed because it is too large
Load Diff
Vendored
+7846
File diff suppressed because it is too large
Load Diff
+45
-39
@@ -1,51 +1,57 @@
|
||||
#include "common/bar.h"
|
||||
#include "common/color.h"
|
||||
#include "util/textModifier.h"
|
||||
#include "bar.h"
|
||||
|
||||
// green, yellow, red: print the color on nth (0~9) block
|
||||
// set its value == 10 means the color will not be printed
|
||||
void ffAppendPercentBar(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red)
|
||||
void ffAppendPercentBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, uint8_t red)
|
||||
{
|
||||
assert(green <= 10 && yellow <= 10 && red <= 10);
|
||||
assert(green <= 100 && yellow <= 100 && red <= 100);
|
||||
|
||||
// [ 0%, 5%) prints 0 blocks
|
||||
// [ 5%, 15%) prints 1 block;
|
||||
// ...
|
||||
// [85%, 95%) prints 9 blocks;
|
||||
// [95%,100%] prints 10 blocks
|
||||
percent = (uint8_t)(percent + 5) / 10;
|
||||
assert(percent <= 10);
|
||||
uint32_t blocksPercent = (uint32_t) (percent / 100.0 * instance.config.barWidth + 0.5);
|
||||
uint32_t blocksGreen = (uint32_t) (green / 100.0 * instance.config.barWidth + 0.5);
|
||||
uint32_t blocksYellow = (uint32_t) (yellow / 100.0 * instance.config.barWidth + 0.5);
|
||||
uint32_t blocksRed = (uint32_t) (red / 100.0 * instance.config.barWidth + 0.5);
|
||||
assert(blocksPercent <= instance.config.barWidth);
|
||||
|
||||
if(!instance.config.pipe)
|
||||
ffStrbufAppendS(buffer, "\033[97m[ ");
|
||||
else
|
||||
ffStrbufAppendS(buffer, "[ ");
|
||||
if(instance.config.barBorder)
|
||||
{
|
||||
if(!instance.config.pipe)
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m[ ");
|
||||
else
|
||||
ffStrbufAppendS(buffer, "[ ");
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < percent; ++i)
|
||||
for (uint32_t i = 0; i < blocksPercent; ++i)
|
||||
{
|
||||
if(!instance.config.pipe)
|
||||
{
|
||||
if (i == green)
|
||||
ffStrbufAppendS(buffer, "\033[32m");
|
||||
else if (i == yellow)
|
||||
ffStrbufAppendS(buffer, "\033[93m");
|
||||
else if (i == red)
|
||||
ffStrbufAppendS(buffer, "\033[91m");
|
||||
if (i == blocksGreen)
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_GREEN "m");
|
||||
else if (i == blocksYellow)
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_YELLOW "m");
|
||||
else if (i == blocksRed)
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_RED "m");
|
||||
}
|
||||
ffStrbufAppendS(buffer, "■");
|
||||
ffStrbufAppend(buffer, &instance.config.barCharElapsed);
|
||||
}
|
||||
|
||||
if (percent < 10)
|
||||
if (blocksPercent < instance.config.barWidth)
|
||||
{
|
||||
if(!instance.config.pipe)
|
||||
ffStrbufAppendS(buffer, "\033[97m");
|
||||
for (uint8_t i = percent; i < 10; ++i)
|
||||
ffStrbufAppendS(buffer, "-");
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m");
|
||||
for (uint32_t i = blocksPercent; i < instance.config.barWidth; ++i)
|
||||
ffStrbufAppend(buffer, &instance.config.barCharTotal);
|
||||
}
|
||||
|
||||
if(instance.config.barBorder)
|
||||
{
|
||||
if(!instance.config.pipe)
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m ]");
|
||||
else
|
||||
ffStrbufAppendS(buffer, " ]");
|
||||
}
|
||||
|
||||
if(!instance.config.pipe)
|
||||
ffStrbufAppendS(buffer, "\033[97m ]" FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
else
|
||||
ffStrbufAppendS(buffer, " ]");
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
}
|
||||
|
||||
// if (green < yellow)
|
||||
@@ -57,7 +63,7 @@ void ffAppendPercentBar(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_
|
||||
// [green, 100]: print green
|
||||
// [yellow, green): print yellow
|
||||
// [0, yellow): PRINT RED
|
||||
void ffAppendPercentNum(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses)
|
||||
void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, bool parentheses)
|
||||
{
|
||||
assert(green <= 100 && yellow <= 100);
|
||||
|
||||
@@ -71,23 +77,23 @@ void ffAppendPercentNum(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_
|
||||
if(green < yellow)
|
||||
{
|
||||
if (percent <= green)
|
||||
ffStrbufAppendS(buffer, "\033[32m");
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_GREEN "m");
|
||||
else if (percent <= yellow)
|
||||
ffStrbufAppendS(buffer, "\033[93m");
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_YELLOW "m");
|
||||
else
|
||||
ffStrbufAppendS(buffer, "\033[91m");
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_RED "m");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (percent >= green)
|
||||
ffStrbufAppendS(buffer, "\033[32m");
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_GREEN "m");
|
||||
else if (percent >= yellow)
|
||||
ffStrbufAppendS(buffer, "\033[93m");
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_YELLOW "m");
|
||||
else
|
||||
ffStrbufAppendS(buffer, "\033[91m");
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_RED "m");
|
||||
}
|
||||
}
|
||||
ffStrbufAppendF(buffer, "%u%%", (unsigned) percent);
|
||||
ffStrbufAppendF(buffer, "%.*f%%", instance.config.percentNdigits, percent);
|
||||
|
||||
if (colored && !instance.config.pipe)
|
||||
{
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ enum
|
||||
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
|
||||
};
|
||||
|
||||
void ffAppendPercentBar(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red);
|
||||
void ffAppendPercentNum(FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses);
|
||||
void ffAppendPercentBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, uint8_t red);
|
||||
void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, bool parentheses);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "commandoption.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
bool ffParseModuleCommand(const char* type)
|
||||
{
|
||||
if(!isalpha(type[0])) return false;
|
||||
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(type[0]) - 'A']; *modules; ++modules)
|
||||
{
|
||||
FFModuleBaseInfo* baseInfo = *modules;
|
||||
if (ffStrEqualsIgnCase(type, baseInfo->name))
|
||||
{
|
||||
baseInfo->printModule(baseInfo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ffParseModuleOptions(const char* key, const char* value)
|
||||
{
|
||||
if (!ffStrStartsWith(key, "--") || !isalpha(key[2])) return false;
|
||||
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(key[2]) - 'A']; *modules; ++modules)
|
||||
{
|
||||
FFModuleBaseInfo* baseInfo = *modules;
|
||||
if (baseInfo->parseCommandOptions(baseInfo, key, value)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef FF_INCLUDED_common_commandoption
|
||||
#define FF_INCLUDED_common_commandoption
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
bool ffParseModuleCommand(const char* type);
|
||||
bool ffParseModuleOptions(const char* key, const char* value);
|
||||
|
||||
#endif
|
||||
+97
-82
@@ -48,7 +48,6 @@ static void defaultConfig(void)
|
||||
#endif
|
||||
|
||||
instance.config.showErrors = false;
|
||||
instance.config.recache = false;
|
||||
instance.config.allowSlowOperations = false;
|
||||
instance.config.pipe = !isatty(STDOUT_FILENO);
|
||||
|
||||
@@ -68,58 +67,70 @@ static void defaultConfig(void)
|
||||
instance.config.multithreading = true;
|
||||
instance.config.stat = false;
|
||||
instance.config.noBuffer = false;
|
||||
instance.config.keyWidth = 0;
|
||||
|
||||
ffInitTitleOptions(&instance.config.title);
|
||||
ffInitOSOptions(&instance.config.os);
|
||||
ffInitHostOptions(&instance.config.host);
|
||||
ffStrbufInitStatic(&instance.config.barCharElapsed, "■");
|
||||
ffStrbufInitStatic(&instance.config.barCharTotal, "-");
|
||||
instance.config.barWidth = 10;
|
||||
instance.config.barBorder = true;
|
||||
instance.config.percentType = 1;
|
||||
instance.config.percentNdigits = 0;
|
||||
|
||||
ffInitBatteryOptions(&instance.config.battery);
|
||||
ffInitBiosOptions(&instance.config.bios);
|
||||
ffInitBluetoothOptions(&instance.config.bluetooth);
|
||||
ffInitBoardOptions(&instance.config.board);
|
||||
ffInitBreakOptions(&instance.config.break_);
|
||||
ffInitBrightnessOptions(&instance.config.brightness);
|
||||
ffInitChassisOptions(&instance.config.chassis);
|
||||
ffInitCommandOptions(&instance.config.command);
|
||||
ffInitCustomOptions(&instance.config.custom);
|
||||
ffInitKernelOptions(&instance.config.kernel);
|
||||
ffInitUptimeOptions(&instance.config.uptime);
|
||||
ffInitProcessesOptions(&instance.config.processes);
|
||||
ffInitPackagesOptions(&instance.config.packages);
|
||||
ffInitShellOptions(&instance.config.shell);
|
||||
ffInitDisplayOptions(&instance.config.display);
|
||||
ffInitDEOptions(&instance.config.de);
|
||||
ffInitWMOptions(&instance.config.wm);
|
||||
ffInitWMThemeOptions(&instance.config.wmTheme);
|
||||
ffInitThemeOptions(&instance.config.theme);
|
||||
ffInitIconsOptions(&instance.config.icons);
|
||||
ffInitFontOptions(&instance.config.font);
|
||||
ffInitCursorOptions(&instance.config.cursor);
|
||||
ffInitTerminalOptions(&instance.config.terminal);
|
||||
ffInitTerminalFontOptions(&instance.config.terminalFont);
|
||||
ffInitCPUOptions(&instance.config.cpu);
|
||||
ffInitCPUUsageOptions(&instance.config.cpuUsage);
|
||||
ffInitGPUOptions(&instance.config.gpu);
|
||||
ffInitMemoryOptions(&instance.config.memory);
|
||||
ffInitSwapOptions(&instance.config.swap);
|
||||
ffInitChassisOptions(&instance.config.chassis);
|
||||
ffInitColorsOptions(&instance.config.colors);
|
||||
ffInitCommandOptions(&instance.config.command);
|
||||
ffInitCursorOptions(&instance.config.cursor);
|
||||
ffInitCustomOptions(&instance.config.custom);
|
||||
ffInitDEOptions(&instance.config.de);
|
||||
ffInitDateTimeOptions(&instance.config.dateTime);
|
||||
ffInitDiskOptions(&instance.config.disk);
|
||||
ffInitBatteryOptions(&instance.config.battery);
|
||||
ffInitPowerAdapterOptions(&instance.config.powerAdapter);
|
||||
ffInitDisplayOptions(&instance.config.display);
|
||||
ffInitFontOptions(&instance.config.font);
|
||||
ffInitGPUOptions(&instance.config.gpu);
|
||||
ffInitGamepadOptions(&instance.config.gamepad);
|
||||
ffInitHostOptions(&instance.config.host);
|
||||
ffInitIconsOptions(&instance.config.icons);
|
||||
ffInitKernelOptions(&instance.config.kernel);
|
||||
ffInitLMOptions(&instance.config.lm);
|
||||
ffInitLocaleOptions(&instance.config.locale);
|
||||
ffInitLocalIpOptions(&instance.config.localIP);
|
||||
ffInitLocaleOptions(&instance.config.locale);
|
||||
ffInitMediaOptions(&instance.config.media);
|
||||
ffInitMemoryOptions(&instance.config.memory);
|
||||
ffInitMonitorOptions(&instance.config.monitor);
|
||||
ffInitOSOptions(&instance.config.os);
|
||||
ffInitOpenCLOptions(&instance.config.openCL);
|
||||
ffInitOpenGLOptions(&instance.config.openGL);
|
||||
ffInitPackagesOptions(&instance.config.packages);
|
||||
ffInitPlayerOptions(&instance.config.player);
|
||||
ffInitPowerAdapterOptions(&instance.config.powerAdapter);
|
||||
ffInitProcessesOptions(&instance.config.processes);
|
||||
ffInitPublicIpOptions(&instance.config.publicIP);
|
||||
ffInitSeparatorOptions(&instance.config.separator);
|
||||
ffInitShellOptions(&instance.config.shell);
|
||||
ffInitSoundOptions(&instance.config.sound);
|
||||
ffInitSwapOptions(&instance.config.swap);
|
||||
ffInitTerminalFontOptions(&instance.config.terminalFont);
|
||||
ffInitTerminalOptions(&instance.config.terminal);
|
||||
ffInitTerminalSizeOptions(&instance.config.terminalSize);
|
||||
ffInitThemeOptions(&instance.config.theme);
|
||||
ffInitTitleOptions(&instance.config.title);
|
||||
ffInitUptimeOptions(&instance.config.uptime);
|
||||
ffInitUsersOptions(&instance.config.users);
|
||||
ffInitVersionOptions(&instance.config.version);
|
||||
ffInitVulkanOptions(&instance.config.vulkan);
|
||||
ffInitWMOptions(&instance.config.wm);
|
||||
ffInitWMThemeOptions(&instance.config.wmTheme);
|
||||
ffInitWallpaperOptions(&instance.config.wallpaper);
|
||||
ffInitWeatherOptions(&instance.config.weather);
|
||||
ffInitWifiOptions(&instance.config.wifi);
|
||||
ffInitPlayerOptions(&instance.config.player);
|
||||
ffInitMediaOptions(&instance.config.media);
|
||||
ffInitDateTimeOptions(&instance.config.dateTime);
|
||||
ffInitVulkanOptions(&instance.config.vulkan);
|
||||
ffInitWallpaperOptions(&instance.config.wallpaper);
|
||||
ffInitOpenGLOptions(&instance.config.openGL);
|
||||
ffInitOpenCLOptions(&instance.config.openCL);
|
||||
ffInitUsersOptions(&instance.config.users);
|
||||
ffInitBluetoothOptions(&instance.config.bluetooth);
|
||||
ffInitSoundOptions(&instance.config.sound);
|
||||
ffInitSeparatorOptions(&instance.config.separator);
|
||||
ffInitGamepadOptions(&instance.config.gamepad);
|
||||
ffInitColorsOptions(&instance.config.colors);
|
||||
|
||||
ffStrbufInit(&instance.config.libPCI);
|
||||
ffStrbufInit(&instance.config.libVulkan);
|
||||
@@ -145,8 +156,6 @@ static void defaultConfig(void)
|
||||
ffStrbufInit(&instance.config.libPulse);
|
||||
ffStrbufInit(&instance.config.libnm);
|
||||
ffStrbufInit(&instance.config.libDdcutil);
|
||||
|
||||
instance.config.percentType = 1;
|
||||
}
|
||||
|
||||
void ffInitInstance(void)
|
||||
@@ -272,63 +281,69 @@ static void destroyConfig(void)
|
||||
ffStrbufDestroy(&instance.config.colorKeys);
|
||||
ffStrbufDestroy(&instance.config.colorTitle);
|
||||
ffStrbufDestroy(&instance.config.keyValueSeparator);
|
||||
ffStrbufDestroy(&instance.config.barCharElapsed);
|
||||
ffStrbufDestroy(&instance.config.barCharTotal);
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
ffStrbufDestroy(&instance.config.playerName);
|
||||
ffStrbufDestroy(&instance.config.osFile);
|
||||
#endif
|
||||
|
||||
ffDestroyTitleOptions(&instance.config.title);
|
||||
ffDestroyOSOptions(&instance.config.os);
|
||||
ffDestroyHostOptions(&instance.config.host);
|
||||
ffDestroyBatteryOptions(&instance.config.battery);
|
||||
ffDestroyBiosOptions(&instance.config.bios);
|
||||
ffDestroyBluetoothOptions(&instance.config.bluetooth);
|
||||
ffDestroyBoardOptions(&instance.config.board);
|
||||
ffDestroyBreakOptions(&instance.config.break_);
|
||||
ffDestroyBrightnessOptions(&instance.config.brightness);
|
||||
ffDestroyChassisOptions(&instance.config.chassis);
|
||||
ffDestroyCommandOptions(&instance.config.command);
|
||||
ffDestroyCustomOptions(&instance.config.custom);
|
||||
ffDestroyKernelOptions(&instance.config.kernel);
|
||||
ffDestroyUptimeOptions(&instance.config.uptime);
|
||||
ffDestroyProcessesOptions(&instance.config.processes);
|
||||
ffDestroyPackagesOptions(&instance.config.packages);
|
||||
ffDestroyShellOptions(&instance.config.shell);
|
||||
ffDestroyDisplayOptions(&instance.config.display);
|
||||
ffDestroyDEOptions(&instance.config.de);
|
||||
ffDestroyWMOptions(&instance.config.wm);
|
||||
ffDestroyWMThemeOptions(&instance.config.wmTheme);
|
||||
ffDestroyThemeOptions(&instance.config.theme);
|
||||
ffDestroyIconsOptions(&instance.config.icons);
|
||||
ffDestroyFontOptions(&instance.config.font);
|
||||
ffDestroyCursorOptions(&instance.config.cursor);
|
||||
ffDestroyTerminalOptions(&instance.config.terminal);
|
||||
ffDestroyTerminalFontOptions(&instance.config.terminalFont);
|
||||
ffDestroyCPUOptions(&instance.config.cpu);
|
||||
ffDestroyCPUUsageOptions(&instance.config.cpuUsage);
|
||||
ffDestroyGPUOptions(&instance.config.gpu);
|
||||
ffDestroyMemoryOptions(&instance.config.memory);
|
||||
ffDestroySwapOptions(&instance.config.swap);
|
||||
ffDestroyChassisOptions(&instance.config.chassis);
|
||||
ffDestroyColorsOptions(&instance.config.colors);
|
||||
ffDestroyCommandOptions(&instance.config.command);
|
||||
ffDestroyCursorOptions(&instance.config.cursor);
|
||||
ffDestroyCustomOptions(&instance.config.custom);
|
||||
ffDestroyDEOptions(&instance.config.de);
|
||||
ffDestroyDateTimeOptions(&instance.config.dateTime);
|
||||
ffDestroyDiskOptions(&instance.config.disk);
|
||||
ffDestroyBatteryOptions(&instance.config.battery);
|
||||
ffDestroyPowerAdapterOptions(&instance.config.powerAdapter);
|
||||
ffDestroyDisplayOptions(&instance.config.display);
|
||||
ffDestroyFontOptions(&instance.config.font);
|
||||
ffDestroyGPUOptions(&instance.config.gpu);
|
||||
ffDestroyGamepadOptions(&instance.config.gamepad);
|
||||
ffDestroyHostOptions(&instance.config.host);
|
||||
ffDestroyIconsOptions(&instance.config.icons);
|
||||
ffDestroyKernelOptions(&instance.config.kernel);
|
||||
ffDestroyLMOptions(&instance.config.lm);
|
||||
ffDestroyLocaleOptions(&instance.config.locale);
|
||||
ffDestroyLocalIpOptions(&instance.config.localIP);
|
||||
ffDestroyLocaleOptions(&instance.config.locale);
|
||||
ffDestroyMediaOptions(&instance.config.media);
|
||||
ffDestroyMemoryOptions(&instance.config.memory);
|
||||
ffDestroyMonitorOptions(&instance.config.monitor);
|
||||
ffDestroyOSOptions(&instance.config.os);
|
||||
ffDestroyOpenCLOptions(&instance.config.openCL);
|
||||
ffDestroyOpenGLOptions(&instance.config.openGL);
|
||||
ffDestroyPackagesOptions(&instance.config.packages);
|
||||
ffDestroyPlayerOptions(&instance.config.player);
|
||||
ffDestroyPowerAdapterOptions(&instance.config.powerAdapter);
|
||||
ffDestroyProcessesOptions(&instance.config.processes);
|
||||
ffDestroyPublicIpOptions(&instance.config.publicIP);
|
||||
ffDestroySeparatorOptions(&instance.config.separator);
|
||||
ffDestroyShellOptions(&instance.config.shell);
|
||||
ffDestroySoundOptions(&instance.config.sound);
|
||||
ffDestroySwapOptions(&instance.config.swap);
|
||||
ffDestroyTerminalFontOptions(&instance.config.terminalFont);
|
||||
ffDestroyTerminalOptions(&instance.config.terminal);
|
||||
ffDestroyTerminalSizeOptions(&instance.config.terminalSize);
|
||||
ffDestroyThemeOptions(&instance.config.theme);
|
||||
ffDestroyTitleOptions(&instance.config.title);
|
||||
ffDestroyUptimeOptions(&instance.config.uptime);
|
||||
ffDestroyUsersOptions(&instance.config.users);
|
||||
ffDestroyVersionOptions(&instance.config.version);
|
||||
ffDestroyVulkanOptions(&instance.config.vulkan);
|
||||
ffDestroyWMOptions(&instance.config.wm);
|
||||
ffDestroyWMThemeOptions(&instance.config.wmTheme);
|
||||
ffDestroyWallpaperOptions(&instance.config.wallpaper);
|
||||
ffDestroyWeatherOptions(&instance.config.weather);
|
||||
ffDestroyWifiOptions(&instance.config.wifi);
|
||||
ffDestroyPlayerOptions(&instance.config.player);
|
||||
ffDestroyMediaOptions(&instance.config.media);
|
||||
ffDestroyDateTimeOptions(&instance.config.dateTime);
|
||||
ffDestroyVulkanOptions(&instance.config.vulkan);
|
||||
ffDestroyOpenGLOptions(&instance.config.openGL);
|
||||
ffDestroyOpenCLOptions(&instance.config.openCL);
|
||||
ffDestroyUsersOptions(&instance.config.users);
|
||||
ffDestroyBluetoothOptions(&instance.config.bluetooth);
|
||||
ffDestroySeparatorOptions(&instance.config.separator);
|
||||
ffDestroySoundOptions(&instance.config.sound);
|
||||
ffDestroyGamepadOptions(&instance.config.gamepad);
|
||||
ffDestroyColorsOptions(&instance.config.colors);
|
||||
|
||||
ffStrbufDestroy(&instance.config.libPCI);
|
||||
ffStrbufDestroy(&instance.config.libVulkan);
|
||||
|
||||
+76
-154
@@ -17,14 +17,19 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs*
|
||||
ffStrbufSetNS(&moduleArgs->key, (uint32_t) yyjson_get_len(val), yyjson_get_str(val));
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "format"))
|
||||
{
|
||||
ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val));
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "keyColor"))
|
||||
{
|
||||
ffOptionParseColor(yyjson_get_str(val), &moduleArgs->keyColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "format"))
|
||||
else if(ffStrEqualsIgnCase(key, "keyWidth"))
|
||||
{
|
||||
ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val));
|
||||
moduleArgs->keyWidth = (uint32_t) yyjson_get_uint(val);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -65,165 +70,53 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p
|
||||
return "Invalid enum value type; must be a string or integer";
|
||||
}
|
||||
|
||||
static inline bool tryModule(const char* type, yyjson_val* module, const char* moduleName, void (*const f)(yyjson_val *module))
|
||||
static bool parseModuleJsonObject(const char* type, yyjson_val* jsonVal)
|
||||
{
|
||||
if (ffStrEqualsIgnCase(type, moduleName))
|
||||
if(!isalpha(type[0])) return false;
|
||||
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(type[0]) - 'A']; *modules; ++modules)
|
||||
{
|
||||
f(module);
|
||||
return true;
|
||||
FFModuleBaseInfo* baseInfo = *modules;
|
||||
if (ffStrEqualsIgnCase(type, baseInfo->name))
|
||||
{
|
||||
if (jsonVal) baseInfo->parseJsonObject(baseInfo, jsonVal);
|
||||
baseInfo->printModule(baseInfo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool parseModuleJsonObject(const char* type, yyjson_val* module)
|
||||
static void prepareModuleJsonObject(const char* type, yyjson_val* module)
|
||||
{
|
||||
switch (toupper(type[0]))
|
||||
FFconfig* cfg = &instance.config;
|
||||
switch (type[0])
|
||||
{
|
||||
case 'B': {
|
||||
return
|
||||
tryModule(type, module, FF_BATTERY_MODULE_NAME, ffParseBatteryJsonObject) ||
|
||||
tryModule(type, module, FF_BIOS_MODULE_NAME, ffParseBiosJsonObject) ||
|
||||
tryModule(type, module, FF_BLUETOOTH_MODULE_NAME, ffParseBluetoothJsonObject) ||
|
||||
tryModule(type, module, FF_BOARD_MODULE_NAME, ffParseBoardJsonObject) ||
|
||||
tryModule(type, module, FF_BREAK_MODULE_NAME, ffParseBreakJsonObject) ||
|
||||
tryModule(type, module, FF_BRIGHTNESS_MODULE_NAME, ffParseBrightnessJsonObject) ||
|
||||
false;
|
||||
case 'b': case 'B': {
|
||||
if (ffStrEqualsIgnCase(type, FF_CPUUSAGE_MODULE_NAME))
|
||||
ffPrepareCPUUsage();
|
||||
break;
|
||||
}
|
||||
|
||||
case 'C': {
|
||||
return
|
||||
tryModule(type, module, FF_CHASSIS_MODULE_NAME, ffParseChassisJsonObject) ||
|
||||
tryModule(type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) ||
|
||||
tryModule(type, module, FF_COLORS_MODULE_NAME, ffParseColorsJsonObject) ||
|
||||
tryModule(type, module, FF_CPU_MODULE_NAME, ffParseCPUJsonObject) ||
|
||||
tryModule(type, module, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageJsonObject) ||
|
||||
tryModule(type, module, FF_CURSOR_MODULE_NAME, ffParseCursorJsonObject) ||
|
||||
tryModule(type, module, FF_CUSTOM_MODULE_NAME, ffParseCustomJsonObject) ||
|
||||
false;
|
||||
case 'p': case 'P': {
|
||||
if (ffStrEqualsIgnCase(type, FF_PUBLICIP_MODULE_NAME))
|
||||
{
|
||||
if (module) ffParsePublicIpJsonObject(&cfg->publicIP, module);
|
||||
ffPreparePublicIp(&cfg->publicIP);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'D': {
|
||||
return
|
||||
tryModule(type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) ||
|
||||
tryModule(type, module, FF_DE_MODULE_NAME, ffParseDEJsonObject) ||
|
||||
tryModule(type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) ||
|
||||
tryModule(type, module, FF_DISK_MODULE_NAME, ffParseDiskJsonObject) ||
|
||||
false;
|
||||
case 'w': case 'W': {
|
||||
if (ffStrEqualsIgnCase(type, FF_WEATHER_MODULE_NAME))
|
||||
{
|
||||
if (module) ffParseWeatherJsonObject(&cfg->weather, module);
|
||||
ffPrepareWeather(&cfg->weather);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'F': {
|
||||
return
|
||||
tryModule(type, module, FF_FONT_MODULE_NAME, ffParseFontJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'G': {
|
||||
return
|
||||
tryModule(type, module, FF_GAMEPAD_MODULE_NAME, ffParseGamepadJsonObject) ||
|
||||
tryModule(type, module, FF_GPU_MODULE_NAME, ffParseGPUJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'H': {
|
||||
return
|
||||
tryModule(type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'I': {
|
||||
return
|
||||
tryModule(type, module, FF_ICONS_MODULE_NAME, ffParseIconsJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'K': {
|
||||
return
|
||||
tryModule(type, module, FF_KERNEL_MODULE_NAME, ffParseKernelJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'L': {
|
||||
return
|
||||
tryModule(type, module, FF_LM_MODULE_NAME, ffParseLMJsonObject) ||
|
||||
tryModule(type, module, FF_LOCALE_MODULE_NAME, ffParseLocaleJsonObject) ||
|
||||
tryModule(type, module, FF_LOCALIP_MODULE_NAME, ffParseLocalIpJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'M': {
|
||||
return
|
||||
tryModule(type, module, FF_MEDIA_MODULE_NAME, ffParseMediaJsonObject) ||
|
||||
tryModule(type, module, FF_MEMORY_MODULE_NAME, ffParseMemoryJsonObject) ||
|
||||
tryModule(type, module, FF_MONITOR_MODULE_NAME, ffParseMonitorJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'O': {
|
||||
return
|
||||
tryModule(type, module, FF_OPENCL_MODULE_NAME, ffParseOpenCLJsonObject) ||
|
||||
tryModule(type, module, FF_OPENGL_MODULE_NAME, ffParseOpenGLJsonObject) ||
|
||||
tryModule(type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'P': {
|
||||
return
|
||||
tryModule(type, module, FF_PACKAGES_MODULE_NAME, ffParsePackagesJsonObject) ||
|
||||
tryModule(type, module, FF_PLAYER_MODULE_NAME, ffParsePlayerJsonObject) ||
|
||||
tryModule(type, module, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterJsonObject) ||
|
||||
tryModule(type, module, FF_PROCESSES_MODULE_NAME, ffParseProcessesJsonObject) ||
|
||||
tryModule(type, module, FF_PUBLICIP_MODULE_NAME, ffParsePublicIpJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'S': {
|
||||
return
|
||||
tryModule(type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) ||
|
||||
tryModule(type, module, FF_SHELL_MODULE_NAME, ffParseShellJsonObject) ||
|
||||
tryModule(type, module, FF_SOUND_MODULE_NAME, ffParseSoundJsonObject) ||
|
||||
tryModule(type, module, FF_SWAP_MODULE_NAME, ffParseSwapJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'T': {
|
||||
return
|
||||
tryModule(type, module, FF_TERMINAL_MODULE_NAME, ffParseTerminalJsonObject) ||
|
||||
tryModule(type, module, FF_TERMINALFONT_MODULE_NAME, ffParseTerminalFontJsonObject) ||
|
||||
tryModule(type, module, FF_TERMINALSIZE_MODULE_NAME, ffParseTerminalSizeJsonObject) ||
|
||||
tryModule(type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) ||
|
||||
tryModule(type, module, FF_THEME_MODULE_NAME, ffParseThemeJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'U': {
|
||||
return
|
||||
tryModule(type, module, FF_UPTIME_MODULE_NAME, ffParseUptimeJsonObject) ||
|
||||
tryModule(type, module, FF_USERS_MODULE_NAME, ffParseUsersJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'V': {
|
||||
return
|
||||
tryModule(type, module, FF_VULKAN_MODULE_NAME, ffParseVulkanJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'W': {
|
||||
return
|
||||
tryModule(type, module, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperJsonObject) ||
|
||||
tryModule(type, module, FF_WEATHER_MODULE_NAME, ffParseWeatherJsonObject) ||
|
||||
tryModule(type, module, FF_WM_MODULE_NAME, ffParseWMJsonObject) ||
|
||||
tryModule(type, module, FF_WIFI_MODULE_NAME, ffParseWifiJsonObject) ||
|
||||
tryModule(type, module, FF_WMTHEME_MODULE_NAME, ffParseWMThemeJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* printJsonConfig(void)
|
||||
static const char* printJsonConfig(bool prepare)
|
||||
{
|
||||
yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc);
|
||||
assert(root);
|
||||
@@ -240,7 +133,7 @@ static const char* printJsonConfig(void)
|
||||
yyjson_arr_foreach(modules, idx, max, item)
|
||||
{
|
||||
uint64_t ms = 0;
|
||||
if(__builtin_expect(instance.config.stat, false))
|
||||
if(!prepare && instance.config.stat)
|
||||
ms = ffTimeGetTick();
|
||||
|
||||
yyjson_val* module = item;
|
||||
@@ -257,10 +150,12 @@ static const char* printJsonConfig(void)
|
||||
else
|
||||
return "modules must be an array of strings or objects";
|
||||
|
||||
if(!parseModuleJsonObject(type, module))
|
||||
if(prepare)
|
||||
prepareModuleJsonObject(type, module);
|
||||
else if(!parseModuleJsonObject(type, module))
|
||||
return "Unknown module type";
|
||||
|
||||
if(__builtin_expect(instance.config.stat, false))
|
||||
if(!prepare && instance.config.stat)
|
||||
{
|
||||
char str[32];
|
||||
int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms);
|
||||
@@ -430,9 +325,36 @@ const char* ffParseDisplayJsonConfig(void)
|
||||
config->temperatureUnit = (FFTemperatureUnit) value;
|
||||
}
|
||||
else if (ffStrEqualsIgnCase(key, "percentType"))
|
||||
config->percentType = (uint32_t) yyjson_get_uint(val);
|
||||
config->percentType = (uint8_t) yyjson_get_uint(val);
|
||||
else if (ffStrEqualsIgnCase(key, "percentNdigits"))
|
||||
config->percentNdigits = (uint8_t) yyjson_get_uint(val);
|
||||
else if (ffStrEqualsIgnCase(key, "bar"))
|
||||
{
|
||||
if (yyjson_is_obj(val))
|
||||
{
|
||||
const char* charElapsed = yyjson_get_str(yyjson_obj_get(val, "charElapsed"));
|
||||
if (charElapsed)
|
||||
ffStrbufSetS(&config->barCharElapsed, charElapsed);
|
||||
|
||||
const char* charTotal = yyjson_get_str(yyjson_obj_get(val, "charTotal"));
|
||||
if (charTotal)
|
||||
ffStrbufSetS(&config->barCharTotal, charTotal);
|
||||
|
||||
yyjson_val* border = yyjson_obj_get(val, "border");
|
||||
if (border)
|
||||
config->barBorder = yyjson_get_bool(border);
|
||||
|
||||
yyjson_val* width = yyjson_obj_get(val, "width");
|
||||
if (width)
|
||||
config->barWidth = (uint8_t) yyjson_get_uint(width);
|
||||
}
|
||||
else
|
||||
return "display.bar must be an object";
|
||||
}
|
||||
else if (ffStrEqualsIgnCase(key, "noBuffer"))
|
||||
config->noBuffer = yyjson_get_bool(val);
|
||||
else if (ffStrEqualsIgnCase(key, "keyWidth"))
|
||||
config->keyWidth = (uint32_t) yyjson_get_uint(val);
|
||||
else
|
||||
return "Unknown display property";
|
||||
}
|
||||
@@ -515,9 +437,9 @@ const char* ffParseLibraryJsonConfig(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ffPrintJsonConfig(void)
|
||||
void ffPrintJsonConfig(bool prepare)
|
||||
{
|
||||
const char* error = printJsonConfig();
|
||||
const char* error = printJsonConfig(prepare);
|
||||
if (error)
|
||||
ffPrintErrorString("JsonConfig", 0, NULL, NULL, "%s", error);
|
||||
ffPrintErrorString("JsonConfig", 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "%s", error);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs);
|
||||
const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[]);
|
||||
void ffPrintJsonConfig();
|
||||
const char* ffParseGeneralJsonConfig();
|
||||
const char* ffParseDisplayJsonConfig();
|
||||
const char* ffParseLibraryJsonConfig();
|
||||
void ffPrintJsonConfig(bool prepare);
|
||||
const char* ffParseGeneralJsonConfig(void);
|
||||
const char* ffParseDisplayJsonConfig(void);
|
||||
const char* ffParseLibraryJsonConfig(void);
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
static FFModuleBaseInfo* A[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* B[] = {
|
||||
(void*) &instance.config.battery,
|
||||
(void*) &instance.config.bios,
|
||||
(void*) &instance.config.bluetooth,
|
||||
(void*) &instance.config.board,
|
||||
(void*) &instance.config.break_,
|
||||
(void*) &instance.config.brightness,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* C[] = {
|
||||
(void*) &instance.config.chassis,
|
||||
(void*) &instance.config.command,
|
||||
(void*) &instance.config.colors,
|
||||
(void*) &instance.config.cpu,
|
||||
(void*) &instance.config.cpuUsage,
|
||||
(void*) &instance.config.cursor,
|
||||
(void*) &instance.config.custom,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* D[] = {
|
||||
(void*) &instance.config.dateTime,
|
||||
(void*) &instance.config.de,
|
||||
(void*) &instance.config.display,
|
||||
(void*) &instance.config.disk,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* E[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* F[] = {
|
||||
(void*) &instance.config.font,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* G[] = {
|
||||
(void*) &instance.config.gamepad,
|
||||
(void*) &instance.config.gpu,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* H[] = {
|
||||
(void*) &instance.config.host,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* I[] = {
|
||||
(void*) &instance.config.icons,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* J[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* K[] = {
|
||||
(void*) &instance.config.kernel,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* L[] = {
|
||||
(void*) &instance.config.lm,
|
||||
(void*) &instance.config.locale,
|
||||
(void*) &instance.config.localIP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* M[] = {
|
||||
(void*) &instance.config.media,
|
||||
(void*) &instance.config.memory,
|
||||
(void*) &instance.config.monitor,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* N[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* O[] = {
|
||||
(void*) &instance.config.openCL,
|
||||
(void*) &instance.config.openGL,
|
||||
(void*) &instance.config.os,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* P[] = {
|
||||
(void*) &instance.config.packages,
|
||||
(void*) &instance.config.player,
|
||||
(void*) &instance.config.powerAdapter,
|
||||
(void*) &instance.config.processes,
|
||||
(void*) &instance.config.publicIP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* Q[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* R[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* S[] = {
|
||||
(void*) &instance.config.separator,
|
||||
(void*) &instance.config.shell,
|
||||
(void*) &instance.config.sound,
|
||||
(void*) &instance.config.swap,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* T[] = {
|
||||
(void*) &instance.config.terminal,
|
||||
(void*) &instance.config.terminalFont,
|
||||
(void*) &instance.config.terminalSize,
|
||||
(void*) &instance.config.title,
|
||||
(void*) &instance.config.theme,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* U[] = {
|
||||
(void*) &instance.config.uptime,
|
||||
(void*) &instance.config.users,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* V[] = {
|
||||
(void*) &instance.config.version,
|
||||
(void*) &instance.config.vulkan,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* W[] = {
|
||||
(void*) &instance.config.wallpaper,
|
||||
(void*) &instance.config.weather,
|
||||
(void*) &instance.config.wm,
|
||||
(void*) &instance.config.wifi,
|
||||
(void*) &instance.config.wmTheme,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* X[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* Y[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static FFModuleBaseInfo* Z[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
FFModuleBaseInfo** ffModuleInfos[] = {
|
||||
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
|
||||
};
|
||||
+8
-2
@@ -34,6 +34,11 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const
|
||||
ffOptionParseString(argumentKey, value, &result->key);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "format"))
|
||||
{
|
||||
ffOptionParseString(argumentKey, value, &result->outputFormat);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "key-color"))
|
||||
{
|
||||
if(value == NULL)
|
||||
@@ -44,9 +49,9 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const
|
||||
ffOptionParseColor(value, &result->keyColor);
|
||||
return true;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subKey, "format"))
|
||||
else if(ffStrEqualsIgnCase(subKey, "key-width"))
|
||||
{
|
||||
ffOptionParseString(argumentKey, value, &result->outputFormat);
|
||||
result->keyWidth = ffOptionParseUInt32(argumentKey, value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -175,6 +180,7 @@ void ffOptionInitModuleArg(FFModuleArgs* args)
|
||||
ffStrbufInit(&args->key);
|
||||
ffStrbufInit(&args->keyColor);
|
||||
ffStrbufInit(&args->outputFormat);
|
||||
args->keyWidth = 0;
|
||||
}
|
||||
|
||||
void ffOptionDestroyModuleArg(FFModuleArgs* args)
|
||||
|
||||
@@ -2,11 +2,37 @@
|
||||
|
||||
#include "util/FFstrbuf.h"
|
||||
|
||||
struct yyjson_val;
|
||||
|
||||
// Must be the first field of FFModuleOptions
|
||||
typedef struct FFModuleBaseInfo
|
||||
{
|
||||
const char* name;
|
||||
bool (*parseCommandOptions)(void* options, const char* key, const char* value);
|
||||
void (*parseJsonObject)(void* options, struct yyjson_val *module);
|
||||
void (*printModule)(void* options);
|
||||
} FFModuleBaseInfo;
|
||||
|
||||
static inline void ffOptionInitModuleBaseInfo(
|
||||
FFModuleBaseInfo* baseInfo,
|
||||
const char* name,
|
||||
void* parseCommandOptions, // bool (*const parseCommandOptions)(void* options, const char* key, const char* value)
|
||||
void* parseJsonObject, // void (*const parseJsonObject)(void* options, yyjson_val *module)
|
||||
void* printModule // void (*const printModule)(void* options)
|
||||
)
|
||||
{
|
||||
baseInfo->name = name;
|
||||
baseInfo->parseCommandOptions = (__typeof__(baseInfo->parseCommandOptions)) parseCommandOptions;
|
||||
baseInfo->parseJsonObject = (__typeof__(baseInfo->parseJsonObject)) parseJsonObject;
|
||||
baseInfo->printModule = (__typeof__(baseInfo->printModule)) printModule;
|
||||
}
|
||||
|
||||
typedef struct FFModuleArgs
|
||||
{
|
||||
FFstrbuf key;
|
||||
FFstrbuf keyColor;
|
||||
FFstrbuf outputFormat;
|
||||
uint32_t keyWidth;
|
||||
} FFModuleArgs;
|
||||
|
||||
typedef struct FFKeyValuePair
|
||||
|
||||
+27
-53
@@ -2,7 +2,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "util/textModifier.h"
|
||||
|
||||
void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor)
|
||||
void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType)
|
||||
{
|
||||
ffLogoPrintLine();
|
||||
|
||||
@@ -16,14 +16,14 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb
|
||||
if (instance.config.brightColor)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
||||
|
||||
if(customKeyColor != NULL && customKeyColor->length > 0)
|
||||
ffPrintColor(customKeyColor);
|
||||
if(moduleArgs && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR) && moduleArgs->keyColor.length > 0)
|
||||
ffPrintColor(&moduleArgs->keyColor);
|
||||
else
|
||||
ffPrintColor(&instance.config.colorKeys);
|
||||
}
|
||||
|
||||
//NULL check is required for modules with custom keys, e.g. disk with the folder path
|
||||
if(customKeyFormat == NULL || customKeyFormat->length == 0)
|
||||
if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0)
|
||||
{
|
||||
fputs(moduleName, stdout);
|
||||
|
||||
@@ -33,10 +33,10 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
ffParseFormatString(&key, customKeyFormat, 1, (FFformatarg[]){
|
||||
ffParseFormatString(&key, &moduleArgs->key, 1, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
|
||||
});
|
||||
ffPrintUserString(key.chars);
|
||||
ffStrbufWriteTo(&key, stdout);
|
||||
}
|
||||
|
||||
if(!instance.config.pipe)
|
||||
@@ -46,32 +46,37 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb
|
||||
|
||||
if(!instance.config.pipe)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
}
|
||||
|
||||
void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateA(256);
|
||||
ffParseFormatString(&buffer, format, numArgs, arguments);
|
||||
|
||||
if(buffer.length > 0)
|
||||
if (!instance.config.pipe && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
|
||||
{
|
||||
ffPrintLogoAndKey(moduleName, moduleIndex, customKeyFormat, customKeyColor);
|
||||
ffPrintUserString(buffer.chars);
|
||||
putchar('\n');
|
||||
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.keyWidth;
|
||||
if (keyWidth > 0)
|
||||
printf("\e[%uG", (unsigned) (keyWidth + instance.state.logoWidth));
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments)
|
||||
void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments)
|
||||
{
|
||||
ffPrintFormatString(moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, &moduleArgs->outputFormat, numArgs, arguments);
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
if (moduleArgs)
|
||||
ffParseFormatString(&buffer, &moduleArgs->outputFormat, numArgs, arguments);
|
||||
else
|
||||
ffStrbufAppendS(&buffer, "unknown");
|
||||
|
||||
if(buffer.length > 0)
|
||||
{
|
||||
ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType);
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
static void printError(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, va_list arguments)
|
||||
static void printError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, va_list arguments)
|
||||
{
|
||||
if(!instance.config.showErrors)
|
||||
return;
|
||||
|
||||
ffPrintLogoAndKey(moduleName, moduleIndex, customKeyFormat, customKeyColor);
|
||||
ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType);
|
||||
|
||||
if(!instance.config.pipe)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout);
|
||||
@@ -84,11 +89,11 @@ static void printError(const char* moduleName, uint8_t moduleIndex, const FFstrb
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...)
|
||||
void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...)
|
||||
{
|
||||
va_list arguments;
|
||||
va_start(arguments, message);
|
||||
printError(moduleName, moduleIndex, customKeyFormat, customKeyColor, message, arguments);
|
||||
printError(moduleName, moduleIndex, moduleArgs, printType, message, arguments);
|
||||
va_end(arguments);
|
||||
}
|
||||
|
||||
@@ -96,7 +101,7 @@ void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArg
|
||||
{
|
||||
va_list arguments;
|
||||
va_start(arguments, message);
|
||||
printError(moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, message, arguments);
|
||||
printError(moduleName, moduleIndex, moduleArgs, FF_PRINT_TYPE_DEFAULT, message, arguments);
|
||||
va_end(arguments);
|
||||
}
|
||||
|
||||
@@ -125,34 +130,3 @@ void ffPrintCharTimes(char c, uint32_t times)
|
||||
if(remaining > 0)
|
||||
fwrite(str, 1, remaining, stdout);
|
||||
}
|
||||
|
||||
void ffPrintUserString(const char* value)
|
||||
{
|
||||
while(*value != '\0')
|
||||
{
|
||||
if(*value != '\\')
|
||||
{
|
||||
putchar(*value);
|
||||
++value;
|
||||
continue;
|
||||
}
|
||||
|
||||
++value;
|
||||
|
||||
if(*value == 'n')
|
||||
putchar('\n');
|
||||
else if(*value == 't')
|
||||
putchar('\t');
|
||||
else if(*value == 'e')
|
||||
putchar('\e');
|
||||
else if(*value == '\\')
|
||||
putchar('\\');
|
||||
else
|
||||
{
|
||||
putchar('\\');
|
||||
putchar(*value);
|
||||
}
|
||||
|
||||
++value;
|
||||
}
|
||||
}
|
||||
|
||||
+15
-5
@@ -6,13 +6,23 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/format.h"
|
||||
|
||||
void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor);
|
||||
void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments);
|
||||
void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments);
|
||||
FF_C_PRINTF(5, 6) void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...);
|
||||
typedef enum FFPrintType {
|
||||
FF_PRINT_TYPE_DEFAULT = 0,
|
||||
FF_PRINT_TYPE_NO_CUSTOM_KEY = 1 << 0,
|
||||
FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR = 1 << 1,
|
||||
FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH = 1 << 2,
|
||||
FF_PRINT_TYPE_NO_CUSTOM_OUTPUT_FORMAT = 1 << 3, // reserved
|
||||
} FFPrintType;
|
||||
|
||||
void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType);
|
||||
void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments);
|
||||
static inline void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments)
|
||||
{
|
||||
ffPrintFormatString(moduleName, moduleIndex, moduleArgs, FF_PRINT_TYPE_DEFAULT, numArgs, arguments);
|
||||
}
|
||||
FF_C_PRINTF(5, 6) void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
|
||||
FF_C_PRINTF(4, 5) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...);
|
||||
void ffPrintColor(const FFstrbuf* colorValue);
|
||||
void ffPrintCharTimes(char c, uint32_t times);
|
||||
void ffPrintUserString(const char* str);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -376,6 +376,7 @@
|
||||
#--player-key Media Player
|
||||
#--media-key Media
|
||||
#--datetime-key Date Time
|
||||
#--version-key Version
|
||||
#--vulkan-key Vulkan
|
||||
#--opengl-key OpenGL
|
||||
#--opencl-key OpenCL
|
||||
@@ -426,6 +427,7 @@
|
||||
#--player-format
|
||||
#--media-format
|
||||
#--datetime-format
|
||||
#--version-format
|
||||
#--vulkan-format
|
||||
#--opengl-format
|
||||
#--opencl-format
|
||||
@@ -473,6 +475,7 @@
|
||||
#--player-key-color
|
||||
#--media-key-color
|
||||
#--datetime-key-color
|
||||
#--version-key-color
|
||||
#--vulkan-key-color
|
||||
#--opengl-key-color
|
||||
#--opencl-key-color
|
||||
|
||||
+12
-1
@@ -19,6 +19,7 @@ Informative options:
|
||||
|
||||
General options:
|
||||
--load-config <file>: Load a config file or preset (+)
|
||||
--config <file>: Alias of --load-config (+)
|
||||
--multithreading <?value>: Use multiple threads to detect values
|
||||
--stat <?value>: Show time usage (in ms) for individual modules
|
||||
--allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output
|
||||
@@ -40,6 +41,7 @@ Logo options:
|
||||
--logo-padding-right <padding>: Set the padding on the right of the logo
|
||||
--logo-padding-top <padding>: Set the padding on the top of the logo
|
||||
--logo-print-remaining <?value>: Whether to print the remaining logo, if it has more lines than modules to display
|
||||
--logo-recache <?value>: If true, regenerate image logo cache
|
||||
--file <file>: Short for --logo-type file --logo <file>
|
||||
--file-raw <file>: Short for --logo-type file-raw --logo <file>
|
||||
--data <data>: Short for --logo-type data --logo <data>
|
||||
@@ -58,8 +60,9 @@ Display options:
|
||||
-s,--structure <structure>: Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
|
||||
--color-keys <color>: Set the color of the keys
|
||||
--color-title <color>: Set the color of the title
|
||||
--color <color>: Set the color of both the keys and title
|
||||
--key-width <num>: Align the width of keys to <num> characters
|
||||
--bright-color <?value>: Set if the keys, title and ASCII logo should be printed in bright color. Default is true
|
||||
-c,--color <color>: Set the color of both the keys and title
|
||||
--separator <str>: Set the separator between key and value. Default is a colon with a space
|
||||
--set <key=value>: Hard set the value of a key
|
||||
--set-keyless <key=value>: Hard set the value of a key, but don't print the key or the separator
|
||||
@@ -68,6 +71,11 @@ Display options:
|
||||
--hide-cursor <?value>: Whether to hide the cursor during the run
|
||||
--binary-prefix <value>: Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC
|
||||
--percent-type <value>: Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1
|
||||
--percent-ndigits <value>: Set the number of digits to keep after the decimal point when formatting percentage numbers. Default is 0
|
||||
--bar-char-elapsed <str>: Set the character to use in elapsed part. Default is '■'
|
||||
--bar-char-total <str>: Set the character to use in total part. Default is '-'
|
||||
--bar-width <?num>: Set the width of the bar, in number of characters. Default is 10
|
||||
--bar-border <?value>: Whether to show a border around the bar. Default is true
|
||||
--no-buffer <?value>: Set if the stdout application buffer should be disabled. Default is false
|
||||
--size-ndigits <value>: Set the number of digits to keep after the decimal point when formatting sizes
|
||||
--size-max-prefix <value>: Set the largest binary prefix to use when formatting sizes. Default is YB
|
||||
@@ -82,6 +90,7 @@ General module options:
|
||||
For modules which print multiple lines, the string is parsed as a format string with the index as first character.
|
||||
|
||||
--<module>-key-color <format>: Override the global `--color-keys` option for each specific module.
|
||||
--<module>-key-width <num>: Override the global `--key-width` option for each specific module.
|
||||
|
||||
Library options: Set the path of a library to load
|
||||
--lib-PCI <path>
|
||||
@@ -120,7 +129,9 @@ Module specific options:
|
||||
--disk-show-external <?value>: Set if external volume should be printed. Default is true
|
||||
--disk-show-hidden <?value>: Set if hidden volumes should be printed. Default is false
|
||||
--disk-show-subvolumes <?value>: Set if subvolumes should be printed. Default is false
|
||||
--disk-show-readonly <?value>: Set if read only volumes should be printed. Default is false
|
||||
--disk-show-unknown <?value>: Set if unknown (unable to detect sizes) volumes should be printed. Default is false
|
||||
--disk-use-available <?value>: Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes. 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
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
Battery
|
||||
Bios
|
||||
Bluetooth
|
||||
Board
|
||||
Break
|
||||
Chassis
|
||||
Colors
|
||||
CPU
|
||||
CPUUsage
|
||||
Cursor
|
||||
Date
|
||||
Datetime
|
||||
DE
|
||||
Disk
|
||||
Display
|
||||
Font
|
||||
GPU
|
||||
Host
|
||||
Icons
|
||||
Kernel
|
||||
Locale
|
||||
LocalIP
|
||||
Media
|
||||
Memory
|
||||
OpenGL
|
||||
OS
|
||||
Packages
|
||||
Player
|
||||
PowerAdapter
|
||||
Processes
|
||||
PublicIP
|
||||
Separator
|
||||
Shell
|
||||
Swap
|
||||
Terminal
|
||||
TerminalFont
|
||||
Theme
|
||||
Time
|
||||
Title
|
||||
Uptime
|
||||
Vulkan
|
||||
Weather
|
||||
Wifi
|
||||
WM
|
||||
WMTheme
|
||||
@@ -31,7 +31,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa
|
||||
|
||||
// https://github.com/waydabber/m1ddc
|
||||
// Works for Apple Silicon and USB-C adapter connection ( but not HTMI )
|
||||
static const char* detectWithDdcci(FFlist* result)
|
||||
FF_MAYBE_UNUSED static const char* detectWithDdcci(FFlist* result)
|
||||
{
|
||||
if (!IOAVServiceCreate || !IOAVServiceReadI2C)
|
||||
return "IOAVService is not available";
|
||||
@@ -108,8 +108,10 @@ const char* ffDetectBrightness(FFlist* result)
|
||||
|
||||
detectWithDisplayServices(displayServer, result);
|
||||
|
||||
if (instance.config.allowSlowOperations && displayServer->displays.length > result->length)
|
||||
#ifdef __aarch64__
|
||||
if (displayServer->displays.length > result->length)
|
||||
detectWithDdcci(result);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -139,12 +139,9 @@ const char* ffDetectBrightness(FFlist* result)
|
||||
detectWithBacklight(result);
|
||||
|
||||
#ifdef FF_HAVE_DDCUTIL
|
||||
if (instance.config.allowSlowOperations)
|
||||
{
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
if (result->length < displayServer->displays.length)
|
||||
detectWithDdcci(result);
|
||||
}
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
if (result->length < displayServer->displays.length)
|
||||
detectWithDdcci(result);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -76,7 +76,7 @@ const char* ffDetectBrightness(FFlist* result)
|
||||
if (hasBuiltinDisplay(displayServer))
|
||||
detectWithWmi(result);
|
||||
|
||||
if (instance.config.allowSlowOperations && result->length < displayServer->displays.length)
|
||||
if (result->length < displayServer->displays.length)
|
||||
detectWithDdcci(displayServer, result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ const char* ffGetCpuUsageResult(double* result)
|
||||
if(inUseAll2 != inUseAll1)
|
||||
{
|
||||
*result = (double)(inUseAll2 - inUseAll1) / (double)(totalAll2 - totalAll1) * 100;
|
||||
inUseAll1 = inUseAll2;
|
||||
totalAll1 = totalAll2;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -7,7 +7,7 @@ static int compareDisks(const void* disk1, const void* disk2)
|
||||
return ffStrbufCompAlphabetically(&((const FFDisk*) disk1)->mountpoint, &((const FFDisk*) disk2)->mountpoint);
|
||||
}
|
||||
|
||||
const char* ffDetectDisks(FFlist* disks)
|
||||
const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks)
|
||||
{
|
||||
const char* error = ffDetectDisksImpl(disks);
|
||||
|
||||
@@ -22,7 +22,13 @@ const char* ffDetectDisks(FFlist* disks)
|
||||
FF_LIST_FOR_EACH(FFDisk, disk, *disks)
|
||||
{
|
||||
if(disk->bytesTotal == 0)
|
||||
disk->type |= FF_DISK_TYPE_UNKNOWN_BIT;
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
|
||||
else
|
||||
{
|
||||
disk->bytesUsed = disk->bytesTotal - (
|
||||
options->calcType == FF_DISK_CALC_TYPE_FREE ? disk->bytesFree : disk->bytesAvailable
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -10,9 +10,11 @@ typedef struct FFDisk
|
||||
FFstrbuf mountpoint;
|
||||
FFstrbuf filesystem;
|
||||
FFstrbuf name;
|
||||
FFDiskType type;
|
||||
FFDiskVolumeType type;
|
||||
|
||||
uint64_t bytesUsed;
|
||||
uint64_t bytesFree;
|
||||
uint64_t bytesAvailable;
|
||||
uint64_t bytesTotal;
|
||||
|
||||
uint32_t filesUsed;
|
||||
@@ -23,6 +25,6 @@ typedef struct FFDisk
|
||||
* Returns a List of FFDisk, sorted alphabetically by mountpoint.
|
||||
* If error is not set, disks contains at least one disk.
|
||||
*/
|
||||
const char* ffDetectDisks(FFlist* result /* list of FFDisk */);
|
||||
const char* ffDetectDisks(FFDiskOptions* options, FFlist* result /* list of FFDisk */);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,11 +7,11 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
|
||||
{
|
||||
// FreeBSD doesn't support these flags
|
||||
if(fs->f_flags & MNT_DONTBROWSE)
|
||||
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
else if(fs->f_flags & MNT_REMOVABLE)
|
||||
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
disk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
|
||||
ffStrbufInitS(&disk->name, [NSFileManager.defaultManager displayNameAtPath:@(fs->f_mntonname)].UTF8String);
|
||||
}
|
||||
|
||||
@@ -3,22 +3,22 @@
|
||||
#include <sys/mount.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
static void detectFsInfo(struct statfs* fs, FFDisk* disk)
|
||||
{
|
||||
if(
|
||||
ffStrbufStartsWithS(&disk->mountpoint, "/boot") ||
|
||||
ffStrbufStartsWithS(&disk->mountpoint, "/dev") ||
|
||||
ffStrbufStartsWithS(&disk->mountpoint, "/var") ||
|
||||
ffStrbufStartsWithS(&disk->mountpoint, "/tmp") ||
|
||||
ffStrbufStartsWithS(&disk->mountpoint, "/proc") ||
|
||||
ffStrbufStartsWithS(&disk->mountpoint, "/zroot") ||
|
||||
ffStrbufStartsWithS(&disk->mountpoint, "/compat/linux/")
|
||||
)
|
||||
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
else if((fs->f_flags & MNT_NOSUID) || !(fs->f_flags & MNT_LOCAL))
|
||||
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
if(ffStrbufEqualS(&disk->filesystem, "zfs"))
|
||||
{
|
||||
disk->type = !ffStrStartsWith(fs->f_mntfromname, "zroot/") || ffStrStartsWith(fs->f_mntfromname, "zroot/ROOT/")
|
||||
? FF_DISK_VOLUME_TYPE_REGULAR_BIT
|
||||
: FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
|
||||
}
|
||||
else if(!ffStrStartsWith(fs->f_mntfromname, "/dev/"))
|
||||
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
else if(!(fs->f_flags & MNT_LOCAL))
|
||||
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
disk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
|
||||
ffStrbufInit(&disk->name);
|
||||
}
|
||||
@@ -45,7 +45,9 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
#endif
|
||||
|
||||
disk->bytesTotal = fs->f_blocks * fs->f_bsize;
|
||||
disk->bytesUsed = disk->bytesTotal - ((uint64_t)fs->f_bfree * fs->f_bsize);
|
||||
disk->bytesFree = (uint64_t)fs->f_bfree * fs->f_bsize;
|
||||
disk->bytesAvailable = (uint64_t)fs->f_bavail * fs->f_bsize;
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
disk->filesTotal = (uint32_t) fs->f_files;
|
||||
disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs->f_ffree);
|
||||
@@ -53,6 +55,9 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
ffStrbufInitS(&disk->mountpoint, fs->f_mntonname);
|
||||
ffStrbufInitS(&disk->filesystem, fs->f_fstypename);
|
||||
detectFsInfo(fs, disk);
|
||||
|
||||
if(fs->f_flags & MNT_RDONLY)
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -122,20 +122,32 @@ static void detectName(FFDisk* disk, const FFstrbuf* device)
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY basePath = ffStrbufCreate();
|
||||
|
||||
//Try partlabel first
|
||||
ffStrbufSetS(&basePath, "/dev/disk/by-partlabel/");
|
||||
//Try label first
|
||||
ffStrbufSetS(&basePath, "/dev/disk/by-label/");
|
||||
detectNameFromPath(disk, &deviceStat, &basePath);
|
||||
|
||||
//Try label second
|
||||
if(disk->name.length == 0)
|
||||
{
|
||||
ffStrbufSetS(&basePath, "/dev/disk/by-label/");
|
||||
//Try partlabel second
|
||||
ffStrbufSetS(&basePath, "/dev/disk/by-partlabel/");
|
||||
detectNameFromPath(disk, &deviceStat, &basePath);
|
||||
}
|
||||
|
||||
//Use the mountpoint as a last resort
|
||||
if(disk->name.length == 0)
|
||||
ffStrbufAppend(&disk->name, &disk->mountpoint);
|
||||
// Basic\x20data\x20partition
|
||||
for (uint32_t i = ffStrbufFirstIndexS(&disk->name, "\\x");
|
||||
i != disk->name.length;
|
||||
i = ffStrbufNextIndexS(&disk->name, i + 1, "\\x"))
|
||||
{
|
||||
uint32_t len = (uint32_t) strlen("\\x20");
|
||||
if (disk->name.length >= len)
|
||||
{
|
||||
char bak = disk->name.chars[i + len];
|
||||
disk->name.chars[i + len] = '\0';
|
||||
disk->name.chars[i] = (char) strtoul(&disk->name.chars[i + 2], NULL, 16);
|
||||
ffStrbufRemoveSubstr(&disk->name, i + 1, i + len);
|
||||
disk->name.chars[i + 1] = bak;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
@@ -143,11 +155,11 @@ static void detectName(FFDisk* disk, const FFstrbuf* device)
|
||||
static void detectType(FF_MAYBE_UNUSED const FFlist* devices, FFDisk* currentDisk, FF_MAYBE_UNUSED const char* options)
|
||||
{
|
||||
if(ffStrbufEqualS(¤tDisk->mountpoint, "/") || ffStrbufEqualS(¤tDisk->mountpoint, "/storage/emulated"))
|
||||
currentDisk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
else if(ffStrbufStartsWithS(¤tDisk->mountpoint, "/mnt/media_rw/"))
|
||||
currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -179,13 +191,13 @@ static bool isSubvolume(const FFlist* devices)
|
||||
static void detectType(const FFlist* devices, FFDisk* currentDisk, const char* options)
|
||||
{
|
||||
if(isSubvolume(devices))
|
||||
currentDisk->type = FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
|
||||
else if(strstr(options, "nosuid") != NULL || strstr(options, "nodev") != NULL)
|
||||
currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else if(ffStrbufStartsWithS(¤tDisk->mountpoint, "/boot") || ffStrbufStartsWithS(¤tDisk->mountpoint, "/efi"))
|
||||
currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
else
|
||||
currentDisk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -197,10 +209,15 @@ static void detectStats(FFDisk* disk)
|
||||
memset(&fs, 0, sizeof(struct statvfs)); //Set all values to 0, so our values get initialized to 0 too
|
||||
|
||||
disk->bytesTotal = fs.f_blocks * fs.f_frsize;
|
||||
disk->bytesUsed = disk->bytesTotal - (fs.f_bfree * fs.f_frsize);
|
||||
disk->bytesFree = fs.f_bfree * fs.f_frsize;
|
||||
disk->bytesAvailable = fs.f_bavail * fs.f_frsize;
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
disk->filesTotal = (uint32_t) fs.f_files;
|
||||
disk->filesUsed = (uint32_t) (disk->filesTotal - fs.f_ffree);
|
||||
|
||||
if(fs.f_flag & ST_RDONLY)
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
}
|
||||
|
||||
const char* ffDetectDisksImpl(FFlist* disks)
|
||||
|
||||
@@ -25,20 +25,25 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
FFDisk* disk = ffListAdd(disks);
|
||||
ffStrbufInitWS(&disk->mountpoint, mountpoint);
|
||||
|
||||
uint64_t bytesFree;
|
||||
if(!GetDiskFreeSpaceExW(mountpoint, NULL, (PULARGE_INTEGER)&disk->bytesTotal, (PULARGE_INTEGER)&bytesFree))
|
||||
if(!GetDiskFreeSpaceExW(
|
||||
mountpoint,
|
||||
(PULARGE_INTEGER)&disk->bytesAvailable,
|
||||
(PULARGE_INTEGER)&disk->bytesTotal,
|
||||
(PULARGE_INTEGER)&disk->bytesFree
|
||||
))
|
||||
{
|
||||
disk->bytesTotal = 0;
|
||||
bytesFree = 0;
|
||||
disk->bytesFree = 0;
|
||||
disk->bytesAvailable = 0;
|
||||
}
|
||||
disk->bytesUsed = disk->bytesTotal - bytesFree;
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
if(driveType == DRIVE_REMOVABLE || driveType == DRIVE_REMOTE || driveType == DRIVE_CDROM)
|
||||
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
|
||||
else if(driveType == DRIVE_FIXED)
|
||||
disk->type = FF_DISK_TYPE_REGULAR_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
else
|
||||
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
|
||||
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
|
||||
|
||||
ffStrbufInit(&disk->filesystem);
|
||||
ffStrbufInit(&disk->name);
|
||||
@@ -47,11 +52,12 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
//https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa#remarks
|
||||
UINT errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
|
||||
|
||||
DWORD diskFlags;
|
||||
BOOL result = GetVolumeInformationW(mountpoint,
|
||||
diskName, sizeof(diskName) / sizeof(*diskName), //Volume name
|
||||
NULL, //Serial number
|
||||
NULL, //Max component length
|
||||
NULL, //File system flags
|
||||
&diskFlags, //File system flags
|
||||
diskFileSystem, sizeof(diskFileSystem) / sizeof(*diskFileSystem)
|
||||
);
|
||||
SetErrorMode(errorMode);
|
||||
@@ -60,6 +66,8 @@ const char* ffDetectDisksImpl(FFlist* disks)
|
||||
{
|
||||
ffStrbufSetWS(&disk->filesystem, diskFileSystem);
|
||||
ffStrbufSetWS(&disk->name, diskName);
|
||||
if(diskFlags & FILE_READ_ONLY_VOLUME)
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
}
|
||||
|
||||
//Unsupported
|
||||
|
||||
@@ -116,6 +116,7 @@ typedef struct XrandrData
|
||||
{
|
||||
FF_LIBRARY_SYMBOL(XInternAtom)
|
||||
FF_LIBRARY_SYMBOL(XGetAtomName);
|
||||
FF_LIBRARY_SYMBOL(XFree);
|
||||
FF_LIBRARY_SYMBOL(XRRGetScreenInfo)
|
||||
FF_LIBRARY_SYMBOL(XRRConfigCurrentConfiguration)
|
||||
FF_LIBRARY_SYMBOL(XRRConfigCurrentRate)
|
||||
@@ -207,9 +208,11 @@ static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name
|
||||
Atom atomEdid = data->ffXInternAtom(data->display, "EDID", true);
|
||||
if (atomEdid != None)
|
||||
{
|
||||
unsigned long nitems = 0;
|
||||
int actual_format = 0;
|
||||
unsigned long nitems = 0, bytes_after = 0;
|
||||
Atom actual_type = None;
|
||||
uint8_t* edidData = NULL;
|
||||
if (data->ffXRRGetOutputProperty(data->display, output, atomEdid, 0, 100, 0, 0, AnyPropertyType, NULL, NULL, &nitems, NULL, &edidData) == Success)
|
||||
if (data->ffXRRGetOutputProperty(data->display, output, atomEdid, 0, 100, false, false, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &edidData) == Success)
|
||||
{
|
||||
if (nitems >= 128)
|
||||
{
|
||||
@@ -217,6 +220,8 @@ static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name
|
||||
ffEdidGetName(edidData, name);
|
||||
}
|
||||
}
|
||||
if (edidData)
|
||||
data->ffXFree(edidData);
|
||||
}
|
||||
bool res = xrandrHandleCrtc(data, outputInfo->crtc, name, primary);
|
||||
|
||||
@@ -228,8 +233,9 @@ static bool xrandrHandleOutput(XrandrData* data, RROutput output, FFstrbuf* name
|
||||
static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
|
||||
{
|
||||
bool foundOutput = false;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(data->ffXGetAtomName(data->display, monitorInfo->name));
|
||||
char* xname = data->ffXGetAtomName(data->display, monitorInfo->name);
|
||||
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(xname);
|
||||
data->ffXFree(xname);
|
||||
for(int i = 0; i < monitorInfo->noutput; i++)
|
||||
{
|
||||
if(xrandrHandleOutput(data, monitorInfo->outputs[i], &name, monitorInfo->primary))
|
||||
@@ -341,6 +347,7 @@ void ffdsConnectXrandr(FFDisplayServerResult* result)
|
||||
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XInternAtom,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XGetAtomName,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XFree,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenInfo,)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentRate,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentConfiguration,);
|
||||
|
||||
@@ -59,7 +59,7 @@ const char* ffDetectHost(FFHostResult* host)
|
||||
ffStrbufAppendF(&host->productName, " - %s", wslDistroName);
|
||||
ffStrbufAppendS(&host->productFamily, "WSL");
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY wslVer = ffStrbufCreate(); //Wide charactors
|
||||
FF_STRBUF_AUTO_DESTROY wslVer = ffStrbufCreate(); //Wide characters
|
||||
if(!ffProcessAppendStdOut(&wslVer, (char* const[]){
|
||||
"wsl.exe",
|
||||
"--version",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram)
|
||||
{
|
||||
uint64_t length = sizeof(ram->bytesTotal);
|
||||
size_t length = sizeof(ram->bytesTotal);
|
||||
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
|
||||
return "Failed to read hw.physmem";
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "common/io/io.h"
|
||||
#include "util/edidHelper.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -30,15 +29,9 @@ const char* ffDetectMonitor(FFlist* results)
|
||||
ffStrbufAppendS(&drmDir, entry->d_name);
|
||||
ffStrbufAppendS(&drmDir, "/edid");
|
||||
|
||||
struct stat fileStat;
|
||||
if (stat(drmDir.chars, &fileStat) < 0 || fileStat.st_size == 0 || fileStat.st_size % 128 != 0)
|
||||
{
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
continue;
|
||||
}
|
||||
|
||||
FF_AUTO_FREE uint8_t* edidData = malloc((size_t) fileStat.st_size);
|
||||
if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) != sizeof(edidData))
|
||||
uint8_t edidData[512];
|
||||
ssize_t edidLength = ffReadFileData(drmDir.chars, sizeof(edidData), edidData);
|
||||
if(edidLength <= 0 || edidLength % 128 != 0)
|
||||
{
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
continue;
|
||||
@@ -54,7 +47,7 @@ const char* ffDetectMonitor(FFlist* results)
|
||||
ffStrbufInit(&display->name);
|
||||
ffEdidGetName(edidData, &display->name);
|
||||
ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight);
|
||||
display->hdrCompatible = ffEdidGetHdrCompatible(edidData, (uint32_t) fileStat.st_size);
|
||||
display->hdrCompatible = ffEdidGetHdrCompatible(edidData, (uint32_t) edidLength);
|
||||
}
|
||||
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
|
||||
@@ -13,6 +13,6 @@ typedef struct FFOpenGLResult
|
||||
FFstrbuf slv;
|
||||
} FFOpenGLResult;
|
||||
|
||||
const char* ffDetectOpenGL(FFOpenGLResult* result);
|
||||
const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ static const char* cglHandlePixelFormat(FFOpenGLResult* result, CGLPixelFormatOb
|
||||
return error;
|
||||
}
|
||||
|
||||
const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
const char* ffDetectOpenGL(FF_MAYBE_UNUSED FFOpenGLOptions* options, FFOpenGLResult* result)
|
||||
{
|
||||
CGLPixelFormatObj pixelFormat;
|
||||
CGLPixelFormatAttribute attrs[] = {
|
||||
|
||||
@@ -314,11 +314,11 @@ static const char* osMesaPrint(FFOpenGLResult* result)
|
||||
|
||||
#endif //FF_HAVE_OSMESA
|
||||
|
||||
const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result)
|
||||
{
|
||||
#if FF_HAVE_GL
|
||||
|
||||
if(instance.config.openGL.library == FF_OPENGL_LIBRARY_GLX)
|
||||
if(options->library == FF_OPENGL_LIBRARY_GLX)
|
||||
{
|
||||
#ifdef FF_HAVE_GLX
|
||||
return glxPrint(result);
|
||||
@@ -327,7 +327,7 @@ const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
#endif
|
||||
}
|
||||
|
||||
if(instance.config.openGL.library == FF_OPENGL_LIBRARY_EGL)
|
||||
if(options->library == FF_OPENGL_LIBRARY_EGL)
|
||||
{
|
||||
#ifdef FF_HAVE_EGL
|
||||
return eglPrint(result);
|
||||
@@ -336,7 +336,7 @@ const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
#endif
|
||||
}
|
||||
|
||||
if(instance.config.openGL.library == FF_OPENGL_LIBRARY_OSMESA)
|
||||
if(options->library == FF_OPENGL_LIBRARY_OSMESA)
|
||||
{
|
||||
#ifdef FF_HAVE_OSMESA
|
||||
return osMesaPrint(result);
|
||||
|
||||
@@ -82,7 +82,7 @@ LRESULT CALLBACK wglHandleWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
|
||||
}
|
||||
}
|
||||
|
||||
const char* ffDetectOpenGL(FFOpenGLResult* result)
|
||||
const char* ffDetectOpenGL(FF_MAYBE_UNUSED FFOpenGLOptions* options, FFOpenGLResult* result)
|
||||
{
|
||||
MSG msg = {0};
|
||||
WNDCLASSW wc = {
|
||||
|
||||
@@ -62,7 +62,6 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont)
|
||||
#include "common/processing.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <yyjson.h>
|
||||
|
||||
static const char* detectWTProfile(yyjson_val* profile, FFstrbuf* name, double* size)
|
||||
{
|
||||
@@ -355,7 +354,7 @@ static bool detectTerminalFontCommon(const FFTerminalShellResult* terminalShell,
|
||||
#ifndef _WIN32
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/pts/"))
|
||||
ffStrbufAppendS(&terminalFont->error, "Terminal font detection is not supported on PTS");
|
||||
else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalPrettyName, "kitty"))
|
||||
else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "kitty"))
|
||||
detectKitty(terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/tty"))
|
||||
detectTTY(terminalFont);
|
||||
|
||||
@@ -48,7 +48,7 @@ static void getProcessInformation(pid_t pid, FFstrbuf* processName, FFstrbuf* ex
|
||||
if(length > 0)
|
||||
exe->length = (uint32_t)length;
|
||||
|
||||
#else
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
size_t size = exe->allocated;
|
||||
if(!sysctl(
|
||||
@@ -375,12 +375,19 @@ const FFTerminalShellResult* ffDetectTerminalShell()
|
||||
ffStrbufInitS(&result.shellPrettyName, result.shellExeName);
|
||||
}
|
||||
|
||||
if(result.terminalExeName[0] == '.' && ffStrEndsWith(result.terminalExeName, "-wrapper"))
|
||||
{
|
||||
// For NixOS. Ref: #510 and https://github.com/NixOS/nixpkgs/pull/249428
|
||||
// We use terminalProcessName when detecting version and font, overriding it for simplication
|
||||
ffStrbufSetNS(
|
||||
&result.terminalProcessName,
|
||||
(uint32_t) (strlen(result.terminalExeName) - strlen(".-wrapper")),
|
||||
result.terminalExeName + 1);
|
||||
}
|
||||
|
||||
|
||||
if(ffStrbufEqualS(&result.terminalProcessName, "wezterm-gui"))
|
||||
ffStrbufInitStatic(&result.terminalPrettyName, "WezTerm");
|
||||
else if(ffStrbufEqualS(&result.terminalProcessName, ".kitty-wrapped"))
|
||||
ffStrbufInitStatic(&result.terminalPrettyName, "kitty"); // #510
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
|
||||
else if(ffStrbufStartsWithS(&result.terminalProcessName, "gnome-terminal-"))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "version.h"
|
||||
|
||||
#if defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64)
|
||||
#define FF_ARCHITECTURE "x86_64"
|
||||
#elif defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(__i586__) || defined(__i586) || defined(__i686__) || defined(__i686)
|
||||
#define FF_ARCHITECTURE "i386"
|
||||
#elif defined(__aarch64__)
|
||||
#define FF_ARCHITECTURE "aarch64"
|
||||
#elif defined(__arm__)
|
||||
#define FF_ARCHITECTURE "arm"
|
||||
#elif defined(__mips__)
|
||||
#define FF_ARCHITECTURE "mips"
|
||||
#elif defined(__powerpc__) || defined(__powerpc)
|
||||
#define FF_ARCHITECTURE "powerpc"
|
||||
#elif defined(__riscv__) || defined(__riscv)
|
||||
#define FF_ARCHITECTURE "riscv"
|
||||
#elif defined(__s390x__)
|
||||
#define FF_ARCHITECTURE "s390x"
|
||||
#else
|
||||
#define FF_ARCHITECTURE "unknown"
|
||||
#endif
|
||||
|
||||
void ffDetectVersion(FFVersionResult* version)
|
||||
{
|
||||
version->projectName = FASTFETCH_PROJECT_NAME;
|
||||
version->architecture = FF_ARCHITECTURE;
|
||||
version->version = FASTFETCH_PROJECT_VERSION;
|
||||
version->versionTweak = FASTFETCH_PROJECT_VERSION_TWEAK;
|
||||
version->cmakeBuiltType = FASTFETCH_PROJECT_CMAKE_BUILD_TYPE;
|
||||
#ifndef NDEBUG
|
||||
version->debugMode = true;
|
||||
#else
|
||||
version->debugMode = false;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef FF_INCLUDED_detection_version_version
|
||||
#define FF_INCLUDED_detection_version_version
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFVersionResult
|
||||
{
|
||||
const char* projectName;
|
||||
const char* architecture;
|
||||
const char* version;
|
||||
const char* versionTweak;
|
||||
const char* cmakeBuiltType;
|
||||
bool debugMode;
|
||||
} FFVersionResult;
|
||||
|
||||
void ffDetectVersion(FFVersionResult* version);
|
||||
|
||||
#endif
|
||||
+154
-264
@@ -1,9 +1,11 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/commandoption.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/time.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/version/version.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "logo/logo.h"
|
||||
#include "fastfetch_datatext.h"
|
||||
@@ -56,11 +58,11 @@ static inline void printCommandHelp(const char* command)
|
||||
{
|
||||
if(command == NULL)
|
||||
puts(FASTFETCH_DATATEXT_HELP);
|
||||
else if(ffStrEqualsIgnCase(command, "c") || ffStrEqualsIgnCase(command, "color"))
|
||||
else if(ffStrEqualsIgnCase(command, "color"))
|
||||
puts(FASTFETCH_DATATEXT_HELP_COLOR);
|
||||
else if(ffStrEqualsIgnCase(command, "format"))
|
||||
puts(FASTFETCH_DATATEXT_HELP_FORMAT);
|
||||
else if(ffStrEqualsIgnCase(command, "load-config") || ffStrEqualsIgnCase(command, "loadconfig") || ffStrEqualsIgnCase(command, "config"))
|
||||
else if(ffStrEqualsIgnCase(command, "load-config") || ffStrEqualsIgnCase(command, "config"))
|
||||
puts(FASTFETCH_DATATEXT_HELP_CONFIG);
|
||||
else if(ffStrEqualsIgnCase(command, "os-format"))
|
||||
{
|
||||
@@ -455,6 +457,17 @@ static inline void printCommandHelp(const char* command)
|
||||
"second with leading zero"
|
||||
);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(command, "version-format"))
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("version", "{1} {2}{3} (5)", 6,
|
||||
"Project name",
|
||||
"Version",
|
||||
"Version tweak",
|
||||
"Build type (debug or release)",
|
||||
"Architecture",
|
||||
"CMake build type (Debug, Release, RelWithDebInfo, MinSizeRel)"
|
||||
);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(command, "vulkan-format"))
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("vulkan", "{} (driver), {} (api version)", 3,
|
||||
@@ -553,6 +566,19 @@ static void listDataPaths(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void listModules()
|
||||
{
|
||||
unsigned count = 0;
|
||||
for (int i = 0; i <= 'Z' - 'A'; ++i)
|
||||
{
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[i]; *modules; ++modules)
|
||||
{
|
||||
++count;
|
||||
printf("%d)%s%s\n", count, count > 9 ? " " : " ", (*modules)->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void parseOption(FFdata* data, const char* key, const char* value);
|
||||
|
||||
static bool parseJsoncFile(const char* path)
|
||||
@@ -563,7 +589,7 @@ static bool parseJsoncFile(const char* path)
|
||||
{
|
||||
if (error.code != YYJSON_READ_ERROR_FILE_OPEN)
|
||||
{
|
||||
fprintf(stderr, "ERROR: failed to parse JSON config file `%s` at pos %zu: %s\n", path, error.pos, error.msg);
|
||||
fprintf(stderr, "Error: failed to parse JSON config file `%s` at pos %zu: %s\n", path, error.pos, error.msg);
|
||||
exit(477);
|
||||
}
|
||||
return false;
|
||||
@@ -584,6 +610,7 @@ static bool parseConfigFile(FFdata* data, const char* path)
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
FF_STRBUF_AUTO_DESTROY unescaped = ffStrbufCreate();
|
||||
|
||||
while ((read = getline(&line, &len, file)) != -1)
|
||||
{
|
||||
@@ -628,7 +655,42 @@ static bool parseConfigFile(FFdata* data, const char* path)
|
||||
--lineEnd;
|
||||
}
|
||||
|
||||
parseOption(data, lineStart, valueStart);
|
||||
if (strchr(valueStart, '\\'))
|
||||
{
|
||||
// Unescape all `\x`s
|
||||
const char* value = valueStart;
|
||||
while(*value != '\0')
|
||||
{
|
||||
if(*value != '\\')
|
||||
{
|
||||
ffStrbufAppendC(&unescaped, *value);
|
||||
++value;
|
||||
continue;
|
||||
}
|
||||
|
||||
++value;
|
||||
|
||||
switch(*value)
|
||||
{
|
||||
case 'n': ffStrbufAppendC(&unescaped, '\n'); break;
|
||||
case 't': ffStrbufAppendC(&unescaped, '\t'); break;
|
||||
case 'e': ffStrbufAppendC(&unescaped, '\e'); break;
|
||||
case '\\': ffStrbufAppendC(&unescaped, '\\'); break;
|
||||
default:
|
||||
ffStrbufAppendC(&unescaped, '\\');
|
||||
ffStrbufAppendC(&unescaped, *value);
|
||||
break;
|
||||
}
|
||||
|
||||
++value;
|
||||
}
|
||||
parseOption(data, lineStart, unescaped.chars);
|
||||
ffStrbufClear(&unescaped);
|
||||
}
|
||||
else
|
||||
{
|
||||
parseOption(data, lineStart, valueStart);
|
||||
}
|
||||
}
|
||||
|
||||
if(line != NULL)
|
||||
@@ -696,7 +758,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
|
||||
FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128);
|
||||
if (ffPathExpandEnv(value, &absolutePath))
|
||||
{
|
||||
bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, absolutePath.chars);
|
||||
bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars);
|
||||
|
||||
if(success)
|
||||
return;
|
||||
@@ -711,7 +773,20 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
|
||||
ffStrbufAppendS(&absolutePath, "fastfetch/presets/");
|
||||
ffStrbufAppendS(&absolutePath, value);
|
||||
|
||||
bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, absolutePath.chars);
|
||||
bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars);
|
||||
|
||||
if(success)
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
//Try exe path
|
||||
ffStrbufSet(&absolutePath, &instance.state.platform.exePath);
|
||||
ffStrbufSubstrBeforeLastC(&absolutePath, '/');
|
||||
ffStrbufAppendS(&absolutePath, "/presets/");
|
||||
ffStrbufAppendS(&absolutePath, value);
|
||||
|
||||
bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars);
|
||||
|
||||
if(success)
|
||||
return;
|
||||
@@ -733,6 +808,13 @@ static inline void optionCheckString(const char* key, const char* value, FFstrbu
|
||||
ffStrbufEnsureFree(buffer, 63); //This is not needed, as ffStrbufSetS will resize capacity if needed, but giving a higher start should improve performance
|
||||
}
|
||||
|
||||
static void printVersion()
|
||||
{
|
||||
FFVersionResult result = {};
|
||||
ffDetectVersion(&result);
|
||||
printf("%s %s%s%s (%s)\n", result.projectName, result.version, result.versionTweak, result.debugMode ? "-debug" : "", result.architecture);
|
||||
}
|
||||
|
||||
static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
{
|
||||
///////////////////////
|
||||
@@ -746,37 +828,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "-v") || ffStrEqualsIgnCase(key, "--version"))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#define FF_BUILD_TYPE "-debug"
|
||||
#else
|
||||
#define FF_BUILD_TYPE
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64)
|
||||
#define FF_ARCHITECTURE "x86_64"
|
||||
#elif defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(__i586__) || defined(__i586) || defined(__i686__) || defined(__i686)
|
||||
#define FF_ARCHITECTURE "i386"
|
||||
#elif defined(__aarch64__)
|
||||
#define FF_ARCHITECTURE "aarch64"
|
||||
#elif defined(__arm__)
|
||||
#define FF_ARCHITECTURE "arm"
|
||||
#elif defined(__mips__)
|
||||
#define FF_ARCHITECTURE "mips"
|
||||
#elif defined(__powerpc__) || defined(__powerpc)
|
||||
#define FF_ARCHITECTURE "powerpc"
|
||||
#elif defined(__riscv__) || defined(__riscv)
|
||||
#define FF_ARCHITECTURE "riscv"
|
||||
#elif defined(__s390x__)
|
||||
#define FF_ARCHITECTURE "s390x"
|
||||
#else
|
||||
#define FF_ARCHITECTURE "unknown"
|
||||
#endif
|
||||
|
||||
puts("fastfetch " FASTFETCH_PROJECT_VERSION FASTFETCH_PROJECT_VERSION_TWEAK FF_BUILD_TYPE " (" FF_ARCHITECTURE ")");
|
||||
|
||||
#undef FF_ARCHITECTURE
|
||||
#undef FF_BUILD_TYPE
|
||||
|
||||
printVersion();
|
||||
exit(0);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "--version-raw"))
|
||||
@@ -815,7 +867,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
const char* subkey = key + strlen("--list");
|
||||
if(ffStrEqualsIgnCase(subkey, "-modules"))
|
||||
{
|
||||
puts(FASTFETCH_DATATEXT_MODULES);
|
||||
listModules();
|
||||
exit(0);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subkey, "-presets"))
|
||||
@@ -893,9 +945,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
//General options//
|
||||
///////////////////
|
||||
|
||||
else if(ffStrEqualsIgnCase(key, "-r") || ffStrEqualsIgnCase(key, "--recache"))
|
||||
instance.config.recache = ffOptionParseBoolean(value);
|
||||
else if(ffStrEqualsIgnCase(key, "--load-config"))
|
||||
else if(ffStrEqualsIgnCase(key, "--load-config") || ffStrEqualsIgnCase(key, "--config"))
|
||||
optionParseConfigFile(data, key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--gen-config"))
|
||||
generateConfigFile(false, value);
|
||||
@@ -951,24 +1001,32 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
ffOptionParseString(key, value, &data->structure);
|
||||
else if(ffStrEqualsIgnCase(key, "--separator"))
|
||||
ffOptionParseString(key, value, &instance.config.keyValueSeparator);
|
||||
else if(ffStrEqualsIgnCase(key, "--color-keys"))
|
||||
else if(ffStrStartsWith(key, "--color"))
|
||||
{
|
||||
optionCheckString(key, value, &instance.config.colorKeys);
|
||||
ffOptionParseColor(value, &instance.config.colorKeys);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "--color-title"))
|
||||
{
|
||||
optionCheckString(key, value, &instance.config.colorTitle);
|
||||
ffOptionParseColor(value, &instance.config.colorTitle);
|
||||
const char* subkey = key + strlen("--color");
|
||||
if(*subkey == '\0')
|
||||
{
|
||||
optionCheckString(key, value, &instance.config.colorKeys);
|
||||
ffOptionParseColor(value, &instance.config.colorKeys);
|
||||
ffStrbufSet(&instance.config.colorTitle, &instance.config.colorKeys);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subkey, "-keys"))
|
||||
{
|
||||
optionCheckString(key, value, &instance.config.colorKeys);
|
||||
ffOptionParseColor(value, &instance.config.colorKeys);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(subkey, "-title"))
|
||||
{
|
||||
optionCheckString(key, value, &instance.config.colorTitle);
|
||||
ffOptionParseColor(value, &instance.config.colorTitle);
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "--key-width"))
|
||||
instance.config.keyWidth = ffOptionParseUInt32(key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--bright-color"))
|
||||
instance.config.brightColor = ffOptionParseBoolean(value);
|
||||
else if(ffStrEqualsIgnCase(key, "-c") || ffStrEqualsIgnCase(key, "--color"))
|
||||
{
|
||||
optionCheckString(key, value, &instance.config.colorKeys);
|
||||
ffOptionParseColor(value, &instance.config.colorKeys);
|
||||
ffStrbufSet(&instance.config.colorTitle, &instance.config.colorKeys);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "--binary-prefix"))
|
||||
{
|
||||
instance.config.binaryPrefixType = (FFBinaryPrefixType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
|
||||
@@ -1008,67 +1066,25 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
});
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(key, "--percent-type"))
|
||||
instance.config.percentType = ffOptionParseUInt32(key, value);
|
||||
instance.config.percentType = (uint8_t) ffOptionParseUInt32(key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--percent-ndigits"))
|
||||
instance.config.percentNdigits = (uint8_t) ffOptionParseUInt32(key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--no-buffer"))
|
||||
instance.config.noBuffer = ffOptionParseBoolean(value);
|
||||
|
||||
///////////////////////
|
||||
//Module args options//
|
||||
///////////////////////
|
||||
|
||||
else if(ffParseOSCommandOptions(&instance.config.os, key, value)) {}
|
||||
else if(ffParseHostCommandOptions(&instance.config.host, key, value)) {}
|
||||
else if(ffParseOSCommandOptions(&instance.config.os, key, value)) {}
|
||||
else if(ffParseBiosCommandOptions(&instance.config.bios, key, value)) {}
|
||||
else if(ffParseBoardCommandOptions(&instance.config.board, key, value)) {}
|
||||
else if(ffParseChassisCommandOptions(&instance.config.chassis, key, value)) {}
|
||||
else if(ffParseCommandCommandOptions(&instance.config.command, key, value)) {}
|
||||
else if(ffParseCustomCommandOptions(&instance.config.custom, key, value)) {}
|
||||
else if(ffParseKernelCommandOptions(&instance.config.kernel, key, value)) {}
|
||||
else if(ffParseUptimeCommandOptions(&instance.config.uptime, key, value)) {}
|
||||
else if(ffParseProcessesCommandOptions(&instance.config.processes, key, value)) {}
|
||||
else if(ffParsePackagesCommandOptions(&instance.config.packages, key, value)) {}
|
||||
else if(ffParseShellCommandOptions(&instance.config.shell, key, value)) {}
|
||||
else if(ffParseDisplayCommandOptions(&instance.config.display, key, value)) {}
|
||||
else if(ffParseBrightnessCommandOptions(&instance.config.brightness, key, value)) {}
|
||||
else if(ffParseMonitorCommandOptions(&instance.config.nativeResolution, key, value)) {}
|
||||
else if(ffParseDECommandOptions(&instance.config.de, key, value)) {}
|
||||
else if(ffParseWifiCommandOptions(&instance.config.wifi, key, value)) {}
|
||||
else if(ffParseWMCommandOptions(&instance.config.wm, key, value)) {}
|
||||
else if(ffParseWMThemeCommandOptions(&instance.config.wmTheme, key, value)) {}
|
||||
else if(ffParseTitleCommandOptions(&instance.config.title, key, value)) {}
|
||||
else if(ffParseThemeCommandOptions(&instance.config.theme, key, value)) {}
|
||||
else if(ffParseIconsCommandOptions(&instance.config.icons, key, value)) {}
|
||||
else if(ffParseWallpaperCommandOptions(&instance.config.wallpaper, key, value)) {}
|
||||
else if(ffParseFontCommandOptions(&instance.config.font, key, value)) {}
|
||||
else if(ffParseCursorCommandOptions(&instance.config.cursor, key, value)) {}
|
||||
else if(ffParseTerminalCommandOptions(&instance.config.terminal, key, value)) {}
|
||||
else if(ffParseTerminalFontCommandOptions(&instance.config.terminalFont, key, value)) {}
|
||||
else if(ffParseTerminalSizeCommandOptions(&instance.config.terminalSize, key, value)) {}
|
||||
else if(ffParseCPUCommandOptions(&instance.config.cpu, key, value)) {}
|
||||
else if(ffParseCPUUsageCommandOptions(&instance.config.cpuUsage, key, value)) {}
|
||||
else if(ffParseGPUCommandOptions(&instance.config.gpu, key, value)) {}
|
||||
else if(ffParseMemoryCommandOptions(&instance.config.memory, key, value)) {}
|
||||
else if(ffParseSwapCommandOptions(&instance.config.swap, key, value)) {}
|
||||
else if(ffParseDiskCommandOptions(&instance.config.disk, key, value)) {}
|
||||
else if(ffParseBatteryCommandOptions(&instance.config.battery, key, value)) {}
|
||||
else if(ffParsePowerAdapterCommandOptions(&instance.config.powerAdapter, key, value)) {}
|
||||
else if(ffParseLocaleCommandOptions(&instance.config.locale, key, value)) {}
|
||||
else if(ffParseLocalIpCommandOptions(&instance.config.localIP, key, value)) {}
|
||||
else if(ffParsePublicIpCommandOptions(&instance.config.publicIP, key, value)) {}
|
||||
else if(ffParseWeatherCommandOptions(&instance.config.weather, key, value)) {}
|
||||
else if(ffParsePlayerCommandOptions(&instance.config.player, key, value)) {}
|
||||
else if(ffParseMediaCommandOptions(&instance.config.media, key, value)) {}
|
||||
else if(ffParseDateTimeCommandOptions(&instance.config.dateTime, key, value)) {}
|
||||
else if(ffParseVulkanCommandOptions(&instance.config.vulkan, key, value)) {}
|
||||
else if(ffParseOpenGLCommandOptions(&instance.config.openGL, key, value)) {}
|
||||
else if(ffParseOpenCLCommandOptions(&instance.config.openCL, key, value)) {}
|
||||
else if(ffParseUsersCommandOptions(&instance.config.users, key, value)) {}
|
||||
else if(ffParseBluetoothCommandOptions(&instance.config.bluetooth, key, value)) {}
|
||||
else if(ffParseSeparatorCommandOptions(&instance.config.separator, key, value)) {}
|
||||
else if(ffParseSoundCommandOptions(&instance.config.sound, key, value)) {}
|
||||
else if(ffParseGamepadCommandOptions(&instance.config.gamepad, key, value)) {}
|
||||
else if(ffParseColorsCommandOptions(&instance.config.colors, key, value)) {}
|
||||
else if(ffStrStartsWithIgnCase(key, "--bar"))
|
||||
{
|
||||
const char* subkey = key + strlen("--bar");
|
||||
if(ffStrEqualsIgnCase(subkey, "-char-elapsed"))
|
||||
ffOptionParseString(key, value, &instance.config.barCharElapsed);
|
||||
else if(ffStrEqualsIgnCase(subkey, "-char-total"))
|
||||
ffOptionParseString(key, value, &instance.config.barCharTotal);
|
||||
else if(ffStrEqualsIgnCase(subkey, "-width"))
|
||||
instance.config.barWidth = (uint8_t) ffOptionParseUInt32(key, value);
|
||||
else if(ffStrEqualsIgnCase(subkey, "-border"))
|
||||
instance.config.barBorder = ffOptionParseBoolean(value);
|
||||
else
|
||||
goto error;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
//Library options//
|
||||
@@ -1129,6 +1145,12 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
goto error;
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
//Module args options//
|
||||
///////////////////////
|
||||
|
||||
else if(ffParseModuleOptions(key, value)) {}
|
||||
|
||||
//////////////////
|
||||
//Unknown option//
|
||||
//////////////////
|
||||
@@ -1175,8 +1197,16 @@ static void parseArguments(FFdata* data, int argc, const char** argv)
|
||||
|
||||
for(int i = 1; i < argc; i++)
|
||||
{
|
||||
const char* key = argv[i];
|
||||
if(*key != '-')
|
||||
{
|
||||
fprintf(stderr, "Error: invalid option: %s. An option must start with `-`\n", key);
|
||||
exit(400);
|
||||
}
|
||||
|
||||
if(i == argc - 1 || (
|
||||
*argv[i + 1] == '-' &&
|
||||
argv[i + 1][0] == '-' &&
|
||||
argv[i + 1][1] != '\0' && // `-` is used as an alias for `/dev/stdin`
|
||||
strcasecmp(argv[i], "--separator-string") != 0 // Separator string can start with a -
|
||||
)) {
|
||||
parseOption(data, argv[i], NULL);
|
||||
@@ -1206,152 +1236,8 @@ static void parseStructureCommand(const char* line, FFlist* customValues)
|
||||
}
|
||||
}
|
||||
|
||||
switch (toupper(line[0]))
|
||||
{
|
||||
case 'B':
|
||||
if(ffStrEqualsIgnCase(line, FF_BATTERY_MODULE_NAME))
|
||||
return ffPrintBattery(&instance.config.battery);
|
||||
if(ffStrEqualsIgnCase(line, FF_BIOS_MODULE_NAME))
|
||||
return ffPrintBios(&instance.config.bios);
|
||||
if(ffStrEqualsIgnCase(line, FF_BLUETOOTH_MODULE_NAME))
|
||||
return ffPrintBluetooth(&instance.config.bluetooth);
|
||||
if(ffStrEqualsIgnCase(line, FF_BOARD_MODULE_NAME))
|
||||
return ffPrintBoard(&instance.config.board);
|
||||
if(ffStrEqualsIgnCase(line, FF_BREAK_MODULE_NAME))
|
||||
return ffPrintBreak();
|
||||
if(ffStrEqualsIgnCase(line, FF_BRIGHTNESS_MODULE_NAME))
|
||||
return ffPrintBrightness(&instance.config.brightness);
|
||||
break;
|
||||
case 'C':
|
||||
if(ffStrEqualsIgnCase(line, FF_CHASSIS_MODULE_NAME))
|
||||
return ffPrintChassis(&instance.config.chassis);
|
||||
if(ffStrEqualsIgnCase(line, FF_COMMAND_MODULE_NAME))
|
||||
return ffPrintCommand(&instance.config.command);
|
||||
if(ffStrEqualsIgnCase(line, FF_CPU_MODULE_NAME))
|
||||
return ffPrintCPU(&instance.config.cpu);
|
||||
if(ffStrEqualsIgnCase(line, FF_CPUUSAGE_MODULE_NAME))
|
||||
return ffPrintCPUUsage(&instance.config.cpuUsage);
|
||||
if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME))
|
||||
return ffPrintColors(&instance.config.colors);
|
||||
if(ffStrEqualsIgnCase(line, FF_CURSOR_MODULE_NAME))
|
||||
return ffPrintCursor(&instance.config.cursor);
|
||||
if(ffStrEqualsIgnCase(line, FF_CUSTOM_MODULE_NAME))
|
||||
return ffPrintCustom(&instance.config.custom);
|
||||
break;
|
||||
case 'D':
|
||||
if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME))
|
||||
return ffPrintDateTime(&instance.config.dateTime);
|
||||
if(ffStrEqualsIgnCase(line, FF_DE_MODULE_NAME))
|
||||
return ffPrintDE(&instance.config.de);
|
||||
if(ffStrEqualsIgnCase(line, FF_DISPLAY_MODULE_NAME))
|
||||
return ffPrintDisplay(&instance.config.display);
|
||||
if(ffStrEqualsIgnCase(line, FF_DISK_MODULE_NAME))
|
||||
return ffPrintDisk(&instance.config.disk);
|
||||
break;
|
||||
case 'F':
|
||||
if(ffStrEqualsIgnCase(line, FF_FONT_MODULE_NAME))
|
||||
return ffPrintFont(&instance.config.font);
|
||||
break;
|
||||
case 'G':
|
||||
if(ffStrEqualsIgnCase(line, FF_GAMEPAD_MODULE_NAME))
|
||||
return ffPrintGamepad(&instance.config.gamepad);
|
||||
if(ffStrEqualsIgnCase(line, FF_GPU_MODULE_NAME))
|
||||
return ffPrintGPU(&instance.config.gpu);
|
||||
break;
|
||||
case 'H':
|
||||
if(ffStrEqualsIgnCase(line, FF_HOST_MODULE_NAME))
|
||||
return ffPrintHost(&instance.config.host);
|
||||
break;
|
||||
case 'I':
|
||||
if(ffStrEqualsIgnCase(line, FF_ICONS_MODULE_NAME))
|
||||
return ffPrintIcons(&instance.config.icons);
|
||||
break;
|
||||
case 'K':
|
||||
if(ffStrEqualsIgnCase(line, FF_KERNEL_MODULE_NAME))
|
||||
return ffPrintKernel(&instance.config.kernel);
|
||||
break;
|
||||
case 'L':
|
||||
if(ffStrEqualsIgnCase(line, FF_LM_MODULE_NAME))
|
||||
return ffPrintLM(&instance.config.lm);
|
||||
if(ffStrEqualsIgnCase(line, FF_LOCALE_MODULE_NAME))
|
||||
return ffPrintLocale(&instance.config.locale);
|
||||
if(ffStrEqualsIgnCase(line, FF_LOCALIP_MODULE_NAME))
|
||||
return ffPrintLocalIp(&instance.config.localIP);
|
||||
break;
|
||||
case 'M':
|
||||
if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME))
|
||||
return ffPrintMedia(&instance.config.media);
|
||||
if(ffStrEqualsIgnCase(line, FF_MEMORY_MODULE_NAME))
|
||||
return ffPrintMemory(&instance.config.memory);
|
||||
if(ffStrEqualsIgnCase(line, FF_MONITOR_MODULE_NAME))
|
||||
return ffPrintMonitor(&instance.config.nativeResolution);
|
||||
break;
|
||||
case 'O':
|
||||
if(ffStrEqualsIgnCase(line, FF_OPENCL_MODULE_NAME))
|
||||
return ffPrintOpenCL(&instance.config.openCL);
|
||||
if(ffStrEqualsIgnCase(line, FF_OPENGL_MODULE_NAME))
|
||||
return ffPrintOpenGL(&instance.config.openGL);
|
||||
if(ffStrEqualsIgnCase(line, FF_OS_MODULE_NAME))
|
||||
return ffPrintOS(&instance.config.os);
|
||||
break;
|
||||
case 'P':
|
||||
if(ffStrEqualsIgnCase(line, FF_PACKAGES_MODULE_NAME))
|
||||
return ffPrintPackages(&instance.config.packages);
|
||||
if(ffStrEqualsIgnCase(line, FF_PLAYER_MODULE_NAME))
|
||||
return ffPrintPlayer(&instance.config.player);
|
||||
if(ffStrEqualsIgnCase(line, FF_POWERADAPTER_MODULE_NAME))
|
||||
return ffPrintPowerAdapter(&instance.config.powerAdapter);
|
||||
if(ffStrEqualsIgnCase(line, FF_PROCESSES_MODULE_NAME))
|
||||
return ffPrintProcesses(&instance.config.processes);
|
||||
if(ffStrEqualsIgnCase(line, FF_PUBLICIP_MODULE_NAME))
|
||||
return ffPrintPublicIp(&instance.config.publicIP);
|
||||
break;
|
||||
case 'S':
|
||||
if(ffStrEqualsIgnCase(line, FF_SEPARATOR_MODULE_NAME))
|
||||
return ffPrintSeparator(&instance.config.separator);
|
||||
if(ffStrEqualsIgnCase(line, FF_SHELL_MODULE_NAME))
|
||||
return ffPrintShell(&instance.config.shell);
|
||||
if(ffStrEqualsIgnCase(line, FF_SOUND_MODULE_NAME))
|
||||
return ffPrintSound(&instance.config.sound);
|
||||
if(ffStrEqualsIgnCase(line, FF_SWAP_MODULE_NAME))
|
||||
return ffPrintSwap(&instance.config.swap);
|
||||
break;
|
||||
case 'T':
|
||||
if(ffStrEqualsIgnCase(line, FF_TERMINAL_MODULE_NAME))
|
||||
return ffPrintTerminal(&instance.config.terminal);
|
||||
if(ffStrEqualsIgnCase(line, FF_TERMINALFONT_MODULE_NAME))
|
||||
return ffPrintTerminalFont(&instance.config.terminalFont);
|
||||
if(ffStrEqualsIgnCase(line, FF_TERMINALSIZE_MODULE_NAME))
|
||||
return ffPrintTerminalSize(&instance.config.terminalSize);
|
||||
if(ffStrEqualsIgnCase(line, FF_TITLE_MODULE_NAME))
|
||||
return ffPrintTitle(&instance.config.title);
|
||||
if(ffStrEqualsIgnCase(line, FF_THEME_MODULE_NAME))
|
||||
return ffPrintTheme(&instance.config.theme);
|
||||
break;
|
||||
case 'U':
|
||||
if(ffStrEqualsIgnCase(line, FF_UPTIME_MODULE_NAME))
|
||||
return ffPrintUptime(&instance.config.uptime);
|
||||
if(ffStrEqualsIgnCase(line, FF_USERS_MODULE_NAME))
|
||||
return ffPrintUsers(&instance.config.users);
|
||||
break;
|
||||
case 'V':
|
||||
if(ffStrEqualsIgnCase(line, FF_VULKAN_MODULE_NAME))
|
||||
return ffPrintVulkan(&instance.config.vulkan);
|
||||
break;
|
||||
case 'W':
|
||||
if(ffStrEqualsIgnCase(line, FF_WALLPAPER_MODULE_NAME))
|
||||
return ffPrintWallpaper(&instance.config.wallpaper);
|
||||
if(ffStrEqualsIgnCase(line, FF_WEATHER_MODULE_NAME))
|
||||
return ffPrintWeather(&instance.config.weather);
|
||||
if(ffStrEqualsIgnCase(line, FF_WIFI_MODULE_NAME))
|
||||
return ffPrintWifi(&instance.config.wifi);
|
||||
if(ffStrEqualsIgnCase(line, FF_WM_MODULE_NAME))
|
||||
return ffPrintWM(&instance.config.wm);
|
||||
if(ffStrEqualsIgnCase(line, FF_WMTHEME_MODULE_NAME))
|
||||
return ffPrintWMTheme(&instance.config.wmTheme);
|
||||
break;
|
||||
}
|
||||
ffPrintErrorString(line, 0, NULL, NULL, "<no implementation provided>");
|
||||
if(!ffParseModuleCommand(line))
|
||||
ffPrintErrorString(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "<no implementation provided>");
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
@@ -1384,7 +1270,11 @@ int main(int argc, const char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
if(data.structure.length > 0 || !instance.state.configDoc)
|
||||
const bool useJsonConfig = data.structure.length == 0 && instance.state.configDoc;
|
||||
|
||||
if(useJsonConfig)
|
||||
ffPrintJsonConfig(true);
|
||||
else
|
||||
{
|
||||
//If we don't have a custom structure, use the default one
|
||||
if(data.structure.length == 0)
|
||||
@@ -1409,9 +1299,9 @@ int main(int argc, const char** argv)
|
||||
if (!instance.config.noBuffer) fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (data.structure.length == 0 && instance.state.configDoc)
|
||||
if (useJsonConfig)
|
||||
{
|
||||
ffPrintJsonConfig();
|
||||
ffPrintJsonConfig(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+63
-53
@@ -7,7 +7,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <yyjson.h>
|
||||
|
||||
#ifdef FF_USE_SYSTEM_YYJSON
|
||||
#include <yyjson.h>
|
||||
#else
|
||||
#include "3rdparty/yyjson/yyjson.h"
|
||||
#endif
|
||||
|
||||
#include "util/FFstrbuf.h"
|
||||
#include "util/FFlist.h"
|
||||
@@ -44,7 +49,6 @@ typedef struct FFconfig
|
||||
FFstrbuf keyValueSeparator;
|
||||
|
||||
bool showErrors;
|
||||
bool recache;
|
||||
bool allowSlowOperations;
|
||||
bool disableLinewrap;
|
||||
bool hideCursor;
|
||||
@@ -53,11 +57,18 @@ typedef struct FFconfig
|
||||
uint8_t sizeNdigits;
|
||||
uint8_t sizeMaxPrefix;
|
||||
FFTemperatureUnit temperatureUnit;
|
||||
FFstrbuf barCharElapsed;
|
||||
FFstrbuf barCharTotal;
|
||||
uint8_t barWidth;
|
||||
bool barBorder;
|
||||
uint8_t percentType;
|
||||
uint8_t percentNdigits;
|
||||
bool pipe; //disables logo and all escape sequences
|
||||
bool multithreading;
|
||||
bool stat;
|
||||
bool noBuffer;
|
||||
int32_t processingTimeout;
|
||||
uint32_t keyWidth;
|
||||
|
||||
// Module options that cannot be put in module option structure
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
@@ -68,59 +79,61 @@ typedef struct FFconfig
|
||||
int32_t wmiTimeout;
|
||||
#endif
|
||||
|
||||
FFTitleOptions title;
|
||||
FFOSOptions os;
|
||||
FFHostOptions host;
|
||||
FFBatteryOptions battery;
|
||||
FFBiosOptions bios;
|
||||
FFBluetoothOptions bluetooth;
|
||||
FFBoardOptions board;
|
||||
FFBreakOptions break_;
|
||||
FFBrightnessOptions brightness;
|
||||
FFChassisOptions chassis;
|
||||
FFCommandOptions command;
|
||||
FFKernelOptions kernel;
|
||||
FFUptimeOptions uptime;
|
||||
FFProcessesOptions processes;
|
||||
FFPackagesOptions packages;
|
||||
FFShellOptions shell;
|
||||
FFDisplayOptions display;
|
||||
FFDEOptions de;
|
||||
FFWallpaperOptions wallpaper;
|
||||
FFWifiOptions wifi;
|
||||
FFWMOptions wm;
|
||||
FFWMThemeOptions wmTheme;
|
||||
FFThemeOptions theme;
|
||||
FFIconsOptions icons;
|
||||
FFFontOptions font;
|
||||
FFCursorOptions cursor;
|
||||
FFTerminalOptions terminal;
|
||||
FFTerminalFontOptions terminalFont;
|
||||
FFTerminalSizeOptions terminalSize;
|
||||
FFCPUOptions cpu;
|
||||
FFCPUUsageOptions cpuUsage;
|
||||
FFCustomOptions custom;
|
||||
FFGPUOptions gpu;
|
||||
FFMemoryOptions memory;
|
||||
FFSwapOptions swap;
|
||||
FFDiskOptions disk;
|
||||
FFBatteryOptions battery;
|
||||
FFPowerAdapterOptions powerAdapter;
|
||||
FFLMOptions lm;
|
||||
FFLocaleOptions locale;
|
||||
FFLocalIpOptions localIP;
|
||||
FFPublicIpOptions publicIP;
|
||||
FFWeatherOptions weather;
|
||||
FFPlayerOptions player;
|
||||
FFMediaOptions media;
|
||||
FFMonitorOptions nativeResolution;
|
||||
FFDateTimeOptions dateTime;
|
||||
FFVulkanOptions vulkan;
|
||||
FFOpenGLOptions openGL;
|
||||
FFOpenCLOptions openCL;
|
||||
FFUsersOptions users;
|
||||
FFBluetoothOptions bluetooth;
|
||||
FFSeparatorOptions separator;
|
||||
FFSoundOptions sound;
|
||||
FFGamepadOptions gamepad;
|
||||
FFChassisOptions chassis;
|
||||
FFColorsOptions colors;
|
||||
FFCommandOptions command;
|
||||
FFCursorOptions cursor;
|
||||
FFCustomOptions custom;
|
||||
FFDEOptions de;
|
||||
FFDateTimeOptions dateTime;
|
||||
FFDiskOptions disk;
|
||||
FFDisplayOptions display;
|
||||
FFFontOptions font;
|
||||
FFGPUOptions gpu;
|
||||
FFGamepadOptions gamepad;
|
||||
FFHostOptions host;
|
||||
FFIconsOptions icons;
|
||||
FFKernelOptions kernel;
|
||||
FFLMOptions lm;
|
||||
FFLocalIpOptions localIP;
|
||||
FFLocaleOptions locale;
|
||||
FFMediaOptions media;
|
||||
FFMemoryOptions memory;
|
||||
FFMonitorOptions monitor;
|
||||
FFOSOptions os;
|
||||
FFOpenCLOptions openCL;
|
||||
FFOpenGLOptions openGL;
|
||||
FFPackagesOptions packages;
|
||||
FFPlayerOptions player;
|
||||
FFPowerAdapterOptions powerAdapter;
|
||||
FFProcessesOptions processes;
|
||||
FFPublicIpOptions publicIP;
|
||||
FFSeparatorOptions separator;
|
||||
FFShellOptions shell;
|
||||
FFSoundOptions sound;
|
||||
FFSwapOptions swap;
|
||||
FFTerminalFontOptions terminalFont;
|
||||
FFTerminalOptions terminal;
|
||||
FFTerminalSizeOptions terminalSize;
|
||||
FFThemeOptions theme;
|
||||
FFTitleOptions title;
|
||||
FFUptimeOptions uptime;
|
||||
FFUsersOptions users;
|
||||
FFVersionOptions version;
|
||||
FFVulkanOptions vulkan;
|
||||
FFWMOptions wm;
|
||||
FFWMThemeOptions wmTheme;
|
||||
FFWallpaperOptions wallpaper;
|
||||
FFWeatherOptions weather;
|
||||
FFWifiOptions wifi;
|
||||
|
||||
FFstrbuf libPCI;
|
||||
FFstrbuf libVulkan;
|
||||
@@ -146,10 +159,6 @@ typedef struct FFconfig
|
||||
FFstrbuf libPulse;
|
||||
FFstrbuf libnm;
|
||||
FFstrbuf libDdcutil;
|
||||
|
||||
uint32_t percentType;
|
||||
|
||||
bool jsonConfig;
|
||||
} FFconfig;
|
||||
|
||||
typedef struct FFstate
|
||||
@@ -168,6 +177,7 @@ typedef struct FFinstance
|
||||
FFstate state;
|
||||
} FFinstance;
|
||||
extern FFinstance instance; // Defined in `common/init.c`
|
||||
extern FFModuleBaseInfo** ffModuleInfos[];
|
||||
|
||||
//////////////////////
|
||||
// Init functions //
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#define FASTFETCH_PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define FASTFETCH_PROJECT_VERSION_TWEAK "@PROJECT_VERSION_TWEAK@"
|
||||
#define FASTFETCH_PROJECT_VERSION_TWEAK_NUM @PROJECT_VERSION_TWEAK_NUM@
|
||||
#define FASTFETCH_PROJECT_CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
|
||||
#define FASTFETCH_PROJECT_HOMEPAGE_URL "@PROJECT_HOMEPAGE_URL@"
|
||||
#define FASTFETCH_PROJECT_DESCRIPTION "@PROJECT_DESCRIPTION@"
|
||||
#define FASTFETCH_PROJECT_LICENSE "@PROJECT_LICENSE@"
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#define FASTFETCH_DATATEXT_CONFIG_SYSTEM "@DATATEXT_CONFIG_SYSTEM@"
|
||||
#define FASTFETCH_DATATEXT_CONFIG_USER "@DATATEXT_CONFIG_USER@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set
|
||||
#define FASTFETCH_DATATEXT_CONFIG_USER_JSONC "@DATATEXT_CONFIG_USER_JSONC@"
|
||||
#define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@"
|
||||
#define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@"
|
||||
#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@"
|
||||
#define FASTFETCH_DATATEXT_HELP_FORMAT "@DATATEXT_HELP_FORMAT@"
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ int main(void)
|
||||
//ffPrintBluetooth(&instance.config.bluetooth);
|
||||
//ffPrintSound(&instance.config.sound);
|
||||
//ffPrintGamepad(&instance.config.gamepad);
|
||||
ffPrintBreak();
|
||||
ffPrintBreak(&instance.config.break_);
|
||||
ffPrintColors(&instance.config.colors);
|
||||
|
||||
ffFinish();
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
ooo OOO OOO ooo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
OOo
|
||||
OOo
|
||||
OOo
|
||||
OOo
|
||||
OOo
|
||||
OOo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
oO OOo
|
||||
oOO OOo
|
||||
oOO OOo
|
||||
ooo OOO OOO ooo
|
||||
@@ -0,0 +1,18 @@
|
||||
:--==========================--:
|
||||
.-=================================.
|
||||
-==================================-
|
||||
====================================
|
||||
=======-....:==========:....:=======
|
||||
=======: -======-. .=======
|
||||
=======: :====- .=======
|
||||
=======: :==: .=======
|
||||
=======: .. .=======
|
||||
=======: .: .: .=======
|
||||
=======: .=- :=: .=======
|
||||
=======: .===. .-==: .=======
|
||||
=======: .==========: .=======
|
||||
=======: :==========: :=======
|
||||
====================================
|
||||
-===================================
|
||||
.==================================:
|
||||
:--===========================-:.
|
||||
@@ -0,0 +1,16 @@
|
||||
#############################+
|
||||
.%#######################%@@@+
|
||||
. :#@%-
|
||||
.#@%%%- =@@#.
|
||||
*@%@@= +@@+
|
||||
=@@%@+.#@%-
|
||||
-@@%@@@#:
|
||||
.#@%%@-
|
||||
:#@@%@@=
|
||||
=@@+=@@%@+
|
||||
.#@@= -@@%@#
|
||||
-%@#: :%@%@%:
|
||||
*@@+ .#%%%%-
|
||||
:%@%- .
|
||||
+@@@%#%%%%%%%%%%%%%%%%%%%%%%%.
|
||||
+######################*******
|
||||
+19
-15
@@ -1,15 +1,19 @@
|
||||
::::::: :::::::
|
||||
mMMMMMMm dMMMMMMm
|
||||
/MMMMMMMo +MMMMMMM/
|
||||
yMMMMMMN mMMMMMMy
|
||||
NMMMMMMs oMMMMMMm
|
||||
+MMMMMMN: NMMMMMM+
|
||||
hMMMMMMy sMMMMMMy
|
||||
:NMMMMMM::NMMMMMN:
|
||||
oMMMMMMyyMMMMMM+
|
||||
dMMMMMMMMMMMMh
|
||||
/MMMMMMMMMMMN:
|
||||
sMMMMMMMMMMo
|
||||
mMMMMMMMMd
|
||||
+MMMMMMMN:
|
||||
::::::
|
||||
`-`
|
||||
-yys+/-`
|
||||
`oyyyyy: /osyyyyso+:.
|
||||
/yyyyy+`+yyyyyyyyyys/.
|
||||
.-yyyyys.:+//+oyyyyyyyo.
|
||||
`oy/`oyyyyy/ ./syyyyy:
|
||||
syyys`:yyyyyo` :yyyyy:
|
||||
/yyyyo .syyyyy- .yyyyy.
|
||||
yyyyy. +yyyyy/ /yyyy/
|
||||
`yyyyy :yyyyys` -yyyyo
|
||||
yyyyy. `syyyyy- /yyyy/
|
||||
/yyyyo /yyyyy+ .yyyyy.
|
||||
syyyys. -yyyyys.:yyyy:
|
||||
`oyyyyyo-` `oyyyyy:.sy:
|
||||
:syyyyyyso+/++`/yyyyyo``
|
||||
-oyyyyyyyyyyy-.syyyys.
|
||||
-/+osyyyyso.`+yyyyy/
|
||||
.-/+syo`
|
||||
`.
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
++**
|
||||
*===**====+*
|
||||
*====* +===+
|
||||
*==*+===* *===*
|
||||
*===* *===+ *===*
|
||||
*===* +===+ *===*
|
||||
*===* +===* *===*
|
||||
*===* *===+*==*
|
||||
+===+ *===+=*
|
||||
*+====**===*
|
||||
**++
|
||||
@@ -13,6 +13,15 @@ const FFlogo ffLogoUnknown = {
|
||||
};
|
||||
|
||||
static const FFlogo A[] = {
|
||||
// AerOS
|
||||
{
|
||||
.names = {"aerOS"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_AEROS,
|
||||
.colors = {
|
||||
FF_COLOR_FG_CYAN,
|
||||
FF_COLOR_FG_CYAN,
|
||||
},
|
||||
},
|
||||
// AIX
|
||||
{
|
||||
.names = {"aix"},
|
||||
@@ -2332,6 +2341,15 @@ static const FFlogo M[] = {
|
||||
.colorKeys = FF_COLOR_FG_256 "29",
|
||||
.colorTitle = FF_COLOR_FG_WHITE,
|
||||
},
|
||||
// MOS
|
||||
{
|
||||
.names = {"MOS"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_MOS,
|
||||
.colors = {
|
||||
FF_COLOR_FG_CYAN,
|
||||
FF_COLOR_FG_BLUE,
|
||||
},
|
||||
},
|
||||
// Msys2
|
||||
{
|
||||
.names = {"Msys2"},
|
||||
@@ -3639,6 +3657,15 @@ static const FFlogo T[] = {
|
||||
FF_COLOR_FG_CYAN,
|
||||
},
|
||||
},
|
||||
// TuxedoOS
|
||||
{
|
||||
.names = {"Tuxedo OS"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_TUXEDO_OS,
|
||||
.colors = {
|
||||
FF_COLOR_FG_WHITE,
|
||||
FF_COLOR_FG_RED,
|
||||
},
|
||||
},
|
||||
// Twister
|
||||
{
|
||||
.names = {"Twister"},
|
||||
@@ -3899,6 +3926,16 @@ static const FFlogo V[] = {
|
||||
FF_COLOR_FG_BLUE,
|
||||
},
|
||||
},
|
||||
// VenomSmall
|
||||
{
|
||||
.names = {"Venom_small"},
|
||||
.type = FF_LOGO_LINE_TYPE_SMALL_BIT,
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_VENOM_SMALL,
|
||||
.colors = {
|
||||
FF_COLOR_FG_LIGHT_BLACK,
|
||||
FF_COLOR_FG_BLUE,
|
||||
},
|
||||
},
|
||||
// Vnux
|
||||
{
|
||||
.names = {"Vnux"},
|
||||
|
||||
+8
-18
@@ -3,6 +3,7 @@
|
||||
#include "common/printing.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/syslimits.h>
|
||||
@@ -184,12 +185,6 @@ static inline bool checkAllocationResult(void* data, size_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline uint32_t simpleCeil(double value)
|
||||
{
|
||||
uint32_t result = (uint32_t) value;
|
||||
return value == (double) result ? result : result + 1;
|
||||
}
|
||||
|
||||
static void writeCacheStrbuf(FFLogoRequestData* requestData, const FFstrbuf* value, const char* cacheFileName)
|
||||
{
|
||||
uint32_t cacheDirLength = requestData->cacheDir.length;
|
||||
@@ -463,8 +458,8 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI
|
||||
else if(requestData->logoPixelHeight == 0)
|
||||
requestData->logoPixelHeight = (uint32_t) ((double) imageData.image->rows / (double) imageData.image->columns * requestData->logoPixelWidth);
|
||||
|
||||
requestData->logoCharacterWidth = simpleCeil((double) requestData->logoPixelWidth / requestData->characterPixelWidth);
|
||||
requestData->logoCharacterHeight = simpleCeil((double) requestData->logoPixelHeight / requestData->characterPixelHeight);
|
||||
requestData->logoCharacterWidth = (uint32_t) ceil((double) requestData->logoPixelWidth / requestData->characterPixelWidth);
|
||||
requestData->logoCharacterHeight = (uint32_t) ceil((double) requestData->logoPixelHeight / requestData->characterPixelHeight);
|
||||
|
||||
if(requestData->logoPixelWidth == 0 || requestData->logoPixelHeight == 0 || requestData->logoCharacterWidth == 0 || requestData->logoCharacterHeight == 0)
|
||||
{
|
||||
@@ -608,8 +603,7 @@ static bool printCachedPixel(FFLogoRequestData* requestData)
|
||||
instance.state.logoHeight = requestData->logoCharacterHeight + instance.config.logo.paddingTop;
|
||||
|
||||
//Go to upper left corner
|
||||
fputs("\033[9999999D", stdout);
|
||||
printf("\033[%uA", instance.state.logoHeight);
|
||||
printf("\033[9999999D\033[%uA", instance.state.logoHeight);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -674,8 +668,8 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError)
|
||||
return false;
|
||||
}
|
||||
|
||||
requestData.logoPixelWidth = simpleCeil((double) instance.config.logo.width * requestData.characterPixelWidth);
|
||||
requestData.logoPixelHeight = simpleCeil((double) instance.config.logo.height * requestData.characterPixelHeight);
|
||||
requestData.logoPixelWidth = (uint32_t) ceil((double) instance.config.logo.width * requestData.characterPixelWidth);
|
||||
requestData.logoPixelHeight = (uint32_t) ceil((double) instance.config.logo.height * requestData.characterPixelHeight);
|
||||
|
||||
ffStrbufInit(&requestData.cacheDir);
|
||||
ffStrbufAppend(&requestData.cacheDir, &instance.state.platform.cacheDir);
|
||||
@@ -692,13 +686,9 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError)
|
||||
}
|
||||
ffStrbufRecalculateLength(&requestData.cacheDir);
|
||||
ffStrbufEnsureEndsWithC(&requestData.cacheDir, '/');
|
||||
ffStrbufAppendF(&requestData.cacheDir, "%u*%u/", requestData.logoPixelWidth, requestData.logoPixelHeight);
|
||||
|
||||
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelWidth);
|
||||
ffStrbufAppendC(&requestData.cacheDir, '*');
|
||||
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelHeight);
|
||||
ffStrbufAppendC(&requestData.cacheDir, '/');
|
||||
|
||||
if(!instance.config.recache && printCached(&requestData))
|
||||
if(!instance.config.logo.recache && printCached(&requestData))
|
||||
{
|
||||
ffStrbufDestroy(&requestData.cacheDir);
|
||||
return true;
|
||||
|
||||
+4
-1
@@ -359,7 +359,10 @@ static bool logoPrintFileIfExists(bool doColorReplacement, bool raw)
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
|
||||
|
||||
if(!ffAppendFileBuffer(options->source.chars, &content))
|
||||
if(ffStrbufEqualS(&options->source, "-")
|
||||
? !ffAppendFDBuffer(FFUnixFD2NativeFD(STDIN_FILENO), &content)
|
||||
: !ffAppendFileBuffer(options->source.chars, &content)
|
||||
)
|
||||
{
|
||||
fprintf(stderr, "Logo: Failed to load file content from logo source: %s \n", options->source.chars);
|
||||
return false;
|
||||
|
||||
+9
-1
@@ -16,6 +16,7 @@ void ffInitLogoOptions(FFLogoOptions* options)
|
||||
options->paddingRight = 4;
|
||||
options->printRemaining = true;
|
||||
options->preserveAspectRadio = false;
|
||||
options->recache = false;
|
||||
|
||||
options->chafaFgOnly = false;
|
||||
ffStrbufInitStatic(&options->chafaSymbols, "block+border+space-wide-inverted"); // Chafa default
|
||||
@@ -113,6 +114,8 @@ logoType:
|
||||
options->printRemaining = ffOptionParseBoolean(value);
|
||||
else if(strcasecmp(subKey, "preserve-aspect-radio") == 0)
|
||||
options->preserveAspectRadio = ffOptionParseBoolean(value);
|
||||
else if(strcasecmp(subKey, "recache") == 0)
|
||||
options->recache = ffOptionParseBoolean(value);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -123,7 +126,7 @@ logoType:
|
||||
ffOptionParseString(key, value, &options->source);
|
||||
options->type = FF_LOGO_TYPE_FILE;
|
||||
}
|
||||
else if(strcasecmp(key, "raw") == 0)
|
||||
else if(strcasecmp(subKey, "raw") == 0)
|
||||
{
|
||||
ffOptionParseString(key, value, &options->source);
|
||||
options->type = FF_LOGO_TYPE_FILE_RAW;
|
||||
@@ -334,6 +337,11 @@ const char* ffParseLogoJsonConfig(void)
|
||||
options->preserveAspectRadio = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
else if (strcasecmp(key, "recache") == 0)
|
||||
{
|
||||
options->recache = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
else if (strcasecmp(key, "chafa") == 0)
|
||||
{
|
||||
if (!yyjson_is_obj(val))
|
||||
|
||||
@@ -35,6 +35,7 @@ typedef struct FFLogoOptions
|
||||
uint32_t paddingRight;
|
||||
bool printRemaining;
|
||||
bool preserveAspectRadio;
|
||||
bool recache;
|
||||
|
||||
bool chafaFgOnly;
|
||||
FFstrbuf chafaSymbols;
|
||||
|
||||
@@ -10,27 +10,26 @@
|
||||
|
||||
static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8_t index)
|
||||
{
|
||||
if(instance.config.battery.moduleArgs.outputFormat.length == 0)
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
bool showStatus =
|
||||
!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) &&
|
||||
result->status.length > 0 &&
|
||||
ffStrbufIgnCaseCompS(&result->status, "Unknown") != 0;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(result->capacity >= 0)
|
||||
{
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
if(result->capacity <= 20)
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 10, 10, 0);
|
||||
ffAppendPercentBar(&str, result->capacity, 100, 100, 0);
|
||||
else if(result->capacity <= 50)
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 10, 0, 10);
|
||||
ffAppendPercentBar(&str, result->capacity, 100, 0, 100);
|
||||
else
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 0, 10, 10);
|
||||
ffAppendPercentBar(&str, result->capacity, 0, 100, 100);
|
||||
}
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -38,7 +37,7 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffAppendPercentNum(&str, (uint8_t) result->capacity, 51, 21, str.length > 0);
|
||||
ffAppendPercentNum(&str, result->capacity, 51, 21, str.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,11 +61,13 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY capacityStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&capacityStr, result->capacity, 51, 21, false);
|
||||
ffPrintFormat(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->capacity},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->status},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->temperature},
|
||||
});
|
||||
@@ -105,7 +106,7 @@ void ffPrintBattery(FFBatteryOptions* options)
|
||||
|
||||
void ffInitBatteryOptions(FFBatteryOptions* options)
|
||||
{
|
||||
options->moduleName = FF_BATTERY_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_BATTERY_MODULE_NAME, ffParseBatteryCommandOptions, ffParseBatteryJsonObject, ffPrintBattery);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->temp = false;
|
||||
|
||||
@@ -147,41 +148,33 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ffParseBatteryJsonObject(yyjson_val* module)
|
||||
void ffParseBatteryJsonObject(FFBatteryOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options;
|
||||
ffInitBatteryOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
#ifdef __linux__
|
||||
if (ffStrEqualsIgnCase(key, "dir"))
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
#ifdef __linux__
|
||||
if (ffStrEqualsIgnCase(key, "dir"))
|
||||
{
|
||||
ffStrbufSetS(&options.dir, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "temp"))
|
||||
{
|
||||
options.temp = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffStrbufSetS(&options->dir, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ffPrintBattery(&options);
|
||||
if (ffStrEqualsIgnCase(key, "temp"))
|
||||
{
|
||||
options->temp = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ void ffPrintBattery(FFBatteryOptions* options);
|
||||
void ffInitBatteryOptions(FFBatteryOptions* options);
|
||||
bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBatteryOptions(FFBatteryOptions* options);
|
||||
void ffParseBatteryJsonObject(yyjson_val* module);
|
||||
void ffParseBatteryJsonObject(FFBatteryOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
typedef struct FFBatteryOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
bool temp;
|
||||
|
||||
+12
-20
@@ -30,7 +30,7 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&bios.version, stdout);
|
||||
if (bios.release.length)
|
||||
printf(" (%s)", bios.release.chars);
|
||||
@@ -55,7 +55,7 @@ exit:
|
||||
|
||||
void ffInitBiosOptions(FFBiosOptions* options)
|
||||
{
|
||||
options->moduleName = FF_BIOS_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_BIOS_MODULE_NAME, ffParseBiosCommandOptions, ffParseBiosJsonObject, ffPrintBios);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -74,27 +74,19 @@ void ffDestroyBiosOptions(FFBiosOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseBiosJsonObject(yyjson_val* module)
|
||||
void ffParseBiosJsonObject(FFBiosOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options;
|
||||
ffInitBiosOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
|
||||
ffPrintBios(&options);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintBios(FFBiosOptions* options);
|
||||
void ffInitBiosOptions(FFBiosOptions* options);
|
||||
bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBiosOptions(FFBiosOptions* options);
|
||||
void ffParseBiosJsonObject(yyjson_val* module);
|
||||
void ffParseBiosJsonObject(FFBiosOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
typedef struct FFBiosOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFBiosOptions;
|
||||
|
||||
@@ -10,7 +10,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothDevice* de
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&device->name, stdout);
|
||||
|
||||
if(device->battery > 0)
|
||||
@@ -75,7 +75,7 @@ void ffPrintBluetooth(FFBluetoothOptions* options)
|
||||
|
||||
void ffInitBluetoothOptions(FFBluetoothOptions* options)
|
||||
{
|
||||
options->moduleName = FF_BLUETOOTH_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_BLUETOOTH_MODULE_NAME, ffParseBluetoothCommandOptions, ffParseBluetoothJsonObject, ffPrintBluetooth);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->showDisconnected = false;
|
||||
}
|
||||
@@ -101,33 +101,25 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseBluetoothJsonObject(yyjson_val* module)
|
||||
void ffParseBluetoothJsonObject(FFBluetoothOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options;
|
||||
ffInitBluetoothOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "showDisconnected"))
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "showDisconnected"))
|
||||
{
|
||||
options.showDisconnected = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
options->showDisconnected = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintBluetooth(&options);
|
||||
ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintBluetooth(FFBluetoothOptions* options);
|
||||
void ffInitBluetoothOptions(FFBluetoothOptions* options);
|
||||
bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBluetoothOptions(FFBluetoothOptions* options);
|
||||
void ffParseBluetoothJsonObject(yyjson_val* module);
|
||||
void ffParseBluetoothJsonObject(FFBluetoothOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
typedef struct FFBluetoothOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
bool showDisconnected;
|
||||
|
||||
+12
-20
@@ -28,7 +28,7 @@ void ffPrintBoard(FFBoardOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&result.name, stdout);
|
||||
if (result.version.length)
|
||||
printf(" (%s)", result.version.chars);
|
||||
@@ -51,7 +51,7 @@ exit:
|
||||
|
||||
void ffInitBoardOptions(FFBoardOptions* options)
|
||||
{
|
||||
options->moduleName = FF_BOARD_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_BOARD_MODULE_NAME, ffParseBoardCommandOptions, ffParseBoardJsonObject, ffPrintBoard);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -70,27 +70,19 @@ void ffDestroyBoardOptions(FFBoardOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseBoardJsonObject(yyjson_val* module)
|
||||
void ffParseBoardJsonObject(FFBoardOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options;
|
||||
ffInitBoardOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
|
||||
ffPrintBoard(&options);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintBoard(FFBoardOptions* options);
|
||||
void ffInitBoardOptions(FFBoardOptions* options);
|
||||
bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBoardOptions(FFBoardOptions* options);
|
||||
void ffParseBoardJsonObject(yyjson_val* module);
|
||||
void ffParseBoardJsonObject(FFBoardOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
typedef struct FFBoardOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFBoardOptions;
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
#include "common/printing.h"
|
||||
#include "modules/break/break.h"
|
||||
|
||||
void ffPrintBreak(void)
|
||||
void ffPrintBreak(FF_MAYBE_UNUSED FFBreakOptions* options)
|
||||
{
|
||||
ffLogoPrintLine();
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void ffParseBreakJsonObject(FF_MAYBE_UNUSED yyjson_val* module)
|
||||
void ffInitBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options)
|
||||
{
|
||||
return ffPrintBreak();
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_BREAK_MODULE_NAME, ffParseBreakCommandOptions, ffParseBreakJsonObject, ffPrintBreak);
|
||||
}
|
||||
|
||||
bool ffParseBreakCommandOptions(FF_MAYBE_UNUSED FFBreakOptions* options, FF_MAYBE_UNUSED const char* key, FF_MAYBE_UNUSED const char* value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffDestroyBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options)
|
||||
{
|
||||
}
|
||||
|
||||
void ffParseBreakJsonObject(FF_MAYBE_UNUSED FFBreakOptions* options, FF_MAYBE_UNUSED yyjson_val* module)
|
||||
{
|
||||
ffPrintBreak(options);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,8 @@
|
||||
|
||||
#define FF_BREAK_MODULE_NAME "Break"
|
||||
|
||||
void ffPrintBreak();
|
||||
void ffParseBreakJsonObject(yyjson_val* module);
|
||||
void ffPrintBreak(FFBreakOptions* options);
|
||||
void ffInitBreakOptions(FFBreakOptions* options);
|
||||
bool ffParseBreakCommandOptions(FFBreakOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBreakOptions(FFBreakOptions* options);
|
||||
void ffParseBreakJsonObject(FFBreakOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef struct FFBreakOptions
|
||||
{
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
} FFBreakOptions;
|
||||
@@ -27,6 +27,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
|
||||
uint32_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFBrightnessResult, item, result)
|
||||
{
|
||||
if(options->moduleArgs.key.length == 0)
|
||||
@@ -35,20 +36,21 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){
|
||||
uint32_t moduleIndex = result.length == 1 ? 0 : index + 1;
|
||||
ffParseFormatString(&key, &options->moduleArgs.key, 2, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name}
|
||||
});
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
|
||||
|
||||
if (instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(&str, (uint8_t) (item->value + 0.5), 0, 10, 10);
|
||||
ffAppendPercentBar(&str, item->value, 0, 100, 100);
|
||||
}
|
||||
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -56,27 +58,30 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffAppendPercentNum(&str, (uint8_t) (item->value + 0.5), 10, 10, str.length > 0);
|
||||
ffAppendPercentNum(&str, item->value, 10, 10, str.length > 0);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_FLOAT, &item->value},
|
||||
FF_STRBUF_AUTO_DESTROY valueStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&valueStr, item->value, 10, 10, false);
|
||||
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &valueStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name},
|
||||
});
|
||||
}
|
||||
|
||||
ffStrbufClear(&key);
|
||||
ffStrbufDestroy(&item->name);
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
void ffInitBrightnessOptions(FFBrightnessOptions* options)
|
||||
{
|
||||
options->moduleName = FF_BRIGHTNESS_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_BRIGHTNESS_MODULE_NAME, ffParseBrightnessCommandOptions, ffParseBrightnessJsonObject, ffPrintBrightness);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -95,27 +100,19 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseBrightnessJsonObject(yyjson_val* module)
|
||||
void ffParseBrightnessJsonObject(FFBrightnessOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options;
|
||||
ffInitBrightnessOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
|
||||
ffPrintBrightness(&options);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintBrightness(FFBrightnessOptions* options);
|
||||
void ffInitBrightnessOptions(FFBrightnessOptions* options);
|
||||
bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBrightnessOptions(FFBrightnessOptions* options);
|
||||
void ffParseBrightnessJsonObject(yyjson_val* module);
|
||||
void ffParseBrightnessJsonObject(FFBrightnessOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
typedef struct FFBrightnessOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFBrightnessOptions;
|
||||
|
||||
@@ -29,7 +29,7 @@ void ffPrintChassis(FFChassisOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&result.type, stdout);
|
||||
if (result.version.length)
|
||||
printf(" (%s)", result.version.chars);
|
||||
@@ -52,7 +52,7 @@ exit:
|
||||
|
||||
void ffInitChassisOptions(FFChassisOptions* options)
|
||||
{
|
||||
options->moduleName = FF_CHASSIS_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_CHASSIS_MODULE_NAME, ffParseChassisCommandOptions, ffParseChassisJsonObject, ffPrintChassis);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -71,27 +71,19 @@ void ffDestroyChassisOptions(FFChassisOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseChassisJsonObject(yyjson_val* module)
|
||||
void ffParseChassisJsonObject(FFChassisOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFChassisOptions __attribute__((__cleanup__(ffDestroyChassisOptions))) options;
|
||||
ffInitChassisOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
|
||||
ffPrintChassis(&options);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintChassis(FFChassisOptions* options);
|
||||
void ffInitChassisOptions(FFChassisOptions* options);
|
||||
bool ffParseChassisCommandOptions(FFChassisOptions* options, const char* key, const char* value);
|
||||
void ffDestroyChassisOptions(FFChassisOptions* options);
|
||||
void ffParseChassisJsonObject(yyjson_val* module);
|
||||
void ffParseChassisJsonObject(FFChassisOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
typedef struct FFChassisOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFChassisOptions;
|
||||
|
||||
+33
-41
@@ -57,7 +57,7 @@ void ffPrintColors(FFColorsOptions* options)
|
||||
|
||||
void ffInitColorsOptions(FFColorsOptions* options)
|
||||
{
|
||||
options->moduleName = FF_COLORS_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_COLORS_MODULE_NAME, ffParseColorsCommandOptions, ffParseColorsJsonObject, ffPrintColors);
|
||||
options->symbol = FF_COLORS_SYMBOL_BLOCK;
|
||||
options->paddingLeft = 0;
|
||||
}
|
||||
@@ -94,49 +94,41 @@ void ffDestroyColorsOptions(FF_MAYBE_UNUSED FFColorsOptions* options)
|
||||
{
|
||||
}
|
||||
|
||||
void ffParseColorsJsonObject(yyjson_val* module)
|
||||
void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFColorsOptions __attribute__((__cleanup__(ffDestroyColorsOptions))) options;
|
||||
ffInitColorsOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "symbol"))
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "symbol"))
|
||||
{
|
||||
int value;
|
||||
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
|
||||
{ "block", FF_COLORS_SYMBOL_BLOCK },
|
||||
{ "circle", FF_COLORS_SYMBOL_CIRCLE },
|
||||
{ "diamond", FF_COLORS_SYMBOL_DIAMOND },
|
||||
{ "triangle", FF_COLORS_SYMBOL_TRIANGLE },
|
||||
{ "square", FF_COLORS_SYMBOL_SQUARE },
|
||||
{ "star", FF_COLORS_SYMBOL_STAR },
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options.symbol = (FFColorsSymbol) value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "paddingLeft"))
|
||||
{
|
||||
options.paddingLeft = (uint32_t) yyjson_get_uint(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
|
||||
int value;
|
||||
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
|
||||
{ "block", FF_COLORS_SYMBOL_BLOCK },
|
||||
{ "circle", FF_COLORS_SYMBOL_CIRCLE },
|
||||
{ "diamond", FF_COLORS_SYMBOL_DIAMOND },
|
||||
{ "triangle", FF_COLORS_SYMBOL_TRIANGLE },
|
||||
{ "square", FF_COLORS_SYMBOL_SQUARE },
|
||||
{ "star", FF_COLORS_SYMBOL_STAR },
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options->symbol = (FFColorsSymbol) value;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintColors(&options);
|
||||
if (ffStrEqualsIgnCase(key, "paddingLeft"))
|
||||
{
|
||||
options->paddingLeft = (uint32_t) yyjson_get_uint(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintColors(FFColorsOptions* options);
|
||||
void ffInitColorsOptions(FFColorsOptions* options);
|
||||
void ffDestroyColorsOptions(FFColorsOptions* options);
|
||||
bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, const char* value);
|
||||
void ffParseColorsJsonObject(yyjson_val* module);
|
||||
void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -16,7 +16,7 @@ typedef enum FFColorsSymbol
|
||||
|
||||
typedef struct FFColorsOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFColorsSymbol symbol;
|
||||
uint32_t paddingLeft;
|
||||
} FFColorsOptions;
|
||||
|
||||
@@ -30,13 +30,13 @@ void ffPrintCommand(FFCommandOptions* options)
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufPutTo(&result, stdout);
|
||||
}
|
||||
|
||||
void ffInitCommandOptions(FFCommandOptions* options)
|
||||
{
|
||||
options->moduleName = FF_COMMAND_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_COMMAND_MODULE_NAME, ffParseCommandCommandOptions, ffParseCommandJsonObject, ffPrintCommand);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
|
||||
ffStrbufInitStatic(&options->shell,
|
||||
@@ -79,39 +79,31 @@ void ffDestroyCommandOptions(FFCommandOptions* options)
|
||||
ffStrbufDestroy(&options->text);
|
||||
}
|
||||
|
||||
void ffParseCommandJsonObject(yyjson_val* module)
|
||||
void ffParseCommandJsonObject(FFCommandOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options;
|
||||
ffInitCommandOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "shell"))
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "shell"))
|
||||
{
|
||||
ffStrbufSetS(&options.shell, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "text"))
|
||||
{
|
||||
ffStrbufSetS(&options.text, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffStrbufSetS(&options->shell, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintCommand(&options);
|
||||
if (ffStrEqualsIgnCase(key, "text"))
|
||||
{
|
||||
ffStrbufSetS(&options->text, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintCommand(FFCommandOptions* options);
|
||||
void ffInitCommandOptions(FFCommandOptions* options);
|
||||
bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCommandOptions(FFCommandOptions* options);
|
||||
void ffParseCommandJsonObject(yyjson_val* module);
|
||||
void ffParseCommandJsonObject(FFCommandOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
typedef struct FFCommandOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFstrbuf shell;
|
||||
|
||||
+18
-26
@@ -30,7 +30,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
@@ -79,7 +79,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
|
||||
void ffInitCPUOptions(FFCPUOptions* options)
|
||||
{
|
||||
options->moduleName = FF_CPU_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_CPU_MODULE_NAME, ffParseCPUCommandOptions, ffParseCPUJsonObject, ffPrintCPU);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->temp = false;
|
||||
}
|
||||
@@ -105,33 +105,25 @@ void ffDestroyCPUOptions(FFCPUOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseCPUJsonObject(yyjson_val* module)
|
||||
void ffParseCPUJsonObject(FFCPUOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFCPUOptions __attribute__((__cleanup__(ffDestroyCPUOptions))) options;
|
||||
ffInitCPUOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "temp"))
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "temp"))
|
||||
{
|
||||
options.temp = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_CPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
options->temp = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintCPU(&options);
|
||||
ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintCPU(FFCPUOptions* options);
|
||||
void ffInitCPUOptions(FFCPUOptions* options);
|
||||
bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCPUOptions(FFCPUOptions* options);
|
||||
void ffParseCPUJsonObject(yyjson_val* module);
|
||||
void ffParseCPUJsonObject(FFCPUOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
typedef struct FFCPUOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
bool temp;
|
||||
|
||||
@@ -21,30 +21,32 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffAppendPercentBar(&str, (uint8_t)percentage, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, percentage, 0, 50, 80);
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
ffAppendPercentNum(&str, percentage, 50, 80, str.length > 0);
|
||||
}
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffAppendPercentNum(&percentageStr, percentage, 50, 80, false);
|
||||
ffPrintFormat(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &percentage}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
{
|
||||
options->moduleName = FF_CPUUSAGE_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_CPUUSAGE_MODULE_NAME, ffParseCPUUsageCommandOptions, ffParseCPUUsageJsonObject, ffPrintCPUUsage);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -63,27 +65,19 @@ void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseCPUUsageJsonObject(yyjson_val* module)
|
||||
void ffParseCPUUsageJsonObject(FFCPUUsageOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFCPUUsageOptions __attribute__((__cleanup__(ffDestroyCPUUsageOptions))) options;
|
||||
ffInitCPUUsageOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_CPUUSAGE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
ffPrintError(FF_CPUUSAGE_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
|
||||
ffPrintCPUUsage(&options);
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options);
|
||||
void ffInitCPUUsageOptions(FFCPUUsageOptions* options);
|
||||
bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options);
|
||||
void ffParseCPUUsageJsonObject(yyjson_val* module);
|
||||
void ffParseCPUUsageJsonObject(FFCPUUsageOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
typedef struct FFCPUUsageOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFCPUUsageOptions;
|
||||
|
||||
+13
-21
@@ -28,10 +28,10 @@ void ffPrintCursor(FFCursorOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&result.theme, stdout);
|
||||
|
||||
if(result.size.length > 0)
|
||||
if(result.size.length > 0 && !ffStrbufEqualS(&result.size, "0"))
|
||||
printf(" (%spx)", result.size.chars);
|
||||
|
||||
putchar('\n');
|
||||
@@ -52,7 +52,7 @@ void ffPrintCursor(FFCursorOptions* options)
|
||||
|
||||
void ffInitCursorOptions(FFCursorOptions* options)
|
||||
{
|
||||
options->moduleName = FF_CURSOR_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_CURSOR_MODULE_NAME, ffParseCursorCommandOptions, ffParseCursorJsonObject, ffPrintCursor);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -71,27 +71,19 @@ void ffDestroyCursorOptions(FFCursorOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseCursorJsonObject(yyjson_val* module)
|
||||
void ffParseCursorJsonObject(FFCursorOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFCursorOptions __attribute__((__cleanup__(ffDestroyCursorOptions))) options;
|
||||
ffInitCursorOptions(&options);
|
||||
|
||||
if (module)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
|
||||
ffPrintCursor(&options);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user