mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Compare commits
181 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 779dbab647 | |||
| 47373998d5 | |||
| 11809e30b5 | |||
| 35253e085c | |||
| 112e83b7c3 | |||
| c74b34aa39 | |||
| b2e0034c34 | |||
| e3cdf9d9fd | |||
| 6cdb694e33 | |||
| 83016289e9 | |||
| f9562d7132 | |||
| 2f66bc2c95 | |||
| d7c848225c | |||
| 8404ae8e70 | |||
| d75f72c8fe | |||
| 9fa00081e3 | |||
| fca37b59c8 | |||
| 2fe7476c67 | |||
| 03cbd64d8a | |||
| f65aeed96f | |||
| b63f419cde | |||
| 99aa2f7b45 | |||
| b251c32c12 | |||
| 034e23d7e3 | |||
| bba912d42e | |||
| 597652c35a | |||
| 7f67846ad9 | |||
| bc2e292e22 | |||
| 75dc228120 | |||
| bc783f6efd | |||
| 85e1d2b40c | |||
| 3338189354 | |||
| d4c836fd25 | |||
| 6787f1eba8 | |||
| eedc277bcf | |||
| d4b32eaaec | |||
| 910f63f0ad | |||
| 9a0aa2ac72 | |||
| dce81055fe | |||
| 66a4fc1600 | |||
| 159a114bb7 | |||
| ac08b46e71 | |||
| ceb92dafd7 | |||
| 31eeb6dd08 | |||
| c021689a2b | |||
| 2ac2762c9f | |||
| 27dd097671 | |||
| c7bf471e29 | |||
| 298bc10e5f | |||
| 676485ef74 | |||
| fb6da20b0c | |||
| 0c81d3e894 | |||
| 5c1aa20042 | |||
| 46a27c4e39 | |||
| 128302596e | |||
| 7a15dee2be | |||
| 000bd37f1d | |||
| 707e0f930d | |||
| 7676a313c5 | |||
| 6e0d76a2fb | |||
| 4c7b7e4a4d | |||
| 4d34091573 | |||
| c971e28aca | |||
| c41a29a5c1 | |||
| 5c73125693 | |||
| cea48474a1 | |||
| 536f914f3e | |||
| 778856dd57 | |||
| 4a43144991 | |||
| ac96cfc748 | |||
| f18ffe3239 | |||
| 986bbeebb3 | |||
| b9d360af97 | |||
| ec1981c545 | |||
| f7e7d8e9f2 | |||
| ad9fc5845a | |||
| a6b169f3e2 | |||
| 8aff9939bc | |||
| 0b8f51188b | |||
| 3c99a82619 | |||
| d5f3ff1cfe | |||
| 011c033091 | |||
| 63bf22fb00 | |||
| f74973db65 | |||
| 85656fd515 | |||
| 23bf7a407b | |||
| e570cacbc9 | |||
| a96f79795b | |||
| 2d51d935c8 | |||
| 9d395f7235 | |||
| 5f16394916 | |||
| 6581c9d378 | |||
| 67ac7eef59 | |||
| b95e83e9e5 | |||
| e9d9b942fa | |||
| c95ad74ea2 | |||
| 85b0be5213 | |||
| da671d6cfe | |||
| 18af9ab902 | |||
| 558fbc20e2 | |||
| d9bbbd4fa8 | |||
| 292a809703 | |||
| fa13826043 | |||
| 7bc85b2397 | |||
| 1863d8377a | |||
| f9e17f44b1 | |||
| 02cc214dfc | |||
| 609fa14f4f | |||
| 7d6f92a446 | |||
| bc76ebfb3f | |||
| c2da7b19f9 | |||
| 41b024d3b1 | |||
| 9b62d17d8d | |||
| 1861d55f7d | |||
| 3b2a6e4a6e | |||
| 8ab7a8ba37 | |||
| 22a3ab4a81 | |||
| 44d6780545 | |||
| 5820c9bbff | |||
| 3ba486a5b8 | |||
| 2d2ba4c5b3 | |||
| 94ad782caa | |||
| b079e86c5e | |||
| 91ba03d988 | |||
| c440fdfca8 | |||
| af0c72aa61 | |||
| 8fa09ca093 | |||
| 6e731c80d0 | |||
| 45eae78980 | |||
| fb35a6e889 | |||
| 26d17250b6 | |||
| 9176797327 | |||
| 9d3f762c20 | |||
| fe71291769 | |||
| f35dc9f46a | |||
| a6209187ae | |||
| af2f97e0c9 | |||
| 0691112e5e | |||
| e61b31acab | |||
| 5d853f3b17 | |||
| 20e2f1e19d | |||
| ad28b3aac5 | |||
| eb0bbd0796 | |||
| da77a7936f | |||
| eac875b8b1 | |||
| 97d2096df8 | |||
| 6e3e717224 | |||
| aae182c889 | |||
| 5c7b9d223a | |||
| c80f8cf422 | |||
| b150e8d106 | |||
| bb897f03f0 | |||
| 517d80eadc | |||
| 36964d6b1d | |||
| 5e96ba8384 | |||
| 481affa50a | |||
| a33e296656 | |||
| 85a36ae7ef | |||
| 1eff343733 | |||
| acdbf6933c | |||
| ea53833466 | |||
| c491c11988 | |||
| dcaeab7e96 | |||
| bccd1cf960 | |||
| 5b030de20a | |||
| fa9b38eb2d | |||
| 716522e29a | |||
| 921e4a6c8d | |||
| 7d43118abb | |||
| d8bb36f119 | |||
| ae8b5bde65 | |||
| 3d8a071781 | |||
| 4cf912e535 | |||
| e1b5445783 | |||
| a04daf1fff | |||
| df0a4c0d46 | |||
| d70e160d72 | |||
| 8c52cd0d91 | |||
| 4622d7a300 | |||
| 09f7180dd5 | |||
| 6ae8b46f68 |
@@ -25,6 +25,9 @@ Output of `fastfetch --load-config devinfo`:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Output of `fastfetch --load-config devinfo-verbose`:
|
Output of `fastfetch --load-config devinfo-verbose`:
|
||||||
|
<!--
|
||||||
|
Note that this output will contain you public IP. If it is not relevant for the issue, feel free to remove it before uploading.
|
||||||
|
-->
|
||||||
```
|
```
|
||||||
//paste here
|
//paste here
|
||||||
```
|
```
|
||||||
@@ -38,4 +41,3 @@ Output of `fastfetch --list-features`:
|
|||||||
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 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 `fastfetch --show-errors --recache --multithreading false --disable-linewrap false`.
|
If this isn't possible (or too much work) for you, post the output of `fastfetch --show-errors --recache --multithreading false --disable-linewrap false`.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
name: Logo request
|
||||||
|
about: Request a new logo
|
||||||
|
title: ''
|
||||||
|
labels: logo request
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# OS
|
||||||
|
```
|
||||||
|
paste content of /etc/os-release here. If this file doesn't exist, describe a way to identify the distro.
|
||||||
|
```
|
||||||
|
|
||||||
|
# Ascii
|
||||||
|
```
|
||||||
|
paste ascii art here. If you leave this empty, i will try to find the logo myself.
|
||||||
|
```
|
||||||
@@ -24,7 +24,7 @@ jobs:
|
|||||||
- name: configure project
|
- name: configure project
|
||||||
# We reuse the build binary only for the releases.
|
# We reuse the build binary only for the releases.
|
||||||
# We set tweak version to off, because it is wrong, as git tag will happen after this step. Releases don't have a tweak, so this is ok.
|
# We set tweak version to off, because it is wrong, as git tag will happen after this step. Releases don't have a tweak, so this is ok.
|
||||||
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
|
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
|
||||||
|
|
||||||
- name: build project
|
- name: build project
|
||||||
run: cmake --build . -j$(nproc) --target package
|
run: cmake --build . -j$(nproc) --target package
|
||||||
|
|||||||
@@ -5,5 +5,3 @@
|
|||||||
cscope.*
|
cscope.*
|
||||||
tags
|
tags
|
||||||
fastfetch.kdev4
|
fastfetch.kdev4
|
||||||
**/*.deb
|
|
||||||
packaging/deb/fastfetch
|
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# 1.6.4
|
||||||
|
|
||||||
|
Releasing this, so fedora can package fastfetch. Thanks to @jonathanspw for doing that!
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* --set-keyless option (#215)
|
||||||
|
* Replace `\n`, `\t`, `\e` and `\\` in user provided strings, just like c would do it (#215)
|
||||||
|
* APK (Alpine Package Keeper) support (@mxkrsv, #216)
|
||||||
|
|
||||||
|
Logos:
|
||||||
|
* Alma Linux (@jonathanspw, #214)
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* replace deprecated gethostbyname call with getaddrinfo (#217)
|
||||||
|
|
||||||
|
# 1.6.3
|
||||||
|
|
||||||
|
Fixes installing presets in their own directory (@ceamac, #212)
|
||||||
|
|
||||||
|
# 1.6.2
|
||||||
|
|
||||||
|
Releasing this, so void linux can package fastfetch.
|
||||||
|
|
||||||
|
Logos:
|
||||||
|
* Rosa linux (#206)
|
||||||
|
* KISS linux (@draumaz, #207)
|
||||||
|
* LangitKetujuh (@hervyqa, #208)
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* Using musl as libc does work now (#210)
|
||||||
|
* XBPS packages are once again printed (#209)
|
||||||
|
* configured target dirs are applied to install directories too
|
||||||
|
* empty XDG_* env vars don't cause a crash anymore
|
||||||
|
|
||||||
|
# 1.6.1
|
||||||
|
|
||||||
|
Fixes build on android (#205)
|
||||||
|
|
||||||
|
# 1.6.0
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Detect QT on more DEs than just KDE Plasma. The [Plasma] category was therefore renamed to [QT]
|
||||||
|
* Alacritty font detection
|
||||||
|
* Load `/etc/fastfetch/config.conf` before user config
|
||||||
|
* Disk: print one decimal point if size < 100GB
|
||||||
|
* `--title-fqdn` option, to print fully qualified domain name instead of host name in title
|
||||||
|
|
||||||
|
Logos:
|
||||||
|
* updated old NixOS logo
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* Correctly detect GTK on DEs that store their settings in dconf
|
||||||
|
* Correctly detect NixOS packages
|
||||||
|
* Mutter WM detected once again
|
||||||
|
* Show full NixOS version in OS output
|
||||||
|
* Don't segfault if an invalid structure is given
|
||||||
|
* WSL doesn't output GPU anymore, as the name is always meaningless
|
||||||
+30
-28
@@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.9.0) # CMAKE_INTERPROCEDURAL_OPTIMIZATION
|
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs
|
||||||
|
|
||||||
project(fastfetch
|
project(fastfetch
|
||||||
VERSION 1.5.3
|
VERSION 1.6.4
|
||||||
LANGUAGES C
|
LANGUAGES C
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -115,7 +115,8 @@ function(fastfetch_load_text FILENAME OUTVAR)
|
|||||||
endfunction(fastfetch_load_text)
|
endfunction(fastfetch_load_text)
|
||||||
|
|
||||||
fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE)
|
fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE)
|
||||||
fastfetch_load_text(src/data/config.txt DATATEXT_CONFIG)
|
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/modules.txt DATATEXT_MODULES)
|
fastfetch_load_text(src/data/modules.txt DATATEXT_MODULES)
|
||||||
fastfetch_load_text(src/data/help.txt DATATEXT_HELP)
|
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_color.txt DATATEXT_HELP_COLOR)
|
||||||
@@ -132,12 +133,11 @@ configure_file(src/fastfetch_config.h.in fastfetch_config.h)
|
|||||||
# libfastfetch target #
|
# libfastfetch target #
|
||||||
#######################
|
#######################
|
||||||
|
|
||||||
add_library(libfastfetch STATIC
|
add_library(libfastfetch OBJECT
|
||||||
src/util/FFstrbuf.c
|
src/util/FFstrbuf.c
|
||||||
src/util/FFlist.c
|
src/util/FFlist.c
|
||||||
src/util/FFvaluestore.c
|
src/util/FFvaluestore.c
|
||||||
src/common/init.c
|
src/common/init.c
|
||||||
src/common/threading.c
|
|
||||||
src/common/io.c
|
src/common/io.c
|
||||||
src/common/printing.c
|
src/common/printing.c
|
||||||
src/common/caching.c
|
src/common/caching.c
|
||||||
@@ -155,12 +155,14 @@ add_library(libfastfetch STATIC
|
|||||||
src/logo/image/im7.c
|
src/logo/image/im7.c
|
||||||
src/logo/image/im6.c
|
src/logo/image/im6.c
|
||||||
src/detection/os.c
|
src/detection/os.c
|
||||||
src/detection/plasma.c
|
src/detection/qt.c
|
||||||
src/detection/gtk.c
|
src/detection/gtk.c
|
||||||
src/detection/terminalShell.c
|
src/detection/terminalShell.c
|
||||||
src/detection/vulkan.c
|
src/detection/vulkan.c
|
||||||
src/detection/media.c
|
src/detection/media.c
|
||||||
src/detection/datetime.c
|
src/detection/datetime.c
|
||||||
|
src/detection/temps.c
|
||||||
|
src/detection/title.c
|
||||||
src/detection/displayserver/displayServer.c
|
src/detection/displayserver/displayServer.c
|
||||||
src/detection/displayserver/wayland.c
|
src/detection/displayserver/wayland.c
|
||||||
src/detection/displayserver/xcb.c
|
src/detection/displayserver/xcb.c
|
||||||
@@ -453,10 +455,6 @@ target_link_libraries(libfastfetch
|
|||||||
PRIVATE Threads::Threads
|
PRIVATE Threads::Threads
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(libfastfetch PROPERTIES
|
|
||||||
OUTPUT_NAME "fastfetch"
|
|
||||||
)
|
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Executable targets #
|
# Executable targets #
|
||||||
######################
|
######################
|
||||||
@@ -480,13 +478,6 @@ target_link_libraries(flashfetch
|
|||||||
###################
|
###################
|
||||||
|
|
||||||
if (BUILD_TESTS)
|
if (BUILD_TESTS)
|
||||||
add_executable(fastfetch-test-performance
|
|
||||||
tests/performance.c
|
|
||||||
)
|
|
||||||
target_link_libraries(fastfetch-test-performance
|
|
||||||
PRIVATE libfastfetch
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(fastfetch-test-strbuf
|
add_executable(fastfetch-test-strbuf
|
||||||
tests/strbuf.c
|
tests/strbuf.c
|
||||||
)
|
)
|
||||||
@@ -502,32 +493,42 @@ endif()
|
|||||||
# install target #
|
# install target #
|
||||||
##################
|
##################
|
||||||
|
|
||||||
|
#https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
|
||||||
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "${TARGET_DIR_USR}" CACHE PATH "..." FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT CMAKE_INSTALL_SYSCONFDIR)
|
||||||
|
set(CMAKE_INSTALL_SYSCONFDIR "${TARGET_DIR_ROOT}/etc")
|
||||||
|
endif()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
TARGETS fastfetch
|
TARGETS fastfetch flashfetch
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
TARGETS flashfetch
|
FILES "${CMAKE_SOURCE_DIR}/src/data/config_system.txt"
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}"
|
||||||
|
RENAME "config.conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES completions/bash
|
FILES "${CMAKE_SOURCE_DIR}/completions/bash"
|
||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions
|
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions"
|
||||||
RENAME ${CMAKE_PROJECT_NAME}
|
RENAME "${CMAKE_PROJECT_NAME}"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY presets
|
DIRECTORY "${CMAKE_SOURCE_DIR}/presets"
|
||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}
|
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES ./LICENSE
|
FILES "${CMAKE_SOURCE_DIR}/LICENSE"
|
||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}
|
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}"
|
||||||
)
|
)
|
||||||
|
|
||||||
##################
|
##################
|
||||||
@@ -535,6 +536,7 @@ install(
|
|||||||
##################
|
##################
|
||||||
|
|
||||||
set(CPACK_GENERATOR "DEB;RPM;TGZ;ZIP")
|
set(CPACK_GENERATOR "DEB;RPM;TGZ;ZIP")
|
||||||
|
set(CPACK_SET_DESTDIR ON)
|
||||||
|
|
||||||
set(CPACK_PACKAGE_CONTACT "Linus Dierheimer <Linus@Dierheimer.de>")
|
set(CPACK_PACKAGE_CONTACT "Linus Dierheimer <Linus@Dierheimer.de>")
|
||||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Neofetch clone written in C")
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Neofetch clone written in C")
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ Here i just add things that are easy to forget.
|
|||||||
- `libffprint`: contains the printing functions, logos, format etc
|
- `libffprint`: contains the printing functions, logos, format etc
|
||||||
- `fastfetch` and `flashfetch`: Executables, that initialize the config of libffprint. Fist one at runtime, second one at compile time
|
- `fastfetch` and `flashfetch`: Executables, that initialize the config of libffprint. Fist one at runtime, second one at compile time
|
||||||
- [ ] Better OS output for all possible combinations of /etc/os-release variables.
|
- [ ] Better OS output for all possible combinations of /etc/os-release variables.
|
||||||
- [ ] Expose temperatures to CPU format string
|
|
||||||
- [ ] Expose temperatures to GPU format string
|
|
||||||
- [ ] Find wayland compositor by looking at \${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}
|
- [ ] Find wayland compositor by looking at \${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}
|
||||||
- [ ] Make LocalIP module more configurable
|
- [ ] Make LocalIP module more configurable
|
||||||
- [ ] Automatic migrate old config files to newer versions
|
- [ ] Automatic migrate old config files to newer versions
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ Title, Separator, OS, Host, Kernel, Uptime, Processes, Packages, Shell, Resoluti
|
|||||||
|
|
||||||
##### Logos
|
##### Logos
|
||||||
```
|
```
|
||||||
Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, Debian, Devuan, Deepin, Endeavour, Fedora, Garuda, Gentoo, KDE Neon, Kubuntu, Linux, Manjaro, Mint, NixOS, OpenSUSE, OpenSUSE Tumbleweed, OpenSUSE LEAP, Pop!_OS, RebornOS, RedstarOS, Rocky, Ubuntu, Void, Zorin
|
AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, Debian, Devuan, Deepin, Endeavour, Fedora, Garuda, Gentoo, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, Manjaro, Mint, NixOS, OpenSUSE, OpenSUSE Tumbleweed, OpenSUSE LEAP, Pop!_OS, RebornOS, RedstarOS, Rocky, Rosa, Ubuntu, Void, Zorin
|
||||||
```
|
```
|
||||||
* Most of the logos have a small variant. Access it by appending _small to the logo name.
|
* Most of the logos have a small variant. Access it by appending _small to the logo name.
|
||||||
* Some logos have an old variant. Access it by appending _old to the logo name.
|
* Some logos have an old variant. Access it by appending _old to the logo name.
|
||||||
@@ -60,7 +60,7 @@ Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, Debian, Devuan, Deepin, En
|
|||||||
|
|
||||||
##### Package managers
|
##### Package managers
|
||||||
```
|
```
|
||||||
Pacman, dpkg, rpm, emerge, xbps, nix, Flatpak, Snap
|
Pacman, dpkg, rpm, emerge, xbps, nix, Flatpak, Snap, apk
|
||||||
```
|
```
|
||||||
|
|
||||||
##### WM themes
|
##### WM themes
|
||||||
@@ -75,7 +75,7 @@ KDE Plasma, Gnome, Cinnamon, Mate, XFCE4, LXQt
|
|||||||
|
|
||||||
##### Terminal fonts
|
##### Terminal fonts
|
||||||
```
|
```
|
||||||
konsole, gnome-terminal-server, tilix, xfce4-terminal, lxterminal, TTY
|
konsole, gnome-terminal-server, tilix, xfce4-terminal, alacritty, lxterminal, TTY
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
@@ -98,10 +98,8 @@ If pkg-config fails to find the headers for a library listed in [dependencies](#
|
|||||||
|
|
||||||
### Manual
|
### Manual
|
||||||
|
|
||||||
Build: Follow the [build instructions](#building).
|
* DEB / RPM package: `cmake --build . --target package`
|
||||||
|
* Install directly: `cmake --install . --prefix /usr/local`
|
||||||
* Create DEB / RPM: Run `cmake --build . --target package`.
|
|
||||||
* Install directly: Run `sudo cmake --install . --prefix /usr/local`
|
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
|
|||||||
+39
-1
@@ -108,7 +108,8 @@ __fastfetch_completion()
|
|||||||
"--list-presets"
|
"--list-presets"
|
||||||
"--list-features"
|
"--list-features"
|
||||||
"--print-logos"
|
"--print-logos"
|
||||||
"--print-config"
|
"--print-config-system"
|
||||||
|
"--print-config-user"
|
||||||
"--print-structure"
|
"--print-structure"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -132,6 +133,7 @@ __fastfetch_completion()
|
|||||||
"--localip-show-loop"
|
"--localip-show-loop"
|
||||||
"--escape-bedrock"
|
"--escape-bedrock"
|
||||||
"--pipe"
|
"--pipe"
|
||||||
|
"--title-fqdn"
|
||||||
)
|
)
|
||||||
|
|
||||||
local FF_OPTIONS_STRING=(
|
local FF_OPTIONS_STRING=(
|
||||||
@@ -154,6 +156,7 @@ __fastfetch_completion()
|
|||||||
"-s"
|
"-s"
|
||||||
"--structure"
|
"--structure"
|
||||||
"--set"
|
"--set"
|
||||||
|
"--set-keyless"
|
||||||
"--gl"
|
"--gl"
|
||||||
"--os-format"
|
"--os-format"
|
||||||
"--os-key"
|
"--os-key"
|
||||||
@@ -225,6 +228,41 @@ __fastfetch_completion()
|
|||||||
"--opengl-format"
|
"--opengl-format"
|
||||||
"--opencl-key"
|
"--opencl-key"
|
||||||
"--opencl-format"
|
"--opencl-format"
|
||||||
|
"--os-error"
|
||||||
|
"--host-error"
|
||||||
|
"--kernel-error"
|
||||||
|
"--uptime-error"
|
||||||
|
"--processes-error"
|
||||||
|
"--packages-error"
|
||||||
|
"--shell-error"
|
||||||
|
"--resolution-error"
|
||||||
|
"--de-error"
|
||||||
|
"--wm-error"
|
||||||
|
"--wm-theme-error"
|
||||||
|
"--theme-error"
|
||||||
|
"--icons-error"
|
||||||
|
"--font-error"
|
||||||
|
"--cursor-error"
|
||||||
|
"--terminal-error"
|
||||||
|
"--terminal-font-error"
|
||||||
|
"--cpu-error"
|
||||||
|
"--cpu-usage-error"
|
||||||
|
"--gpu-error"
|
||||||
|
"--memory-error"
|
||||||
|
"--disk-error"
|
||||||
|
"--battery-error"
|
||||||
|
"--locale-error"
|
||||||
|
"--disk-error"
|
||||||
|
"--local-ip-error"
|
||||||
|
"--public-ip-error"
|
||||||
|
"--player-error"
|
||||||
|
"--song-error"
|
||||||
|
"--datetime-error"
|
||||||
|
"--date-error"
|
||||||
|
"--time-error"
|
||||||
|
"--vulkan-error"
|
||||||
|
"--opengl-error"
|
||||||
|
"--opencl-error"
|
||||||
)
|
)
|
||||||
|
|
||||||
local FF_OPTIONS_PATH=(
|
local FF_OPTIONS_PATH=(
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
--load-config all
|
--load-config all
|
||||||
|
|
||||||
--os-format "System: {}; Name: {}; Pretty name: {}; ID: {}; ID like: {}; Variant: {}; Variant ID: {}; Version: {}; Version ID: {}; Version codename: {}; Build ID: {}; Architecture: {}"
|
--os-format "System: {}; Name: {}; Pretty name: {}; ID: {}; ID like: {}; Variant: {}; Variant ID: {}; Version: {}; Version ID: {}; Version codename: {}; Build ID: {}; Architecture: {}"
|
||||||
--host-format "Family: {}; Name: {}; Version: {}"
|
--host-format "Family: "product_family: {}; product_name: {}; product_version: {}; product_sku: {}; bios_date: {}; bios_release: {}; bios_vendor: {}; bios_version: {}; board_name: {}; board_vendor: {}; board_version: {}; chassis_type: {}; chassis_vendor: {}; chassis_version: {}; sys_vendor: {}"
|
||||||
--kernel-format "Sysname: {}; Release: {}; Version: {}"
|
--kernel-format "Sysname: {}; Release: {}; Version: {}"
|
||||||
--uptime-format "Days: {}; Hours: {}; Minutes: {}; Seconds: {}"
|
--uptime-format "Days: {}; Hours: {}; Minutes: {}; Seconds: {}"
|
||||||
--processes-format "Count: {}"
|
--processes-format "Count: {}"
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
--cursor-format "Theme: {}; Size: {}"
|
--cursor-format "Theme: {}; Size: {}"
|
||||||
--terminal-format "Process: {}; Path: {}; Exe: {}"
|
--terminal-format "Process: {}; Path: {}; Exe: {}"
|
||||||
--terminal-font-format "Raw: {}; Name: {}; Size: {}; Styles: {}; Pretty: {}"
|
--terminal-font-format "Raw: {}; Name: {}; Size: {}; Styles: {}; Pretty: {}"
|
||||||
--cpu-format "Name: {}; Pretty: {}; Vendor: {}; Logical online: {}; Logical configured: {}; Physical: {}; Cores: {}; bios: {}; scaling max: {}; scaling min: {}; info max: {}; info min: {}; cpuinfo: {}; frequency: {}"
|
--cpu-format "Name: {}; Pretty: {}; Vendor: {}; Logical online: {}; Logical configured: {}; Physical: {}; Cores: {}; temperature: {}; bios: {}; scaling max: {}; scaling min: {}; info max: {}; info min: {}; cpuinfo: {}; frequency: {}"
|
||||||
--cpu-usage-format "Percentage: {}"
|
--cpu-usage-format "Percentage: {}"
|
||||||
--gpu-format "Vendor: {}; Vendor pretty: {}; Name: {}; Name pretty: {}; Driver: {}"
|
--gpu-format "Vendor: {}; Vendor pretty: {}; Name: {}; Name pretty: {}; Driver: {}; Temperature: {}"
|
||||||
--memory-format "Used: {}; Total: {}; Percentage: {}"
|
--memory-format "Used: {}; Total: {}; Percentage: {}"
|
||||||
--disk-format "Used: {}; Total: {}; Files: {}; Percentage: {}"
|
--disk-format "Used: {}; Total: {}; Files: {}; Percentage: {}"
|
||||||
--battery-format "Manufactor: {}; Model: {}; Technology: {}; Capacaty: {}; Status: {}"
|
--battery-format "Manufactor: {}; Model: {}; Technology: {}; Capacaty: {}; Status: {}"
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
#!/bin/env sh
|
#!/bin/env sh
|
||||||
|
|
||||||
|
# make the script exit if any of the commands fail,
|
||||||
|
# making fastfetch not run if the build failed.
|
||||||
|
set -e
|
||||||
|
|
||||||
mkdir -p build/
|
mkdir -p build/
|
||||||
cd build/
|
cd build/
|
||||||
cmake ..
|
cmake ..
|
||||||
|
|||||||
+46
-17
@@ -1,9 +1,16 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/caching.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define FF_CACHE_VALUE_EXTENSION "ffcv"
|
#define FF_CACHE_VALUE_EXTENSION "ffcv"
|
||||||
#define FF_CACHE_SPLIT_EXTENSION "ffcs"
|
#define FF_CACHE_SPLIT_EXTENSION "ffcs"
|
||||||
|
|
||||||
static void getCacheFilePath(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
|
#define FF_CACHE_EXTENSION_DATA "ffcd"
|
||||||
|
|
||||||
|
static void getCacheFilePath(const FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
|
||||||
{
|
{
|
||||||
ffStrbufAppend(buffer, &instance->state.cacheDir);
|
ffStrbufAppend(buffer, &instance->state.cacheDir);
|
||||||
ffStrbufAppendS(buffer, moduleName);
|
ffStrbufAppendS(buffer, moduleName);
|
||||||
@@ -20,7 +27,7 @@ static void readCacheFile(FFinstance* instance, const char* moduleName, const ch
|
|||||||
FFstrbuf path;
|
FFstrbuf path;
|
||||||
ffStrbufInitA(&path, 64);
|
ffStrbufInitA(&path, 64);
|
||||||
getCacheFilePath(instance, moduleName, extension, &path);
|
getCacheFilePath(instance, moduleName, extension, &path);
|
||||||
ffAppendFileContent(path.chars, buffer);
|
ffAppendFileBuffer(path.chars, buffer);
|
||||||
ffStrbufDestroy(&path);
|
ffStrbufDestroy(&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +36,7 @@ static void writeCacheFile(FFinstance* instance, const char* moduleName, const c
|
|||||||
FFstrbuf path;
|
FFstrbuf path;
|
||||||
ffStrbufInitA(&path, 64);
|
ffStrbufInitA(&path, 64);
|
||||||
getCacheFilePath(instance, moduleName, extension, &path);
|
getCacheFilePath(instance, moduleName, extension, &path);
|
||||||
ffWriteFileContent(path.chars, content);
|
ffWriteFileBuffer(path.chars, content);
|
||||||
ffStrbufDestroy(&path);
|
ffStrbufDestroy(&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +84,7 @@ void ffCacheClose(FFcache* cache)
|
|||||||
fclose(cache->split);
|
fclose(cache->split);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool printCachedValue(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat)
|
static bool printCachedValue(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs)
|
||||||
{
|
{
|
||||||
FFstrbuf content;
|
FFstrbuf content;
|
||||||
ffStrbufInitA(&content, 512);
|
ffStrbufInitA(&content, 512);
|
||||||
@@ -95,7 +102,7 @@ static bool printCachedValue(FFinstance* instance, const char* moduleName, const
|
|||||||
{
|
{
|
||||||
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
|
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
|
||||||
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
|
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
|
||||||
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
|
ffPrintLogoAndKey(instance, moduleName, moduleIndex, &moduleArgs->key);
|
||||||
puts(content.chars + startIndex);
|
puts(content.chars + startIndex);
|
||||||
startIndex = nullByteIndex + 1;
|
startIndex = nullByteIndex + 1;
|
||||||
++moduleCounter;
|
++moduleCounter;
|
||||||
@@ -106,7 +113,7 @@ static bool printCachedValue(FFinstance* instance, const char* moduleName, const
|
|||||||
return moduleCounter > 1;
|
return moduleCounter > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool printCachedFormat(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numArgs)
|
static bool printCachedFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs)
|
||||||
{
|
{
|
||||||
FFstrbuf content;
|
FFstrbuf content;
|
||||||
ffStrbufInitA(&content, 512);
|
ffStrbufInitA(&content, 512);
|
||||||
@@ -134,7 +141,7 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
|
|||||||
if(argumentCounter == numArgs)
|
if(argumentCounter == numArgs)
|
||||||
{
|
{
|
||||||
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
|
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
|
||||||
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, formatString, NULL, numArgs, arguments);
|
ffPrintFormat(instance, moduleName, moduleIndex, moduleArgs, numArgs, arguments);
|
||||||
++moduleCounter;
|
++moduleCounter;
|
||||||
argumentCounter = 0;
|
argumentCounter = 0;
|
||||||
}
|
}
|
||||||
@@ -148,27 +155,27 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
|
|||||||
return moduleCounter > 1;
|
return moduleCounter > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numArgs)
|
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs)
|
||||||
{
|
{
|
||||||
if(instance->config.recache)
|
if(instance->config.recache)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(formatString == NULL || formatString->length == 0)
|
if(moduleArgs->outputFormat.length == 0)
|
||||||
return printCachedValue(instance, moduleName, customKeyFormat);
|
return printCachedValue(instance, moduleName, moduleArgs);
|
||||||
else
|
else
|
||||||
return printCachedFormat(instance, moduleName, customKeyFormat, formatString, numArgs);
|
return printCachedFormat(instance, moduleName, moduleArgs, numArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, FFcache* cache, const FFstrbuf* value, const FFstrbuf* formatString, uint32_t numArgs, const FFformatarg* arguments)
|
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFcache* cache, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments)
|
||||||
{
|
{
|
||||||
if(formatString == NULL || formatString->length == 0)
|
if(moduleArgs->outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
|
ffPrintLogoAndKey(instance, moduleName, moduleIndex, &moduleArgs->key);
|
||||||
ffStrbufPutTo(value, stdout);
|
ffStrbufPutTo(value, stdout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, formatString, NULL, numArgs, arguments);
|
ffPrintFormat(instance, moduleName, moduleIndex, moduleArgs, numArgs, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cache->value != NULL)
|
if(cache->value != NULL)
|
||||||
@@ -191,10 +198,32 @@ void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* value, const FFstrbuf* formatString, uint32_t numArgs, const FFformatarg* arguments)
|
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments)
|
||||||
{
|
{
|
||||||
FFcache cache;
|
FFcache cache;
|
||||||
ffCacheOpenWrite(instance, moduleName, &cache);
|
ffCacheOpenWrite(instance, moduleName, &cache);
|
||||||
ffPrintAndAppendToCache(instance, moduleName, 0, customKeyFormat, &cache, value, formatString, numArgs, arguments);
|
ffPrintAndAppendToCache(instance, moduleName, 0, moduleArgs, &cache, value, numArgs, arguments);
|
||||||
ffCacheClose(&cache);
|
ffCacheClose(&cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ffCachingWriteData(const FFinstance* instance, const char* moduleName, size_t dataSize, const void* data)
|
||||||
|
{
|
||||||
|
FFstrbuf path;
|
||||||
|
ffStrbufInitA(&path, 128);
|
||||||
|
getCacheFilePath(instance, moduleName, FF_CACHE_EXTENSION_DATA, &path);
|
||||||
|
ffWriteFileData(path.chars, dataSize, data);
|
||||||
|
ffStrbufDestroy(&path);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ffCachingReadData(const FFinstance* instance, const char* moduleName, size_t dataSize, void* data)
|
||||||
|
{
|
||||||
|
if(instance->config.recache)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
FFstrbuf path;
|
||||||
|
ffStrbufInitA(&path, 128);
|
||||||
|
getCacheFilePath(instance, moduleName, FF_CACHE_EXTENSION_DATA, &path);
|
||||||
|
ssize_t result = ffReadFileData(path.chars, dataSize, data);
|
||||||
|
ffStrbufDestroy(&path);
|
||||||
|
return result > 0 && (size_t) result == dataSize;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_caching
|
||||||
|
#define FF_INCLUDED_common_caching
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
#include "common/format.h"
|
||||||
|
|
||||||
|
typedef struct FFcache
|
||||||
|
{
|
||||||
|
FILE* value;
|
||||||
|
FILE* split;
|
||||||
|
} FFcache;
|
||||||
|
|
||||||
|
void ffCacheValidate(FFinstance* instance);
|
||||||
|
|
||||||
|
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache);
|
||||||
|
void ffCacheClose(FFcache* cache);
|
||||||
|
|
||||||
|
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs);
|
||||||
|
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFcache* cache, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
|
||||||
|
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
|
||||||
|
|
||||||
|
void ffCachingWriteData(const FFinstance* instance, const char* moduleName, size_t dataSize, const void* data);
|
||||||
|
bool ffCachingReadData(const FFinstance* instance, const char* moduleName, size_t dataSize, void* data);
|
||||||
|
|
||||||
|
#endif
|
||||||
+10
-1
@@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/font.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -188,13 +189,21 @@ void ffFontInitPango(FFfont* font, const char* data)
|
|||||||
fontInitPretty(font);
|
fontInitPretty(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffFontInitCopy(FFfont* font, const char* name)
|
void ffFontInitValues(FFfont* font, const char* name, const char* size)
|
||||||
{
|
{
|
||||||
fontInit(font);
|
fontInit(font);
|
||||||
|
|
||||||
ffStrbufAppendS(&font->name, name);
|
ffStrbufAppendS(&font->name, name);
|
||||||
|
ffStrbufAppendS(&font->size, size);
|
||||||
|
|
||||||
fontInitPretty(font);
|
fontInitPretty(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ffFontInitCopy(FFfont* font, const char* name)
|
||||||
|
{
|
||||||
|
ffFontInitValues(font, name, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void ffFontDestroy(FFfont* font)
|
void ffFontDestroy(FFfont* font)
|
||||||
{
|
{
|
||||||
ffStrbufDestroy(&font->pretty);
|
ffStrbufDestroy(&font->pretty);
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_font
|
||||||
|
#define FF_INCLUDED_common_font
|
||||||
|
|
||||||
|
#include "util/FFstrbuf.h"
|
||||||
|
#include "util/FFlist.h"
|
||||||
|
|
||||||
|
typedef struct FFfont
|
||||||
|
{
|
||||||
|
FFstrbuf pretty;
|
||||||
|
FFstrbuf name;
|
||||||
|
FFstrbuf size;
|
||||||
|
FFlist styles;
|
||||||
|
} FFfont;
|
||||||
|
|
||||||
|
void ffFontInitQt(FFfont* font, const char* data);
|
||||||
|
void ffFontInitPango(FFfont* font, const char* data);
|
||||||
|
void ffFontInitCopy(FFfont* font, const char* name);
|
||||||
|
void ffFontInitValues(FFfont* font, const char* name, const char* size);
|
||||||
|
void ffFontDestroy(FFfont* font);
|
||||||
|
|
||||||
|
#endif
|
||||||
+3
-33
@@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/format.h"
|
||||||
|
|
||||||
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
|
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
|
||||||
{
|
{
|
||||||
@@ -32,15 +33,6 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool placeholderValueIsForError(const FFstrbuf* placeholderValue)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
ffStrbufIgnCaseCompS(placeholderValue, "e") == 0 ||
|
|
||||||
ffStrbufIgnCaseCompS(placeholderValue, "error") == 0 ||
|
|
||||||
ffStrbufIgnCaseCompS(placeholderValue, "0") == 0
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t getArgumentIndex(const FFstrbuf* placeholderValue)
|
static inline uint32_t getArgumentIndex(const FFstrbuf* placeholderValue)
|
||||||
{
|
{
|
||||||
uint32_t result = UINT32_MAX;
|
uint32_t result = UINT32_MAX;
|
||||||
@@ -72,6 +64,7 @@ static inline bool formatArgSet(const FFformatarg* arg)
|
|||||||
{
|
{
|
||||||
return arg->value != NULL && (
|
return arg->value != NULL && (
|
||||||
(arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value > 0) ||
|
(arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value > 0) ||
|
||||||
|
(arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value == *(double*)arg->value) || //NaN
|
||||||
(arg->type == FF_FORMAT_ARG_TYPE_INT && *(int*)arg->value > 0) ||
|
(arg->type == FF_FORMAT_ARG_TYPE_INT && *(int*)arg->value > 0) ||
|
||||||
(arg->type == FF_FORMAT_ARG_TYPE_STRBUF && ((FFstrbuf*)arg->value)->length > 0) ||
|
(arg->type == FF_FORMAT_ARG_TYPE_STRBUF && ((FFstrbuf*)arg->value)->length > 0) ||
|
||||||
(arg->type == FF_FORMAT_ARG_TYPE_STRING && *(const char*)arg->value != '\0') ||
|
(arg->type == FF_FORMAT_ARG_TYPE_STRING && *(const char*)arg->value != '\0') ||
|
||||||
@@ -81,7 +74,7 @@ static inline bool formatArgSet(const FFformatarg* arg)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments)
|
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments)
|
||||||
{
|
{
|
||||||
uint32_t argCounter = 0;
|
uint32_t argCounter = 0;
|
||||||
|
|
||||||
@@ -128,13 +121,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
|
|||||||
while(i < formatstr->length && formatstr->chars[i] != '}')
|
while(i < formatstr->length && formatstr->chars[i] != '}')
|
||||||
ffStrbufAppendC(&placeholderValue, formatstr->chars[i++]);
|
ffStrbufAppendC(&placeholderValue, formatstr->chars[i++]);
|
||||||
|
|
||||||
// test for error, if so print it
|
|
||||||
if(placeholderValueIsForError(&placeholderValue)) {
|
|
||||||
ffStrbufAppend(buffer, error);
|
|
||||||
ffStrbufDestroy(&placeholderValue);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// test if for stop, if so break the loop
|
// test if for stop, if so break the loop
|
||||||
if(placeholderValue.length == 1 && placeholderValue.chars[0] == '-')
|
if(placeholderValue.length == 1 && placeholderValue.chars[0] == '-')
|
||||||
{
|
{
|
||||||
@@ -186,14 +172,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
|
|||||||
{
|
{
|
||||||
ffStrbufSubstrAfter(&placeholderValue, 0);
|
ffStrbufSubstrAfter(&placeholderValue, 0);
|
||||||
|
|
||||||
// continue if an error is set
|
|
||||||
if(placeholderValueIsForError(&placeholderValue) && error != NULL && error->length > 0)
|
|
||||||
{
|
|
||||||
++numOpenIfs;
|
|
||||||
ffStrbufDestroy(&placeholderValue);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t index = getArgumentIndex(&placeholderValue);
|
uint32_t index = getArgumentIndex(&placeholderValue);
|
||||||
|
|
||||||
// testing for an invalid index
|
// testing for an invalid index
|
||||||
@@ -223,14 +201,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
|
|||||||
{
|
{
|
||||||
ffStrbufSubstrAfter(&placeholderValue, 0);
|
ffStrbufSubstrAfter(&placeholderValue, 0);
|
||||||
|
|
||||||
//continue if an error os not set
|
|
||||||
if(placeholderValueIsForError(&placeholderValue) && (error == NULL || error->length == 0))
|
|
||||||
{
|
|
||||||
++numOpenNotIfs;
|
|
||||||
ffStrbufDestroy(&placeholderValue);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t index = getArgumentIndex(&placeholderValue);
|
uint32_t index = getArgumentIndex(&placeholderValue);
|
||||||
|
|
||||||
// testing for an invalid index
|
// testing for an invalid index
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_format
|
||||||
|
#define FF_INCLUDED_common_format
|
||||||
|
|
||||||
|
typedef enum FFformatargtype
|
||||||
|
{
|
||||||
|
FF_FORMAT_ARG_TYPE_NULL = 0,
|
||||||
|
FF_FORMAT_ARG_TYPE_UINT,
|
||||||
|
FF_FORMAT_ARG_TYPE_UINT16,
|
||||||
|
FF_FORMAT_ARG_TYPE_UINT8,
|
||||||
|
FF_FORMAT_ARG_TYPE_INT,
|
||||||
|
FF_FORMAT_ARG_TYPE_STRING,
|
||||||
|
FF_FORMAT_ARG_TYPE_STRBUF,
|
||||||
|
FF_FORMAT_ARG_TYPE_DOUBLE,
|
||||||
|
FF_FORMAT_ARG_TYPE_LIST
|
||||||
|
} FFformatargtype;
|
||||||
|
|
||||||
|
typedef struct FFformatarg
|
||||||
|
{
|
||||||
|
FFformatargtype type;
|
||||||
|
const void* value;
|
||||||
|
} FFformatarg;
|
||||||
|
|
||||||
|
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
|
||||||
|
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
|
||||||
|
|
||||||
|
#endif
|
||||||
+151
-89
@@ -1,8 +1,15 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/caching.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
#include "detection/qt.h"
|
||||||
|
#include "detection/gtk.h"
|
||||||
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
static bool strbufEqualsAdapter(const void* first, const void* second)
|
static bool strbufEqualsAdapter(const void* first, const void* second)
|
||||||
{
|
{
|
||||||
@@ -14,18 +21,14 @@ static void initConfigDirs(FFstate* state)
|
|||||||
ffListInit(&state->configDirs, sizeof(FFstrbuf));
|
ffListInit(&state->configDirs, sizeof(FFstrbuf));
|
||||||
|
|
||||||
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
|
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
|
||||||
if(xdgConfigHome != NULL)
|
if(ffStrSet(xdgConfigHome))
|
||||||
{
|
{
|
||||||
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
|
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
|
||||||
ffStrbufInitA(buffer, 64);
|
ffStrbufInitA(buffer, 64);
|
||||||
ffStrbufAppendS(buffer, xdgConfigHome);
|
ffStrbufAppendS(buffer, xdgConfigHome);
|
||||||
ffStrbufTrimRight(buffer, '/');
|
ffStrbufEnsureEndsWithC(buffer, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
FFstrbuf xdgConfigDirs;
|
|
||||||
ffStrbufInitA(&xdgConfigDirs, 64);
|
|
||||||
ffStrbufAppendS(&xdgConfigDirs, getenv("XDG_CONFIG_DIRS"));
|
|
||||||
|
|
||||||
#define FF_ENSURE_ONLY_ONCE_IN_LIST(element) \
|
#define FF_ENSURE_ONLY_ONCE_IN_LIST(element) \
|
||||||
if(ffListFirstIndexComp(&state->configDirs, element, strbufEqualsAdapter) < state->configDirs.length - 1) \
|
if(ffListFirstIndexComp(&state->configDirs, element, strbufEqualsAdapter) < state->configDirs.length - 1) \
|
||||||
--state->configDirs.length;
|
--state->configDirs.length;
|
||||||
@@ -33,24 +36,35 @@ static void initConfigDirs(FFstate* state)
|
|||||||
FFstrbuf* userConfigHome = ffListAdd(&state->configDirs);
|
FFstrbuf* userConfigHome = ffListAdd(&state->configDirs);
|
||||||
ffStrbufInitA(userConfigHome, 64);
|
ffStrbufInitA(userConfigHome, 64);
|
||||||
ffStrbufAppendS(userConfigHome, state->passwd->pw_dir);
|
ffStrbufAppendS(userConfigHome, state->passwd->pw_dir);
|
||||||
ffStrbufAppendS(userConfigHome, "/.config");
|
ffStrbufAppendS(userConfigHome, "/.config/");
|
||||||
FF_ENSURE_ONLY_ONCE_IN_LIST(userConfigHome)
|
FF_ENSURE_ONLY_ONCE_IN_LIST(userConfigHome)
|
||||||
|
|
||||||
FFstrbuf* userHome = ffListAdd(&state->configDirs);
|
FFstrbuf* userHome = ffListAdd(&state->configDirs);
|
||||||
ffStrbufInitA(userHome, 64);
|
ffStrbufInitA(userHome, 64);
|
||||||
ffStrbufAppendS(userHome, state->passwd->pw_dir);
|
ffStrbufAppendS(userHome, state->passwd->pw_dir);
|
||||||
|
ffStrbufEnsureEndsWithC(userHome, '/');
|
||||||
FF_ENSURE_ONLY_ONCE_IN_LIST(userHome)
|
FF_ENSURE_ONLY_ONCE_IN_LIST(userHome)
|
||||||
|
|
||||||
|
FFstrbuf xdgConfigDirs;
|
||||||
|
ffStrbufInitA(&xdgConfigDirs, 64);
|
||||||
|
ffStrbufAppendS(&xdgConfigDirs, getenv("XDG_CONFIG_DIRS"));
|
||||||
|
|
||||||
uint32_t startIndex = 0;
|
uint32_t startIndex = 0;
|
||||||
while (startIndex < xdgConfigDirs.length)
|
while (startIndex < xdgConfigDirs.length)
|
||||||
{
|
{
|
||||||
uint32_t colonIndex = ffStrbufNextIndexC(&xdgConfigDirs, startIndex, ':');
|
uint32_t colonIndex = ffStrbufNextIndexC(&xdgConfigDirs, startIndex, ':');
|
||||||
xdgConfigDirs.chars[colonIndex] = '\0';
|
xdgConfigDirs.chars[colonIndex] = '\0';
|
||||||
|
|
||||||
|
if(!ffStrSet(xdgConfigDirs.chars + startIndex))
|
||||||
|
{
|
||||||
|
startIndex = colonIndex + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
|
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
|
||||||
ffStrbufInitA(buffer, 64);
|
ffStrbufInitA(buffer, 64);
|
||||||
ffStrbufAppendS(buffer, xdgConfigDirs.chars + startIndex);
|
ffStrbufAppendS(buffer, xdgConfigDirs.chars + startIndex);
|
||||||
ffStrbufTrimRight(buffer, '/');
|
ffStrbufEnsureEndsWithC(buffer, '/');
|
||||||
FF_ENSURE_ONLY_ONCE_IN_LIST(buffer);
|
FF_ENSURE_ONLY_ONCE_IN_LIST(buffer);
|
||||||
|
|
||||||
startIndex = colonIndex + 1;
|
startIndex = colonIndex + 1;
|
||||||
@@ -58,12 +72,12 @@ static void initConfigDirs(FFstate* state)
|
|||||||
|
|
||||||
FFstrbuf* systemConfigHome = ffListAdd(&state->configDirs);
|
FFstrbuf* systemConfigHome = ffListAdd(&state->configDirs);
|
||||||
ffStrbufInitA(systemConfigHome, 64);
|
ffStrbufInitA(systemConfigHome, 64);
|
||||||
ffStrbufAppendS(systemConfigHome, FASTFETCH_TARGET_DIR_ROOT"/etc/xdg");
|
ffStrbufAppendS(systemConfigHome, FASTFETCH_TARGET_DIR_ROOT"/etc/xdg/");
|
||||||
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfigHome)
|
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfigHome)
|
||||||
|
|
||||||
FFstrbuf* systemConfig = ffListAdd(&state->configDirs);
|
FFstrbuf* systemConfig = ffListAdd(&state->configDirs);
|
||||||
ffStrbufInitA(systemConfig, 64);
|
ffStrbufInitA(systemConfig, 64);
|
||||||
ffStrbufAppendS(systemConfig, FASTFETCH_TARGET_DIR_ROOT"/etc");
|
ffStrbufAppendS(systemConfig, FASTFETCH_TARGET_DIR_ROOT"/etc/");
|
||||||
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfig)
|
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfig)
|
||||||
|
|
||||||
#undef FF_ENSURE_ONLY_ONCE_IN_LIST
|
#undef FF_ENSURE_ONLY_ONCE_IN_LIST
|
||||||
@@ -80,8 +94,8 @@ static void initCacheDir(FFstate* state)
|
|||||||
ffStrbufAppendS(&state->cacheDir, state->passwd->pw_dir);
|
ffStrbufAppendS(&state->cacheDir, state->passwd->pw_dir);
|
||||||
ffStrbufAppendS(&state->cacheDir, "/.cache/");
|
ffStrbufAppendS(&state->cacheDir, "/.cache/");
|
||||||
}
|
}
|
||||||
else if(!ffStrbufEndsWithC(&state->cacheDir, '/'))
|
else
|
||||||
ffStrbufAppendC(&state->cacheDir, '/');
|
ffStrbufEnsureEndsWithC(&state->cacheDir, '/');
|
||||||
|
|
||||||
mkdir(state->cacheDir.chars, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH); //I hope everybody has a cache folder, but who knows
|
mkdir(state->cacheDir.chars, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH); //I hope everybody has a cache folder, but who knows
|
||||||
|
|
||||||
@@ -102,17 +116,24 @@ static void initState(FFstate* state)
|
|||||||
initCacheDir(state);
|
initCacheDir(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void initModuleArg(FFModuleArgs* args)
|
||||||
|
{
|
||||||
|
ffStrbufInitA(&args->key, 0);
|
||||||
|
ffStrbufInitA(&args->outputFormat, 0);
|
||||||
|
ffStrbufInitA(&args->errorFormat, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void defaultConfig(FFinstance* instance)
|
static void defaultConfig(FFinstance* instance)
|
||||||
{
|
{
|
||||||
ffStrbufInit(&instance->config.logoSource);
|
ffStrbufInit(&instance->config.logo.source);
|
||||||
instance->config.logoType = FF_LOGO_TYPE_AUTO;
|
instance->config.logo.type = FF_LOGO_TYPE_AUTO;
|
||||||
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
|
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
|
||||||
ffStrbufInit(&instance->config.logoColors[i]);
|
ffStrbufInit(&instance->config.logo.colors[i]);
|
||||||
instance->config.logoWidth = 0;
|
instance->config.logo.width = 0;
|
||||||
instance->config.logoHeight = 0; //preserve aspect ratio
|
instance->config.logo.height = 0; //preserve aspect ratio
|
||||||
instance->config.logoPaddingLeft = 0;
|
instance->config.logo.paddingLeft = 0;
|
||||||
instance->config.logoPaddingRight = 4;
|
instance->config.logo.paddingRight = 4;
|
||||||
instance->config.logoPrintRemaining = true;
|
instance->config.logo.printRemaining = true;
|
||||||
|
|
||||||
ffStrbufInit(&instance->config.mainColor);
|
ffStrbufInit(&instance->config.mainColor);
|
||||||
ffStrbufInit(&instance->config.separator);
|
ffStrbufInit(&instance->config.separator);
|
||||||
@@ -127,75 +148,42 @@ static void defaultConfig(FFinstance* instance)
|
|||||||
instance->config.escapeBedrock = true;
|
instance->config.escapeBedrock = true;
|
||||||
instance->config.glType = FF_GL_TYPE_AUTO;
|
instance->config.glType = FF_GL_TYPE_AUTO;
|
||||||
instance->config.pipe = false;
|
instance->config.pipe = false;
|
||||||
|
instance->config.multithreading = true;
|
||||||
|
|
||||||
ffStrbufInitA(&instance->config.osFormat, 0);
|
initModuleArg(&instance->config.os);
|
||||||
ffStrbufInitA(&instance->config.osKey, 0);
|
initModuleArg(&instance->config.host);
|
||||||
ffStrbufInitA(&instance->config.hostFormat, 0);
|
initModuleArg(&instance->config.kernel);
|
||||||
ffStrbufInitA(&instance->config.hostKey, 0);
|
initModuleArg(&instance->config.uptime);
|
||||||
ffStrbufInitA(&instance->config.kernelFormat, 0);
|
initModuleArg(&instance->config.processes);
|
||||||
ffStrbufInitA(&instance->config.kernelKey, 0);
|
initModuleArg(&instance->config.packages);
|
||||||
ffStrbufInitA(&instance->config.uptimeFormat, 0);
|
initModuleArg(&instance->config.shell);
|
||||||
ffStrbufInitA(&instance->config.uptimeKey, 0);
|
initModuleArg(&instance->config.resolution);
|
||||||
ffStrbufInitA(&instance->config.processesFormat, 0);
|
initModuleArg(&instance->config.de);
|
||||||
ffStrbufInitA(&instance->config.processesKey, 0);
|
initModuleArg(&instance->config.wm);
|
||||||
ffStrbufInitA(&instance->config.packagesFormat, 0);
|
initModuleArg(&instance->config.wmTheme);
|
||||||
ffStrbufInitA(&instance->config.packagesKey, 0);
|
initModuleArg(&instance->config.theme);
|
||||||
ffStrbufInitA(&instance->config.shellFormat, 0);
|
initModuleArg(&instance->config.icons);
|
||||||
ffStrbufInitA(&instance->config.shellKey, 0);
|
initModuleArg(&instance->config.font);
|
||||||
ffStrbufInitA(&instance->config.resolutionFormat, 0);
|
initModuleArg(&instance->config.cursor);
|
||||||
ffStrbufInitA(&instance->config.resolutionKey, 0);
|
initModuleArg(&instance->config.terminal);
|
||||||
ffStrbufInitA(&instance->config.deFormat, 0);
|
initModuleArg(&instance->config.terminalFont);
|
||||||
ffStrbufInitA(&instance->config.deKey, 0);
|
initModuleArg(&instance->config.cpu);
|
||||||
ffStrbufInitA(&instance->config.wmFormat, 0);
|
initModuleArg(&instance->config.cpuUsage);
|
||||||
ffStrbufInitA(&instance->config.wmKey, 0);
|
initModuleArg(&instance->config.gpu);
|
||||||
ffStrbufInitA(&instance->config.wmThemeFormat, 0);
|
initModuleArg(&instance->config.memory);
|
||||||
ffStrbufInitA(&instance->config.wmThemeKey, 0);
|
initModuleArg(&instance->config.disk);
|
||||||
ffStrbufInitA(&instance->config.themeFormat, 0);
|
initModuleArg(&instance->config.battery);
|
||||||
ffStrbufInitA(&instance->config.themeKey, 0);
|
initModuleArg(&instance->config.locale);
|
||||||
ffStrbufInitA(&instance->config.iconsFormat, 0);
|
initModuleArg(&instance->config.localIP);
|
||||||
ffStrbufInitA(&instance->config.iconsKey, 0);
|
initModuleArg(&instance->config.publicIP);
|
||||||
ffStrbufInitA(&instance->config.fontFormat, 0);
|
initModuleArg(&instance->config.player);
|
||||||
ffStrbufInitA(&instance->config.fontKey, 0);
|
initModuleArg(&instance->config.song);
|
||||||
ffStrbufInitA(&instance->config.cursorKey, 0);
|
initModuleArg(&instance->config.dateTime);
|
||||||
ffStrbufInitA(&instance->config.cursorFormat, 0);
|
initModuleArg(&instance->config.date);
|
||||||
ffStrbufInitA(&instance->config.terminalFormat, 0);
|
initModuleArg(&instance->config.time);
|
||||||
ffStrbufInitA(&instance->config.terminalKey, 0);
|
initModuleArg(&instance->config.vulkan);
|
||||||
ffStrbufInitA(&instance->config.termFontFormat, 0);
|
initModuleArg(&instance->config.openGL);
|
||||||
ffStrbufInitA(&instance->config.termFontKey, 0);
|
initModuleArg(&instance->config.openCL);
|
||||||
ffStrbufInitA(&instance->config.cpuFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.cpuKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.cpuUsageFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.cpuUsageKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.gpuFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.gpuKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.memoryFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.memoryKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.diskFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.diskKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.batteryFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.batteryKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.localeFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.localeKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.localIpKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.localIpFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.publicIpKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.publicIpFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.playerKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.playerFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.songKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.songFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.dateTimeKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.dateTimeFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.dateKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.dateFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.timeKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.timeFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.vulkanKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.vulkanFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.openGLKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.openGLFormat, 0);
|
|
||||||
ffStrbufInitA(&instance->config.openCLKey, 0);
|
|
||||||
ffStrbufInitA(&instance->config.openCLFormat, 0);
|
|
||||||
|
|
||||||
ffStrbufInitA(&instance->config.libPCI, 0);
|
ffStrbufInitA(&instance->config.libPCI, 0);
|
||||||
ffStrbufInitA(&instance->config.libVulkan, 0);
|
ffStrbufInitA(&instance->config.libVulkan, 0);
|
||||||
@@ -218,6 +206,8 @@ static void defaultConfig(FFinstance* instance)
|
|||||||
ffStrbufInitA(&instance->config.libOSMesa, 0);
|
ffStrbufInitA(&instance->config.libOSMesa, 0);
|
||||||
ffStrbufInitA(&instance->config.libOpenCL, 0);
|
ffStrbufInitA(&instance->config.libOpenCL, 0);
|
||||||
|
|
||||||
|
instance->config.titleFQDN = false;
|
||||||
|
|
||||||
ffStrbufInitA(&instance->config.diskFolders, 0);
|
ffStrbufInitA(&instance->config.diskFolders, 0);
|
||||||
|
|
||||||
ffStrbufInitA(&instance->config.batteryDir, 0);
|
ffStrbufInitA(&instance->config.batteryDir, 0);
|
||||||
@@ -241,6 +231,75 @@ void ffInitInstance(FFinstance* instance)
|
|||||||
defaultConfig(instance);
|
defaultConfig(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void* detectPlasmaThreadMain(void* instance)
|
||||||
|
{
|
||||||
|
ffDetectQt((FFinstance*)instance);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void* detectGTK2ThreadMain(void* instance)
|
||||||
|
{
|
||||||
|
ffDetectGTK2((FFinstance*)instance);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void* detectGTK3ThreadMain(void* instance)
|
||||||
|
{
|
||||||
|
ffDetectGTK3((FFinstance*)instance);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void* detectGTK4ThreadMain(void* instance)
|
||||||
|
{
|
||||||
|
ffDetectGTK4((FFinstance*)instance);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void* connectDisplayServerThreadMain(void* instance)
|
||||||
|
{
|
||||||
|
ffConnectDisplayServer((FFinstance*)instance);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void* startThreadsThreadMain(void* instance)
|
||||||
|
{
|
||||||
|
pthread_t dsThread;
|
||||||
|
pthread_create(&dsThread, NULL, connectDisplayServerThreadMain, instance);
|
||||||
|
pthread_detach(dsThread);
|
||||||
|
|
||||||
|
pthread_t gtk2Thread;
|
||||||
|
pthread_create(>k2Thread, NULL, detectGTK2ThreadMain, instance);
|
||||||
|
pthread_detach(gtk2Thread);
|
||||||
|
|
||||||
|
pthread_t gtk3Thread;
|
||||||
|
pthread_create(>k3Thread, NULL, detectGTK3ThreadMain, instance);
|
||||||
|
pthread_detach(gtk3Thread);
|
||||||
|
|
||||||
|
pthread_t gtk4Thread;
|
||||||
|
pthread_create(>k4Thread, NULL, detectGTK4ThreadMain, instance);
|
||||||
|
pthread_detach(gtk4Thread);
|
||||||
|
|
||||||
|
pthread_t plasmaThread;
|
||||||
|
pthread_create(&plasmaThread, NULL, detectPlasmaThreadMain, instance);
|
||||||
|
pthread_detach(plasmaThread);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void startDetectionThreads(FFinstance* instance)
|
||||||
|
{
|
||||||
|
//Android needs none of the things that are detected here
|
||||||
|
//And using gsettings sometimes hangs the program in android for some unknown reason,
|
||||||
|
//and since we don't need it we just never call it.
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pthread_t startThreadsThread;
|
||||||
|
pthread_create(&startThreadsThread, NULL, startThreadsThreadMain, instance);
|
||||||
|
pthread_detach(startThreadsThread);
|
||||||
|
}
|
||||||
|
|
||||||
static volatile bool ffDisableLinewrap = true;
|
static volatile bool ffDisableLinewrap = true;
|
||||||
static volatile bool ffHideCursor = true;
|
static volatile bool ffHideCursor = true;
|
||||||
|
|
||||||
@@ -262,6 +321,9 @@ static void exitSignalHandler(int signal)
|
|||||||
|
|
||||||
void ffStart(FFinstance* instance)
|
void ffStart(FFinstance* instance)
|
||||||
{
|
{
|
||||||
|
if(instance->config.multithreading)
|
||||||
|
startDetectionThreads(instance);
|
||||||
|
|
||||||
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
|
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
|
||||||
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
|
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
|
||||||
|
|
||||||
@@ -291,7 +353,7 @@ void ffStart(FFinstance* instance)
|
|||||||
|
|
||||||
void ffFinish(FFinstance* instance)
|
void ffFinish(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(instance->config.logoPrintRemaining)
|
if(instance->config.logo.printRemaining)
|
||||||
ffLogoPrintRemaining(instance);
|
ffLogoPrintRemaining(instance);
|
||||||
|
|
||||||
resetConsole();
|
resetConsole();
|
||||||
|
|||||||
+37
-15
@@ -1,17 +1,12 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
bool ffWriteFDContent(int fd, const FFstrbuf* content)
|
|
||||||
{
|
|
||||||
return write(fd, content->chars, content->length) != -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void createSubfolders(const char* fileName)
|
static void createSubfolders(const char* fileName)
|
||||||
{
|
{
|
||||||
FFstrbuf path;
|
FFstrbuf path;
|
||||||
@@ -28,7 +23,13 @@ static void createSubfolders(const char* fileName)
|
|||||||
ffStrbufDestroy(&path);
|
ffStrbufDestroy(&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ffWriteFileContent(const char* fileName, const FFstrbuf* content)
|
|
||||||
|
bool ffWriteFDBuffer(int fd, const FFstrbuf* content)
|
||||||
|
{
|
||||||
|
return write(fd, content->chars, content->length) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
|
||||||
{
|
{
|
||||||
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC;
|
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC;
|
||||||
int openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
int openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||||
@@ -42,14 +43,19 @@ bool ffWriteFileContent(const char* fileName, const FFstrbuf* content)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = ffWriteFDContent(fd, content);
|
bool ret = write(fd, data, dataSize) != -1;
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffAppendFDContent(int fd, FFstrbuf* buffer)
|
bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer)
|
||||||
|
{
|
||||||
|
return ffWriteFileData(fileName, buffer->length, buffer->chars);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer)
|
||||||
{
|
{
|
||||||
ssize_t readed = 0;
|
ssize_t readed = 0;
|
||||||
|
|
||||||
@@ -73,24 +79,40 @@ void ffAppendFDContent(int fd, FFstrbuf* buffer)
|
|||||||
|
|
||||||
ffStrbufTrimRight(buffer, '\n');
|
ffStrbufTrimRight(buffer, '\n');
|
||||||
ffStrbufTrimRight(buffer, ' ');
|
ffStrbufTrimRight(buffer, ' ');
|
||||||
|
|
||||||
|
return readed >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ffAppendFileContent(const char* fileName, FFstrbuf* buffer)
|
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
|
||||||
|
{
|
||||||
|
int fd = open(fileName, O_RDONLY);
|
||||||
|
if(fd == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ssize_t readed = read(fd, data, dataSize);
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return readed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
|
||||||
{
|
{
|
||||||
int fd = open(fileName, O_RDONLY);
|
int fd = open(fileName, O_RDONLY);
|
||||||
if(fd == -1)
|
if(fd == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ffAppendFDContent(fd, buffer);
|
bool ret = ffAppendFDBuffer(fd, buffer);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return true;
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ffGetFileContent(const char* fileName, FFstrbuf* buffer)
|
bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer)
|
||||||
{
|
{
|
||||||
ffStrbufClear(buffer);
|
ffStrbufClear(buffer);
|
||||||
return ffAppendFileContent(fileName, buffer);
|
return ffAppendFileBuffer(fileName, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not thread safe!
|
// Not thread safe!
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_io
|
||||||
|
#define FF_INCLUDED_common_io
|
||||||
|
|
||||||
|
#include <sys/types.h> //mode_t
|
||||||
|
|
||||||
|
bool ffWriteFDBuffer(int fd, const FFstrbuf* content);
|
||||||
|
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
|
||||||
|
bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer);
|
||||||
|
|
||||||
|
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer);
|
||||||
|
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data);
|
||||||
|
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer);
|
||||||
|
bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer);
|
||||||
|
|
||||||
|
bool ffFileExists(const char* fileName, mode_t mode);
|
||||||
|
|
||||||
|
// Not thread safe!
|
||||||
|
void ffSuppressIO(bool suppress);
|
||||||
|
|
||||||
|
void ffGetTerminalResponse(const char* request, const char* format, ...);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/library.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_library
|
||||||
|
#define FF_INCLUDED_common_library
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#define FF_LIBRARY_SYMBOL(symbolName) \
|
||||||
|
__typeof__(&symbolName) ff ## symbolName;
|
||||||
|
|
||||||
|
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
|
||||||
|
void* libraryObjectName = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL);\
|
||||||
|
if(libraryObjectName == NULL) \
|
||||||
|
return returnValue;
|
||||||
|
|
||||||
|
#define FF_LIBRARY_LOAD_SYMBOL_ADRESS(library, symbolMapping, symbolName, returnValue) \
|
||||||
|
symbolMapping = dlsym(library, #symbolName); \
|
||||||
|
if(symbolMapping == NULL) \
|
||||||
|
{ \
|
||||||
|
dlclose(library); \
|
||||||
|
return returnValue; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
||||||
|
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADRESS(library, ff ## symbolName, symbolName, returnValue);
|
||||||
|
|
||||||
|
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/networking.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
@@ -10,7 +11,6 @@ void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, F
|
|||||||
struct addrinfo hints = {0};
|
struct addrinfo hints = {0};
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_protocol = 0;
|
|
||||||
|
|
||||||
struct addrinfo* addr;
|
struct addrinfo* addr;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_networking
|
||||||
|
#define FF_INCLUDED_common_networking
|
||||||
|
|
||||||
|
#include "util/FFstrbuf.h"
|
||||||
|
|
||||||
|
void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, FFstrbuf* buffer);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
|
||||||
bool ffStrSet(const char* str)
|
bool ffStrSet(const char* str)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_parsing_h
|
||||||
|
#define FF_INCLUDED_parsing_h
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef struct FFVersion
|
||||||
|
{
|
||||||
|
uint32_t major;
|
||||||
|
uint32_t minor;
|
||||||
|
uint32_t patch;
|
||||||
|
} FFVersion;
|
||||||
|
|
||||||
|
#define FF_VERSION_INIT ((FFVersion) {0})
|
||||||
|
|
||||||
|
bool ffStrSet(const char* str);
|
||||||
|
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);
|
||||||
|
void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4);
|
||||||
|
|
||||||
|
void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty);
|
||||||
|
int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2);
|
||||||
|
|
||||||
|
#endif
|
||||||
+96
-37
@@ -1,15 +1,21 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
|
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
|
||||||
{
|
{
|
||||||
ffLogoPrintLine(instance);
|
ffLogoPrintLine(instance);
|
||||||
|
|
||||||
|
//This is used by --set-keyless, in this case we wan't neither the module name nor the separator
|
||||||
|
if(moduleName == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if(!instance->config.pipe)
|
if(!instance->config.pipe)
|
||||||
{
|
{
|
||||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
||||||
ffPrintColor(&instance->config.mainColor);
|
ffPrintColor(&instance->config.mainColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//NULL check is required for modules with custom keys, e.g. disk with the folder path
|
||||||
if(customKeyFormat == NULL || customKeyFormat->length == 0)
|
if(customKeyFormat == NULL || customKeyFormat->length == 0)
|
||||||
{
|
{
|
||||||
fputs(moduleName, stdout);
|
fputs(moduleName, stdout);
|
||||||
@@ -21,10 +27,10 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod
|
|||||||
{
|
{
|
||||||
FFstrbuf key;
|
FFstrbuf key;
|
||||||
ffStrbufInit(&key);
|
ffStrbufInit(&key);
|
||||||
ffParseFormatString(&key, customKeyFormat, NULL, 1, (FFformatarg[]){
|
ffParseFormatString(&key, customKeyFormat, 1, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
|
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
|
||||||
});
|
});
|
||||||
ffStrbufWriteTo(&key, stdout);
|
ffPrintUserString(key.chars);
|
||||||
ffStrbufDestroy(&key);
|
ffStrbufDestroy(&key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,54 +43,76 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod
|
|||||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numFormatArgs, const char* message, ...)
|
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments)
|
||||||
{
|
|
||||||
if(!instance->config.showErrors)
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_list arguments;
|
|
||||||
va_start(arguments, message);
|
|
||||||
|
|
||||||
if(formatString == NULL || formatString->length == 0)
|
|
||||||
{
|
|
||||||
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
|
|
||||||
fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout);
|
|
||||||
vprintf(message, arguments);
|
|
||||||
puts(FASTFETCH_TEXT_MODIFIER_RESET);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FF_STRBUF_CREATE(error);
|
|
||||||
ffStrbufAppendVF(&error, message, arguments);
|
|
||||||
|
|
||||||
// calloc sets all to 0 and FF_FORMAT_ARG_TYPE_NULL also has value 0 so we don't need to explictly set it
|
|
||||||
FFformatarg* nullArgs = calloc(numFormatArgs, sizeof(FFformatarg));
|
|
||||||
|
|
||||||
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, formatString, &error, numFormatArgs, nullArgs);
|
|
||||||
|
|
||||||
free(nullArgs);
|
|
||||||
ffStrbufDestroy(&error);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments)
|
|
||||||
{
|
{
|
||||||
FFstrbuf buffer;
|
FFstrbuf buffer;
|
||||||
ffStrbufInitA(&buffer, 256);
|
ffStrbufInitA(&buffer, 256);
|
||||||
|
|
||||||
ffParseFormatString(&buffer, formatString, error, numArgs, arguments);
|
ffParseFormatString(&buffer, format, numArgs, arguments);
|
||||||
|
|
||||||
if(buffer.length > 0)
|
if(buffer.length > 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
|
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
|
||||||
ffStrbufPutTo(&buffer, stdout);
|
ffPrintUserString(buffer.chars);
|
||||||
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
ffStrbufDestroy(&buffer);
|
ffStrbufDestroy(&buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments)
|
||||||
|
{
|
||||||
|
ffPrintFormatString(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->outputFormat, numArgs, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void printError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, va_list arguments)
|
||||||
|
{
|
||||||
|
bool hasCustomErrorFormat = customErrorFormat != NULL && customErrorFormat->length > 0;
|
||||||
|
if(!hasCustomErrorFormat && !instance->config.showErrors)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(hasCustomErrorFormat)
|
||||||
|
{
|
||||||
|
FFstrbuf error;
|
||||||
|
ffStrbufInit(&error);
|
||||||
|
ffStrbufAppendVF(&error, message, arguments);
|
||||||
|
|
||||||
|
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, customErrorFormat, 1, (FFformatarg[]) {
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &error}
|
||||||
|
});
|
||||||
|
|
||||||
|
ffStrbufDestroy(&error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
|
||||||
|
|
||||||
|
if(!instance->config.pipe)
|
||||||
|
fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout);
|
||||||
|
|
||||||
|
vprintf(message, arguments);
|
||||||
|
|
||||||
|
if(!instance->config.pipe)
|
||||||
|
puts(FASTFETCH_TEXT_MODIFIER_RESET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...)
|
||||||
|
{
|
||||||
|
va_list arguments;
|
||||||
|
va_start(arguments, message);
|
||||||
|
printError(instance, moduleName, moduleIndex, customKeyFormat, customErrorFormat, message, arguments);
|
||||||
|
va_end(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...)
|
||||||
|
{
|
||||||
|
va_list arguments;
|
||||||
|
va_start(arguments, message);
|
||||||
|
printError(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->errorFormat, message, arguments);
|
||||||
|
va_end(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
void ffPrintColor(const FFstrbuf* colorValue)
|
void ffPrintColor(const FFstrbuf* colorValue)
|
||||||
{
|
{
|
||||||
//If the color is not set, this would reset in \033[m, which resets everything.
|
//If the color is not set, this would reset in \033[m, which resets everything.
|
||||||
@@ -102,3 +130,34 @@ void ffPrintCharTimes(char c, uint32_t times)
|
|||||||
for(uint32_t i = 0; i < times; i++)
|
for(uint32_t i = 0; i < times; i++)
|
||||||
putchar(c);
|
putchar(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_printing
|
||||||
|
#define FF_INCLUDED_common_printing
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
#include "common/format.h"
|
||||||
|
|
||||||
|
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat);
|
||||||
|
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments);
|
||||||
|
void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments);
|
||||||
|
void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...);
|
||||||
|
void ffPrintError(FFinstance* instance, 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
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/processing.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
@@ -29,6 +31,6 @@ void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
|
|||||||
//Parent
|
//Parent
|
||||||
close(pipes[1]);
|
close(pipes[1]);
|
||||||
waitpid(childPid, NULL, 0);
|
waitpid(childPid, NULL, 0);
|
||||||
ffAppendFDContent(pipes[0], buffer);
|
ffAppendFDBuffer(pipes[0], buffer);
|
||||||
close(pipes[0]);
|
close(pipes[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_processing
|
||||||
|
#define FF_INCLUDED_common_processing
|
||||||
|
|
||||||
|
#include "util/FFstrbuf.h"
|
||||||
|
|
||||||
|
void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]);
|
||||||
|
|
||||||
|
#endif
|
||||||
+18
-23
@@ -1,4 +1,7 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
static bool parsePropLinePointer(const char** line, const char* start, FFstrbuf* buffer)
|
static bool parsePropLinePointer(const char** line, const char* start, FFstrbuf* buffer)
|
||||||
{
|
{
|
||||||
@@ -86,10 +89,13 @@ bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer)
|
|||||||
// The following functions return true if the file was found, independently if start was found
|
// The following functions return true if the file was found, independently if start was found
|
||||||
// Buffers which already contain content are not overwritten
|
// Buffers which already contain content are not overwritten
|
||||||
// The last occurence of start in the first file will be the one used
|
// The last occurence of start in the first file will be the one used
|
||||||
// The *Values methods always return true, if all properties were already found before, without testing if the file exists
|
|
||||||
|
|
||||||
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries)
|
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries)
|
||||||
{
|
{
|
||||||
|
FILE* file = fopen(filename, "r");
|
||||||
|
if(file == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool valueStorage[4];
|
bool valueStorage[4];
|
||||||
bool* unsetValues;
|
bool* unsetValues;
|
||||||
|
|
||||||
@@ -105,17 +111,8 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
|
|||||||
allSet = false;
|
allSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* file = fopen(filename, "r");
|
|
||||||
if(file == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(allSet)
|
if(allSet)
|
||||||
{
|
goto done;
|
||||||
fclose(file);
|
|
||||||
if(unsetValues != valueStorage)
|
|
||||||
free(unsetValues);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* line = NULL;
|
char* line = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
@@ -137,11 +134,10 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
|
|||||||
if(line != NULL)
|
if(line != NULL)
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
|
done:
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if(unsetValues != valueStorage)
|
if(unsetValues != valueStorage)
|
||||||
free(unsetValues);
|
free(unsetValues);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,21 +170,18 @@ bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativ
|
|||||||
{
|
{
|
||||||
bool foundAFile = false;
|
bool foundAFile = false;
|
||||||
|
|
||||||
|
FFstrbuf baseDir;
|
||||||
|
ffStrbufInitA(&baseDir, 64);
|
||||||
|
|
||||||
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
||||||
{
|
{
|
||||||
FFstrbuf* baseDir = (FFstrbuf*) ffListGet(&instance->state.configDirs, i);
|
//We need to copy the config dir each time, because it used by multiple threads, so we can't directly write to it.
|
||||||
uint32_t baseDirLength = baseDir->length;
|
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
|
||||||
|
ffStrbufAppendS(&baseDir, relativeFile);
|
||||||
|
|
||||||
if(*relativeFile != '/')
|
if(ffParsePropFileValues(baseDir.chars, numQueries, queries))
|
||||||
ffStrbufAppendC(baseDir, '/');
|
|
||||||
|
|
||||||
ffStrbufAppendS(baseDir, relativeFile);
|
|
||||||
|
|
||||||
if(ffParsePropFileValues(baseDir->chars, numQueries, queries))
|
|
||||||
foundAFile = true;
|
foundAFile = true;
|
||||||
|
|
||||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
|
||||||
|
|
||||||
bool allSet = true;
|
bool allSet = true;
|
||||||
for(uint32_t k = 0; k < numQueries; k++)
|
for(uint32_t k = 0; k < numQueries; k++)
|
||||||
{
|
{
|
||||||
@@ -203,6 +196,8 @@ bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativ
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ffStrbufDestroy(&baseDir);
|
||||||
|
|
||||||
return foundAFile;
|
return foundAFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_properties
|
||||||
|
#define FF_INCLUDED_common_properties
|
||||||
|
|
||||||
|
#include "util/FFstrbuf.h"
|
||||||
|
|
||||||
|
typedef struct FFpropquery
|
||||||
|
{
|
||||||
|
const char* start;
|
||||||
|
FFstrbuf* buffer;
|
||||||
|
} FFpropquery;
|
||||||
|
|
||||||
|
bool ffParsePropLine(const char* line, const char* start, FFstrbuf* buffer);
|
||||||
|
bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer);
|
||||||
|
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries);
|
||||||
|
bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer);
|
||||||
|
bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
|
||||||
|
bool ffParsePropFileHome(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
|
||||||
|
bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
|
||||||
|
bool ffParsePropFileConfig(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,8 +1,18 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/settings.h"
|
||||||
|
#include "common/library.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
typedef enum FFInitState
|
||||||
|
{
|
||||||
|
FF_INITSTATE_UNINITIALIZED = 0,
|
||||||
|
FF_INITSTATE_SUCCESSFUL = 1,
|
||||||
|
FF_INITSTATE_FAILED = 2
|
||||||
|
} FFInitState;
|
||||||
|
|
||||||
#define FF_LIBRARY_DATA_LOAD_INIT(dataObject, userLibraryName, ...) \
|
#define FF_LIBRARY_DATA_LOAD_INIT(dataObject, userLibraryName, ...) \
|
||||||
static dataObject data; \
|
static dataObject data; \
|
||||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; \
|
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; \
|
||||||
@@ -270,6 +280,7 @@ FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, con
|
|||||||
|
|
||||||
#ifdef FF_HAVE_SQLITE3
|
#ifdef FF_HAVE_SQLITE3
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
typedef struct SQLiteData
|
typedef struct SQLiteData
|
||||||
{
|
{
|
||||||
@@ -299,6 +310,9 @@ static const SQLiteData* getSQLiteData(const FFinstance* instance)
|
|||||||
|
|
||||||
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query)
|
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query)
|
||||||
{
|
{
|
||||||
|
if(!ffFileExists(dbPath, S_IFREG))
|
||||||
|
return 0;
|
||||||
|
|
||||||
const SQLiteData* data = getSQLiteData(instance);
|
const SQLiteData* data = getSQLiteData(instance);
|
||||||
if(data == NULL)
|
if(data == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_settings
|
||||||
|
#define FF_INCLUDED_common_settings
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef enum FFvarianttype
|
||||||
|
{
|
||||||
|
FF_VARIANT_TYPE_STRING,
|
||||||
|
FF_VARIANT_TYPE_BOOL,
|
||||||
|
FF_VARIANT_TYPE_INT
|
||||||
|
} FFvarianttype;
|
||||||
|
|
||||||
|
typedef union FFvariant
|
||||||
|
{
|
||||||
|
const char* strValue;
|
||||||
|
int32_t intValue;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool boolValueSet;
|
||||||
|
bool boolValue;
|
||||||
|
};
|
||||||
|
} FFvariant;
|
||||||
|
|
||||||
|
#define FF_VARIANT_NULL ((FFvariant){.strValue = NULL})
|
||||||
|
|
||||||
|
FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttype type);
|
||||||
|
FFvariant ffSettingsGetGSettings(FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type);
|
||||||
|
FFvariant ffSettingsGet(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type);
|
||||||
|
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type);
|
||||||
|
|
||||||
|
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query);
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
#include "fastfetch.h"
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
static inline void* detectPlasmaThreadMain(void* instance)
|
|
||||||
{
|
|
||||||
ffDetectPlasma((FFinstance*)instance);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void* detectGTK2ThreadMain(void* instance)
|
|
||||||
{
|
|
||||||
ffDetectGTK2((FFinstance*)instance);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void* detectGTK3ThreadMain(void* instance)
|
|
||||||
{
|
|
||||||
ffDetectGTK3((FFinstance*)instance);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void* detectGTK4ThreadMain(void* instance)
|
|
||||||
{
|
|
||||||
ffDetectGTK4((FFinstance*)instance);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void* connectDisplayServerThreadMain(void* instance)
|
|
||||||
{
|
|
||||||
ffConnectDisplayServer((FFinstance*)instance);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void* startThreadsThreadMain(void* instance)
|
|
||||||
{
|
|
||||||
pthread_t dsThread;
|
|
||||||
pthread_create(&dsThread, NULL, connectDisplayServerThreadMain, instance);
|
|
||||||
pthread_detach(dsThread);
|
|
||||||
|
|
||||||
pthread_t gtk2Thread;
|
|
||||||
pthread_create(>k2Thread, NULL, detectGTK2ThreadMain, instance);
|
|
||||||
pthread_detach(gtk2Thread);
|
|
||||||
|
|
||||||
pthread_t gtk3Thread;
|
|
||||||
pthread_create(>k3Thread, NULL, detectGTK3ThreadMain, instance);
|
|
||||||
pthread_detach(gtk3Thread);
|
|
||||||
|
|
||||||
pthread_t gtk4Thread;
|
|
||||||
pthread_create(>k4Thread, NULL, detectGTK4ThreadMain, instance);
|
|
||||||
pthread_detach(gtk4Thread);
|
|
||||||
|
|
||||||
pthread_t plasmaThread;
|
|
||||||
pthread_create(&plasmaThread, NULL, detectPlasmaThreadMain, instance);
|
|
||||||
pthread_detach(plasmaThread);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ffStartDetectionThreads(FFinstance* instance)
|
|
||||||
{
|
|
||||||
//Android needs none of the things that are detected here
|
|
||||||
//And using gsettings sometimes hangs the program in android for some unknown reason,
|
|
||||||
//and since we don't need it we just never call it.
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pthread_t startThreadsThread;
|
|
||||||
pthread_create(&startThreadsThread, NULL, startThreadsThreadMain, instance);
|
|
||||||
pthread_detach(startThreadsThread);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Fastfetch system configuration
|
||||||
|
# This file sets the defaults for all users of the system.
|
||||||
|
|
||||||
|
# For more information about configuration files work,
|
||||||
|
# see the file ~/.config/fastfetch/config.conf, generated during first
|
||||||
|
# All options that can be put there (or passed as argument) can be put here too.
|
||||||
|
|
||||||
|
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
|
||||||
|
# Use fastfetch --print-config-system > /etc/fastfetch/config.conf to overwrite this file with the current defaults
|
||||||
|
|
||||||
|
# User config option
|
||||||
|
# Sets if fastfetch should load user provided configuration.
|
||||||
|
# If this is off, fastfetch ignores the user config file and any passed arguments
|
||||||
|
# Must be true or false
|
||||||
|
# Default is true.
|
||||||
|
#--load-user-config true
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
# Empty lines or lines starting with # are ignored.
|
# Empty lines or lines starting with # are ignored.
|
||||||
|
|
||||||
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
|
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
|
||||||
# Use fastfetch --print-config > ~/.config/fastfetch/config.conf to overwrite this with the current defaults
|
# Use fastfetch --print-config-user > ~/.config/fastfetch/config.conf to overwrite this file with the current defaults
|
||||||
|
|
||||||
# Below some often usefull options are listed. Uncomment and modify them so they take affect.
|
# Below some often usefull options are listed. Uncomment and modify them so they take affect.
|
||||||
# Note that there are a lot more options than the ones listed here, take a look at "fastfetch --help".
|
# Note that there are a lot more options than the ones listed here, take a look at "fastfetch --help".
|
||||||
@@ -120,6 +120,12 @@
|
|||||||
# Use "fastfetch --help color" to learn more and see examples.
|
# Use "fastfetch --help color" to learn more and see examples.
|
||||||
#--color magenta
|
#--color magenta
|
||||||
|
|
||||||
|
# Title FQDN option:
|
||||||
|
# Sets if the title should use the fully qualified domain name.
|
||||||
|
# Must be true or false.
|
||||||
|
# Default is false.
|
||||||
|
#--title-fqdn false
|
||||||
|
|
||||||
# Separator option:
|
# Separator option:
|
||||||
# Sets the string placed between a key and its value.
|
# Sets the string placed between a key and its value.
|
||||||
# Can be any string.
|
# Can be any string.
|
||||||
@@ -237,6 +243,44 @@
|
|||||||
#--opengl-format
|
#--opengl-format
|
||||||
#--opencl-format
|
#--opencl-format
|
||||||
|
|
||||||
|
# Error options:
|
||||||
|
# Sets the format string to use if an error occured
|
||||||
|
# For information on format strings, see "fastfetch --help format".
|
||||||
|
# Each of them take the error as first and only argument.
|
||||||
|
# If one of them is set, the module will appear, even if --show-errors is not given.
|
||||||
|
#--os-error
|
||||||
|
#--host-error
|
||||||
|
#--kernel-error
|
||||||
|
#--uptime-error
|
||||||
|
#--processes-error
|
||||||
|
#--packages-error
|
||||||
|
#--shell-error
|
||||||
|
#--resolution-error
|
||||||
|
#--de-error
|
||||||
|
#--wm-error
|
||||||
|
#--wm-theme-error
|
||||||
|
#--theme-error
|
||||||
|
#--icons-error
|
||||||
|
#--font-error
|
||||||
|
#--cursor-error
|
||||||
|
#--terminal-error
|
||||||
|
#--terminal-font-error
|
||||||
|
#--cpu-error
|
||||||
|
#--cpu-usage-error
|
||||||
|
#--gpu-error
|
||||||
|
#--memory-error
|
||||||
|
#--disk-error
|
||||||
|
#--battery-error
|
||||||
|
#--locale-error
|
||||||
|
#--local-ip-error
|
||||||
|
#--public-ip-error
|
||||||
|
#--player-error
|
||||||
|
#--song-error
|
||||||
|
#--datetime-error
|
||||||
|
#--vulkan-error
|
||||||
|
#--opengl-error
|
||||||
|
#--opencl-error
|
||||||
|
|
||||||
# Library options:
|
# Library options:
|
||||||
# Sets an user specific path to a library to load.
|
# Sets an user specific path to a library to load.
|
||||||
# Must be a valid path to a library.
|
# Must be a valid path to a library.
|
||||||
@@ -259,4 +303,4 @@
|
|||||||
#--lib-egl /usr/lib/libEGL.so
|
#--lib-egl /usr/lib/libEGL.so
|
||||||
#--lib-glx /usr/lib/libGLX.so
|
#--lib-glx /usr/lib/libGLX.so
|
||||||
#--lib-osmesa /usr/lib/libOSMesa.so
|
#--lib-osmesa /usr/lib/libOSMesa.so
|
||||||
#--lib-opencl /usr/lib/libOpenCL.so
|
#--lib-opencl /usr/lib/libOpenCL.so
|
||||||
+23
-80
@@ -1,16 +1,17 @@
|
|||||||
Usage: fastfetch <options>
|
Usage: fastfetch <options>
|
||||||
|
|
||||||
Informative options:
|
Informative options:
|
||||||
-h,--help: shows this message and exits
|
-h,--help: shows this message and exits
|
||||||
-h,--help <command>: shows help for a specific command and exits
|
-h,--help <command>: shows help for a specific command and exits
|
||||||
-v,--version: prints the version of fastfetch and exits
|
-v,--version: prints the version of fastfetch and exits
|
||||||
--list-logos: list available logos and exits
|
--list-logos: list available logos and exits
|
||||||
--list-modules: lists available modules and exits
|
--list-modules: lists available modules and exits
|
||||||
--list-presets: list presets fastfetch knows about and exits. They can be loaded with --load-config. (+)
|
--list-presets: list presets fastfetch knows about and exits. They can be loaded with --load-config. (+)
|
||||||
--list-features: list the supported features fastfetch was compiled with and exits. Mainly for development.
|
--list-features: list the supported features fastfetch was compiled with and exits. Mainly for development.
|
||||||
--print-logos: show available logos and exits
|
--print-logos: show available logos and exits
|
||||||
--print-config: prints the default config and exits
|
--print-config-system: prints the default system config and exits
|
||||||
--print-structure: prints the default stucture and exits
|
--print-config-user: prints the default user config and exits
|
||||||
|
--print-structure: prints the default stucture and exits
|
||||||
|
|
||||||
General options:
|
General options:
|
||||||
-r,--recache <?value>: generate new cached values
|
-r,--recache <?value>: generate new cached values
|
||||||
@@ -42,81 +43,22 @@ Display options:
|
|||||||
-c,--color <color>: sets the color of the keys. Must be a linux console color code or the name of a color (+)
|
-c,--color <color>: sets the color of the keys. Must be a linux console color code or the name of a color (+)
|
||||||
--separator <str>: sets the separator between key and value. Default is a colon with a space
|
--separator <str>: sets the separator between key and value. Default is a colon with a space
|
||||||
--set <key=value>: hard set the value of a key
|
--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
|
||||||
--show-errors <?value>: print occuring errors
|
--show-errors <?value>: print occuring errors
|
||||||
--disable-linewrap <?value>: weather to disable linewrap during the run
|
--disable-linewrap <?value>: weather to disable linewrap during the run
|
||||||
--hide-cursor <?value>: weather to hide the cursor during the run
|
--hide-cursor <?value>: weather to hide the cursor during the run
|
||||||
|
|
||||||
Format options: Provide the format string for custom output. Use fastfetch --help *-format for specific help.
|
General module options:
|
||||||
--os-format <format>
|
--<module>-format <format>: Sets the format string to use for each specific module.
|
||||||
--host-format <format>
|
To see how a format string works, use fastfetch --help format.
|
||||||
--kernel-format <format>
|
To see help about a specific format string, use fastfetch --help <module>-format.
|
||||||
--uptime-format <format>
|
|
||||||
--processes-format <format>
|
|
||||||
--packages-format <format>
|
|
||||||
--shell-format <format>
|
|
||||||
--resolution-format <format>
|
|
||||||
--de-format <format>
|
|
||||||
--wm-format <format>
|
|
||||||
--wm-theme-format <format>
|
|
||||||
--theme-format <format>
|
|
||||||
--icons-format <format>
|
|
||||||
--font-format <format>
|
|
||||||
--cursor-format <format>
|
|
||||||
--terminal-format <format>
|
|
||||||
--terminal-font-format <format>
|
|
||||||
--cpu-format <format>
|
|
||||||
--cpu-usage-format <format>
|
|
||||||
--gpu-format <format>
|
|
||||||
--memory-format <format>
|
|
||||||
--disk-format <format>
|
|
||||||
--battery-format <format>
|
|
||||||
--locale-format <format>
|
|
||||||
--local-ip-format <format>
|
|
||||||
--public-ip-format <format>
|
|
||||||
--player-format <format>
|
|
||||||
--song-format <format>
|
|
||||||
--datetime-format <format>
|
|
||||||
--time-format <format>
|
|
||||||
--date-format <format>
|
|
||||||
--vulkan-format <format>
|
|
||||||
--opengl-format <format>
|
|
||||||
--opencl-format <format>
|
|
||||||
|
|
||||||
Key options: Provide a custom key for an output
|
--<module>-key <key>: Sets the key to use for each specific module.
|
||||||
--os-key <key>
|
For modules which print multiple lines, the string is parsed as a format string with the index as first character.
|
||||||
--host-key <key>
|
|
||||||
--kernel-key <key>
|
--<module>-error <format>: Sets the error format string to use for each specific module.
|
||||||
--uptime-key <key>
|
The error is given as the first and only argument.
|
||||||
--processes-key <key>
|
Setting this for a module will cause it to appear, even if --show-errors is not given.
|
||||||
--packages-key <key>
|
|
||||||
--shell-key <key>
|
|
||||||
--resolution-key <key>: takes the resolution index as argument
|
|
||||||
--de-key <key>
|
|
||||||
--wm-key <key>
|
|
||||||
--wm-theme-key <key>
|
|
||||||
--theme-key <key>
|
|
||||||
--icons-key <key>
|
|
||||||
--font-key <key>
|
|
||||||
--cursor-key <key>
|
|
||||||
--terminal-key <key>
|
|
||||||
--terminal-font-key <key>
|
|
||||||
--cpu-key <key>
|
|
||||||
--cpu-usage-key <key>
|
|
||||||
--gpu-key <key>: takes the gpu index as format argument
|
|
||||||
--memory-key <key>
|
|
||||||
--disk-key <key>: takes the mount path as format argument
|
|
||||||
--battery-key <key>: takes the battery index as format argument
|
|
||||||
--locale-key <key>
|
|
||||||
--local-ip-key <key>: takes the name of this network interface as format argument
|
|
||||||
--public-ip-key <key>
|
|
||||||
--player-key <key>
|
|
||||||
--song-key <key>
|
|
||||||
--datetime-key <key>
|
|
||||||
--time-key <key>
|
|
||||||
--date-key <key>
|
|
||||||
--vulkan-key <key>
|
|
||||||
--opengl-key <key>
|
|
||||||
--opencl-key <key>
|
|
||||||
|
|
||||||
Library options: Set the path of a library to load
|
Library options: Set the path of a library to load
|
||||||
--lib-PCI <path>
|
--lib-PCI <path>
|
||||||
@@ -141,6 +83,7 @@ Library options: Set the path of a library to load
|
|||||||
--lib-opencl <path>
|
--lib-opencl <path>
|
||||||
|
|
||||||
Module specific options:
|
Module specific options:
|
||||||
|
--title-fqdn <?value>: sets if the title should use fully qualified domain name. Default is false.
|
||||||
--separator-string <str>: Set the string printed by the separator module
|
--separator-string <str>: Set the string printed by the separator module
|
||||||
--os-file <path>: Set the path to the file containing OS informations
|
--os-file <path>: Set the path to the file containing OS informations
|
||||||
--disk-folders <folders>: A colon separated list of folder paths for the disk output. Default is "/:/home"
|
--disk-folders <folders>: A colon separated list of folder paths for the disk output. Default is "/:/home"
|
||||||
|
|||||||
@@ -19,24 +19,18 @@ If a "{?}" is found without an opener, it is printed as is.
|
|||||||
To only print something if a variable is not set, do the same as with if, just replace every '?' with a '!'.
|
To only print something if a variable is not set, do the same as with if, just replace every '?' with a '!'.
|
||||||
For example to print a fallback for a second value if it is not set, use "{?2}{2}{?}{/2}Second value fallback{/}"
|
For example to print a fallback for a second value if it is not set, use "{?2}{2}{?}{/2}Second value fallback{/}"
|
||||||
|
|
||||||
There is a special variable set if an error occured during detection. You can access it with "{e}", "{error}" o
|
|
||||||
You can use ifs and not ifs with it like with an index. For example use "{?e}some text{?}", to print a text if an
|
|
||||||
|
|
||||||
To stop formatting at any point in the format string, use "{-}".
|
To stop formatting at any point in the format string, use "{-}".
|
||||||
For example to print an error instead of the normal output if it occured, prefix the format string with "{?e}{e}{-
|
|
||||||
|
|
||||||
To print something with color, start a placeholder with a '#' and then the linux terminal color encoding.
|
To print something with color, start a placeholder with a '#' and then the linux terminal color encoding.
|
||||||
"\\033[" at the start, and an 'm' at the end is automatically added, so don't do that.
|
"\\033[" at the start, and an 'm' at the end is automatically added, so don't do that.
|
||||||
A "{#}" is equivalent to a "{#0}" and resets everything to normal.
|
A "{#}" is equivalent to a "{#0}" and resets everything to normal.
|
||||||
For example to print something pink and underline, use "{#4;35}...{#}".
|
For example to print something pink and underline, use "{#4;35}...{#}".
|
||||||
If not in a format string, fastfetch wraps errors with "{#1;31}error{#}", so you might want to do that to if you
|
|
||||||
Information about what the numbers mean can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Sele
|
Information about what the numbers mean can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Sele
|
||||||
Which escape codes are supported and how they look is defined by your terminal.
|
Which escape codes are supported and how they look is defined by your terminal.
|
||||||
|
|
||||||
If a format string evaluates to an empty value, the whole line in the output will be discarded.
|
If a format string evaluates to an empty value, the whole line in the output will be discarded.
|
||||||
You can therefore use --host-format " " to disable host output.
|
You can therefore use --host-format " " to disable host output.
|
||||||
Note that --host-format "" would evaluate as not set, and therefore use the built-in host format
|
Note that --host-format "" would evaluate as not set, and therefore use the built-in host format
|
||||||
This can be used to print nothing if an error occured: prefix the format string with "{?e}{-}{?}...".
|
|
||||||
|
|
||||||
Format string is also the way to go to set a fixed value - just use one without placeholders.
|
Format string is also the way to go to set a fixed value - just use one without placeholders.
|
||||||
For example when running in headless mode, you could use "--resolution-format "Preferred".
|
For example when running in headless mode, you could use "--resolution-format "Preferred".
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/datetime.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance)
|
const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance)
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_datetime
|
||||||
|
#define FF_INCLUDED_detection_datetime
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFDateTimeResult
|
||||||
|
{
|
||||||
|
//Examples for 21.02.2022 - 15:18:37
|
||||||
|
uint16_t year; //2022
|
||||||
|
uint8_t yearShort; //22
|
||||||
|
uint8_t month; //2
|
||||||
|
FFstrbuf monthPretty; //02
|
||||||
|
FFstrbuf monthName; //February
|
||||||
|
FFstrbuf monthNameShort; //Feb
|
||||||
|
uint8_t week; //8
|
||||||
|
FFstrbuf weekday; //Monday
|
||||||
|
FFstrbuf weekdayShort; //Mon
|
||||||
|
uint16_t dayInYear; //52
|
||||||
|
uint8_t dayInMonth; //21
|
||||||
|
uint8_t dayInWeek; //1
|
||||||
|
uint8_t hour; //15
|
||||||
|
FFstrbuf hourPretty; //15
|
||||||
|
uint8_t hour12; //3
|
||||||
|
FFstrbuf hour12Pretty; //03
|
||||||
|
uint8_t minute; //18
|
||||||
|
FFstrbuf minutePretty; //18
|
||||||
|
uint8_t second; //37
|
||||||
|
FFstrbuf secondPretty; //37
|
||||||
|
} FFDateTimeResult;
|
||||||
|
|
||||||
|
const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_displayserver
|
||||||
|
#define FF_INCLUDED_detection_displayserver
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFResolutionResult
|
||||||
|
{
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
uint32_t refreshRate;
|
||||||
|
} FFResolutionResult;
|
||||||
|
|
||||||
|
typedef struct FFDisplayServerResult
|
||||||
|
{
|
||||||
|
FFstrbuf wmProcessName;
|
||||||
|
FFstrbuf wmPrettyName;
|
||||||
|
FFstrbuf wmProtocolName;
|
||||||
|
FFstrbuf deProcessName;
|
||||||
|
FFstrbuf dePrettyName;
|
||||||
|
FFstrbuf deVersion;
|
||||||
|
FFlist resolutions; //List of FFResolutionResult
|
||||||
|
} FFDisplayServerResult;
|
||||||
|
|
||||||
|
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "displayServer.h"
|
#include "displayServer.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#define FASTFETCH_INCLUDED_DISPLAYSERVER
|
#define FASTFETCH_INCLUDED_DISPLAYSERVER
|
||||||
|
|
||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
#define FF_DISPLAYSERVER_PROTOCOL_WAYLAND "Wayland"
|
#define FF_DISPLAYSERVER_PROTOCOL_WAYLAND "Wayland"
|
||||||
#define FF_DISPLAYSERVER_PROTOCOL_X11 "X11"
|
#define FF_DISPLAYSERVER_PROTOCOL_X11 "X11"
|
||||||
|
|||||||
@@ -1,50 +1,53 @@
|
|||||||
|
#define _GNU_SOURCE //required for struct ucred
|
||||||
|
|
||||||
#include "displayServer.h"
|
#include "displayServer.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef FF_HAVE_WAYLAND
|
#ifdef FF_HAVE_WAYLAND
|
||||||
#include <wayland-client.h>
|
#include "common/library.h"
|
||||||
|
#include "common/io.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <wayland-client.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
typedef struct WaylandData
|
typedef struct WaylandData
|
||||||
{
|
{
|
||||||
const FFinstance* instance;
|
|
||||||
FFlist* results;
|
FFlist* results;
|
||||||
FF_LIBRARY_SYMBOL(wl_proxy_marshal_constructor_versioned)
|
FF_LIBRARY_SYMBOL(wl_proxy_marshal_constructor_versioned)
|
||||||
FF_LIBRARY_SYMBOL(wl_proxy_add_listener)
|
FF_LIBRARY_SYMBOL(wl_proxy_add_listener)
|
||||||
FF_LIBRARY_SYMBOL(wl_proxy_destroy)
|
|
||||||
const struct wl_interface* ffwl_output_interface;
|
const struct wl_interface* ffwl_output_interface;
|
||||||
struct wl_output_listener output_listener;
|
|
||||||
} WaylandData;
|
} WaylandData;
|
||||||
|
|
||||||
static void waylandGlobalRemoveListener(void* data, struct wl_registry* wl_registry, uint32_t name){
|
static void waylandDetectWM(int fd, FFDisplayServerResult* result)
|
||||||
FF_UNUSED(data, wl_registry, name);
|
{
|
||||||
|
struct ucred ucred;
|
||||||
|
socklen_t len = sizeof(struct ucred);
|
||||||
|
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FFstrbuf procPath;
|
||||||
|
ffStrbufInit(&procPath);
|
||||||
|
ffStrbufAppendF(&procPath, "/proc/%d/cmdline", ucred.pid); //We check the cmdline for the process name, because it is not trimmed.
|
||||||
|
ffReadFileBuffer(procPath.chars, &result->wmProcessName);
|
||||||
|
ffStrbufSubstrBeforeFirstC(&result->wmProcessName, '\0'); //Trim the arguments
|
||||||
|
ffStrbufSubstrAfterLastC(&result->wmProcessName, '/'); //Trim the path
|
||||||
|
ffStrbufDestroy(&procPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void waylandOutputGeometryListener(void* data, struct wl_output* wl_output, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char* make, const char* model, int32_t transform)
|
static void stubListener(void* data, ...)
|
||||||
{
|
{
|
||||||
FF_UNUSED(data, wl_output, x, y, physical_width, physical_height, subpixel, make, model, transform);
|
(void) data;
|
||||||
}
|
|
||||||
|
|
||||||
static void waylandOutputDoneListener(void* data, struct wl_output* wl_output)
|
|
||||||
{
|
|
||||||
FF_UNUSED(data, wl_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void waylandOutputScaleListener(void* data, struct wl_output* wl_output, int32_t factor)
|
|
||||||
{
|
|
||||||
FF_UNUSED(data, wl_output, factor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void waylandOutputModeListener(void* data, struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate)
|
static void waylandOutputModeListener(void* data, struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate)
|
||||||
{
|
{
|
||||||
if(!(flags & WL_OUTPUT_MODE_CURRENT))
|
FF_UNUSED(output);
|
||||||
return;
|
|
||||||
|
|
||||||
WaylandData* wldata = (WaylandData*) data;
|
WaylandData* wldata = data;
|
||||||
|
|
||||||
wldata->ffwl_proxy_destroy((struct wl_proxy*) output);
|
if(!(flags & WL_OUTPUT_MODE_CURRENT) || width <= 0 || height <= 0)
|
||||||
|
|
||||||
if(width <= 0 || height <= 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
@@ -61,92 +64,106 @@ static void waylandOutputModeListener(void* data, struct wl_output* output, uint
|
|||||||
|
|
||||||
static void waylandGlobalAddListener(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
|
static void waylandGlobalAddListener(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
|
||||||
{
|
{
|
||||||
if(strcmp(interface, "wl_output") == 0)
|
WaylandData* wldata = data;
|
||||||
{
|
|
||||||
WaylandData* wldata = (WaylandData*) data;
|
|
||||||
|
|
||||||
struct wl_output* output = (struct wl_output*) wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy *) registry, WL_REGISTRY_BIND, wldata->ffwl_output_interface, version, name, wldata->ffwl_output_interface->name, version, NULL);
|
if(strcmp(interface, wldata->ffwl_output_interface->name) == 0)
|
||||||
|
{
|
||||||
|
struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, wldata->ffwl_output_interface, version, name, wldata->ffwl_output_interface->name, version, NULL);
|
||||||
if(output == NULL)
|
if(output == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wldata->ffwl_proxy_add_listener((struct wl_proxy*) output, (void(**)(void)) &wldata->output_listener, data);
|
//Needs to be static, because the scope of the function will already be lost when calling the listener
|
||||||
|
static struct wl_output_listener outputListener = {
|
||||||
|
.mode = waylandOutputModeListener,
|
||||||
|
.geometry = (void*) stubListener,
|
||||||
|
|
||||||
|
//https://lists.freedesktop.org/archives/wayland-devel/2013-July/010278.html
|
||||||
|
#if WAYLAND_VERSION_MINOR >= 2
|
||||||
|
.done = (void*) stubListener,
|
||||||
|
.scale = (void*) stubListener,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//https://lists.freedesktop.org/archives/wayland-devel/2021-December/042064.html
|
||||||
|
#if WAYLAND_VERSION_MINOR >= 20
|
||||||
|
.name = (void*) stubListener,
|
||||||
|
.description = (void*) stubListener,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
wldata->ffwl_proxy_add_listener(output, (void(**)(void)) &outputListener, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* result)
|
bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
|
||||||
{
|
{
|
||||||
if(getenv("XDG_RUNTIME_DIR") == NULL)
|
FF_LIBRARY_LOAD(wayland, instance->config.libWayland, false, "libwayland-client.so", 1)
|
||||||
return;
|
|
||||||
|
|
||||||
FF_LIBRARY_LOAD(wayland, instance->config.libWayland, , "libwayland-client.so", 1)
|
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_connect, false)
|
||||||
|
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_get_fd, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_connect,)
|
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_dispatch, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_dispatch,)
|
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_roundtrip, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_roundtrip,)
|
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_proxy_marshal_constructor, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_proxy_marshal_constructor,)
|
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_disconnect, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_disconnect,)
|
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_registry_interface, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_registry_interface,)
|
|
||||||
|
|
||||||
WaylandData data;
|
WaylandData data;
|
||||||
|
|
||||||
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_marshal_constructor_versioned, wl_proxy_marshal_constructor_versioned,)
|
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_marshal_constructor_versioned, wl_proxy_marshal_constructor_versioned, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_add_listener, wl_proxy_add_listener,)
|
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_add_listener, wl_proxy_add_listener, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_output_interface, wl_output_interface,)
|
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_output_interface, wl_output_interface, false)
|
||||||
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_destroy, wl_proxy_destroy,)
|
|
||||||
|
|
||||||
struct wl_display* display = ffwl_display_connect(NULL);
|
struct wl_display* display = ffwl_display_connect(NULL);
|
||||||
if(display == NULL)
|
if(display == NULL)
|
||||||
{
|
{
|
||||||
dlclose(wayland);
|
dlclose(wayland);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_registry* registry = (struct wl_registry*) ffwl_proxy_marshal_constructor((struct wl_proxy*) display, WL_DISPLAY_GET_REGISTRY, ffwl_registry_interface, NULL);
|
waylandDetectWM(ffwl_display_get_fd(display), result);
|
||||||
|
|
||||||
|
struct wl_proxy* registry = ffwl_proxy_marshal_constructor((struct wl_proxy*) display, WL_DISPLAY_GET_REGISTRY, ffwl_registry_interface, NULL);
|
||||||
if(registry == NULL)
|
if(registry == NULL)
|
||||||
{
|
{
|
||||||
ffwl_display_disconnect(display);
|
ffwl_display_disconnect(display);
|
||||||
dlclose(wayland);
|
dlclose(wayland);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.instance = instance;
|
|
||||||
data.results = &result->resolutions;
|
data.results = &result->resolutions;
|
||||||
|
|
||||||
struct wl_registry_listener regestry_listener;
|
struct wl_registry_listener registry_listener = {
|
||||||
regestry_listener.global = waylandGlobalAddListener;
|
.global = waylandGlobalAddListener,
|
||||||
regestry_listener.global_remove = waylandGlobalRemoveListener;
|
.global_remove = (void*) stubListener
|
||||||
|
};
|
||||||
|
|
||||||
data.output_listener.geometry = waylandOutputGeometryListener;
|
data.ffwl_proxy_add_listener(registry, (void(**)(void)) ®istry_listener, &data);
|
||||||
data.output_listener.mode = waylandOutputModeListener;
|
|
||||||
data.output_listener.done = waylandOutputDoneListener;
|
|
||||||
data.output_listener.scale = waylandOutputScaleListener;
|
|
||||||
|
|
||||||
data.ffwl_proxy_add_listener((struct wl_proxy*) registry, (void(**)(void)) ®estry_listener, &data);
|
|
||||||
ffwl_display_dispatch(display);
|
ffwl_display_dispatch(display);
|
||||||
ffwl_display_roundtrip(display);
|
ffwl_display_roundtrip(display);
|
||||||
|
|
||||||
data.ffwl_proxy_destroy((struct wl_proxy*) registry);
|
ffwl_display_disconnect(display); //This will also destroy our wl_registry and wl_output proxies
|
||||||
ffwl_display_disconnect(display);
|
|
||||||
dlclose(wayland);
|
dlclose(wayland);
|
||||||
|
|
||||||
//We successfully connected to wayland and detected the resolution.
|
//We successfully connected to wayland and detected the resolution.
|
||||||
//So we can set set the session type to wayland.
|
//So we can set set the session type to wayland.
|
||||||
//This is used as an indicator that we are running wayland by the x11 backends.
|
//This is used as an indicator that we are running wayland by the x11 backends.
|
||||||
ffStrbufSetS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND);
|
ffStrbufSetS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#else
|
|
||||||
|
|
||||||
void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* result)
|
void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* result)
|
||||||
{
|
{
|
||||||
FF_UNUSED(instance);
|
|
||||||
|
|
||||||
//We try to detect wayland already here, so the x11 methods only to resolution detection.
|
|
||||||
|
|
||||||
//Wayland requires this to be set
|
//Wayland requires this to be set
|
||||||
if(getenv("XDG_RUNTIME_DIR") == NULL)
|
if(getenv("XDG_RUNTIME_DIR") == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef FF_HAVE_WAYLAND
|
||||||
|
if(detectWayland(instance, result))
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
FF_UNUSED(instance);
|
||||||
|
#endif
|
||||||
|
|
||||||
const char* xdgSessionType = getenv("XDG_SESSION_TYPE");
|
const char* xdgSessionType = getenv("XDG_SESSION_TYPE");
|
||||||
|
|
||||||
//If XDG_SESSION_TYPE is set, and doesn't contain "wayland", we are probably not running in a wayland session.
|
//If XDG_SESSION_TYPE is set, and doesn't contain "wayland", we are probably not running in a wayland session.
|
||||||
@@ -158,9 +175,7 @@ void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* resul
|
|||||||
if(xdgSessionType == NULL && getenv("WAYLAND_DISPLAY") == NULL && getenv("WAYLAND_SOCKET") == NULL)
|
if(xdgSessionType == NULL && getenv("WAYLAND_DISPLAY") == NULL && getenv("WAYLAND_SOCKET") == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//We are probably running a wayland compositor at this point, but fastfetch was compiled without the required library.
|
//We are probably running a wayland compositor at this point,
|
||||||
//Set the protocol name and use DRM for resolution detection.
|
//but fastfetch was compiled without the required library, or loading the library failed.
|
||||||
ffStrbufSetS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND);
|
ffStrbufSetS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
#include "displayServer.h"
|
#include "displayServer.h"
|
||||||
#include <dirent.h>
|
#include "common/io.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
#include "common/processing.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
static const char* parseEnv()
|
static const char* parseEnv()
|
||||||
{
|
{
|
||||||
@@ -40,6 +47,11 @@ static const char* parseEnv()
|
|||||||
if(getenv("TDE_FULL_SESSION") != NULL)
|
if(getenv("TDE_FULL_SESSION") != NULL)
|
||||||
return "Trinity";
|
return "Trinity";
|
||||||
|
|
||||||
|
if(
|
||||||
|
getenv("WAYLAND_DISPLAY") != NULL &&
|
||||||
|
ffFileExists("/mnt/wslg/", S_IFDIR)
|
||||||
|
) return "WSLg";
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,8 +60,23 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* proce
|
|||||||
if(!ffStrSet(processName))
|
if(!ffStrSet(processName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(strcasecmp(processName, "kwin_wayland") == 0 || strcasecmp(processName, "kwin_x11") == 0 || strcasecmp(processName, "kwin") == 0)
|
if(
|
||||||
ffStrbufSetS(&result->wmPrettyName, "KWin");
|
strcasecmp(processName, "kwin_wayland") == 0 ||
|
||||||
|
strcasecmp(processName, "kwin_wayland_wrapper") == 0 ||
|
||||||
|
strcasecmp(processName, "kwin_x11") == 0 ||
|
||||||
|
strcasecmp(processName, "kwin_x11_wrapper") == 0 ||
|
||||||
|
strcasecmp(processName, "kwin") == 0
|
||||||
|
) ffStrbufSetS(&result->wmPrettyName, "KWin");
|
||||||
|
else if(
|
||||||
|
strcasecmp(processName, "gnome-shell") == 0 ||
|
||||||
|
strcasecmp(processName, "gnome shell") == 0 ||
|
||||||
|
strcasecmp(processName, "gnome-session-binary") == 0 ||
|
||||||
|
strcasecmp(processName, "Mutter") == 0
|
||||||
|
) ffStrbufSetS(&result->wmPrettyName, "Mutter");
|
||||||
|
else if(
|
||||||
|
strcasecmp(processName, "cinnamon-session") == 0 ||
|
||||||
|
strcasecmp(processName, "Muffin") == 0
|
||||||
|
) ffStrbufSetS(&result->wmPrettyName, "Muffin");
|
||||||
else if(strcasecmp(processName, "sway") == 0)
|
else if(strcasecmp(processName, "sway") == 0)
|
||||||
ffStrbufSetS(&result->wmPrettyName, "Sway");
|
ffStrbufSetS(&result->wmPrettyName, "Sway");
|
||||||
else if(strcasecmp(processName, "weston") == 0)
|
else if(strcasecmp(processName, "weston") == 0)
|
||||||
@@ -64,10 +91,6 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* proce
|
|||||||
ffStrbufSetS(&result->wmPrettyName, "Marco");
|
ffStrbufSetS(&result->wmPrettyName, "Marco");
|
||||||
else if(strcasecmp(processName, "xmonad") == 0)
|
else if(strcasecmp(processName, "xmonad") == 0)
|
||||||
ffStrbufSetS(&result->wmPrettyName, "XMonad");
|
ffStrbufSetS(&result->wmPrettyName, "XMonad");
|
||||||
else if(strcasecmp(processName, "gnome-session-binary") == 0 || strcasecmp(processName, "Mutter") == 0)
|
|
||||||
ffStrbufSetS(&result->wmPrettyName, "Mutter");
|
|
||||||
else if(strcasecmp(processName, "cinnamon-session") == 0 || strcasecmp(processName, "Muffin") == 0)
|
|
||||||
ffStrbufSetS(&result->wmPrettyName, "Muffin");
|
|
||||||
else if( // WMs where the pretty name matches the process name
|
else if( // WMs where the pretty name matches the process name
|
||||||
strcasecmp(processName, "dwm") == 0 ||
|
strcasecmp(processName, "dwm") == 0 ||
|
||||||
strcasecmp(processName, "bspwm") == 0 ||
|
strcasecmp(processName, "bspwm") == 0 ||
|
||||||
@@ -329,7 +352,7 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re
|
|||||||
|
|
||||||
//Don't check for processes not owend by the current user.
|
//Don't check for processes not owend by the current user.
|
||||||
ffStrbufAppendS(&procPath, "/loginuid");
|
ffStrbufAppendS(&procPath, "/loginuid");
|
||||||
ffGetFileContent(procPath.chars, &loginuid);
|
ffReadFileBuffer(procPath.chars, &loginuid);
|
||||||
if(ffStrbufComp(&userID, &loginuid) != 0)
|
if(ffStrbufComp(&userID, &loginuid) != 0)
|
||||||
{
|
{
|
||||||
ffStrbufSubstrBefore(&procPath, procPathLength);
|
ffStrbufSubstrBefore(&procPath, procPathLength);
|
||||||
@@ -340,7 +363,7 @@ static void getFromProcDir(const FFinstance* instance, FFDisplayServerResult* re
|
|||||||
|
|
||||||
//We check the cmdline for the process name, because it is not trimmed.
|
//We check the cmdline for the process name, because it is not trimmed.
|
||||||
ffStrbufAppendS(&procPath, "/cmdline");
|
ffStrbufAppendS(&procPath, "/cmdline");
|
||||||
ffGetFileContent(procPath.chars, &processName);
|
ffReadFileBuffer(procPath.chars, &processName);
|
||||||
ffStrbufSubstrBeforeFirstC(&processName, '\0'); //Trim the arguments
|
ffStrbufSubstrBeforeFirstC(&processName, '\0'); //Trim the arguments
|
||||||
ffStrbufSubstrAfterLastC(&processName, '/');
|
ffStrbufSubstrAfterLastC(&processName, '/');
|
||||||
|
|
||||||
@@ -371,7 +394,7 @@ void ffdsDetectWMDE(const FFinstance* instance, FFDisplayServerResult* result)
|
|||||||
getWMProtocolNameFromEnv(result);
|
getWMProtocolNameFromEnv(result);
|
||||||
|
|
||||||
//We don't want to detect anything in TTY
|
//We don't want to detect anything in TTY
|
||||||
//This can't happen if a X11 connection succeeded, so we don't need to clear wmProcessName
|
//This can't happen if a connection succeeded, so we don't need to clear wmProcessName
|
||||||
if(ffStrbufIgnCaseCompS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_TTY) == 0)
|
if(ffStrbufIgnCaseCompS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_TTY) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#include "displayServer.h"
|
#include "displayServer.h"
|
||||||
|
|
||||||
#ifdef FF_HAVE_XCB
|
#ifdef FF_HAVE_XCB
|
||||||
#include <xcb/xcb.h>
|
#include "common/library.h"
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
typedef struct XcbPropertyData
|
typedef struct XcbPropertyData
|
||||||
{
|
{
|
||||||
@@ -60,7 +62,7 @@ static void* xcbGetProperty(XcbPropertyData* data, xcb_connection_t* connection,
|
|||||||
|
|
||||||
static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connection, xcb_window_t rootWindow, FFDisplayServerResult* result)
|
static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connection, xcb_window_t rootWindow, FFDisplayServerResult* result)
|
||||||
{
|
{
|
||||||
if(result->wmProcessName.length > 0)
|
if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xcb_window_t* wmWindow = (xcb_window_t*) xcbGetProperty(data, connection, rootWindow, "_NET_SUPPORTING_WM_CHECK");
|
xcb_window_t* wmWindow = (xcb_window_t*) xcbGetProperty(data, connection, rootWindow, "_NET_SUPPORTING_WM_CHECK");
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "displayServer.h"
|
#include "displayServer.h"
|
||||||
|
|
||||||
#ifdef FF_HAVE_X11
|
#ifdef FF_HAVE_X11
|
||||||
|
#include "common/library.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
typedef struct X11PropertyData
|
typedef struct X11PropertyData
|
||||||
@@ -34,7 +36,7 @@ static unsigned char* x11GetProperty(X11PropertyData* data, Display* display, Wi
|
|||||||
|
|
||||||
static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDisplayServerResult* result)
|
static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDisplayServerResult* result)
|
||||||
{
|
{
|
||||||
if(result->wmProcessName.length > 0)
|
if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Window* wmWindow = (Window*) x11GetProperty(data, display, DefaultRootWindow(display), "_NET_SUPPORTING_WM_CHECK");
|
Window* wmWindow = (Window*) x11GetProperty(data, display, DefaultRootWindow(display), "_NET_SUPPORTING_WM_CHECK");
|
||||||
|
|||||||
+34
-29
@@ -1,4 +1,8 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/gtk.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
#include "common/settings.h"
|
||||||
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
@@ -10,7 +14,7 @@ static inline bool allPropertiesSet(FFGTKResult* result)
|
|||||||
result->font.length > 0;
|
result->font.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void applyGTKDConfSettings(FFGTKResult* result, const char* themeName, const char* iconsName, const char* fontName, const char* cursorTheme, int cursorSize)
|
static inline void applyGTKSettings(FFGTKResult* result, const char* themeName, const char* iconsName, const char* fontName, const char* cursorTheme, int cursorSize)
|
||||||
{
|
{
|
||||||
if(result->theme.length == 0)
|
if(result->theme.length == 0)
|
||||||
ffStrbufAppendS(&result->theme, themeName);
|
ffStrbufAppendS(&result->theme, themeName);
|
||||||
@@ -28,7 +32,7 @@ static inline void applyGTKDConfSettings(FFGTKResult* result, const char* themeN
|
|||||||
ffStrbufAppendF(&result->cursorSize, "%i", cursorSize);
|
ffStrbufAppendF(&result->cursorSize, "%i", cursorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
static void detectGTKFromSettings(FFinstance* instance, FFGTKResult* result)
|
||||||
{
|
{
|
||||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
@@ -45,7 +49,7 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
|||||||
if(init)
|
if(init)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
applyGTKDConfSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
|
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +57,15 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
|||||||
|
|
||||||
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
||||||
|
|
||||||
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0)
|
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Xfce") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Xfce4") == 0)
|
||||||
|
{
|
||||||
|
themeName = ffSettingsGetXFConf(instance, "xsettings", "/Net/ThemeName", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
|
iconsName = ffSettingsGetXFConf(instance, "xsettings", "/Net/IconThemeName", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
|
fontName = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/FontName", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
|
cursorTheme = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeName", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
|
cursorSize = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue;
|
||||||
|
}
|
||||||
|
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0)
|
||||||
{
|
{
|
||||||
themeName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
|
themeName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
iconsName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
|
iconsName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
@@ -69,7 +81,7 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
|||||||
cursorTheme = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
|
cursorTheme = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
cursorSize = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
|
cursorSize = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
|
||||||
}
|
}
|
||||||
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Gnome") == 0)
|
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Gnome") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Unity") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Budgie") == 0)
|
||||||
{
|
{
|
||||||
themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
|
themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
|
iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
|
||||||
@@ -79,7 +91,7 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
applyGTKDConfSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
|
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result)
|
static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result)
|
||||||
@@ -95,15 +107,10 @@ static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result)
|
|||||||
|
|
||||||
static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFGTKResult* result)
|
static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFGTKResult* result)
|
||||||
{
|
{
|
||||||
//In case of an empty env variable
|
|
||||||
ffStrbufTrim(configDir, ' ');
|
|
||||||
if(configDir->length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
uint32_t configDirLength = configDir->length;
|
uint32_t configDirLength = configDir->length;
|
||||||
|
|
||||||
// <configdir>/gtk-<version>.0/settings.ini
|
// <configdir>/gtk-<version>.0/settings.ini
|
||||||
ffStrbufAppendS(configDir, "/gtk-");
|
ffStrbufAppendS(configDir, "gtk-");
|
||||||
ffStrbufAppendS(configDir, version);
|
ffStrbufAppendS(configDir, version);
|
||||||
ffStrbufAppendS(configDir, ".0/settings.ini");
|
ffStrbufAppendS(configDir, ".0/settings.ini");
|
||||||
detectGTKFromConfigFile(configDir->chars, result);
|
detectGTKFromConfigFile(configDir->chars, result);
|
||||||
@@ -112,7 +119,7 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// <configdir>/gtk-<version>.0/gtkrc
|
// <configdir>/gtk-<version>.0/gtkrc
|
||||||
ffStrbufAppendS(configDir, "/gtk-");
|
ffStrbufAppendS(configDir, "gtk-");
|
||||||
ffStrbufAppendS(configDir, version);
|
ffStrbufAppendS(configDir, version);
|
||||||
ffStrbufAppendS(configDir, ".0/gtkrc");
|
ffStrbufAppendS(configDir, ".0/gtkrc");
|
||||||
detectGTKFromConfigFile(configDir->chars, result);
|
detectGTKFromConfigFile(configDir->chars, result);
|
||||||
@@ -121,7 +128,7 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// <configdir>/gtkrc-<version>.0
|
// <configdir>/gtkrc-<version>.0
|
||||||
ffStrbufAppendS(configDir, "/gtkrc-");
|
ffStrbufAppendS(configDir, "gtkrc-");
|
||||||
ffStrbufAppendS(configDir, version);
|
ffStrbufAppendS(configDir, version);
|
||||||
ffStrbufAppendS(configDir, ".0");
|
ffStrbufAppendS(configDir, ".0");
|
||||||
detectGTKFromConfigFile(configDir->chars, result);
|
detectGTKFromConfigFile(configDir->chars, result);
|
||||||
@@ -130,7 +137,7 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// <configdir>/.gtkrc-<version>.0
|
// <configdir>/.gtkrc-<version>.0
|
||||||
ffStrbufAppendS(configDir, "/.gtkrc-");
|
ffStrbufAppendS(configDir, ".gtkrc-");
|
||||||
ffStrbufAppendS(configDir, version);
|
ffStrbufAppendS(configDir, version);
|
||||||
ffStrbufAppendS(configDir, ".0");
|
ffStrbufAppendS(configDir, ".0");
|
||||||
detectGTKFromConfigFile(configDir->chars, result);
|
detectGTKFromConfigFile(configDir->chars, result);
|
||||||
@@ -139,27 +146,25 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
|
|||||||
|
|
||||||
static void detectGTK(FFinstance* instance, const char* version, FFGTKResult* result)
|
static void detectGTK(FFinstance* instance, const char* version, FFGTKResult* result)
|
||||||
{
|
{
|
||||||
|
//Mate, Cinnamon and Gnome use dconf to save theme config
|
||||||
|
//On other DEs, this will do nothing
|
||||||
|
detectGTKFromSettings(instance, result);
|
||||||
|
if(allPropertiesSet(result))
|
||||||
|
return;
|
||||||
|
|
||||||
//We need to do this because we use multiple threads on configDirs
|
//We need to do this because we use multiple threads on configDirs
|
||||||
FFstrbuf baseDirCopy;
|
FFstrbuf baseDir;
|
||||||
ffStrbufInitA(&baseDirCopy, 64);
|
ffStrbufInitA(&baseDir, 64);
|
||||||
|
|
||||||
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
||||||
{
|
{
|
||||||
FFstrbuf* baseDir = (FFstrbuf*) ffListGet(&instance->state.configDirs, i);
|
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
|
||||||
ffStrbufSet(&baseDirCopy, baseDir);
|
detectGTKFromConfigDir(&baseDir, version, result);
|
||||||
detectGTKFromConfigDir(&baseDirCopy, version, result);
|
|
||||||
if(allPropertiesSet(result))
|
if(allPropertiesSet(result))
|
||||||
{
|
break;
|
||||||
ffStrbufDestroy(&baseDirCopy);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ffStrbufDestroy(&baseDirCopy);
|
ffStrbufDestroy(&baseDir);
|
||||||
|
|
||||||
//Mate, Cinnamon and Gnome use dconf to save theme config
|
|
||||||
//On other DEs, this will do nothing
|
|
||||||
detectGTKFromDConf(instance, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FF_DETECT_GTK_IMPL(version) \
|
#define FF_DETECT_GTK_IMPL(version) \
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_gtk
|
||||||
|
#define FF_INCLUDED_detection_gtk
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFGTKResult
|
||||||
|
{
|
||||||
|
FFstrbuf theme;
|
||||||
|
FFstrbuf icons;
|
||||||
|
FFstrbuf font;
|
||||||
|
FFstrbuf cursor;
|
||||||
|
FFstrbuf cursorSize;
|
||||||
|
} FFGTKResult;
|
||||||
|
|
||||||
|
const FFGTKResult* ffDetectGTK2(FFinstance* instance);
|
||||||
|
const FFGTKResult* ffDetectGTK4(FFinstance* instance);
|
||||||
|
const FFGTKResult* ffDetectGTK3(FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/media.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@@ -7,6 +8,8 @@
|
|||||||
#define FF_DBUS_TIMEOUT_MILLISECONDS 35
|
#define FF_DBUS_TIMEOUT_MILLISECONDS 35
|
||||||
|
|
||||||
#ifdef FF_HAVE_DBUS
|
#ifdef FF_HAVE_DBUS
|
||||||
|
#include "common/library.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
#define FF_DBUS_ITER_CONTINUE(iterator) \
|
#define FF_DBUS_ITER_CONTINUE(iterator) \
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_media
|
||||||
|
#define FF_INCLUDED_detection_media
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFMediaResult
|
||||||
|
{
|
||||||
|
FFstrbuf busNameShort; //e.g. plasma-browser-integration
|
||||||
|
FFstrbuf player; // e.g. Google Chrome
|
||||||
|
FFstrbuf song;
|
||||||
|
FFstrbuf artist;
|
||||||
|
FFstrbuf album;
|
||||||
|
FFstrbuf url;
|
||||||
|
} FFMediaResult;
|
||||||
|
|
||||||
|
const FFMediaResult* ffDetectMedia(FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
+7
-1
@@ -1,9 +1,15 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/os.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#if !defined(__ANDROID__)
|
#if __ANDROID__
|
||||||
|
#include "common/settings.h"
|
||||||
|
#else
|
||||||
|
|
||||||
static bool parseFile(const char* fileName, FFOSResult* result)
|
static bool parseFile(const char* fileName, FFOSResult* result)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_os
|
||||||
|
#define FF_INCLUDED_detection_os
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFOSResult
|
||||||
|
{
|
||||||
|
FFstrbuf systemName;
|
||||||
|
FFstrbuf name;
|
||||||
|
FFstrbuf prettyName;
|
||||||
|
FFstrbuf id;
|
||||||
|
FFstrbuf idLike;
|
||||||
|
FFstrbuf variant;
|
||||||
|
FFstrbuf variantID;
|
||||||
|
FFstrbuf version;
|
||||||
|
FFstrbuf versionID;
|
||||||
|
FFstrbuf codename;
|
||||||
|
FFstrbuf buildID;
|
||||||
|
FFstrbuf architecture;
|
||||||
|
} FFOSResult;
|
||||||
|
|
||||||
|
const FFOSResult* ffDetectOS(const FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,8 +1,21 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/qt.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
static inline bool allValuesSet(const FFQtResult* result)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
result->widgetStyle.length > 0 &&
|
||||||
|
result->colorScheme.length > 0 &&
|
||||||
|
result->icons.length > 0 &&
|
||||||
|
result->font.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum PlasmaCategory
|
typedef enum PlasmaCategory
|
||||||
{
|
{
|
||||||
PLASMA_CATEGORY_GENERAL,
|
PLASMA_CATEGORY_GENERAL,
|
||||||
@@ -11,9 +24,9 @@ typedef enum PlasmaCategory
|
|||||||
PLASMA_CATEGORY_OTHER
|
PLASMA_CATEGORY_OTHER
|
||||||
} PlasmaCategory;
|
} PlasmaCategory;
|
||||||
|
|
||||||
static bool detectFromConfigFile(const FFstrbuf* filename, FFPlasmaResult* result)
|
static bool detectPlasmaFromFile(const char* filename, FFQtResult* result)
|
||||||
{
|
{
|
||||||
FILE* kdeglobals = fopen(filename->chars, "r");
|
FILE* kdeglobals = fopen(filename, "r");
|
||||||
if(kdeglobals == NULL)
|
if(kdeglobals == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -67,10 +80,62 @@ static bool detectFromConfigFile(const FFstrbuf* filename, FFPlasmaResult* resul
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FFPlasmaResult* ffDetectPlasma(FFinstance* instance)
|
static void detectPlasma(const FFinstance* instance, FFQtResult* result)
|
||||||
{
|
{
|
||||||
|
bool foundAFile = false;
|
||||||
|
|
||||||
|
//We need to do this because we use multiple threads on configDirs
|
||||||
|
FFstrbuf baseDir;
|
||||||
|
ffStrbufInitA(&baseDir, 64);
|
||||||
|
|
||||||
|
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
||||||
|
{
|
||||||
|
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
|
||||||
|
ffStrbufAppendS(&baseDir, "kdeglobals");
|
||||||
|
|
||||||
|
if(detectPlasmaFromFile(baseDir.chars, result))
|
||||||
|
foundAFile = true;
|
||||||
|
|
||||||
|
if(allValuesSet(result))
|
||||||
|
{
|
||||||
|
ffStrbufDestroy(&baseDir);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ffStrbufDestroy(&baseDir);
|
||||||
|
if(!foundAFile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//In Plasma the default value is never set in the config file, but the whole key-value is discarded.
|
||||||
|
///We must set these values by our self if the file exists (it always does here)
|
||||||
|
if(result->widgetStyle.length == 0)
|
||||||
|
ffStrbufAppendS(&result->widgetStyle, "Breeze");
|
||||||
|
|
||||||
|
if(result->colorScheme.length == 0)
|
||||||
|
ffStrbufAppendS(&result->colorScheme, "BreezeLight");
|
||||||
|
|
||||||
|
if(result->icons.length == 0)
|
||||||
|
ffStrbufAppendS(&result->icons, "Breeze");
|
||||||
|
|
||||||
|
if(result->font.length == 0)
|
||||||
|
ffStrbufAppendS(&result->font, "Noto Sans, 10");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void detectLXQt(const FFinstance* instance, FFQtResult* result)
|
||||||
|
{
|
||||||
|
ffParsePropFileConfigValues(instance, "lxqt/lxqt.conf", 3, (FFpropquery[]) {
|
||||||
|
{"style = ", &result->widgetStyle},
|
||||||
|
{"icon_theme = ", &result->icons},
|
||||||
|
{"font = ", &result->font}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const FFQtResult* ffDetectQt(FFinstance* instance)
|
||||||
|
{
|
||||||
|
static FFQtResult result;
|
||||||
|
|
||||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static FFPlasmaResult result;
|
|
||||||
static bool init = false;
|
static bool init = false;
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
if(init)
|
if(init)
|
||||||
@@ -86,57 +151,11 @@ const FFPlasmaResult* ffDetectPlasma(FFinstance* instance)
|
|||||||
ffStrbufInit(&result.font);
|
ffStrbufInit(&result.font);
|
||||||
|
|
||||||
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
||||||
if(ffStrbufIgnCaseCompS(&wmde->deProcessName, "plasmashell") != 0)
|
|
||||||
{
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
return &result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool foundAFile = false;
|
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "KDE Plasma") == 0)
|
||||||
|
detectPlasma(instance, &result);
|
||||||
//We need to do this because we use multiple threads on configDirs
|
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "LXQt") == 0)
|
||||||
FFstrbuf baseDirCopy;
|
detectLXQt(instance, &result);
|
||||||
ffStrbufInitA(&baseDirCopy, 64);
|
|
||||||
|
|
||||||
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
|
||||||
{
|
|
||||||
FFstrbuf* baseDir = (FFstrbuf*) ffListGet(&instance->state.configDirs, i);
|
|
||||||
|
|
||||||
ffStrbufSet(&baseDirCopy, baseDir);
|
|
||||||
ffStrbufAppendS(&baseDirCopy, "/kdeglobals");
|
|
||||||
|
|
||||||
if(detectFromConfigFile(&baseDirCopy, &result))
|
|
||||||
foundAFile = true;
|
|
||||||
|
|
||||||
if(
|
|
||||||
result.widgetStyle.length > 0 &&
|
|
||||||
result.colorScheme.length > 0 &&
|
|
||||||
result.icons.length > 0 &&
|
|
||||||
result.font.length > 0
|
|
||||||
) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ffStrbufDestroy(&baseDirCopy);
|
|
||||||
|
|
||||||
if(!foundAFile)
|
|
||||||
{
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
return &result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//In Plasma the default value is never set in the config file, but the whole key-value is discarded.
|
|
||||||
///We must set these values by our self if the file exists (it always does here)
|
|
||||||
if(result.widgetStyle.length == 0)
|
|
||||||
ffStrbufAppendS(&result.widgetStyle, "Breeze");
|
|
||||||
|
|
||||||
if(result.colorScheme.length == 0)
|
|
||||||
ffStrbufAppendS(&result.colorScheme, "BreezeLight");
|
|
||||||
|
|
||||||
if(result.icons.length == 0)
|
|
||||||
ffStrbufAppendS(&result.icons, "Breeze");
|
|
||||||
|
|
||||||
if(result.font.length == 0)
|
|
||||||
ffStrbufAppendS(&result.font, "Noto Sans, 10");
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
return &result;
|
return &result;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_qt
|
||||||
|
#define FF_INCLUDED_detection_qt
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFQtResult
|
||||||
|
{
|
||||||
|
FFstrbuf widgetStyle;
|
||||||
|
FFstrbuf colorScheme;
|
||||||
|
FFstrbuf icons;
|
||||||
|
FFstrbuf font;
|
||||||
|
} FFQtResult;
|
||||||
|
|
||||||
|
const FFQtResult* ffDetectQt(FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
+26
-17
@@ -1,16 +1,15 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/temps.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static bool isTempFile(const char* name)
|
static bool isTempFile(const char* name)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
name[0] == 't' &&
|
strncmp(name, "temp", 4) == 0 &&
|
||||||
name[1] == 'e' &&
|
|
||||||
name[2] == 'm' &&
|
|
||||||
name[3] == 'p' &&
|
|
||||||
name[4] >= '0' &&
|
name[4] >= '0' &&
|
||||||
name[4] <= '9' &&
|
name[4] <= '9' &&
|
||||||
strncmp(name + 5, "_input", 6) == 0;
|
strncmp(name + 5, "_input", 6) == 0;
|
||||||
@@ -23,30 +22,42 @@ static bool parseHwmonDir(FFstrbuf* dir, FFTempValue* value)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32_t dirLength = dir->length;
|
uint32_t dirLength = dir->length;
|
||||||
|
value->value = 0.0 / 0.0; //use NaN as error value
|
||||||
|
|
||||||
|
FFstrbuf valueString;
|
||||||
|
ffStrbufInit(&valueString);
|
||||||
|
|
||||||
struct dirent* dirent;
|
struct dirent* dirent;
|
||||||
while((dirent = readdir(dirp)) != NULL)
|
while((dirent = readdir(dirp)) != NULL)
|
||||||
{
|
{
|
||||||
if(isTempFile(dirent->d_name))
|
if(!isTempFile(dirent->d_name))
|
||||||
{
|
continue;
|
||||||
ffStrbufAppendS(dir, dirent->d_name);
|
|
||||||
ffGetFileContent(dir->chars, &value->value);
|
ffStrbufAppendS(dir, dirent->d_name);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffReadFileBuffer(dir->chars, &valueString);
|
||||||
break;
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
}
|
|
||||||
|
//ffStrbufToDouble() returns NaN if the string couldn't be parsed
|
||||||
|
value->value = ffStrbufToDouble(&valueString);
|
||||||
|
if(value->value != value->value)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
value->value /= 1000.0; //millidegrees to degrees
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
|
ffStrbufDestroy(&valueString);
|
||||||
|
|
||||||
if(value->value.length == 0)
|
if(value->value != value->value)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ffStrbufAppendS(dir, "name");
|
ffStrbufAppendS(dir, "name");
|
||||||
ffGetFileContent(dir->chars, &value->name);
|
ffReadFileBuffer(dir->chars, &value->name);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
|
|
||||||
ffStrbufAppendS(dir, "device/class");
|
ffStrbufAppendS(dir, "device/class");
|
||||||
ffGetFileContent(dir->chars, &value->deviceClass);
|
ffReadFileBuffer(dir->chars, &value->deviceClass);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
|
|
||||||
return value->name.length > 0 || value->deviceClass.length > 0;
|
return value->name.length > 0 || value->deviceClass.length > 0;
|
||||||
@@ -95,12 +106,10 @@ const FFTempsResult* ffDetectTemps(const FFinstance* instance)
|
|||||||
FFTempValue* temp = ffListAdd(&result.values);
|
FFTempValue* temp = ffListAdd(&result.values);
|
||||||
ffStrbufInit(&temp->name);
|
ffStrbufInit(&temp->name);
|
||||||
ffStrbufInit(&temp->deviceClass);
|
ffStrbufInit(&temp->deviceClass);
|
||||||
ffStrbufInit(&temp->value);
|
|
||||||
if(!parseHwmonDir(&baseDir, temp))
|
if(!parseHwmonDir(&baseDir, temp))
|
||||||
{
|
{
|
||||||
ffStrbufDestroy(&temp->name);
|
ffStrbufDestroy(&temp->name);
|
||||||
ffStrbufDestroy(&temp->deviceClass);
|
ffStrbufDestroy(&temp->deviceClass);
|
||||||
ffStrbufDestroy(&temp->value);
|
|
||||||
--result.values.length;
|
--result.values.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_temps
|
||||||
|
#define FF_INCLUDED_detection_temps
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFTempValue
|
||||||
|
{
|
||||||
|
FFstrbuf name;
|
||||||
|
FFstrbuf deviceClass;
|
||||||
|
double value;
|
||||||
|
} FFTempValue;
|
||||||
|
|
||||||
|
typedef struct FFTempsResult
|
||||||
|
{
|
||||||
|
FFlist values; //List of FFTempValue
|
||||||
|
} FFTempsResult;
|
||||||
|
|
||||||
|
const FFTempsResult* ffDetectTemps(const FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/terminalshell.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
#include "common/processing.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
@@ -20,7 +25,7 @@ static void getProcessInformation(const char* pid, FFstrbuf* processName, FFstrb
|
|||||||
ffStrbufAppendS(&cmdlineFilePath, pid);
|
ffStrbufAppendS(&cmdlineFilePath, pid);
|
||||||
ffStrbufAppendS(&cmdlineFilePath, "/cmdline");
|
ffStrbufAppendS(&cmdlineFilePath, "/cmdline");
|
||||||
|
|
||||||
ffGetFileContent(cmdlineFilePath.chars, exe);
|
ffReadFileBuffer(cmdlineFilePath.chars, exe);
|
||||||
ffStrbufSubstrBeforeFirstC(exe, '\0'); //Trim the arguments
|
ffStrbufSubstrBeforeFirstC(exe, '\0'); //Trim the arguments
|
||||||
ffStrbufTrimLeft(exe, '-'); //Happens in TTY
|
ffStrbufTrimLeft(exe, '-'); //Happens in TTY
|
||||||
|
|
||||||
@@ -68,12 +73,13 @@ static void getTerminalShell(FFTerminalShellResult* result, const char* pid)
|
|||||||
|
|
||||||
//Common programs that are between terminal and own process, but are not the shell
|
//Common programs that are between terminal and own process, but are not the shell
|
||||||
if(
|
if(
|
||||||
strcasecmp(name, "sudo") == 0 ||
|
strcasecmp(name, "sudo") == 0 ||
|
||||||
strcasecmp(name, "su") == 0 ||
|
strcasecmp(name, "su") == 0 ||
|
||||||
strcasecmp(name, "doas") == 0 ||
|
strcasecmp(name, "doas") == 0 ||
|
||||||
strcasecmp(name, "strace") == 0 ||
|
strcasecmp(name, "strace") == 0 ||
|
||||||
strcasecmp(name, "sshd") == 0 ||
|
strcasecmp(name, "sshd") == 0 ||
|
||||||
strcasecmp(name, "gdb") == 0
|
strcasecmp(name, "gdb") == 0 ||
|
||||||
|
strcasecmp(name, "guake-wrapped") == 0
|
||||||
) {
|
) {
|
||||||
getTerminalShell(result, ppid);
|
getTerminalShell(result, ppid);
|
||||||
return;
|
return;
|
||||||
@@ -119,8 +125,17 @@ static void getTerminalFromEnv(FFTerminalShellResult* result)
|
|||||||
term = getenv("SSH_TTY");
|
term = getenv("SSH_TTY");
|
||||||
|
|
||||||
//Windows Terminal
|
//Windows Terminal
|
||||||
if(!ffStrSet(term) && getenv("WT_SESSION") != NULL)
|
if(!ffStrSet(term) && (
|
||||||
term = "Windows Terminal";
|
getenv("WT_SESSION") != NULL ||
|
||||||
|
getenv("WT_PROFILE_ID") != NULL
|
||||||
|
)) term = "Windows Terminal";
|
||||||
|
|
||||||
|
//Termux
|
||||||
|
if(!ffStrSet(term) && (
|
||||||
|
getenv("TERMUX_VERSION") != NULL ||
|
||||||
|
getenv("TERMUX_MAIN_PACKAGE_FORMAT") != NULL ||
|
||||||
|
getenv("TMUX_TMPDIR") != NULL
|
||||||
|
)) term = "Termux";
|
||||||
|
|
||||||
//Normal Terminal
|
//Normal Terminal
|
||||||
if(!ffStrSet(term))
|
if(!ffStrSet(term))
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_terminalshell
|
||||||
|
#define FF_INCLUDED_detection_terminalshell
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFTerminalShellResult
|
||||||
|
{
|
||||||
|
FFstrbuf shellProcessName;
|
||||||
|
FFstrbuf shellExe;
|
||||||
|
const char* shellExeName; //pointer to a char in shellExe
|
||||||
|
FFstrbuf shellVersion;
|
||||||
|
|
||||||
|
FFstrbuf terminalProcessName;
|
||||||
|
FFstrbuf terminalExe;
|
||||||
|
const char* terminalExeName; //pointer to a char in terminalExe
|
||||||
|
|
||||||
|
FFstrbuf userShellExe;
|
||||||
|
const char* userShellExeName; //pointer to a char in userShellExe
|
||||||
|
FFstrbuf userShellVersion;
|
||||||
|
} FFTerminalShellResult;
|
||||||
|
|
||||||
|
const FFTerminalShellResult* ffDetectTerminalShell(FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
#include "fastfetch.h"
|
||||||
|
#include "detection/title.h"
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
|
const FFTitleResult* ffDetectTitle(const FFinstance* instance)
|
||||||
|
{
|
||||||
|
static FFTitleResult result;
|
||||||
|
|
||||||
|
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
static bool init = false;
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
|
if(init)
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
return &result;
|
||||||
|
}
|
||||||
|
init = true;
|
||||||
|
|
||||||
|
ffStrbufInit(&result.userName);
|
||||||
|
ffStrbufAppendS(&result.userName, instance->state.passwd->pw_name);
|
||||||
|
|
||||||
|
ffStrbufInitA(&result.hostname, HOST_NAME_MAX);
|
||||||
|
ffStrbufAppendS(&result.hostname, instance->state.utsname.nodename);
|
||||||
|
|
||||||
|
ffStrbufInitA(&result.fqdn, HOST_NAME_MAX);
|
||||||
|
|
||||||
|
struct addrinfo hints = {0};
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_flags = AI_CANONNAME;
|
||||||
|
|
||||||
|
struct addrinfo* info = NULL;
|
||||||
|
|
||||||
|
if(getaddrinfo(result.hostname.chars, "80", &hints, &info) == 0)
|
||||||
|
{
|
||||||
|
struct addrinfo* current = info;
|
||||||
|
while(result.fqdn.length == 0 && current != NULL)
|
||||||
|
{
|
||||||
|
ffStrbufAppendS(&result.fqdn, current->ai_canonname);
|
||||||
|
current = current->ai_next;
|
||||||
|
}
|
||||||
|
|
||||||
|
freeaddrinfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result.fqdn.length == 0)
|
||||||
|
ffStrbufAppend(&result.fqdn, &result.hostname);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
return &result;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_title
|
||||||
|
#define FF_INCLUDED_detection_title
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFTitleResult
|
||||||
|
{
|
||||||
|
FFstrbuf userName;
|
||||||
|
FFstrbuf hostname;
|
||||||
|
FFstrbuf fqdn; //Fully qualified domain name
|
||||||
|
} FFTitleResult;
|
||||||
|
|
||||||
|
const FFTitleResult* ffDetectTitle(const FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "detection/vulkan.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#ifdef FF_HAVE_VULKAN
|
#ifdef FF_HAVE_VULKAN
|
||||||
|
#include "common/library.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
#include <stdlib.h>
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
static inline void applyVulkanVersion(uint32_t vulkanVersion, FFVersion* ffVersion)
|
static inline void applyVulkanVersion(uint32_t vulkanVersion, FFVersion* ffVersion)
|
||||||
@@ -174,6 +179,7 @@ static void detectVulkan(const FFinstance* instance, FFVulkanResult* result)
|
|||||||
ffStrbufInit(&gpu->vendor);
|
ffStrbufInit(&gpu->vendor);
|
||||||
ffStrbufInit(&gpu->name);
|
ffStrbufInit(&gpu->name);
|
||||||
ffStrbufInit(&gpu->driver);
|
ffStrbufInit(&gpu->driver);
|
||||||
|
gpu->temperature = 0.0 / 0.0; //NaN, no way to detect temperature using vulkan
|
||||||
ffStrbufAppendS(&gpu->name, physicalDeviceProperties.properties.deviceName);
|
ffStrbufAppendS(&gpu->name, physicalDeviceProperties.properties.deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_detection_vulkan
|
||||||
|
#define FF_INCLUDED_detection_vulkan
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
typedef struct FFGPUResult
|
||||||
|
{
|
||||||
|
FFstrbuf vendor;
|
||||||
|
FFstrbuf name;
|
||||||
|
FFstrbuf driver;
|
||||||
|
double temperature;
|
||||||
|
} FFGPUResult;
|
||||||
|
|
||||||
|
typedef struct FFVulkanResult
|
||||||
|
{
|
||||||
|
FFstrbuf driver;
|
||||||
|
FFstrbuf apiVersion;
|
||||||
|
FFstrbuf conformanceVersion;
|
||||||
|
FFlist devices; //List of FFGPUResult
|
||||||
|
} FFVulkanResult;
|
||||||
|
|
||||||
|
const FFVulkanResult* ffDetectVulkan(const FFinstance* instance);
|
||||||
|
|
||||||
|
#endif
|
||||||
+326
-204
@@ -1,18 +1,26 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "util/FFvaluestore.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
typedef struct CustomValue
|
||||||
|
{
|
||||||
|
bool printKey;
|
||||||
|
FFstrbuf value;
|
||||||
|
} CustomValue;
|
||||||
|
|
||||||
// Things only needed by fastfetch
|
// Things only needed by fastfetch
|
||||||
typedef struct FFdata
|
typedef struct FFdata
|
||||||
{
|
{
|
||||||
FFvaluestore valuestore;
|
FFvaluestore customValues;
|
||||||
FFstrbuf structure;
|
FFstrbuf structure;
|
||||||
bool multithreading;
|
bool loadUserConfig;
|
||||||
} FFdata;
|
} FFdata;
|
||||||
|
|
||||||
static void constructAndPrintCommandHelpFormat(const char* name, const char* def, uint32_t numArgs, ...)
|
static void constructAndPrintCommandHelpFormat(const char* name, const char* def, uint32_t numArgs, ...)
|
||||||
@@ -28,7 +36,7 @@ static void constructAndPrintCommandHelpFormat(const char* name, const char* def
|
|||||||
for(uint32_t i = 1; i <= numArgs; i++)
|
for(uint32_t i = 1; i <= numArgs; i++)
|
||||||
printf(" {%u}: %s\n", i, va_arg(argp, const char*));
|
printf(" {%u}: %s\n", i, va_arg(argp, const char*));
|
||||||
|
|
||||||
printf("The default is something like \"%s\".\n", def);
|
printf("The default is something similar to \"%s\".\n", def);
|
||||||
|
|
||||||
va_end(argp);
|
va_end(argp);
|
||||||
}
|
}
|
||||||
@@ -62,10 +70,22 @@ static inline void printCommandHelp(const char* command)
|
|||||||
}
|
}
|
||||||
else if(strcasecmp(command, "host-format") == 0)
|
else if(strcasecmp(command, "host-format") == 0)
|
||||||
{
|
{
|
||||||
constructAndPrintCommandHelpFormat("host", "{2} {3}", 3,
|
constructAndPrintCommandHelpFormat("host", "{2} {3}", 15,
|
||||||
"Host family",
|
"product family",
|
||||||
"Host name",
|
"product name",
|
||||||
"Host version"
|
"product version",
|
||||||
|
"product sku",
|
||||||
|
"bios date",
|
||||||
|
"bios release",
|
||||||
|
"bios vendor",
|
||||||
|
"bios version",
|
||||||
|
"board name",
|
||||||
|
"board vendor",
|
||||||
|
"board version",
|
||||||
|
"chassis type",
|
||||||
|
"chassis vendor",
|
||||||
|
"chassis version",
|
||||||
|
"sys vendor"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if(strcasecmp(command, "kernel-format") == 0)
|
else if(strcasecmp(command, "kernel-format") == 0)
|
||||||
@@ -93,7 +113,7 @@ static inline void printCommandHelp(const char* command)
|
|||||||
}
|
}
|
||||||
else if(strcasecmp(command, "packages-format") == 0)
|
else if(strcasecmp(command, "packages-format") == 0)
|
||||||
{
|
{
|
||||||
constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (xbps), {8} (nix-user), {9} (nix-default), {10} (flatpak), {11} (snap)", 11,
|
constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (xbps), {8} (nix-system), {9} (nix-user), {10} (nix-default), {11} (apk), {12} (flatpak), {13} (snap)", 13,
|
||||||
"Number of all packages",
|
"Number of all packages",
|
||||||
"Number of pacman packages",
|
"Number of pacman packages",
|
||||||
"Pacman branch on manjaro",
|
"Pacman branch on manjaro",
|
||||||
@@ -101,8 +121,10 @@ static inline void printCommandHelp(const char* command)
|
|||||||
"Number of rpm packages",
|
"Number of rpm packages",
|
||||||
"Number of emerge packages",
|
"Number of emerge packages",
|
||||||
"Number of xbps packages",
|
"Number of xbps packages",
|
||||||
|
"Number of nix-system packages",
|
||||||
"Number of nix-user packages",
|
"Number of nix-user packages",
|
||||||
"Number of nix-default packages",
|
"Number of nix-default packages",
|
||||||
|
"Number of apk packages",
|
||||||
"Number of flatpak packages",
|
"Number of flatpak packages",
|
||||||
"Number of snap packages"
|
"Number of snap packages"
|
||||||
);
|
);
|
||||||
@@ -224,7 +246,7 @@ static inline void printCommandHelp(const char* command)
|
|||||||
}
|
}
|
||||||
else if(strcasecmp(command, "cpu-format") == 0)
|
else if(strcasecmp(command, "cpu-format") == 0)
|
||||||
{
|
{
|
||||||
constructAndPrintCommandHelpFormat("cpu", "{2} ({7}) @ {14}GHz", 14,
|
constructAndPrintCommandHelpFormat("cpu", "{2} ({7}) @ {15}GHz", 15,
|
||||||
"CPU name",
|
"CPU name",
|
||||||
"Prettified CPU name",
|
"Prettified CPU name",
|
||||||
"CPU Vendor name (Vendor ID)",
|
"CPU Vendor name (Vendor ID)",
|
||||||
@@ -232,6 +254,7 @@ static inline void printCommandHelp(const char* command)
|
|||||||
"CPU logical core count configured",
|
"CPU logical core count configured",
|
||||||
"CPU physical core count",
|
"CPU physical core count",
|
||||||
"Always set core count",
|
"Always set core count",
|
||||||
|
"CPU package temperature",
|
||||||
"frequency bios limit",
|
"frequency bios limit",
|
||||||
"frequency scaling max",
|
"frequency scaling max",
|
||||||
"frequency scaling min",
|
"frequency scaling min",
|
||||||
@@ -249,12 +272,13 @@ static inline void printCommandHelp(const char* command)
|
|||||||
}
|
}
|
||||||
else if(strcasecmp(command, "gpu-format") == 0)
|
else if(strcasecmp(command, "gpu-format") == 0)
|
||||||
{
|
{
|
||||||
constructAndPrintCommandHelpFormat("gpu", "{2} {4}", 5,
|
constructAndPrintCommandHelpFormat("gpu", "{2} {4}", 6,
|
||||||
"GPU vendor",
|
"GPU vendor",
|
||||||
"GPU vendor pretty",
|
"GPU vendor pretty",
|
||||||
"GPU name",
|
"GPU name",
|
||||||
"GPU name pretty",
|
"GPU name pretty",
|
||||||
"GPU driver"
|
"GPU driver",
|
||||||
|
"GPU temperature"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if(strcasecmp(command, "memory-format") == 0)
|
else if(strcasecmp(command, "memory-format") == 0)
|
||||||
@@ -267,7 +291,7 @@ static inline void printCommandHelp(const char* command)
|
|||||||
}
|
}
|
||||||
else if(strcasecmp(command, "disk-format") == 0)
|
else if(strcasecmp(command, "disk-format") == 0)
|
||||||
{
|
{
|
||||||
constructAndPrintCommandHelpFormat("disk", "{}GB / {}GB ({4}%)", 4,
|
constructAndPrintCommandHelpFormat("disk", "{}GiB / {}GiB ({4}%)", 4,
|
||||||
"Used disk space",
|
"Used disk space",
|
||||||
"Total disk space",
|
"Total disk space",
|
||||||
"Number of files",
|
"Number of files",
|
||||||
@@ -336,7 +360,7 @@ static inline void printCommandHelp(const char* command)
|
|||||||
"day in month",
|
"day in month",
|
||||||
"day in Week",
|
"day in Week",
|
||||||
"hour",
|
"hour",
|
||||||
"hout with leading zero",
|
"hour with leading zero",
|
||||||
"hour 12h format",
|
"hour 12h format",
|
||||||
"hour 12h format with leading zero",
|
"hour 12h format with leading zero",
|
||||||
"minute",
|
"minute",
|
||||||
@@ -430,58 +454,57 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
|
|
||||||
static void parseConfigFile(FFinstance* instance, FFdata* data, FILE* file)
|
static void parseConfigFile(FFinstance* instance, FFdata* data, FILE* file)
|
||||||
{
|
{
|
||||||
char* lineStart = NULL;
|
char* line = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
|
|
||||||
FFstrbuf line;
|
while ((read = getline(&line, &len, file)) != -1)
|
||||||
ffStrbufInitA(&line, 256); //The default structure line needs this size
|
|
||||||
|
|
||||||
while ((read = getline(&lineStart, &len, file)) != -1)
|
|
||||||
{
|
{
|
||||||
ffStrbufSetS(&line, lineStart);
|
char* lineStart = line;
|
||||||
ffStrbufTrimRight(&line, '\n');
|
char* lineEnd = line + read - 1;
|
||||||
ffStrbufTrim(&line, ' ');
|
|
||||||
|
|
||||||
if(line.length == 0 || line.chars[0] == '#')
|
//Trim line left
|
||||||
|
while(isspace(*lineStart))
|
||||||
|
++lineStart;
|
||||||
|
|
||||||
|
//Continue if line is empty or a comment
|
||||||
|
if(*lineStart == '\0' || *lineStart == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint32_t firstSpace = ffStrbufFirstIndexC(&line, ' ');
|
//Trim line right
|
||||||
|
while(lineEnd > lineStart && isspace(*lineEnd))
|
||||||
|
--lineEnd;
|
||||||
|
*(lineEnd + 1) = '\0';
|
||||||
|
|
||||||
if(firstSpace >= line.length)
|
char* valueStart = strchr(lineStart, ' ');
|
||||||
|
|
||||||
|
//If the line has no white space, it is only a key
|
||||||
|
if(valueStart == NULL)
|
||||||
{
|
{
|
||||||
parseOption(instance, data, line.chars, NULL);
|
parseOption(instance, data, lineStart, NULL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Separate key and value by simply replacing the first space with a \0
|
//separate the key from the value
|
||||||
char* valueStart = &line.chars[firstSpace];
|
|
||||||
*valueStart = '\0';
|
*valueStart = '\0';
|
||||||
++valueStart;
|
++valueStart;
|
||||||
|
|
||||||
//Trim whitespace at beginning of value
|
//Trim space of value left
|
||||||
while(*valueStart == ' ')
|
while(isspace(*valueStart))
|
||||||
++valueStart;
|
++valueStart;
|
||||||
|
|
||||||
//If we want whitespace in values, we need to quote it. This is done to keep consistency with shell.
|
//If we want whitespace in values, we need to quote it. This is done to keep consistency with shell.
|
||||||
if(*valueStart == '"')
|
if((*valueStart == '"' || *valueStart == '\'') && *valueStart == *lineEnd && lineEnd > valueStart)
|
||||||
{
|
{
|
||||||
char* last = line.chars + line.length - 1;
|
++valueStart;
|
||||||
if(*last == '"')
|
--lineEnd;
|
||||||
{
|
|
||||||
++valueStart;
|
|
||||||
*last = '\0';
|
|
||||||
--line.length;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parseOption(instance, data, line.chars, valueStart);
|
parseOption(instance, data, lineStart, valueStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
ffStrbufDestroy(&line);
|
if(line != NULL)
|
||||||
|
free(line);
|
||||||
if(lineStart != NULL)
|
|
||||||
free(lineStart);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char* key, const char* value)
|
static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char* key, const char* value)
|
||||||
@@ -652,6 +675,32 @@ static uint32_t optionParseUInt32(const char* key, const char* value)
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void optionParseCustomValue(FFdata* data, const char* key, const char* value, bool printKey)
|
||||||
|
{
|
||||||
|
if(value == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: usage: %s <key=value>\n", key);
|
||||||
|
exit(411);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* separator = strchr(value, '=');
|
||||||
|
|
||||||
|
if(separator == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: usage: %s <key=value>, '=' missing\n", key);
|
||||||
|
exit(412);
|
||||||
|
}
|
||||||
|
|
||||||
|
*separator = '\0';
|
||||||
|
|
||||||
|
bool created;
|
||||||
|
CustomValue* customValue = ffValuestoreSet(&data->customValues, value, &created);
|
||||||
|
if(created)
|
||||||
|
ffStrbufInit(&customValue->value);
|
||||||
|
ffStrbufSetS(&customValue->value, separator + 1);
|
||||||
|
customValue->printKey = printKey;
|
||||||
|
}
|
||||||
|
|
||||||
static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value)
|
static void parseOption(FFinstance* instance, FFdata* data, const char* key, const char* value)
|
||||||
{
|
{
|
||||||
///////////////////////
|
///////////////////////
|
||||||
@@ -673,9 +722,14 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
puts(FASTFETCH_PROJECT_VERSION);
|
puts(FASTFETCH_PROJECT_VERSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--print-config") == 0)
|
else if(strcasecmp(key, "--print-config-system") == 0)
|
||||||
{
|
{
|
||||||
fputs(FASTFETCH_DATATEXT_CONFIG, stdout);
|
fputs(FASTFETCH_DATATEXT_CONFIG_SYSTEM, stdout);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
else if(strcasecmp(key, "--print-config-user") == 0)
|
||||||
|
{
|
||||||
|
fputs(FASTFETCH_DATATEXT_CONFIG_USER, stdout);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--print-structure") == 0)
|
else if(strcasecmp(key, "--print-structure") == 0)
|
||||||
@@ -732,13 +786,15 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
else if(strcasecmp(key, "--load-config") == 0)
|
else if(strcasecmp(key, "--load-config") == 0)
|
||||||
optionParseConfigFile(instance, data, key, value);
|
optionParseConfigFile(instance, data, key, value);
|
||||||
else if(strcasecmp(key, "--multithreading") == 0)
|
else if(strcasecmp(key, "--multithreading") == 0)
|
||||||
data->multithreading = optionParseBoolean(value);
|
instance->config.multithreading = optionParseBoolean(value);
|
||||||
else if(strcasecmp(key, "--allow-slow-operations") == 0)
|
else if(strcasecmp(key, "--allow-slow-operations") == 0)
|
||||||
instance->config.allowSlowOperations = optionParseBoolean(value);
|
instance->config.allowSlowOperations = optionParseBoolean(value);
|
||||||
else if(strcasecmp(key, "--escape-bedrock") == 0)
|
else if(strcasecmp(key, "--escape-bedrock") == 0)
|
||||||
instance->config.escapeBedrock = optionParseBoolean(value);
|
instance->config.escapeBedrock = optionParseBoolean(value);
|
||||||
else if(strcasecmp(key, "--pipe") == 0)
|
else if(strcasecmp(key, "--pipe") == 0)
|
||||||
instance->config.pipe = optionParseBoolean(value);
|
instance->config.pipe = optionParseBoolean(value);
|
||||||
|
else if(strcasecmp(key, "--load-user-config") == 0)
|
||||||
|
data->loadUserConfig = optionParseBoolean(value);
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
//Logo options//
|
//Logo options//
|
||||||
@@ -746,13 +802,13 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
|
|
||||||
else if(strcasecmp(key, "-l") == 0 || strcasecmp(key, "--logo") == 0)
|
else if(strcasecmp(key, "-l") == 0 || strcasecmp(key, "--logo") == 0)
|
||||||
{
|
{
|
||||||
optionParseString(key, value, &instance->config.logoSource);
|
optionParseString(key, value, &instance->config.logo.source);
|
||||||
|
|
||||||
//this is usally wanted when using the none logo
|
//this is usally wanted when using the none logo
|
||||||
if(strcasecmp(value, "none") == 0)
|
if(strcasecmp(value, "none") == 0)
|
||||||
{
|
{
|
||||||
instance->config.logoPaddingRight = 0;
|
instance->config.logo.paddingRight = 0;
|
||||||
instance->config.logoPaddingLeft = 0;
|
instance->config.logo.paddingLeft = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--logo-type") == 0)
|
else if(strcasecmp(key, "--logo-type") == 0)
|
||||||
@@ -764,19 +820,19 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(strcasecmp(value, "auto") == 0)
|
if(strcasecmp(value, "auto") == 0)
|
||||||
instance->config.logoType = FF_LOGO_TYPE_AUTO;
|
instance->config.logo.type = FF_LOGO_TYPE_AUTO;
|
||||||
else if(strcasecmp(value, "builtin") == 0)
|
else if(strcasecmp(value, "builtin") == 0)
|
||||||
instance->config.logoType = FF_LOGO_TYPE_BUILTIN;
|
instance->config.logo.type = FF_LOGO_TYPE_BUILTIN;
|
||||||
else if(strcasecmp(value, "file") == 0)
|
else if(strcasecmp(value, "file") == 0)
|
||||||
instance->config.logoType = FF_LOGO_TYPE_FILE;
|
instance->config.logo.type = FF_LOGO_TYPE_FILE;
|
||||||
else if(strcasecmp(value, "raw") == 0)
|
else if(strcasecmp(value, "raw") == 0)
|
||||||
instance->config.logoType = FF_LOGO_TYPE_RAW;
|
instance->config.logo.type = FF_LOGO_TYPE_RAW;
|
||||||
else if(strcasecmp(value, "sixel") == 0)
|
else if(strcasecmp(value, "sixel") == 0)
|
||||||
instance->config.logoType = FF_LOGO_TYPE_SIXEL;
|
instance->config.logo.type = FF_LOGO_TYPE_SIXEL;
|
||||||
else if(strcasecmp(value, "kitty") == 0)
|
else if(strcasecmp(value, "kitty") == 0)
|
||||||
instance->config.logoType = FF_LOGO_TYPE_KITTY;
|
instance->config.logo.type = FF_LOGO_TYPE_KITTY;
|
||||||
else if(strcasecmp(value, "chafa") == 0)
|
else if(strcasecmp(value, "chafa") == 0)
|
||||||
instance->config.logoType = FF_LOGO_TYPE_CHAFA;
|
instance->config.logo.type = FF_LOGO_TYPE_CHAFA;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: unknown logo type: %s\n", value);
|
fprintf(stderr, "Error: unknown logo type: %s\n", value);
|
||||||
@@ -795,48 +851,48 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
exit(472);
|
exit(472);
|
||||||
}
|
}
|
||||||
|
|
||||||
optionParseColor(key, value, &instance->config.logoColors[index]);
|
optionParseColor(key, value, &instance->config.logo.colors[index]);
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--logo-width") == 0)
|
else if(strcasecmp(key, "--logo-width") == 0)
|
||||||
instance->config.logoWidth = optionParseUInt32(key, value);
|
instance->config.logo.width = optionParseUInt32(key, value);
|
||||||
else if(strcasecmp(key, "--logo-height") == 0)
|
else if(strcasecmp(key, "--logo-height") == 0)
|
||||||
instance->config.logoHeight = optionParseUInt32(key, value);
|
instance->config.logo.height = optionParseUInt32(key, value);
|
||||||
else if(strcasecmp(key, "--logo-padding") == 0)
|
else if(strcasecmp(key, "--logo-padding") == 0)
|
||||||
{
|
{
|
||||||
uint32_t padding = optionParseUInt32(key, value);
|
uint32_t padding = optionParseUInt32(key, value);
|
||||||
instance->config.logoPaddingLeft = padding;
|
instance->config.logo.paddingLeft = padding;
|
||||||
instance->config.logoPaddingRight = padding;
|
instance->config.logo.paddingRight = padding;
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--logo-padding-left") == 0)
|
else if(strcasecmp(key, "--logo-padding-left") == 0)
|
||||||
instance->config.logoPaddingLeft = optionParseUInt32(key, value);
|
instance->config.logo.paddingLeft = optionParseUInt32(key, value);
|
||||||
else if(strcasecmp(key, "--logo-padding-right") == 0)
|
else if(strcasecmp(key, "--logo-padding-right") == 0)
|
||||||
instance->config.logoPaddingRight = optionParseUInt32(key, value);
|
instance->config.logo.paddingRight = optionParseUInt32(key, value);
|
||||||
else if(strcasecmp(key, "--logo-print-remaining") == 0)
|
else if(strcasecmp(key, "--logo-print-remaining") == 0)
|
||||||
instance->config.logoPrintRemaining = optionParseBoolean(value);
|
instance->config.logo.printRemaining = optionParseBoolean(value);
|
||||||
else if(strcasecmp(key, "--sixel") == 0)
|
else if(strcasecmp(key, "--sixel") == 0)
|
||||||
{
|
{
|
||||||
optionParseString(key, value, &instance->config.logoSource);
|
optionParseString(key, value, &instance->config.logo.source);
|
||||||
instance->config.logoType = FF_LOGO_TYPE_SIXEL;
|
instance->config.logo.type = FF_LOGO_TYPE_SIXEL;
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--kitty") == 0)
|
else if(strcasecmp(key, "--kitty") == 0)
|
||||||
{
|
{
|
||||||
optionParseString(key, value, &instance->config.logoSource);
|
optionParseString(key, value, &instance->config.logo.source);
|
||||||
instance->config.logoType = FF_LOGO_TYPE_KITTY;
|
instance->config.logo.type = FF_LOGO_TYPE_KITTY;
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--file") == 0)
|
else if(strcasecmp(key, "--file") == 0)
|
||||||
{
|
{
|
||||||
optionCheckString(key, value, &instance->config.logoSource);
|
optionCheckString(key, value, &instance->config.logo.source);
|
||||||
instance->config.logoType = FF_LOGO_TYPE_FILE;
|
instance->config.logo.type = FF_LOGO_TYPE_FILE;
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--raw") == 0)
|
else if(strcasecmp(key, "--raw") == 0)
|
||||||
{
|
{
|
||||||
optionParseString(key, value, &instance->config.logoSource);
|
optionParseString(key, value, &instance->config.logo.source);
|
||||||
instance->config.logoType = FF_LOGO_TYPE_RAW;
|
instance->config.logo.type = FF_LOGO_TYPE_RAW;
|
||||||
}
|
}
|
||||||
else if(strcasecmp(key, "--chafa") == 0)
|
else if(strcasecmp(key, "--chafa") == 0)
|
||||||
{
|
{
|
||||||
optionParseString(key, value, &instance->config.logoSource);
|
optionParseString(key, value, &instance->config.logo.source);
|
||||||
instance->config.logoType = FF_LOGO_TYPE_CHAFA;
|
instance->config.logo.type = FF_LOGO_TYPE_CHAFA;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
@@ -856,166 +912,218 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
else if(strcasecmp(key, "-c") == 0 || strcasecmp(key, "--color") == 0)
|
else if(strcasecmp(key, "-c") == 0 || strcasecmp(key, "--color") == 0)
|
||||||
optionParseColor(key, value, &instance->config.mainColor);
|
optionParseColor(key, value, &instance->config.mainColor);
|
||||||
else if(strcasecmp(key, "--set") == 0)
|
else if(strcasecmp(key, "--set") == 0)
|
||||||
{
|
optionParseCustomValue(data, key, value, true);
|
||||||
if(value == NULL)
|
else if(strcasecmp(key, "--set-keyless") == 0)
|
||||||
{
|
optionParseCustomValue(data, key, value, false);
|
||||||
fprintf(stderr, "Error: usage: %s <key=value>\n", key);
|
|
||||||
exit(411);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* separator = strchr(value, '=');
|
////////////////////////////////
|
||||||
|
//Format + Key + Error options//
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
if(separator == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Error: usage: %s <key=value>, '=' missing\n", key);
|
|
||||||
exit(412);
|
|
||||||
}
|
|
||||||
|
|
||||||
*separator = '\0';
|
|
||||||
|
|
||||||
ffValuestoreSet(&data->valuestore, value, separator + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////
|
|
||||||
//Format + Key options//
|
|
||||||
////////////////////////
|
|
||||||
|
|
||||||
else if(strcasecmp(key, "--os-format") == 0)
|
|
||||||
optionParseString(key, value, &instance->config.osFormat);
|
|
||||||
else if(strcasecmp(key, "--os-key") == 0)
|
else if(strcasecmp(key, "--os-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.osKey);
|
optionParseString(key, value, &instance->config.os.key);
|
||||||
else if(strcasecmp(key, "--host-format") == 0)
|
else if(strcasecmp(key, "--os-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.hostFormat);
|
optionParseString(key, value, &instance->config.os.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--os-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.os.errorFormat);
|
||||||
else if(strcasecmp(key, "--host-key") == 0)
|
else if(strcasecmp(key, "--host-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.hostKey);
|
optionParseString(key, value, &instance->config.host.key);
|
||||||
else if(strcasecmp(key, "--kernel-format") == 0)
|
else if(strcasecmp(key, "--host-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.kernelFormat);
|
optionParseString(key, value, &instance->config.host.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--host-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.host.errorFormat);
|
||||||
else if(strcasecmp(key, "--kernel-key") == 0)
|
else if(strcasecmp(key, "--kernel-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.kernelKey);
|
optionParseString(key, value, &instance->config.kernel.key);
|
||||||
else if(strcasecmp(key, "--uptime-format") == 0)
|
else if(strcasecmp(key, "--kernel-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.uptimeFormat);
|
optionParseString(key, value, &instance->config.kernel.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--kernel-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.kernel.errorFormat);
|
||||||
else if(strcasecmp(key, "--uptime-key") == 0)
|
else if(strcasecmp(key, "--uptime-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.uptimeKey);
|
optionParseString(key, value, &instance->config.uptime.key);
|
||||||
else if(strcasecmp(key, "--processes-format") == 0)
|
else if(strcasecmp(key, "--uptime-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.processesFormat);
|
optionParseString(key, value, &instance->config.uptime.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--uptime-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.uptime.errorFormat);
|
||||||
else if(strcasecmp(key, "--processes-key") == 0)
|
else if(strcasecmp(key, "--processes-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.processesKey);
|
optionParseString(key, value, &instance->config.processes.key);
|
||||||
else if(strcasecmp(key, "--packages-format") == 0)
|
else if(strcasecmp(key, "--processes-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.packagesFormat);
|
optionParseString(key, value, &instance->config.processes.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--processes-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.processes.errorFormat);
|
||||||
else if(strcasecmp(key, "--packages-key") == 0)
|
else if(strcasecmp(key, "--packages-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.packagesKey);
|
optionParseString(key, value, &instance->config.packages.key);
|
||||||
else if(strcasecmp(key, "--shell-format") == 0)
|
else if(strcasecmp(key, "--packages-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.shellFormat);
|
optionParseString(key, value, &instance->config.packages.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--packages-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.packages.errorFormat);
|
||||||
else if(strcasecmp(key, "--shell-key") == 0)
|
else if(strcasecmp(key, "--shell-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.shellKey);
|
optionParseString(key, value, &instance->config.shell.key);
|
||||||
else if(strcasecmp(key, "--resolution-format") == 0)
|
else if(strcasecmp(key, "--shell-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.resolutionFormat);
|
optionParseString(key, value, &instance->config.shell.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--shell-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.shell.errorFormat);
|
||||||
else if(strcasecmp(key, "--resolution-key") == 0)
|
else if(strcasecmp(key, "--resolution-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.resolutionKey);
|
optionParseString(key, value, &instance->config.resolution.key);
|
||||||
else if(strcasecmp(key, "--de-format") == 0)
|
else if(strcasecmp(key, "--resolution-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.deFormat);
|
optionParseString(key, value, &instance->config.resolution.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--resolution-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.resolution.errorFormat);
|
||||||
else if(strcasecmp(key, "--de-key") == 0)
|
else if(strcasecmp(key, "--de-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.deKey);
|
optionParseString(key, value, &instance->config.de.key);
|
||||||
else if(strcasecmp(key, "--wm-format") == 0)
|
else if(strcasecmp(key, "--de-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.wmFormat);
|
optionParseString(key, value, &instance->config.de.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--de-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.de.errorFormat);
|
||||||
else if(strcasecmp(key, "--wm-key") == 0)
|
else if(strcasecmp(key, "--wm-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.wmKey);
|
optionParseString(key, value, &instance->config.wm.key);
|
||||||
else if(strcasecmp(key, "--wm-theme-format") == 0)
|
else if(strcasecmp(key, "--wm-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.wmThemeFormat);
|
optionParseString(key, value, &instance->config.wm.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--wm-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.wm.errorFormat);
|
||||||
else if(strcasecmp(key, "--wm-theme-key") == 0)
|
else if(strcasecmp(key, "--wm-theme-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.wmThemeKey);
|
optionParseString(key, value, &instance->config.wmTheme.key);
|
||||||
else if(strcasecmp(key, "--theme-format") == 0)
|
else if(strcasecmp(key, "--wm-theme-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.themeFormat);
|
optionParseString(key, value, &instance->config.wmTheme.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--wm-theme-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.wmTheme.errorFormat);
|
||||||
else if(strcasecmp(key, "--theme-key") == 0)
|
else if(strcasecmp(key, "--theme-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.themeKey);
|
optionParseString(key, value, &instance->config.theme.key);
|
||||||
else if(strcasecmp(key, "--icons-format") == 0)
|
else if(strcasecmp(key, "--theme-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.iconsFormat);
|
optionParseString(key, value, &instance->config.theme.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--theme-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.theme.errorFormat);
|
||||||
else if(strcasecmp(key, "--icons-key") == 0)
|
else if(strcasecmp(key, "--icons-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.iconsKey);
|
optionParseString(key, value, &instance->config.icons.key);
|
||||||
else if(strcasecmp(key, "--font-format") == 0)
|
else if(strcasecmp(key, "--icons-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.fontFormat);
|
optionParseString(key, value, &instance->config.icons.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--icons-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.icons.errorFormat);
|
||||||
else if(strcasecmp(key, "--font-key") == 0)
|
else if(strcasecmp(key, "--font-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.fontKey);
|
optionParseString(key, value, &instance->config.font.key);
|
||||||
|
else if(strcasecmp(key, "--font-format") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.font.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--font-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.font.errorFormat);
|
||||||
else if(strcasecmp(key, "--cursor-key") == 0)
|
else if(strcasecmp(key, "--cursor-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.cursorKey);
|
optionParseString(key, value, &instance->config.cursor.key);
|
||||||
else if(strcasecmp(key, "--cursor-format") == 0)
|
else if(strcasecmp(key, "--cursor-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.cursorFormat);
|
optionParseString(key, value, &instance->config.cursor.outputFormat);
|
||||||
else if(strcasecmp(key, "--terminal-format") == 0)
|
else if(strcasecmp(key, "--cursor-error") == 0)
|
||||||
optionParseString(key, value, &instance->config.terminalFormat);
|
optionParseString(key, value, &instance->config.cursor.errorFormat);
|
||||||
else if(strcasecmp(key, "--terminal-key") == 0)
|
else if(strcasecmp(key, "--terminal-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.terminalKey);
|
optionParseString(key, value, &instance->config.terminal.key);
|
||||||
else if(strcasecmp(key, "--terminal-font-format") == 0)
|
else if(strcasecmp(key, "--terminal-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.termFontFormat);
|
optionParseString(key, value, &instance->config.terminal.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--terminal-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.terminal.errorFormat);
|
||||||
else if(strcasecmp(key, "--terminal-font-key") == 0)
|
else if(strcasecmp(key, "--terminal-font-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.termFontKey);
|
optionParseString(key, value, &instance->config.terminalFont.key);
|
||||||
else if(strcasecmp(key, "--cpu-format") == 0)
|
else if(strcasecmp(key, "--terminal-font-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.cpuFormat);
|
optionParseString(key, value, &instance->config.terminalFont.outputFormat);
|
||||||
else if(strcasecmp(key, "--cpu-usage-format") == 0)
|
else if(strcasecmp(key, "--terminal-font-error") == 0)
|
||||||
optionParseString(key, value, &instance->config.cpuUsageFormat);
|
optionParseString(key, value, &instance->config.terminalFont.errorFormat);
|
||||||
else if(strcasecmp(key, "--cpu-key") == 0)
|
else if(strcasecmp(key, "--cpu-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.cpuKey);
|
optionParseString(key, value, &instance->config.cpu.key);
|
||||||
|
else if(strcasecmp(key, "--cpu-format") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.cpu.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--cpu-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.cpu.errorFormat);
|
||||||
else if(strcasecmp(key, "--cpu-usage-key") == 0)
|
else if(strcasecmp(key, "--cpu-usage-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.cpuUsageKey);
|
optionParseString(key, value, &instance->config.cpuUsage.key);
|
||||||
else if(strcasecmp(key, "--gpu-format") == 0)
|
else if(strcasecmp(key, "--cpu-usage-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.gpuFormat);
|
optionParseString(key, value, &instance->config.cpuUsage.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--cpu-usage-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.cpuUsage.errorFormat);
|
||||||
else if(strcasecmp(key, "--gpu-key") == 0)
|
else if(strcasecmp(key, "--gpu-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.gpuKey);
|
optionParseString(key, value, &instance->config.gpu.key);
|
||||||
else if(strcasecmp(key, "--memory-format") == 0)
|
else if(strcasecmp(key, "--gpu-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.memoryFormat);
|
optionParseString(key, value, &instance->config.gpu.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--gpu-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.gpu.errorFormat);
|
||||||
else if(strcasecmp(key, "--memory-key") == 0)
|
else if(strcasecmp(key, "--memory-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.memoryKey);
|
optionParseString(key, value, &instance->config.memory.key);
|
||||||
else if(strcasecmp(key, "--disk-format") == 0)
|
else if(strcasecmp(key, "--memory-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.diskFormat);
|
optionParseString(key, value, &instance->config.memory.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--memory-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.memory.errorFormat);
|
||||||
else if(strcasecmp(key, "--disk-key") == 0)
|
else if(strcasecmp(key, "--disk-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.diskKey);
|
optionParseString(key, value, &instance->config.disk.key);
|
||||||
else if(strcasecmp(key, "--battery-format") == 0)
|
else if(strcasecmp(key, "--disk-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.batteryFormat);
|
optionParseString(key, value, &instance->config.disk.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--disk-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.disk.errorFormat);
|
||||||
else if(strcasecmp(key, "--battery-key") == 0)
|
else if(strcasecmp(key, "--battery-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.batteryKey);
|
optionParseString(key, value, &instance->config.battery.key);
|
||||||
else if(strcasecmp(key, "--locale-format") == 0)
|
else if(strcasecmp(key, "--battery-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.localeFormat);
|
optionParseString(key, value, &instance->config.battery.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--battery-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.battery.errorFormat);
|
||||||
else if(strcasecmp(key, "--locale-key") == 0)
|
else if(strcasecmp(key, "--locale-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.localeKey);
|
optionParseString(key, value, &instance->config.locale.key);
|
||||||
|
else if(strcasecmp(key, "--locale-format") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.locale.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--locale-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.locale.errorFormat);
|
||||||
else if(strcasecmp(key, "--local-ip-key") == 0)
|
else if(strcasecmp(key, "--local-ip-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.localIpKey);
|
optionParseString(key, value, &instance->config.localIP.key);
|
||||||
else if(strcasecmp(key, "--local-ip-format") == 0)
|
else if(strcasecmp(key, "--local-ip-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.localIpFormat);
|
optionParseString(key, value, &instance->config.localIP.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--local-ip-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.localIP.errorFormat);
|
||||||
else if(strcasecmp(key, "--public-ip-key") == 0)
|
else if(strcasecmp(key, "--public-ip-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.publicIpKey);
|
optionParseString(key, value, &instance->config.publicIP.key);
|
||||||
else if(strcasecmp(key, "--public-ip-format") == 0)
|
else if(strcasecmp(key, "--public-ip-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.publicIpFormat);
|
optionParseString(key, value, &instance->config.publicIP.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--public-ip-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.publicIP.errorFormat);
|
||||||
else if(strcasecmp(key, "--player-key") == 0)
|
else if(strcasecmp(key, "--player-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.playerKey);
|
optionParseString(key, value, &instance->config.player.key);
|
||||||
else if(strcasecmp(key, "--player-format") == 0)
|
else if(strcasecmp(key, "--player-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.playerFormat);
|
optionParseString(key, value, &instance->config.player.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--player-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.player.errorFormat);
|
||||||
else if(strcasecmp(key, "--song-key") == 0)
|
else if(strcasecmp(key, "--song-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.songKey);
|
optionParseString(key, value, &instance->config.song.key);
|
||||||
else if(strcasecmp(key, "--song-format") == 0)
|
else if(strcasecmp(key, "--song-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.songFormat);
|
optionParseString(key, value, &instance->config.song.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--song-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.song.errorFormat);
|
||||||
else if(strcasecmp(key, "--datetime-key") == 0)
|
else if(strcasecmp(key, "--datetime-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.dateTimeKey);
|
optionParseString(key, value, &instance->config.dateTime.key);
|
||||||
else if(strcasecmp(key, "--datetime-format") == 0)
|
else if(strcasecmp(key, "--datetime-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.dateTimeFormat);
|
optionParseString(key, value, &instance->config.dateTime.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--datetime-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.dateTime.errorFormat);
|
||||||
else if(strcasecmp(key, "--date-key") == 0)
|
else if(strcasecmp(key, "--date-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.dateKey);
|
optionParseString(key, value, &instance->config.date.key);
|
||||||
else if(strcasecmp(key, "--date-format") == 0)
|
else if(strcasecmp(key, "--date-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.dateFormat);
|
optionParseString(key, value, &instance->config.date.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--date-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.date.errorFormat);
|
||||||
else if(strcasecmp(key, "--time-key") == 0)
|
else if(strcasecmp(key, "--time-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.timeKey);
|
optionParseString(key, value, &instance->config.time.key);
|
||||||
else if(strcasecmp(key, "--time-format") == 0)
|
else if(strcasecmp(key, "--time-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.timeFormat);
|
optionParseString(key, value, &instance->config.time.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--time-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.time.errorFormat);
|
||||||
else if(strcasecmp(key, "--vulkan-key") == 0)
|
else if(strcasecmp(key, "--vulkan-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.vulkanKey);
|
optionParseString(key, value, &instance->config.vulkan.key);
|
||||||
else if(strcasecmp(key, "--vulkan-format") == 0)
|
else if(strcasecmp(key, "--vulkan-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.vulkanFormat);
|
optionParseString(key, value, &instance->config.vulkan.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--vulkan-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.vulkan.errorFormat);
|
||||||
else if(strcasecmp(key, "--opengl-key") == 0)
|
else if(strcasecmp(key, "--opengl-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.openGLKey);
|
optionParseString(key, value, &instance->config.openGL.key);
|
||||||
else if(strcasecmp(key, "--opengl-format") == 0)
|
else if(strcasecmp(key, "--opengl-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.openGLFormat);
|
optionParseString(key, value, &instance->config.openGL.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--opengl-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.openGL.errorFormat);
|
||||||
else if(strcasecmp(key, "--opencl-key") == 0)
|
else if(strcasecmp(key, "--opencl-key") == 0)
|
||||||
optionParseString(key, value, &instance->config.openCLKey);
|
optionParseString(key, value, &instance->config.openCL.key);
|
||||||
else if(strcasecmp(key, "--opencl-format") == 0)
|
else if(strcasecmp(key, "--opencl-format") == 0)
|
||||||
optionParseString(key, value, &instance->config.openCLFormat);
|
optionParseString(key, value, &instance->config.openCL.outputFormat);
|
||||||
|
else if(strcasecmp(key, "--opencl-error") == 0)
|
||||||
|
optionParseString(key, value, &instance->config.openCL.errorFormat);
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
//Library options//
|
//Library options//
|
||||||
@@ -1066,6 +1174,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
//Module options//
|
//Module options//
|
||||||
//////////////////
|
//////////////////
|
||||||
|
|
||||||
|
else if(strcasecmp(key, "--title-fqdn") == 0)
|
||||||
|
instance->config.titleFQDN = optionParseBoolean(value);
|
||||||
else if(strcasecmp(key, "--disk-folders") == 0)
|
else if(strcasecmp(key, "--disk-folders") == 0)
|
||||||
optionParseString(key, value, &instance->config.diskFolders);
|
optionParseString(key, value, &instance->config.diskFolders);
|
||||||
else if(strcasecmp(key, "--battery-dir") == 0)
|
else if(strcasecmp(key, "--battery-dir") == 0)
|
||||||
@@ -1118,8 +1228,21 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
|
static void parseConfigFileSystem(FFinstance* instance, FFdata* data)
|
||||||
{
|
{
|
||||||
|
FILE* file = fopen(FASTFETCH_TARGET_DIR_ROOT"/etc/fastfetch/config.conf", "r");
|
||||||
|
if(file == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
parseConfigFile(instance, data, file);
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void parseConfigFileUser(FFinstance* instance, FFdata* data)
|
||||||
|
{
|
||||||
|
if(!data->loadUserConfig)
|
||||||
|
return;
|
||||||
|
|
||||||
FFstrbuf* filename = ffListGet(&instance->state.configDirs, 0);
|
FFstrbuf* filename = ffListGet(&instance->state.configDirs, 0);
|
||||||
uint32_t filenameLength = filename->length;
|
uint32_t filenameLength = filename->length;
|
||||||
|
|
||||||
@@ -1142,7 +1265,7 @@ static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
|
|||||||
file = fopen(filename->chars, "w");
|
file = fopen(filename->chars, "w");
|
||||||
if(file != NULL)
|
if(file != NULL)
|
||||||
{
|
{
|
||||||
fputs(FASTFETCH_DATATEXT_CONFIG, file);
|
fputs(FASTFETCH_DATATEXT_CONFIG_USER, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1151,11 +1274,13 @@ static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
|
|||||||
|
|
||||||
static void parseArguments(FFinstance* instance, FFdata* data, int argc, const char** argv)
|
static void parseArguments(FFinstance* instance, FFdata* data, int argc, const char** argv)
|
||||||
{
|
{
|
||||||
|
if(!data->loadUserConfig)
|
||||||
|
return;
|
||||||
|
|
||||||
for(int i = 1; i < argc; i++)
|
for(int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if(i == argc - 1 || (
|
if(i == argc - 1 || (
|
||||||
*argv[i + 1] == '-' &&
|
*argv[i + 1] == '-' &&
|
||||||
strcasecmp(argv[i], "--offsetx") != 0 && // --offsetx allows negative values
|
|
||||||
strcasecmp(argv[i], "--separator-string") != 0 // Separator string can start with a -
|
strcasecmp(argv[i], "--separator-string") != 0 // Separator string can start with a -
|
||||||
)) {
|
)) {
|
||||||
parseOption(instance, data, argv[i], NULL);
|
parseOption(instance, data, argv[i], NULL);
|
||||||
@@ -1170,10 +1295,10 @@ static void parseArguments(FFinstance* instance, FFdata* data, int argc, const c
|
|||||||
|
|
||||||
static void parseStructureCommand(FFinstance* instance, FFdata* data, const char* line)
|
static void parseStructureCommand(FFinstance* instance, FFdata* data, const char* line)
|
||||||
{
|
{
|
||||||
const char* setValue = ffValuestoreGet(&data->valuestore, line);
|
CustomValue* customValue = ffValuestoreGet(&data->customValues, line);
|
||||||
if(setValue != NULL)
|
if(customValue != NULL)
|
||||||
{
|
{
|
||||||
ffPrintCustom(instance, line, setValue);
|
ffPrintCustom(instance, customValue->printKey ? line : NULL, customValue->value.chars);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1254,7 +1379,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
|
|||||||
else if(strcasecmp(line, "opencl") == 0)
|
else if(strcasecmp(line, "opencl") == 0)
|
||||||
ffPrintOpenCL(instance);
|
ffPrintOpenCL(instance);
|
||||||
else
|
else
|
||||||
ffPrintError(instance, line, 0, NULL, NULL, 0, "<no implementation provided>");
|
ffPrintErrorString(instance, line, 0, NULL, NULL, "<no implementation provided>");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char** argv)
|
int main(int argc, const char** argv)
|
||||||
@@ -1264,17 +1389,14 @@ int main(int argc, const char** argv)
|
|||||||
|
|
||||||
//Data stores things only needed for the configuration of fastfetch
|
//Data stores things only needed for the configuration of fastfetch
|
||||||
FFdata data;
|
FFdata data;
|
||||||
ffValuestoreInit(&data.valuestore);
|
ffValuestoreInit(&data.customValues, sizeof(CustomValue));
|
||||||
ffStrbufInitA(&data.structure, 256);
|
ffStrbufInitA(&data.structure, 256);
|
||||||
data.multithreading = true;
|
data.loadUserConfig = true;
|
||||||
|
|
||||||
parseDefaultConfigFile(&instance, &data);
|
parseConfigFileSystem(&instance, &data);
|
||||||
|
parseConfigFileUser(&instance, &data);
|
||||||
parseArguments(&instance, &data, argc, argv);
|
parseArguments(&instance, &data, argc, argv);
|
||||||
|
|
||||||
//Start detection threads
|
|
||||||
if(data.multithreading)
|
|
||||||
ffStartDetectionThreads(&instance);
|
|
||||||
|
|
||||||
//If we don't have a custom structure, use the default one
|
//If we don't have a custom structure, use the default one
|
||||||
if(data.structure.length == 0)
|
if(data.structure.length == 0)
|
||||||
ffStrbufSetS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
|
ffStrbufSetS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
|
||||||
|
|||||||
+60
-431
@@ -3,24 +3,17 @@
|
|||||||
#ifndef FASTFETCH_INCLUDED
|
#ifndef FASTFETCH_INCLUDED
|
||||||
#define FASTFETCH_INCLUDED
|
#define FASTFETCH_INCLUDED
|
||||||
|
|
||||||
#include <stddef.h>
|
#include "fastfetch_config.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
#include "fastfetch_config.h"
|
|
||||||
|
|
||||||
#include "util/FFstrbuf.h"
|
#include "util/FFstrbuf.h"
|
||||||
#include "util/FFlist.h"
|
#include "util/FFlist.h"
|
||||||
#include "util/FFvaluestore.h"
|
|
||||||
|
|
||||||
static inline void ffUnused(int dummy, ...) { (void) dummy; }
|
static inline void ffUnused(int dummy, ...) { (void) dummy; }
|
||||||
#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__);
|
#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__);
|
||||||
@@ -50,16 +43,26 @@ typedef enum FFGLType
|
|||||||
FF_GL_TYPE_OSMESA
|
FF_GL_TYPE_OSMESA
|
||||||
} FFGLType;
|
} FFGLType;
|
||||||
|
|
||||||
|
typedef struct FFModuleArgs
|
||||||
|
{
|
||||||
|
FFstrbuf key;
|
||||||
|
FFstrbuf outputFormat;
|
||||||
|
FFstrbuf errorFormat;
|
||||||
|
} FFModuleArgs;
|
||||||
|
|
||||||
typedef struct FFconfig
|
typedef struct FFconfig
|
||||||
{
|
{
|
||||||
FFstrbuf logoSource;
|
struct
|
||||||
FFLogoType logoType;
|
{
|
||||||
FFstrbuf logoColors[FASTFETCH_LOGO_MAX_COLORS];
|
FFstrbuf source;
|
||||||
uint32_t logoWidth;
|
FFLogoType type;
|
||||||
uint32_t logoHeight;
|
FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS];
|
||||||
uint32_t logoPaddingLeft;
|
uint32_t width;
|
||||||
uint32_t logoPaddingRight;
|
uint32_t height;
|
||||||
bool logoPrintRemaining;
|
uint32_t paddingLeft;
|
||||||
|
uint32_t paddingRight;
|
||||||
|
bool printRemaining;
|
||||||
|
} logo;
|
||||||
|
|
||||||
FFstrbuf mainColor; //If this is empty, ffLogoPrint will set it to the main color of the logo
|
FFstrbuf mainColor; //If this is empty, ffLogoPrint will set it to the main color of the logo
|
||||||
FFstrbuf separator;
|
FFstrbuf separator;
|
||||||
@@ -73,75 +76,42 @@ typedef struct FFconfig
|
|||||||
bool escapeBedrock;
|
bool escapeBedrock;
|
||||||
FFGLType glType;
|
FFGLType glType;
|
||||||
bool pipe; //disables logo and all escape sequences
|
bool pipe; //disables logo and all escape sequences
|
||||||
|
bool multithreading;
|
||||||
|
|
||||||
FFstrbuf osFormat;
|
FFModuleArgs os;
|
||||||
FFstrbuf osKey;
|
FFModuleArgs host;
|
||||||
FFstrbuf hostFormat;
|
FFModuleArgs kernel;
|
||||||
FFstrbuf hostKey;
|
FFModuleArgs uptime;
|
||||||
FFstrbuf kernelFormat;
|
FFModuleArgs processes;
|
||||||
FFstrbuf kernelKey;
|
FFModuleArgs packages;
|
||||||
FFstrbuf uptimeFormat;
|
FFModuleArgs shell;
|
||||||
FFstrbuf uptimeKey;
|
FFModuleArgs resolution;
|
||||||
FFstrbuf processesFormat;
|
FFModuleArgs de;
|
||||||
FFstrbuf processesKey;
|
FFModuleArgs wm;
|
||||||
FFstrbuf packagesFormat;
|
FFModuleArgs wmTheme;
|
||||||
FFstrbuf packagesKey;
|
FFModuleArgs theme;
|
||||||
FFstrbuf shellFormat;
|
FFModuleArgs icons;
|
||||||
FFstrbuf shellKey;
|
FFModuleArgs font;
|
||||||
FFstrbuf resolutionFormat;
|
FFModuleArgs cursor;
|
||||||
FFstrbuf resolutionKey;
|
FFModuleArgs terminal;
|
||||||
FFstrbuf deFormat;
|
FFModuleArgs terminalFont;
|
||||||
FFstrbuf deKey;
|
FFModuleArgs cpu;
|
||||||
FFstrbuf wmFormat;
|
FFModuleArgs cpuUsage;
|
||||||
FFstrbuf wmKey;
|
FFModuleArgs gpu;
|
||||||
FFstrbuf wmThemeFormat;
|
FFModuleArgs memory;
|
||||||
FFstrbuf wmThemeKey;
|
FFModuleArgs disk;
|
||||||
FFstrbuf themeFormat;
|
FFModuleArgs battery;
|
||||||
FFstrbuf themeKey;
|
FFModuleArgs locale;
|
||||||
FFstrbuf iconsFormat;
|
FFModuleArgs localIP;
|
||||||
FFstrbuf iconsKey;
|
FFModuleArgs publicIP;
|
||||||
FFstrbuf fontFormat;
|
FFModuleArgs player;
|
||||||
FFstrbuf fontKey;
|
FFModuleArgs song;
|
||||||
FFstrbuf cursorFormat;
|
FFModuleArgs dateTime;
|
||||||
FFstrbuf cursorKey;
|
FFModuleArgs date;
|
||||||
FFstrbuf terminalFormat;
|
FFModuleArgs time;
|
||||||
FFstrbuf terminalKey;
|
FFModuleArgs vulkan;
|
||||||
FFstrbuf termFontFormat;
|
FFModuleArgs openGL;
|
||||||
FFstrbuf termFontKey;
|
FFModuleArgs openCL;
|
||||||
FFstrbuf cpuFormat;
|
|
||||||
FFstrbuf cpuKey;
|
|
||||||
FFstrbuf cpuUsageFormat;
|
|
||||||
FFstrbuf cpuUsageKey;
|
|
||||||
FFstrbuf gpuFormat;
|
|
||||||
FFstrbuf gpuKey;
|
|
||||||
FFstrbuf memoryFormat;
|
|
||||||
FFstrbuf memoryKey;
|
|
||||||
FFstrbuf diskFormat;
|
|
||||||
FFstrbuf diskKey;
|
|
||||||
FFstrbuf batteryFormat;
|
|
||||||
FFstrbuf batteryKey;
|
|
||||||
FFstrbuf localeFormat;
|
|
||||||
FFstrbuf localeKey;
|
|
||||||
FFstrbuf localIpKey;
|
|
||||||
FFstrbuf localIpFormat;
|
|
||||||
FFstrbuf publicIpKey;
|
|
||||||
FFstrbuf publicIpFormat;
|
|
||||||
FFstrbuf playerKey;
|
|
||||||
FFstrbuf playerFormat;
|
|
||||||
FFstrbuf songKey;
|
|
||||||
FFstrbuf songFormat;
|
|
||||||
FFstrbuf dateTimeKey;
|
|
||||||
FFstrbuf dateTimeFormat;
|
|
||||||
FFstrbuf dateKey;
|
|
||||||
FFstrbuf dateFormat;
|
|
||||||
FFstrbuf timeKey;
|
|
||||||
FFstrbuf timeFormat;
|
|
||||||
FFstrbuf vulkanKey;
|
|
||||||
FFstrbuf vulkanFormat;
|
|
||||||
FFstrbuf openGLKey;
|
|
||||||
FFstrbuf openGLFormat;
|
|
||||||
FFstrbuf openCLKey;
|
|
||||||
FFstrbuf openCLFormat;
|
|
||||||
|
|
||||||
FFstrbuf libPCI;
|
FFstrbuf libPCI;
|
||||||
FFstrbuf libVulkan;
|
FFstrbuf libVulkan;
|
||||||
@@ -164,6 +134,8 @@ typedef struct FFconfig
|
|||||||
FFstrbuf libOSMesa;
|
FFstrbuf libOSMesa;
|
||||||
FFstrbuf libOpenCL;
|
FFstrbuf libOpenCL;
|
||||||
|
|
||||||
|
bool titleFQDN;
|
||||||
|
|
||||||
FFstrbuf diskFolders;
|
FFstrbuf diskFolders;
|
||||||
|
|
||||||
FFstrbuf batteryDir;
|
FFstrbuf batteryDir;
|
||||||
@@ -201,236 +173,8 @@ typedef struct FFinstance
|
|||||||
FFstate state;
|
FFstate state;
|
||||||
} FFinstance;
|
} FFinstance;
|
||||||
|
|
||||||
typedef struct FFVersion
|
|
||||||
{
|
|
||||||
uint32_t major;
|
|
||||||
uint32_t minor;
|
|
||||||
uint32_t patch;
|
|
||||||
} FFVersion;
|
|
||||||
#define FF_VERSION_INIT ((FFVersion) {0})
|
|
||||||
|
|
||||||
typedef struct FFTitleResult
|
|
||||||
{
|
|
||||||
FFstrbuf userName;
|
|
||||||
FFstrbuf hostname;
|
|
||||||
} FFTitleResult;
|
|
||||||
|
|
||||||
typedef struct FFOSResult
|
|
||||||
{
|
|
||||||
FFstrbuf systemName;
|
|
||||||
FFstrbuf name;
|
|
||||||
FFstrbuf prettyName;
|
|
||||||
FFstrbuf id;
|
|
||||||
FFstrbuf idLike;
|
|
||||||
FFstrbuf variant;
|
|
||||||
FFstrbuf variantID;
|
|
||||||
FFstrbuf version;
|
|
||||||
FFstrbuf versionID;
|
|
||||||
FFstrbuf codename;
|
|
||||||
FFstrbuf buildID;
|
|
||||||
FFstrbuf architecture;
|
|
||||||
} FFOSResult;
|
|
||||||
|
|
||||||
typedef struct FFPlasmaResult
|
|
||||||
{
|
|
||||||
FFstrbuf widgetStyle;
|
|
||||||
FFstrbuf colorScheme;
|
|
||||||
FFstrbuf icons;
|
|
||||||
FFstrbuf font;
|
|
||||||
} FFPlasmaResult;
|
|
||||||
|
|
||||||
typedef struct FFGTKResult
|
|
||||||
{
|
|
||||||
FFstrbuf theme;
|
|
||||||
FFstrbuf icons;
|
|
||||||
FFstrbuf font;
|
|
||||||
FFstrbuf cursor;
|
|
||||||
FFstrbuf cursorSize;
|
|
||||||
} FFGTKResult;
|
|
||||||
|
|
||||||
typedef struct FFTerminalShellResult
|
|
||||||
{
|
|
||||||
FFstrbuf shellProcessName;
|
|
||||||
FFstrbuf shellExe;
|
|
||||||
const char* shellExeName; //pointer to a char in shellExe
|
|
||||||
FFstrbuf shellVersion;
|
|
||||||
|
|
||||||
FFstrbuf terminalProcessName;
|
|
||||||
FFstrbuf terminalExe;
|
|
||||||
const char* terminalExeName; //pointer to a char in terminalExe
|
|
||||||
|
|
||||||
FFstrbuf userShellExe;
|
|
||||||
const char* userShellExeName; //pointer to a char in userShellExe
|
|
||||||
FFstrbuf userShellVersion;
|
|
||||||
} FFTerminalShellResult;
|
|
||||||
|
|
||||||
typedef struct FFGPUResult
|
|
||||||
{
|
|
||||||
FFstrbuf vendor;
|
|
||||||
FFstrbuf name;
|
|
||||||
FFstrbuf driver;
|
|
||||||
} FFGPUResult;
|
|
||||||
|
|
||||||
typedef struct FFVulkanResult
|
|
||||||
{
|
|
||||||
FFstrbuf driver;
|
|
||||||
FFstrbuf apiVersion;
|
|
||||||
FFstrbuf conformanceVersion;
|
|
||||||
FFlist devices; //List of FFGPUResult
|
|
||||||
} FFVulkanResult;
|
|
||||||
|
|
||||||
typedef struct FFResolutionResult
|
|
||||||
{
|
|
||||||
uint32_t width;
|
|
||||||
uint32_t height;
|
|
||||||
uint32_t refreshRate;
|
|
||||||
} FFResolutionResult;
|
|
||||||
|
|
||||||
typedef struct FFDisplayServerResult
|
|
||||||
{
|
|
||||||
FFstrbuf wmProcessName;
|
|
||||||
FFstrbuf wmPrettyName;
|
|
||||||
FFstrbuf wmProtocolName;
|
|
||||||
FFstrbuf deProcessName;
|
|
||||||
FFstrbuf dePrettyName;
|
|
||||||
FFstrbuf deVersion;
|
|
||||||
FFlist resolutions; //List of FFResolutionResult
|
|
||||||
} FFDisplayServerResult;
|
|
||||||
|
|
||||||
typedef struct FFTempValue
|
|
||||||
{
|
|
||||||
FFstrbuf name;
|
|
||||||
FFstrbuf value;
|
|
||||||
FFstrbuf deviceClass;
|
|
||||||
} FFTempValue;
|
|
||||||
|
|
||||||
typedef struct FFTempsResult
|
|
||||||
{
|
|
||||||
FFlist values; //List of FFTempValue
|
|
||||||
} FFTempsResult;
|
|
||||||
|
|
||||||
typedef struct FFMediaResult
|
|
||||||
{
|
|
||||||
FFstrbuf busNameShort; //e.g. plasma-browser-integration
|
|
||||||
FFstrbuf player; // e.g. Google Chrome
|
|
||||||
FFstrbuf song;
|
|
||||||
FFstrbuf artist;
|
|
||||||
FFstrbuf album;
|
|
||||||
FFstrbuf url;
|
|
||||||
} FFMediaResult;
|
|
||||||
|
|
||||||
typedef struct FFDateTimeResult
|
|
||||||
{
|
|
||||||
//Examples for 21.02.2022 - 15:18:37
|
|
||||||
uint16_t year; //2022
|
|
||||||
uint8_t yearShort; //22
|
|
||||||
uint8_t month; //2
|
|
||||||
FFstrbuf monthPretty; //02
|
|
||||||
FFstrbuf monthName; //February
|
|
||||||
FFstrbuf monthNameShort; //Feb
|
|
||||||
uint8_t week; //8
|
|
||||||
FFstrbuf weekday; //Monday
|
|
||||||
FFstrbuf weekdayShort; //Mon
|
|
||||||
uint16_t dayInYear; //52
|
|
||||||
uint8_t dayInMonth; //21
|
|
||||||
uint8_t dayInWeek; //1
|
|
||||||
uint8_t hour; //15
|
|
||||||
FFstrbuf hourPretty; //15
|
|
||||||
uint8_t hour12; //3
|
|
||||||
FFstrbuf hour12Pretty; //03
|
|
||||||
uint8_t minute; //18
|
|
||||||
FFstrbuf minutePretty; //18
|
|
||||||
uint8_t second; //37
|
|
||||||
FFstrbuf secondPretty; //37
|
|
||||||
} FFDateTimeResult;
|
|
||||||
|
|
||||||
typedef enum FFformatargtype
|
|
||||||
{
|
|
||||||
FF_FORMAT_ARG_TYPE_NULL = 0,
|
|
||||||
FF_FORMAT_ARG_TYPE_UINT,
|
|
||||||
FF_FORMAT_ARG_TYPE_UINT16,
|
|
||||||
FF_FORMAT_ARG_TYPE_UINT8,
|
|
||||||
FF_FORMAT_ARG_TYPE_INT,
|
|
||||||
FF_FORMAT_ARG_TYPE_STRING,
|
|
||||||
FF_FORMAT_ARG_TYPE_STRBUF,
|
|
||||||
FF_FORMAT_ARG_TYPE_DOUBLE,
|
|
||||||
FF_FORMAT_ARG_TYPE_LIST
|
|
||||||
} FFformatargtype;
|
|
||||||
|
|
||||||
typedef struct FFformatarg
|
|
||||||
{
|
|
||||||
FFformatargtype type;
|
|
||||||
const void* value;
|
|
||||||
} FFformatarg;
|
|
||||||
|
|
||||||
typedef struct FFcache
|
|
||||||
{
|
|
||||||
FILE* value;
|
|
||||||
FILE* split;
|
|
||||||
} FFcache;
|
|
||||||
|
|
||||||
typedef enum FFvarianttype
|
|
||||||
{
|
|
||||||
FF_VARIANT_TYPE_STRING,
|
|
||||||
FF_VARIANT_TYPE_BOOL,
|
|
||||||
FF_VARIANT_TYPE_INT
|
|
||||||
} FFvarianttype;
|
|
||||||
|
|
||||||
typedef union FFvariant
|
|
||||||
{
|
|
||||||
const char* strValue;
|
|
||||||
int32_t intValue;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
bool boolValueSet;
|
|
||||||
bool boolValue;
|
|
||||||
};
|
|
||||||
} FFvariant;
|
|
||||||
|
|
||||||
#define FF_VARIANT_NULL ((FFvariant){.strValue = NULL})
|
|
||||||
|
|
||||||
typedef struct FFfont
|
|
||||||
{
|
|
||||||
FFstrbuf pretty;
|
|
||||||
FFstrbuf name;
|
|
||||||
FFstrbuf size;
|
|
||||||
FFlist styles;
|
|
||||||
} FFfont;
|
|
||||||
|
|
||||||
typedef struct FFpropquery
|
|
||||||
{
|
|
||||||
const char* start;
|
|
||||||
FFstrbuf* buffer;
|
|
||||||
} FFpropquery;
|
|
||||||
|
|
||||||
typedef enum FFInitState
|
|
||||||
{
|
|
||||||
FF_INITSTATE_UNINITIALIZED = 0,
|
|
||||||
FF_INITSTATE_SUCCESSFUL = 1,
|
|
||||||
FF_INITSTATE_FAILED = 2
|
|
||||||
} FFInitState;
|
|
||||||
|
|
||||||
#define FF_LIBRARY_SYMBOL(symbolName) \
|
|
||||||
__typeof__(&symbolName) ff ## symbolName;
|
|
||||||
|
|
||||||
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
|
|
||||||
void* libraryObjectName = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL);\
|
|
||||||
if(libraryObjectName == NULL) \
|
|
||||||
return returnValue;
|
|
||||||
|
|
||||||
#define FF_LIBRARY_LOAD_SYMBOL_ADRESS(library, symbolMapping, symbolName, returnValue) \
|
|
||||||
symbolMapping = dlsym(library, #symbolName); \
|
|
||||||
if(symbolMapping == NULL) \
|
|
||||||
{ \
|
|
||||||
dlclose(library); \
|
|
||||||
return returnValue; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
|
||||||
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADRESS(library, ff ## symbolName, symbolName, returnValue);
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// Common functions //
|
// Init functions //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
//common/init.c
|
//common/init.c
|
||||||
@@ -440,87 +184,6 @@ void ffFinish(FFinstance* instance);
|
|||||||
|
|
||||||
void ffListFeatures();
|
void ffListFeatures();
|
||||||
|
|
||||||
//common/threading.c
|
|
||||||
void ffStartDetectionThreads(FFinstance* instance);
|
|
||||||
|
|
||||||
//common/io.c
|
|
||||||
void ffAppendFDContent(int fd, FFstrbuf* buffer);
|
|
||||||
bool ffAppendFileContent(const char* fileName, FFstrbuf* buffer); //returns true if open() succeeds. This is used to differentiate between <file not found> and <empty file>
|
|
||||||
bool ffGetFileContent(const char* fileName, FFstrbuf* buffer);
|
|
||||||
bool ffWriteFDContent(int fd, const FFstrbuf* content);
|
|
||||||
bool ffWriteFileContent(const char* fileName, const FFstrbuf* buffer);
|
|
||||||
|
|
||||||
bool ffFileExists(const char* fileName, mode_t mode);
|
|
||||||
void ffSuppressIO(bool suppress); // Not thread safe!
|
|
||||||
|
|
||||||
void ffGetTerminalResponse(const char* request, const char* format, ...);
|
|
||||||
|
|
||||||
//common/printing.c
|
|
||||||
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat);
|
|
||||||
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numFormatArgs, const char* message, ...);
|
|
||||||
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments);
|
|
||||||
void ffPrintColor(const FFstrbuf* colorValue);
|
|
||||||
void ffPrintCharTimes(char c, uint32_t times);
|
|
||||||
|
|
||||||
//common/caching.c
|
|
||||||
void ffCacheValidate(FFinstance* instance);
|
|
||||||
|
|
||||||
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache);
|
|
||||||
void ffCacheClose(FFcache* cache);
|
|
||||||
|
|
||||||
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numArgs);
|
|
||||||
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, FFcache* cache, const FFstrbuf* value, const FFstrbuf* formatString, uint32_t numArgs, const FFformatarg* arguments);
|
|
||||||
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* value, const FFstrbuf* formatString, uint32_t numArgs, const FFformatarg* arguments);
|
|
||||||
|
|
||||||
//common/properties.c
|
|
||||||
bool ffParsePropLine(const char* line, const char* start, FFstrbuf* buffer);
|
|
||||||
bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer);
|
|
||||||
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries);
|
|
||||||
bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer);
|
|
||||||
bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
|
|
||||||
bool ffParsePropFileHome(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
|
|
||||||
bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
|
|
||||||
bool ffParsePropFileConfig(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
|
|
||||||
|
|
||||||
//common/font.c
|
|
||||||
void ffFontInitQt(FFfont* font, const char* data);
|
|
||||||
void ffFontInitPango(FFfont* font, const char* data);
|
|
||||||
void ffFontInitCopy(FFfont* font, const char* name);
|
|
||||||
void ffFontDestroy(FFfont* font);
|
|
||||||
|
|
||||||
//common/format.c
|
|
||||||
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
|
|
||||||
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments);
|
|
||||||
|
|
||||||
//common/parsing.c
|
|
||||||
bool ffStrSet(const char* str);
|
|
||||||
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);
|
|
||||||
void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4);
|
|
||||||
|
|
||||||
void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty);
|
|
||||||
int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2);
|
|
||||||
|
|
||||||
//common/processing.c
|
|
||||||
void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]);
|
|
||||||
|
|
||||||
//common/libraries.c
|
|
||||||
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
|
|
||||||
|
|
||||||
//common/networking.c
|
|
||||||
void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, FFstrbuf* buffer);
|
|
||||||
|
|
||||||
//common/settings.c
|
|
||||||
FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttype type);
|
|
||||||
FFvariant ffSettingsGetGSettings(FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type);
|
|
||||||
FFvariant ffSettingsGet(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type);
|
|
||||||
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type);
|
|
||||||
|
|
||||||
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query);
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
// Logo functions //
|
// Logo functions //
|
||||||
////////////////////
|
////////////////////
|
||||||
@@ -533,47 +196,13 @@ void ffLogoBuiltinPrint(FFinstance* instance);
|
|||||||
void ffLogoBuiltinList();
|
void ffLogoBuiltinList();
|
||||||
void ffLogoBuiltinListAutocompletion();
|
void ffLogoBuiltinListAutocompletion();
|
||||||
|
|
||||||
/////////////////////////
|
|
||||||
// Detection functions //
|
|
||||||
/////////////////////////
|
|
||||||
|
|
||||||
//detection/os.c
|
|
||||||
const FFOSResult* ffDetectOS(const FFinstance* instance);
|
|
||||||
|
|
||||||
//detection/plasma.c
|
|
||||||
const FFPlasmaResult* ffDetectPlasma(FFinstance* instance);
|
|
||||||
|
|
||||||
//detection/gtk.c
|
|
||||||
const FFGTKResult* ffDetectGTK2(FFinstance* instance);
|
|
||||||
const FFGTKResult* ffDetectGTK4(FFinstance* instance);
|
|
||||||
const FFGTKResult* ffDetectGTK3(FFinstance* instance);
|
|
||||||
|
|
||||||
//detection/displayServer.c
|
|
||||||
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance);
|
|
||||||
|
|
||||||
//detection/terminalShell.c
|
|
||||||
const FFTerminalShellResult* ffDetectTerminalShell(FFinstance* instance);
|
|
||||||
|
|
||||||
//detection/temps.c (currently unused)
|
|
||||||
const FFTempsResult* ffDetectTemps(const FFinstance* instance);
|
|
||||||
|
|
||||||
//detection/media.c
|
|
||||||
const FFMediaResult* ffDetectMedia(FFinstance* instance);
|
|
||||||
|
|
||||||
//detection/dateTime.c
|
|
||||||
const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance);
|
|
||||||
|
|
||||||
//detection/vulkan.c
|
|
||||||
const FFVulkanResult* ffDetectVulkan(const FFinstance* instance);
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// Module functions //
|
// Module functions //
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
//Common
|
//Common
|
||||||
const FFTitleResult* ffDetectTitle(FFinstance* instance);
|
|
||||||
|
|
||||||
void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFstrbuf* key, const FFstrbuf* format);
|
void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs);
|
||||||
|
|
||||||
//Printing
|
//Printing
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
#define FASTFETCH_TARGET_DIR_HOME "@TARGET_DIR_HOME@"
|
#define FASTFETCH_TARGET_DIR_HOME "@TARGET_DIR_HOME@"
|
||||||
|
|
||||||
#define FASTFETCH_DATATEXT_STRUCTURE "@DATATEXT_STRUCTURE@"
|
#define FASTFETCH_DATATEXT_STRUCTURE "@DATATEXT_STRUCTURE@"
|
||||||
#define FASTFETCH_DATATEXT_CONFIG "@DATATEXT_CONFIG@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set
|
#define FASTFETCH_DATATEXT_CONFIG_SYSTEM "@DATATEXT_CONFIG_SYSTEM@" //Requires FASTFETCH_PROJECT_VERSION to be set
|
||||||
|
#define FASTFETCH_DATATEXT_CONFIG_USER "@DATATEXT_CONFIG_USER@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set
|
||||||
#define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@"
|
#define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@"
|
||||||
#define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@"
|
#define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@"
|
||||||
#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@"
|
#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@"
|
||||||
|
|||||||
+1
-4
@@ -10,10 +10,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
//Modify instance.config here
|
//Modify instance.config here
|
||||||
|
|
||||||
//Multithreading --> better performance
|
//Does things like starting detection threads, disabling line wrap, etc
|
||||||
ffStartDetectionThreads(&instance);
|
|
||||||
|
|
||||||
//Does things like disabling line wrap
|
|
||||||
ffStart(&instance);
|
ffStart(&instance);
|
||||||
|
|
||||||
//Printing
|
//Printing
|
||||||
|
|||||||
+210
-30
@@ -43,6 +43,92 @@ static const FFlogo* getLogoNone()
|
|||||||
FF_LOGO_RETURN
|
FF_LOGO_RETURN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const FFlogo* getLogoAlmaLinux()
|
||||||
|
{
|
||||||
|
FF_LOGO_INIT
|
||||||
|
FF_LOGO_NAMES("almalinux")
|
||||||
|
FF_LOGO_LINES(
|
||||||
|
"$1 'c:.\n"
|
||||||
|
"$1 lkkkx, .. $2.. ,cc,\n"
|
||||||
|
"$1 okkkk:ckkx' $2.lxkkx.okkkkd\n"
|
||||||
|
"$1 .:llcokkx' $2:kkkxkko:xkkd,\n"
|
||||||
|
"$1 .xkkkkdood: $2;kx, .lkxlll;\n"
|
||||||
|
"$1 xkkx. $2xk' xkkkkk:\n"
|
||||||
|
"$1 'xkx. $2xd .....,.\n"
|
||||||
|
"$3 .. $1:xkl' $2:c ..''..\n"
|
||||||
|
"$3 .dkx' $1.:ldl:'. $2' $4':lollldkkxo;\n"
|
||||||
|
"$3 .''lkkko' $4ckkkx.\n"
|
||||||
|
"$3'xkkkd:kkd. .. $5;' $4:kkxo.\n"
|
||||||
|
"$3,xkkkd;kk' ,d; $5ld. $4':dkd::cc,\n"
|
||||||
|
"$3 .,,.;xkko'.';lxo. $5dx, $4:kkk'xkkkkc\n"
|
||||||
|
"$3 'dkkkkkxo:. $5;kx $4.kkk:;xkkd.\n"
|
||||||
|
"$3 ..... $5.;dk:. $5lkk. $4:;,\n"
|
||||||
|
" $5:kkkkkkkdoxkkx\n"
|
||||||
|
" ,c,,;;;:xkkd.\n"
|
||||||
|
" ;kkkkl...\n"
|
||||||
|
" ;kkkkl\n"
|
||||||
|
" ,od;";
|
||||||
|
)
|
||||||
|
FF_LOGO_COLORS(
|
||||||
|
"31", // red
|
||||||
|
"1;33", // yellow
|
||||||
|
"34", // blue
|
||||||
|
"1;32", // light green
|
||||||
|
"36" // cyan
|
||||||
|
)
|
||||||
|
FF_LOGO_RETURN
|
||||||
|
}
|
||||||
|
|
||||||
|
static const FFlogo* getLogoAlpine()
|
||||||
|
{
|
||||||
|
FF_LOGO_INIT
|
||||||
|
FF_LOGO_NAMES("alpine", "alpinelinux", "alpine-linux")
|
||||||
|
FF_LOGO_LINES(
|
||||||
|
" .hddddddddddddddddddddddh.\n"
|
||||||
|
" :dddddddddddddddddddddddddd:\n"
|
||||||
|
" /dddddddddddddddddddddddddddd/\n"
|
||||||
|
" +dddddddddddddddddddddddddddddd+\n"
|
||||||
|
" `sdddddddddddddddddddddddddddddddds`\n"
|
||||||
|
" `ydddddddddddd++hdddddddddddddddddddy`\n"
|
||||||
|
".hddddddddddd+` `+ddddh:-sdddddddddddh. \n"
|
||||||
|
"hdddddddddd+` `+y: .sddddddddddh\n"
|
||||||
|
"ddddddddh+` `//` `.` -sddddddddd\n"
|
||||||
|
"ddddddh+` `/hddh/` `:s- -sddddddd\n"
|
||||||
|
"ddddh+` `/+/dddddh/` `+s- -sddddd\n"
|
||||||
|
"ddd+` `/o` :dddddddh/` `oy- .yddd\n"
|
||||||
|
"hdddyo+ohddyosdddddddddho+oydddy++ohdddh\n"
|
||||||
|
".hddddddddddddddddddddddddddddddddddddh.\n"
|
||||||
|
" `yddddddddddddddddddddddddddddddddddy`\n"
|
||||||
|
" `sdddddddddddddddddddddddddddddddds`\n"
|
||||||
|
" +dddddddddddddddddddddddddddddd+\n"
|
||||||
|
" /dddddddddddddddddddddddddddd/\n"
|
||||||
|
" :dddddddddddddddddddddddddd:\n"
|
||||||
|
" .hddddddddddddddddddddddh.";
|
||||||
|
)
|
||||||
|
FF_LOGO_COLORS(
|
||||||
|
"34" //blue
|
||||||
|
)
|
||||||
|
FF_LOGO_RETURN
|
||||||
|
}
|
||||||
|
|
||||||
|
static const FFlogo* getLogoAlpineSmall()
|
||||||
|
{
|
||||||
|
FF_LOGO_INIT
|
||||||
|
FF_LOGO_NAMES("alpine_small", "alpine-linux-small")
|
||||||
|
FF_LOGO_LINES(
|
||||||
|
" /\\ /\\\n"
|
||||||
|
" // \\ \\\n"
|
||||||
|
" // \\ \\\n"
|
||||||
|
"/// \\ \\\n"
|
||||||
|
"// \\ \\\n"
|
||||||
|
" \\"
|
||||||
|
)
|
||||||
|
FF_LOGO_COLORS(
|
||||||
|
"34" //blue
|
||||||
|
)
|
||||||
|
FF_LOGO_RETURN
|
||||||
|
}
|
||||||
|
|
||||||
static const FFlogo* getLogoAndroid()
|
static const FFlogo* getLogoAndroid()
|
||||||
{
|
{
|
||||||
FF_LOGO_INIT
|
FF_LOGO_INIT
|
||||||
@@ -155,18 +241,18 @@ static const FFlogo* getLogoArtix()
|
|||||||
" 'oookkxxoo'\n"
|
" 'oookkxxoo'\n"
|
||||||
" 'oiioxkkxxoo'\n"
|
" 'oiioxkkxxoo'\n"
|
||||||
" ':;:iiiioxxxoo'\n"
|
" ':;:iiiioxxxoo'\n"
|
||||||
" `'.;::ioxxoo''\n"
|
" `'.;::ioxxoo'\n"
|
||||||
" '-. `':;jiooo'\n"
|
" '-. `':;jiooo'\n"
|
||||||
" 'oooio-.. `'i:io'\n"
|
" 'oooio-.. `'i:io'\n"
|
||||||
" 'ooooxxxxoio:,. `'-;'\n"
|
" 'ooooxxxxoio:,. `'-;'\n"
|
||||||
" 'ooooxxxxxkkxoooIi:-. `'\n"
|
" 'ooooxxxxxkkxoooIi:-. `'\n"
|
||||||
" 'ooooxxxxxkkkkxoiiiiiji'\n"
|
" 'ooooxxxxxkkkkxoiiiiiji'\n"
|
||||||
" 'ooooxxxxxkxxoiiii:'` .i'\n"
|
" 'ooooxxxxxkxxoiiii:'` .i'\n"
|
||||||
" 'ooooxxxxxoi:::'` .;ioxo'\n"
|
" 'ooooxxxxxoi:::'` .;ioxo'\n"
|
||||||
" 'ooooxooi::'` .:iiixkxxo'\n"
|
" 'ooooxooi::'` .:iiixkxxo'\n"
|
||||||
" 'ooooi:'` `'';ioxxo'\n"
|
" 'ooooi:'` `'';ioxxo'\n"
|
||||||
"'i:'` '':io'\n"
|
" 'i:'` '':io'\n"
|
||||||
"'` `'";
|
"'` `'";
|
||||||
)
|
)
|
||||||
FF_LOGO_COLORS(
|
FF_LOGO_COLORS(
|
||||||
"36" //cyan
|
"36" //cyan
|
||||||
@@ -725,6 +811,27 @@ static const FFlogo* getLogoKDENeon()
|
|||||||
FF_LOGO_RETURN
|
FF_LOGO_RETURN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const FFlogo* getLogoKISSLinux()
|
||||||
|
{
|
||||||
|
FF_LOGO_INIT
|
||||||
|
FF_LOGO_NAMES("kiss", "kiss-linux", "kisslinux")
|
||||||
|
FF_LOGO_LINES(
|
||||||
|
" $3 ___ \n"
|
||||||
|
" ($2.· $3| \n"
|
||||||
|
" ($1<> $3| \n"
|
||||||
|
" / $2__$3 \\ \n"
|
||||||
|
" ( $1/ \\ $3/| \n"
|
||||||
|
"$1_$3/\\ $2__)$3/$1_$3) \n"
|
||||||
|
"$1\\/$3-____$1\\/$2 \n"
|
||||||
|
)
|
||||||
|
FF_LOGO_COLORS(
|
||||||
|
"35", //magenta
|
||||||
|
"37", //white
|
||||||
|
"34" //blue
|
||||||
|
)
|
||||||
|
FF_LOGO_RETURN
|
||||||
|
}
|
||||||
|
|
||||||
static const FFlogo* getLogoKubuntu()
|
static const FFlogo* getLogoKubuntu()
|
||||||
{
|
{
|
||||||
FF_LOGO_INIT
|
FF_LOGO_INIT
|
||||||
@@ -758,6 +865,32 @@ static const FFlogo* getLogoKubuntu()
|
|||||||
FF_LOGO_RETURN
|
FF_LOGO_RETURN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const FFlogo* getLogoLangitKetujuh()
|
||||||
|
{
|
||||||
|
FF_LOGO_INIT
|
||||||
|
FF_LOGO_NAMES("l7", "langitketujuh", "LangitKetujuh")
|
||||||
|
FF_LOGO_LINES(
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
|
" $2. '7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7\n"
|
||||||
|
" $2L7. '7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7\n"
|
||||||
|
" $2L7L7L 7L7L7L7L7L7L7L7L7L7L7L7L7L7\n"
|
||||||
|
" $2L7L7L7 L7L7L7\n"
|
||||||
|
" $2L7L7L7 'L7L7L7L7L7L7L7L7L7L7\n"
|
||||||
|
" $2L7L7L7 'L7L7L7L7L7L7L7L7\n"
|
||||||
|
" $2L7L7L7 'L7L7L7L7L7L7\n"
|
||||||
|
" $2L7L7L7 L7L7L7\n"
|
||||||
|
" $2L7L7L7L7L7L7L7L7L7L7LL7L7L7. '7L7L7\n"
|
||||||
|
" $2L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L. 'L7\n"
|
||||||
|
" $2L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7L7. '\n"
|
||||||
|
)
|
||||||
|
FF_LOGO_COLORS(
|
||||||
|
"34", //blue
|
||||||
|
"37" //white
|
||||||
|
)
|
||||||
|
FF_LOGO_RETURN
|
||||||
|
}
|
||||||
|
|
||||||
static const FFlogo* getLogoLinux()
|
static const FFlogo* getLogoLinux()
|
||||||
{
|
{
|
||||||
FF_LOGO_INIT
|
FF_LOGO_INIT
|
||||||
@@ -948,25 +1081,34 @@ static const FFlogo* getLogoNixOsOld()
|
|||||||
FF_LOGO_INIT
|
FF_LOGO_INIT
|
||||||
FF_LOGO_NAMES("nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old")
|
FF_LOGO_NAMES("nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old")
|
||||||
FF_LOGO_LINES(
|
FF_LOGO_LINES(
|
||||||
"$1 ::::. $2'::::: ::::'\n"
|
"$1 ____ $2_______ ____\n"
|
||||||
"$1 '::::: $2':::::. ::::'\n"
|
"$1 /####\\ $2\\######\\ /####\\\n"
|
||||||
"$1 ::::: $2'::::.:::::\n"
|
"$1 ######\\ $2\\######\\ /#####/\n"
|
||||||
"$1 .......:::::..... $2::::::::\n"
|
"$1 \\######\\ $2\\######\\ /#####/\n"
|
||||||
"$1 ::::::::::::::::::. $2:::::: $1::::.\n"
|
"$1 \\######\\ $2\\######\\/#####/ $1/\\\n"
|
||||||
" ::::::::::::::::::::: $2:::::. $1.::::'\n"
|
"$1 \\######\\ $2\\###########/ $1/##\\\n"
|
||||||
"$2 ..... ::::' $1:::::'\n"
|
"$1 ________\\######\\______$2\\#########/ $1/####\\\n"
|
||||||
"$2 ::::: '::' $1:::::'\n"
|
"$1 /#######################$2\\#######/ $1/######\n"
|
||||||
"$2 ........::::: ' $1:::::::::::.\n"
|
"$1 /#########################$2\\######\\ $1/######/\n"
|
||||||
"$2::::::::::::: $1:::::::::::::\n"
|
"$1 /###########################$2\\######\\ $1/######/\n"
|
||||||
"$2 ::::::::::: $1.. $1:::::\n"
|
"$1 ¯¯¯¯¯¯¯¯¯¯¯¯$2/######/$1¯¯¯¯¯¯¯¯¯$2\\######$1/######/\n"
|
||||||
"$2 .::::: $1.::: $1:::::\n"
|
"$2 /######/ $2\\####$1/######/________\n"
|
||||||
"$2 .::::: $1::::: $1''''' $2.....\n"
|
"$2 _____________/######/ $2\\##$1/################\\\n"
|
||||||
" ::::: $1':::::. $2......:::::::::::::'\n"
|
"$2 /###################/ $2\\$1/##################\\\n"
|
||||||
" ::: $1::::::. $2':::::::::::::::::'\n"
|
"$2 \\##################/$1\\ /###################/\n"
|
||||||
"$1 .:::::::: $2'::::::::::\n"
|
"$2 \\################/$1##\\ /######/¯¯¯¯¯¯¯¯¯¯¯¯¯\n"
|
||||||
"$1 .::::''::::. $2'::::.\n"
|
"$2 ¯¯¯¯¯¯¯¯/######/$1####\\ /######/\n"
|
||||||
"$1 .::::' ::::. $2'::::.\n"
|
"$2 /######/$1######\\$2_________$1/######/$2____________\n"
|
||||||
"$1 .:::: :::: $2'::::."
|
"$2 /######/ $1\\######\\$2###########################/\n"
|
||||||
|
"$2 /######/ $1\\######\\$2#########################/\n"
|
||||||
|
"$2 ######/ $1/#######\\$2#######################/\n"
|
||||||
|
"$2 \\####/ $1/#########\\$2¯¯¯¯¯¯\\######\\¯¯¯¯¯¯¯¯\n"
|
||||||
|
"$2 \\##/ $1/###########\\$2 \\######\\\n"
|
||||||
|
"$2 \\/ $1/#####/\\######\\$2 \\######\\\n"
|
||||||
|
"$1 $1/#####/ \\######\\$2 \\######\\\n"
|
||||||
|
"$1 $1/#####/ \\######\\$2 \\######\n"
|
||||||
|
"$1 $1\\####/ \\######\\$2 \\####/\n"
|
||||||
|
"$1 $1¯¯¯¯ ¯¯¯¯¯¯¯$2 ¯¯¯¯"
|
||||||
)
|
)
|
||||||
FF_LOGO_COLORS(
|
FF_LOGO_COLORS(
|
||||||
"34", //blue
|
"34", //blue
|
||||||
@@ -1299,6 +1441,38 @@ static const FFlogo* getLogoRockyLinux()
|
|||||||
FF_LOGO_RETURN
|
FF_LOGO_RETURN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const FFlogo* getLogoRosaLinux()
|
||||||
|
{
|
||||||
|
FF_LOGO_INIT
|
||||||
|
FF_LOGO_NAMES("rosa", "rosa-linux", "rosalinux")
|
||||||
|
FF_LOGO_LINES(
|
||||||
|
" ROSAROSAROSAROSAR\n"
|
||||||
|
" ROSA AROS\n"
|
||||||
|
" ROS SAROSAROSAROSAR AROS\n"
|
||||||
|
" RO ROSAROSAROSAROSAROSAR RO\n"
|
||||||
|
" ARO AROSAROSAROSARO AROS ROS\n"
|
||||||
|
" ARO ROSAROS OSAR ROSA ROS\n"
|
||||||
|
" RO AROSA ROSAROSAROSA ROSAR RO\n"
|
||||||
|
"RO ROSAR ROSAROSAROSAR R ROSARO RO\n"
|
||||||
|
"RO ROSA AROSAROSAROSA AR ROSARO AR\n"
|
||||||
|
"RO AROS ROSAROSAROSA ROS AROSARO AR\n"
|
||||||
|
"RO AROS ROSAROSARO ROSARO ROSARO AR\n"
|
||||||
|
"RO ROS AROSAROS ROSAROSA AROSAR AR\n"
|
||||||
|
"RO ROSA ROS ROSAROSAR ROSARO RO\n"
|
||||||
|
" RO ROS AROSAROSAROSA ROSARO AR\n"
|
||||||
|
" ARO ROSA ROSAROSAROS AROSAR ARO\n"
|
||||||
|
" ARO OROSA R ROSAROS ROS\n"
|
||||||
|
" RO AROSAROS AROSAROSAR RO\n"
|
||||||
|
" AROS AROSAROSAROSARO AROS\n"
|
||||||
|
" ROSA SARO\n"
|
||||||
|
" ROSAROSAROSAROSAR"
|
||||||
|
)
|
||||||
|
FF_LOGO_COLORS(
|
||||||
|
"34" //blue
|
||||||
|
)
|
||||||
|
FF_LOGO_RETURN
|
||||||
|
}
|
||||||
|
|
||||||
static const FFlogo* getLogoUbuntu()
|
static const FFlogo* getLogoUbuntu()
|
||||||
{
|
{
|
||||||
FF_LOGO_INIT
|
FF_LOGO_INIT
|
||||||
@@ -1434,6 +1608,9 @@ GetLogoMethod* ffLogoBuiltinGetAll()
|
|||||||
static GetLogoMethod logoMethods[] = {
|
static GetLogoMethod logoMethods[] = {
|
||||||
ffLogoBuiltinGetUnknown,
|
ffLogoBuiltinGetUnknown,
|
||||||
getLogoNone,
|
getLogoNone,
|
||||||
|
getLogoAlmaLinux,
|
||||||
|
getLogoAlpine,
|
||||||
|
getLogoAlpineSmall,
|
||||||
getLogoAndroid,
|
getLogoAndroid,
|
||||||
getLogoAndroidSmall,
|
getLogoAndroidSmall,
|
||||||
getLogoArch,
|
getLogoArch,
|
||||||
@@ -1459,7 +1636,9 @@ GetLogoMethod* ffLogoBuiltinGetAll()
|
|||||||
getLogoGentoo,
|
getLogoGentoo,
|
||||||
getLogoGentooSmall,
|
getLogoGentooSmall,
|
||||||
getLogoKDENeon,
|
getLogoKDENeon,
|
||||||
|
getLogoKISSLinux,
|
||||||
getLogoKubuntu,
|
getLogoKubuntu,
|
||||||
|
getLogoLangitKetujuh,
|
||||||
getLogoLinux,
|
getLogoLinux,
|
||||||
getLogoManjaro,
|
getLogoManjaro,
|
||||||
getLogoManjaroSmall,
|
getLogoManjaroSmall,
|
||||||
@@ -1480,6 +1659,7 @@ GetLogoMethod* ffLogoBuiltinGetAll()
|
|||||||
getLogoRedHatEnterpriseLinux,
|
getLogoRedHatEnterpriseLinux,
|
||||||
getLogoRedstarOS,
|
getLogoRedstarOS,
|
||||||
getLogoRockyLinux,
|
getLogoRockyLinux,
|
||||||
|
getLogoRosaLinux,
|
||||||
getLogoUbuntu,
|
getLogoUbuntu,
|
||||||
getLogoUbuntuSmall,
|
getLogoUbuntuSmall,
|
||||||
getLogoVoid,
|
getLogoVoid,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifdef FF_HAVE_IMAGEMAGICK6
|
#ifdef FF_HAVE_IMAGEMAGICK6
|
||||||
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "common/library.h"
|
||||||
|
|
||||||
#include <magick/MagickCore.h>
|
#include <magick/MagickCore.h>
|
||||||
|
|
||||||
static FF_LIBRARY_SYMBOL(ResizeImage);
|
static FF_LIBRARY_SYMBOL(ResizeImage);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifdef FF_HAVE_IMAGEMAGICK7
|
#ifdef FF_HAVE_IMAGEMAGICK7
|
||||||
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "common/library.h"
|
||||||
|
|
||||||
#include <MagickCore/MagickCore.h>
|
#include <MagickCore/MagickCore.h>
|
||||||
|
|
||||||
static FF_LIBRARY_SYMBOL(ResizeImage);
|
static FF_LIBRARY_SYMBOL(ResizeImage);
|
||||||
|
|||||||
+21
-18
@@ -1,4 +1,6 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
#if defined(FF_HAVE_IMAGEMAGICK7) || defined(FF_HAVE_IMAGEMAGICK6)
|
#if defined(FF_HAVE_IMAGEMAGICK7) || defined(FF_HAVE_IMAGEMAGICK6)
|
||||||
|
|
||||||
@@ -17,6 +19,8 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#ifdef FF_HAVE_ZLIB
|
#ifdef FF_HAVE_ZLIB
|
||||||
|
#include "common/library.h"
|
||||||
|
#include <stdlib.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
static bool compressBlob(const FFinstance* instance, void** blob, size_t* length)
|
static bool compressBlob(const FFinstance* instance, void** blob, size_t* length)
|
||||||
@@ -92,7 +96,7 @@ static void writeCacheStrbuf(FFLogoRequestData* requestData, const FFstrbuf* val
|
|||||||
{
|
{
|
||||||
uint32_t cacheDirLength = requestData->cacheDir.length;
|
uint32_t cacheDirLength = requestData->cacheDir.length;
|
||||||
ffStrbufAppendS(&requestData->cacheDir, cacheFileName);
|
ffStrbufAppendS(&requestData->cacheDir, cacheFileName);
|
||||||
ffWriteFileContent(requestData->cacheDir.chars, value);
|
ffWriteFileBuffer(requestData->cacheDir.chars, value);
|
||||||
ffStrbufSubstrBefore(&requestData->cacheDir, cacheDirLength);
|
ffStrbufSubstrBefore(&requestData->cacheDir, cacheDirLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +111,7 @@ static void writeCacheUint32(FFLogoRequestData* requestData, uint32_t value, con
|
|||||||
static void printImagePixels(FFinstance* instance, FFLogoRequestData* requestData, const FFstrbuf* result, const char* cacheFileName)
|
static void printImagePixels(FFinstance* instance, FFLogoRequestData* requestData, const FFstrbuf* result, const char* cacheFileName)
|
||||||
{
|
{
|
||||||
//Calculate character dimensions
|
//Calculate character dimensions
|
||||||
instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logoPaddingLeft + instance->config.logoPaddingRight;
|
instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logo.paddingLeft + instance->config.logo.paddingRight;
|
||||||
|
|
||||||
instance->state.logoHeight = requestData->logoCharacterHeight;
|
instance->state.logoHeight = requestData->logoCharacterHeight;
|
||||||
if(requestData->type == FF_LOGO_TYPE_KITTY)
|
if(requestData->type == FF_LOGO_TYPE_KITTY)
|
||||||
@@ -116,16 +120,16 @@ static void printImagePixels(FFinstance* instance, FFLogoRequestData* requestDat
|
|||||||
//Write cache files
|
//Write cache files
|
||||||
writeCacheStrbuf(requestData, result, cacheFileName);
|
writeCacheStrbuf(requestData, result, cacheFileName);
|
||||||
|
|
||||||
if(instance->config.logoWidth == 0)
|
if(instance->config.logo.width == 0)
|
||||||
writeCacheUint32(requestData, instance->state.logoWidth, FF_CACHE_FILE_WIDTH);
|
writeCacheUint32(requestData, instance->state.logoWidth, FF_CACHE_FILE_WIDTH);
|
||||||
|
|
||||||
if(instance->config.logoHeight == 0)
|
if(instance->config.logo.height == 0)
|
||||||
writeCacheUint32(requestData, instance->state.logoHeight, FF_CACHE_FILE_HEIGHT);
|
writeCacheUint32(requestData, instance->state.logoHeight, FF_CACHE_FILE_HEIGHT);
|
||||||
|
|
||||||
//Write result to stdout
|
//Write result to stdout
|
||||||
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
|
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
ffWriteFDContent(STDOUT_FILENO, result);
|
ffWriteFDBuffer(STDOUT_FILENO, result);
|
||||||
|
|
||||||
//Go to upper left corner
|
//Go to upper left corner
|
||||||
fputs("\033[9999999D", stdout);
|
fputs("\033[9999999D", stdout);
|
||||||
@@ -294,7 +298,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData*
|
|||||||
}
|
}
|
||||||
|
|
||||||
//+1, because we need to copy the null byte too
|
//+1, because we need to copy the null byte too
|
||||||
imageData.ffCopyMagickString(imageInfoIn->filename, instance->config.logoSource.chars, instance->config.logoSource.length + 1);
|
imageData.ffCopyMagickString(imageInfoIn->filename, instance->config.logo.source.chars, instance->config.logo.source.length + 1);
|
||||||
|
|
||||||
imageData.image = ffReadImage(imageInfoIn, imageData.exceptionInfo);
|
imageData.image = ffReadImage(imageInfoIn, imageData.exceptionInfo);
|
||||||
ffDestroyImageInfo(imageInfoIn);
|
ffDestroyImageInfo(imageInfoIn);
|
||||||
@@ -373,7 +377,7 @@ static void readCachedStrbuf(FFLogoRequestData* requestData, FFstrbuf* result, c
|
|||||||
{
|
{
|
||||||
uint32_t cacheDirLength = requestData->cacheDir.length;
|
uint32_t cacheDirLength = requestData->cacheDir.length;
|
||||||
ffStrbufAppendS(&requestData->cacheDir, cacheFileName);
|
ffStrbufAppendS(&requestData->cacheDir, cacheFileName);
|
||||||
ffAppendFileContent(requestData->cacheDir.chars, result);
|
ffAppendFileBuffer(requestData->cacheDir.chars, result);
|
||||||
ffStrbufSubstrBefore(&requestData->cacheDir, cacheDirLength);
|
ffStrbufSubstrBefore(&requestData->cacheDir, cacheDirLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,7 +423,7 @@ static bool printCachedChars(FFinstance* instance, FFLogoRequestData* requestDat
|
|||||||
|
|
||||||
static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestData)
|
static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestData)
|
||||||
{
|
{
|
||||||
requestData->logoCharacterWidth = instance->config.logoWidth;
|
requestData->logoCharacterWidth = instance->config.logo.width;
|
||||||
if(requestData->logoCharacterWidth == 0)
|
if(requestData->logoCharacterWidth == 0)
|
||||||
{
|
{
|
||||||
requestData->logoCharacterWidth = readCachedUint32(requestData, FF_CACHE_FILE_WIDTH);
|
requestData->logoCharacterWidth = readCachedUint32(requestData, FF_CACHE_FILE_WIDTH);
|
||||||
@@ -427,7 +431,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
requestData->logoCharacterHeight = instance->config.logoHeight;
|
requestData->logoCharacterHeight = instance->config.logo.height;
|
||||||
if(requestData->logoCharacterHeight == 0)
|
if(requestData->logoCharacterHeight == 0)
|
||||||
{
|
{
|
||||||
requestData->logoCharacterHeight = readCachedUint32(requestData, FF_CACHE_FILE_HEIGHT);
|
requestData->logoCharacterHeight = readCachedUint32(requestData, FF_CACHE_FILE_HEIGHT);
|
||||||
@@ -448,7 +452,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
|
|||||||
if(fd == -1)
|
if(fd == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
|
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
char buffer[32768];
|
char buffer[32768];
|
||||||
@@ -458,7 +462,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
|
|||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logoPaddingLeft + instance->config.logoPaddingRight;
|
instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logo.paddingLeft + instance->config.logo.paddingRight;
|
||||||
instance->state.logoHeight = requestData->logoCharacterHeight;
|
instance->state.logoHeight = requestData->logoCharacterHeight;
|
||||||
|
|
||||||
//Go to upper left corner
|
//Go to upper left corner
|
||||||
@@ -513,28 +517,27 @@ bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type)
|
|||||||
requestData.characterPixelHeight = 1;
|
requestData.characterPixelHeight = 1;
|
||||||
|
|
||||||
if(
|
if(
|
||||||
(type != FF_LOGO_TYPE_CHAFA || instance->config.logoWidth == 0 || instance->config.logoHeight == 0) &&
|
(type != FF_LOGO_TYPE_CHAFA || instance->config.logo.width == 0 || instance->config.logo.height == 0) &&
|
||||||
!getCharacterPixelDimensions(&requestData)
|
!getCharacterPixelDimensions(&requestData)
|
||||||
)
|
)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
requestData.logoPixelWidth = simpleCeil((double) instance->config.logoWidth * requestData.characterPixelWidth);
|
requestData.logoPixelWidth = simpleCeil((double) instance->config.logo.width * requestData.characterPixelWidth);
|
||||||
requestData.logoPixelHeight = simpleCeil((double) instance->config.logoHeight * requestData.characterPixelHeight);
|
requestData.logoPixelHeight = simpleCeil((double) instance->config.logo.height * requestData.characterPixelHeight);
|
||||||
|
|
||||||
ffStrbufInitA(&requestData.cacheDir, PATH_MAX * 2);
|
ffStrbufInitA(&requestData.cacheDir, PATH_MAX * 2);
|
||||||
ffStrbufAppend(&requestData.cacheDir, &instance->state.cacheDir);
|
ffStrbufAppend(&requestData.cacheDir, &instance->state.cacheDir);
|
||||||
ffStrbufAppendS(&requestData.cacheDir, "images");
|
ffStrbufAppendS(&requestData.cacheDir, "images");
|
||||||
|
|
||||||
ffStrbufEnsureFree(&requestData.cacheDir, PATH_MAX);
|
ffStrbufEnsureFree(&requestData.cacheDir, PATH_MAX);
|
||||||
if(realpath(instance->config.logoSource.chars, requestData.cacheDir.chars + requestData.cacheDir.length) == NULL)
|
if(realpath(instance->config.logo.source.chars, requestData.cacheDir.chars + requestData.cacheDir.length) == NULL)
|
||||||
{
|
{
|
||||||
//We can safely return here, because if realpath failed, we surely won't be able to read the file
|
//We can safely return here, because if realpath failed, we surely won't be able to read the file
|
||||||
ffStrbufDestroy(&requestData.cacheDir);
|
ffStrbufDestroy(&requestData.cacheDir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ffStrbufRecalculateLength(&requestData.cacheDir);
|
ffStrbufRecalculateLength(&requestData.cacheDir);
|
||||||
if(!ffStrbufEndsWithC(&requestData.cacheDir, '/'))
|
ffStrbufEnsureEndsWithC(&requestData.cacheDir, '/');
|
||||||
ffStrbufAppendC(&requestData.cacheDir, '/');
|
|
||||||
|
|
||||||
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelWidth);
|
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelWidth);
|
||||||
ffStrbufAppendC(&requestData.cacheDir, '*');
|
ffStrbufAppendC(&requestData.cacheDir, '*');
|
||||||
|
|||||||
+26
-22
@@ -1,4 +1,8 @@
|
|||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "detection/os.h"
|
||||||
|
#include "detection/terminalshell.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -8,18 +12,18 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
|
|||||||
uint32_t currentlineLength = 0;
|
uint32_t currentlineLength = 0;
|
||||||
|
|
||||||
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
||||||
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
|
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
|
||||||
|
|
||||||
//Use logoColor[0] as the default color
|
//Use logoColor[0] as the default color
|
||||||
if(doColorReplacement)
|
if(doColorReplacement)
|
||||||
ffPrintColor(&instance->config.logoColors[0]);
|
ffPrintColor(&instance->config.logo.colors[0]);
|
||||||
|
|
||||||
while(*data != '\0')
|
while(*data != '\0')
|
||||||
{
|
{
|
||||||
//We are at the end of a line. Print paddings and update max line length
|
//We are at the end of a line. Print paddings and update max line length
|
||||||
if(*data == '\n' || (*data == '\r' && *(data + 1) == '\n'))
|
if(*data == '\n' || (*data == '\r' && *(data + 1) == '\n'))
|
||||||
{
|
{
|
||||||
ffPrintCharTimes(' ', instance->config.logoPaddingRight);
|
ffPrintCharTimes(' ', instance->config.logo.paddingRight);
|
||||||
|
|
||||||
//We have \r\n, skip the \r
|
//We have \r\n, skip the \r
|
||||||
if(*data == '\r')
|
if(*data == '\r')
|
||||||
@@ -28,7 +32,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
|
|||||||
putchar('\n');
|
putchar('\n');
|
||||||
++data;
|
++data;
|
||||||
|
|
||||||
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
|
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
|
||||||
|
|
||||||
if(currentlineLength > instance->state.logoWidth)
|
if(currentlineLength > instance->state.logoWidth)
|
||||||
instance->state.logoWidth = currentlineLength;
|
instance->state.logoWidth = currentlineLength;
|
||||||
@@ -96,7 +100,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintColor(&instance->config.logoColors[index]);
|
ffPrintColor(&instance->config.logo.colors[index]);
|
||||||
++data;
|
++data;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -129,14 +133,14 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ffPrintCharTimes(' ', instance->config.logoPaddingRight);
|
ffPrintCharTimes(' ', instance->config.logo.paddingRight);
|
||||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||||
|
|
||||||
//Happens if the last line is the longest
|
//Happens if the last line is the longest
|
||||||
if(currentlineLength > instance->state.logoWidth)
|
if(currentlineLength > instance->state.logoWidth)
|
||||||
instance->state.logoWidth = currentlineLength;
|
instance->state.logoWidth = currentlineLength;
|
||||||
|
|
||||||
instance->state.logoWidth += instance->config.logoPaddingLeft + instance->config.logoPaddingRight;
|
instance->state.logoWidth += instance->config.logo.paddingLeft + instance->config.logo.paddingRight;
|
||||||
|
|
||||||
//Go to the leftmost position
|
//Go to the leftmost position
|
||||||
fputs("\033[9999999D", stdout);
|
fputs("\033[9999999D", stdout);
|
||||||
@@ -222,8 +226,8 @@ static void logoPrintStruct(FFinstance* instance, const FFlogo* logo)
|
|||||||
const char** colors = logo->builtinColors;
|
const char** colors = logo->builtinColors;
|
||||||
for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++)
|
for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++)
|
||||||
{
|
{
|
||||||
if(instance->config.logoColors[i].length == 0)
|
if(instance->config.logo.colors[i].length == 0)
|
||||||
ffStrbufAppendS(&instance->config.logoColors[i], *colors);
|
ffStrbufAppendS(&instance->config.logo.colors[i], *colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
ffLogoPrintChars(instance, logo->data, true);
|
ffLogoPrintChars(instance, logo->data, true);
|
||||||
@@ -249,7 +253,7 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement)
|
|||||||
FFstrbuf content;
|
FFstrbuf content;
|
||||||
ffStrbufInitA(&content, 2047);
|
ffStrbufInitA(&content, 2047);
|
||||||
|
|
||||||
if(!ffAppendFileContent(instance->config.logoSource.chars, &content))
|
if(!ffAppendFileBuffer(instance->config.logo.source.chars, &content))
|
||||||
{
|
{
|
||||||
ffStrbufDestroy(&content);
|
ffStrbufDestroy(&content);
|
||||||
return false;
|
return false;
|
||||||
@@ -261,9 +265,9 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool logoPrintImageIfExists(FFinstance* instance, FFLogoType logoType)
|
static bool logoPrintImageIfExists(FFinstance* instance, FFLogoType logo)
|
||||||
{
|
{
|
||||||
if(!ffLogoPrintImageIfExists(instance, logoType))
|
if(!ffLogoPrintImageIfExists(instance, logo))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
logoApplyMainColorDetected(instance);
|
logoApplyMainColorDetected(instance);
|
||||||
@@ -274,14 +278,14 @@ static void logoPrintKnownType(FFinstance* instance)
|
|||||||
{
|
{
|
||||||
bool successfull;
|
bool successfull;
|
||||||
|
|
||||||
if(instance->config.logoType == FF_LOGO_TYPE_BUILTIN)
|
if(instance->config.logo.type == FF_LOGO_TYPE_BUILTIN)
|
||||||
successfull = logoPrintBuiltinIfExists(instance, instance->config.logoSource.chars);
|
successfull = logoPrintBuiltinIfExists(instance, instance->config.logo.source.chars);
|
||||||
else if(instance->config.logoType == FF_LOGO_TYPE_FILE)
|
else if(instance->config.logo.type == FF_LOGO_TYPE_FILE)
|
||||||
successfull = logoPrintFileIfExists(instance, true);
|
successfull = logoPrintFileIfExists(instance, true);
|
||||||
else if(instance->config.logoType == FF_LOGO_TYPE_RAW)
|
else if(instance->config.logo.type == FF_LOGO_TYPE_RAW)
|
||||||
successfull = logoPrintFileIfExists(instance, false);
|
successfull = logoPrintFileIfExists(instance, false);
|
||||||
else //image
|
else //image
|
||||||
successfull = logoPrintImageIfExists(instance, instance->config.logoType);
|
successfull = logoPrintImageIfExists(instance, instance->config.logo.type);
|
||||||
|
|
||||||
if(!successfull)
|
if(!successfull)
|
||||||
logoPrintDetected(instance);
|
logoPrintDetected(instance);
|
||||||
@@ -300,21 +304,21 @@ void ffLogoPrint(FFinstance* instance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//If the source is not set, we can directly print the detected logo.
|
//If the source is not set, we can directly print the detected logo.
|
||||||
if(instance->config.logoSource.length == 0)
|
if(instance->config.logo.source.length == 0)
|
||||||
{
|
{
|
||||||
logoPrintDetected(instance);
|
logoPrintDetected(instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the source and source type is set to something else than auto, always print with the set type.
|
//If the source and source type is set to something else than auto, always print with the set type.
|
||||||
if(instance->config.logoSource.length > 0 && instance->config.logoType != FF_LOGO_TYPE_AUTO)
|
if(instance->config.logo.source.length > 0 && instance->config.logo.type != FF_LOGO_TYPE_AUTO)
|
||||||
{
|
{
|
||||||
logoPrintKnownType(instance);
|
logoPrintKnownType(instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//If source matches the name of a builtin logo, print it and return.
|
//If source matches the name of a builtin logo, print it and return.
|
||||||
if(logoPrintBuiltinIfExists(instance, instance->config.logoSource.chars))
|
if(logoPrintBuiltinIfExists(instance, instance->config.logo.source.chars))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance);
|
const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance);
|
||||||
@@ -347,7 +351,7 @@ void ffLogoPrintLine(FFinstance* instance)
|
|||||||
|
|
||||||
void ffLogoPrintRemaining(FFinstance* instance)
|
void ffLogoPrintRemaining(FFinstance* instance)
|
||||||
{
|
{
|
||||||
while(instance->state.keysHeight < instance->state.logoHeight)
|
while(instance->state.keysHeight <= instance->state.logoHeight)
|
||||||
{
|
{
|
||||||
ffLogoPrintLine(instance);
|
ffLogoPrintLine(instance);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
@@ -369,7 +373,7 @@ void ffLogoBuiltinPrint(FFinstance* instance)
|
|||||||
instance->state.logoHeight = 0;
|
instance->state.logoHeight = 0;
|
||||||
instance->state.keysHeight = 0;
|
instance->state.keysHeight = 0;
|
||||||
for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++)
|
for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++)
|
||||||
ffStrbufClear(&instance->config.logoColors[i]);
|
ffStrbufClear(&instance->config.logo.colors[i]);
|
||||||
|
|
||||||
puts("\n");
|
puts("\n");
|
||||||
++methods;
|
++methods;
|
||||||
|
|||||||
+15
-15
@@ -1,6 +1,7 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#define FF_BATTERY_MODULE_NAME "Battery"
|
#define FF_BATTERY_MODULE_NAME "Battery"
|
||||||
@@ -24,7 +25,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
|
|||||||
|
|
||||||
//type must exist and be "Battery"
|
//type must exist and be "Battery"
|
||||||
ffStrbufAppendS(dir, "/type");
|
ffStrbufAppendS(dir, "/type");
|
||||||
ffGetFileContent(dir->chars, &testBatteryBuffer);
|
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
|
|
||||||
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Battery") != 0)
|
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Battery") != 0)
|
||||||
@@ -35,7 +36,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
|
|||||||
|
|
||||||
//scope may not exist or must not be "Device"
|
//scope may not exist or must not be "Device"
|
||||||
ffStrbufAppendS(dir, "/scope");
|
ffStrbufAppendS(dir, "/scope");
|
||||||
ffGetFileContent(dir->chars, &testBatteryBuffer);
|
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
|
|
||||||
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Device") == 0)
|
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Device") == 0)
|
||||||
@@ -50,7 +51,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
|
|||||||
//capacity must exist and be not empty
|
//capacity must exist and be not empty
|
||||||
ffStrbufInit(&result->capacity);
|
ffStrbufInit(&result->capacity);
|
||||||
ffStrbufAppendS(dir, "/capacity");
|
ffStrbufAppendS(dir, "/capacity");
|
||||||
ffGetFileContent(dir->chars, &result->capacity);
|
ffReadFileBuffer(dir->chars, &result->capacity);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
|
|
||||||
if(result->capacity.length == 0)
|
if(result->capacity.length == 0)
|
||||||
@@ -64,30 +65,30 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
|
|||||||
|
|
||||||
ffStrbufInit(&result->manufacturer);
|
ffStrbufInit(&result->manufacturer);
|
||||||
ffStrbufAppendS(dir, "/manufacturer");
|
ffStrbufAppendS(dir, "/manufacturer");
|
||||||
ffGetFileContent(dir->chars, &result->manufacturer);
|
ffReadFileBuffer(dir->chars, &result->manufacturer);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
|
|
||||||
ffStrbufInit(&result->modelName);
|
ffStrbufInit(&result->modelName);
|
||||||
ffStrbufAppendS(dir, "/model_name");
|
ffStrbufAppendS(dir, "/model_name");
|
||||||
ffGetFileContent(dir->chars, &result->modelName);
|
ffReadFileBuffer(dir->chars, &result->modelName);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
|
|
||||||
ffStrbufInit(&result->technology);
|
ffStrbufInit(&result->technology);
|
||||||
ffStrbufAppendS(dir, "/technology");
|
ffStrbufAppendS(dir, "/technology");
|
||||||
ffGetFileContent(dir->chars, &result->technology);
|
ffReadFileBuffer(dir->chars, &result->technology);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
|
|
||||||
ffStrbufInit(&result->status);
|
ffStrbufInit(&result->status);
|
||||||
ffStrbufAppendS(dir, "/status");
|
ffStrbufAppendS(dir, "/status");
|
||||||
ffGetFileContent(dir->chars, &result->status);
|
ffReadFileBuffer(dir->chars, &result->status);
|
||||||
ffStrbufSubstrBefore(dir, dirLength);
|
ffStrbufSubstrBefore(dir, dirLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printBattery(FFinstance* instance, const BatteryResult* result, uint8_t index)
|
static void printBattery(FFinstance* instance, const BatteryResult* result, uint8_t index)
|
||||||
{
|
{
|
||||||
if(instance->config.batteryFormat.length == 0)
|
if(instance->config.battery.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &instance->config.batteryKey);
|
ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &instance->config.battery.key);
|
||||||
|
|
||||||
bool showStatus =
|
bool showStatus =
|
||||||
result->status.length > 0 &&
|
result->status.length > 0 &&
|
||||||
@@ -114,7 +115,7 @@ static void printBattery(FFinstance* instance, const BatteryResult* result, uint
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_BATTERY_MODULE_NAME, index, &instance->config.batteryKey, &instance->config.batteryFormat, NULL, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_BATTERY_MODULE_NAME, index, &instance->config.battery, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology},
|
||||||
@@ -131,8 +132,7 @@ void ffPrintBattery(FFinstance* instance)
|
|||||||
if(instance->config.batteryDir.length > 0)
|
if(instance->config.batteryDir.length > 0)
|
||||||
{
|
{
|
||||||
ffStrbufAppend(&baseDir, &instance->config.batteryDir);
|
ffStrbufAppend(&baseDir, &instance->config.batteryDir);
|
||||||
if(!ffStrbufEndsWithC(&baseDir, '/'))
|
ffStrbufEndsWithC(&baseDir, '/');
|
||||||
ffStrbufAppendC(&baseDir, '/');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -144,7 +144,7 @@ void ffPrintBattery(FFinstance* instance)
|
|||||||
DIR* dirp = opendir(baseDir.chars);
|
DIR* dirp = opendir(baseDir.chars);
|
||||||
if(dirp == NULL)
|
if(dirp == NULL)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &instance->config.batteryKey, &instance->config.batteryFormat, FF_BATTERY_NUM_FORMAT_ARGS, "opendir(\"%s\") == NULL", baseDir.chars);
|
ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &instance->config.battery, "opendir(\"%s\") == NULL", baseDir.chars);
|
||||||
ffStrbufDestroy(&baseDir);
|
ffStrbufDestroy(&baseDir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ void ffPrintBattery(FFinstance* instance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(results.length == 0)
|
if(results.length == 0)
|
||||||
ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &instance->config.batteryKey, &instance->config.batteryFormat, FF_BATTERY_NUM_FORMAT_ARGS, "%s doesn't contain any battery folder", baseDir.chars);
|
ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &instance->config.battery, "%s doesn't contain any battery folder", baseDir.chars);
|
||||||
|
|
||||||
ffListDestroy(&results);
|
ffListDestroy(&results);
|
||||||
ffStrbufDestroy(&baseDir);
|
ffStrbufDestroy(&baseDir);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
void ffPrintBreak(FFinstance* instance)
|
void ffPrintBreak(FFinstance* instance)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
void ffPrintColors(FFinstance* instance)
|
void ffPrintColors(FFinstance* instance)
|
||||||
{
|
{
|
||||||
|
|||||||
+47
-22
@@ -1,48 +1,63 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/caching.h"
|
||||||
|
#include "detection/temps.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define FF_CPU_MODULE_NAME "CPU"
|
#define FF_CPU_MODULE_NAME "CPU"
|
||||||
#define FF_CPU_NUM_FORMAT_ARGS 14
|
#define FF_CPU_NUM_FORMAT_ARGS 15
|
||||||
|
|
||||||
static double parseHz(FFstrbuf* content)
|
|
||||||
{
|
|
||||||
if(content->length == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
double herz;
|
|
||||||
if(sscanf(content->chars, "%lf", &herz) != 1)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return herz;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double getGhz(const char* policyFile, const char* cpuFile)
|
static double getGhz(const char* policyFile, const char* cpuFile)
|
||||||
{
|
{
|
||||||
FFstrbuf content;
|
FFstrbuf content;
|
||||||
ffStrbufInit(&content);
|
ffStrbufInit(&content);
|
||||||
|
|
||||||
ffGetFileContent(policyFile, &content);
|
ffReadFileBuffer(policyFile, &content);
|
||||||
if(content.length == 0)
|
if(content.length == 0)
|
||||||
ffGetFileContent(cpuFile, &content);
|
ffReadFileBuffer(cpuFile, &content);
|
||||||
|
|
||||||
double herz = parseHz(&content);
|
double herz = ffStrbufToDouble(&content);
|
||||||
|
|
||||||
ffStrbufDestroy(&content);
|
ffStrbufDestroy(&content);
|
||||||
|
|
||||||
|
//ffStrbufToDouble failed
|
||||||
|
if(herz != herz)
|
||||||
|
return 0;
|
||||||
|
|
||||||
herz /= 1000.0; //to MHz
|
herz /= 1000.0; //to MHz
|
||||||
return herz / 1000.0; //to GHz
|
return herz / 1000.0; //to GHz
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double detectCPUTemp(const FFinstance* instance)
|
||||||
|
{
|
||||||
|
const FFTempsResult *temps = ffDetectTemps(instance);
|
||||||
|
|
||||||
|
for(uint32_t i = 0; i < temps->values.length; i++)
|
||||||
|
{
|
||||||
|
FFTempValue* value = ffListGet(&temps->values, i);
|
||||||
|
|
||||||
|
if(
|
||||||
|
ffStrbufFirstIndexS(&value->name, "cpu") < value->name.length ||
|
||||||
|
ffStrbufCompS(&value->name, "k10temp") == 0 ||
|
||||||
|
ffStrbufCompS(&value->name, "coretemp") == 0
|
||||||
|
) return value->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0 / 0.0; //NaN
|
||||||
|
}
|
||||||
|
|
||||||
void ffPrintCPU(FFinstance* instance)
|
void ffPrintCPU(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(ffPrintFromCache(instance, FF_CPU_MODULE_NAME, &instance->config.cpuKey, &instance->config.cpuFormat, FF_CPU_NUM_FORMAT_ARGS))
|
if(ffPrintFromCache(instance, FF_CPU_MODULE_NAME, &instance->config.cpu, FF_CPU_NUM_FORMAT_ARGS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FILE* cpuinfo = fopen("/proc/cpuinfo", "r");
|
FILE* cpuinfo = fopen("/proc/cpuinfo", "r");
|
||||||
if(cpuinfo == NULL)
|
if(cpuinfo == NULL)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpuKey, &instance->config.cpuFormat, FF_CPU_NUM_FORMAT_ARGS, "fopen(\"""/proc/cpuinfo\", \"r\") == NULL");
|
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu, "fopen(\"""/proc/cpuinfo\", \"r\") == NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +96,12 @@ void ffPrintCPU(FFinstance* instance)
|
|||||||
|
|
||||||
fclose(cpuinfo);
|
fclose(cpuinfo);
|
||||||
|
|
||||||
double procGhz = parseHz(&procGhzString) / 1000.0; //to GHz
|
double procGhz = ffStrbufToDouble(&procGhzString);
|
||||||
|
if(procGhz != procGhz)
|
||||||
|
procGhz = 0; //NaN
|
||||||
|
else
|
||||||
|
procGhz /= 1000.0; //To GHz
|
||||||
|
|
||||||
ffStrbufDestroy(&procGhzString);
|
ffStrbufDestroy(&procGhzString);
|
||||||
|
|
||||||
double biosLimit = getGhz("/sys/devices/system/cpu/cpufreq/policy0/bios_limit", "/sys/devices/system/cpu/cpu0/cpufreq/bios_limit");
|
double biosLimit = getGhz("/sys/devices/system/cpu/cpufreq/policy0/bios_limit", "/sys/devices/system/cpu/cpu0/cpufreq/bios_limit");
|
||||||
@@ -124,7 +144,7 @@ void ffPrintCPU(FFinstance* instance)
|
|||||||
) {
|
) {
|
||||||
ffStrbufDestroy(&name);
|
ffStrbufDestroy(&name);
|
||||||
ffStrbufDestroy(&vendor);
|
ffStrbufDestroy(&vendor);
|
||||||
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpuKey, &instance->config.cpuFormat, FF_CPU_NUM_FORMAT_ARGS, "No CPU info found in /proc/cpuinfo");
|
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu, "No CPU info found in /proc/cpuinfo");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +163,10 @@ void ffPrintCPU(FFinstance* instance)
|
|||||||
ffStrbufSubstrBeforeFirstC(&namePretty, '@'); //Cut the speed output in the name as we append our own
|
ffStrbufSubstrBeforeFirstC(&namePretty, '@'); //Cut the speed output in the name as we append our own
|
||||||
ffStrbufTrimRight(&namePretty, ' '); //If we removed the @ in previous step there was most likely a space before it
|
ffStrbufTrimRight(&namePretty, ' '); //If we removed the @ in previous step there was most likely a space before it
|
||||||
|
|
||||||
|
double cpuTemp;
|
||||||
|
if(instance->config.cpu.outputFormat.length > 0)
|
||||||
|
cpuTemp = detectCPUTemp(instance);
|
||||||
|
|
||||||
FFstrbuf cpu;
|
FFstrbuf cpu;
|
||||||
ffStrbufInitA(&cpu, 128);
|
ffStrbufInitA(&cpu, 128);
|
||||||
|
|
||||||
@@ -164,7 +188,7 @@ void ffPrintCPU(FFinstance* instance)
|
|||||||
if(ghz > 0)
|
if(ghz > 0)
|
||||||
ffStrbufAppendF(&cpu, " @ %.9gGHz", ghz);
|
ffStrbufAppendF(&cpu, " @ %.9gGHz", ghz);
|
||||||
|
|
||||||
ffPrintAndWriteToCache(instance, FF_CPU_MODULE_NAME, &instance->config.cpuKey, &cpu, &instance->config.cpuFormat, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintAndWriteToCache(instance, FF_CPU_MODULE_NAME, &instance->config.cpu, &cpu, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &name},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &name},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &namePretty},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &namePretty},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &vendor},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &vendor},
|
||||||
@@ -172,6 +196,7 @@ void ffPrintCPU(FFinstance* instance)
|
|||||||
{FF_FORMAT_ARG_TYPE_INT, &numProcsAvailable},
|
{FF_FORMAT_ARG_TYPE_INT, &numProcsAvailable},
|
||||||
{FF_FORMAT_ARG_TYPE_INT, &physicalCores},
|
{FF_FORMAT_ARG_TYPE_INT, &physicalCores},
|
||||||
{FF_FORMAT_ARG_TYPE_INT, &numProcs},
|
{FF_FORMAT_ARG_TYPE_INT, &numProcs},
|
||||||
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpuTemp},
|
||||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &biosLimit},
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &biosLimit},
|
||||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMaxFreq},
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMaxFreq},
|
||||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMinFreq},
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMinFreq},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define FF_CPU_USAGE_MODULE_NAME "CPU Usage"
|
#define FF_CPU_USAGE_MODULE_NAME "CPU Usage"
|
||||||
@@ -12,7 +12,7 @@ void ffPrintCPUUsage(FFinstance* instance)
|
|||||||
FILE* procStat = fopen("/proc/stat", "r");
|
FILE* procStat = fopen("/proc/stat", "r");
|
||||||
if(procStat == NULL)
|
if(procStat == NULL)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsageKey, &instance->config.cpuUsageFormat, FF_CPU_USAGE_NUM_FORMAT_ARGS, "fopen(\"""/proc/stat\", \"r\") == NULL");
|
ffPrintError(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpu, "fopen(\"""/proc/stat\", \"r\") == NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fscanf(procStat, "cpu%ld%ld%ld%ld%ld%ld%ld", &user, &nice, &system, &idle, &iowait, &irq, &softirq) < 0) goto exit;
|
if (fscanf(procStat, "cpu%ld%ld%ld%ld%ld%ld%ld", &user, &nice, &system, &idle, &iowait, &irq, &softirq) < 0) goto exit;
|
||||||
@@ -31,15 +31,15 @@ void ffPrintCPUUsage(FFinstance* instance)
|
|||||||
long totalOverPeriod = totalJiffies2 - totalJiffies1;
|
long totalOverPeriod = totalJiffies2 - totalJiffies1;
|
||||||
double cpuPercent = (double)workOverPeriod / (double)totalOverPeriod * 100;
|
double cpuPercent = (double)workOverPeriod / (double)totalOverPeriod * 100;
|
||||||
|
|
||||||
if(instance->config.cpuUsageFormat.length == 0)
|
if(instance->config.cpuUsage.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsageKey);
|
ffPrintLogoAndKey(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsage.key);
|
||||||
|
|
||||||
printf("%.2lf%%\n", cpuPercent);
|
printf("%.2lf%%\n", cpuPercent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsageKey, &instance->config.cpuUsageFormat, NULL, FF_CPU_USAGE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_CPU_USAGE_MODULE_NAME, 0, &instance->config.cpuUsage, FF_CPU_USAGE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpuPercent}
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpuPercent}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-8
@@ -1,4 +1,12 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
#include "common/settings.h"
|
||||||
|
#include "detection/gtk.h"
|
||||||
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define FF_CURSOR_MODULE_NAME "Cursor"
|
#define FF_CURSOR_MODULE_NAME "Cursor"
|
||||||
#define FF_CURSOR_NUM_FORMAT_ARGS 2
|
#define FF_CURSOR_NUM_FORMAT_ARGS 2
|
||||||
@@ -12,9 +20,9 @@ static void printCursor(FFinstance* instance, FFstrbuf* cursorTheme, const FFstr
|
|||||||
if(cursorTheme->length == 0)
|
if(cursorTheme->length == 0)
|
||||||
ffStrbufAppendS(cursorTheme, "default");
|
ffStrbufAppendS(cursorTheme, "default");
|
||||||
|
|
||||||
if(instance->config.cursorFormat.length == 0)
|
if(instance->config.cursor.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey);
|
ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor.key);
|
||||||
ffStrbufWriteTo(cursorTheme, stdout);
|
ffStrbufWriteTo(cursorTheme, stdout);
|
||||||
|
|
||||||
if(cursorSize != NULL && cursorSize->length > 0)
|
if(cursorSize != NULL && cursorSize->length > 0)
|
||||||
@@ -28,7 +36,7 @@ static void printCursor(FFinstance* instance, FFstrbuf* cursorTheme, const FFstr
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey, &instance->config.cursorFormat, NULL, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, cursorTheme},
|
{FF_FORMAT_ARG_TYPE_STRBUF, cursorTheme},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, cursorSize}
|
{FF_FORMAT_ARG_TYPE_STRBUF, cursorSize}
|
||||||
});
|
});
|
||||||
@@ -47,7 +55,7 @@ static void printCursorGTK(FFinstance* instance)
|
|||||||
|
|
||||||
if(gtk->cursor.length == 0)
|
if(gtk->cursor.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey, &instance->config.cursorFormat, FF_CURSOR_NUM_FORMAT_ARGS, "Couldn't detect GTK Cursor");
|
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "Couldn't detect GTK Cursor");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +77,7 @@ static void printCursorXFCE(FFinstance* instance)
|
|||||||
|
|
||||||
if(cursorTheme.length == 0)
|
if(cursorTheme.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey, &instance->config.cursorFormat, FF_CURSOR_NUM_FORMAT_ARGS, "Couldn't find xfce cursor in xfconf (xsettings::/Gtk/CursorThemeName)");
|
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "Couldn't find xfce cursor in xfconf (xsettings::/Gtk/CursorThemeName)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +113,7 @@ static void printCursorFromConfigFile(FFinstance* instance, const char* relative
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(cursorTheme.length == 0)
|
if(cursorTheme.length == 0)
|
||||||
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey, &instance->config.cursorFormat, FF_CURSOR_NUM_FORMAT_ARGS, "Couldn't find cursor in %s", relativeFilePath);
|
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "Couldn't find cursor in %s", relativeFilePath);
|
||||||
else
|
else
|
||||||
printCursor(instance, &cursorTheme, &cursorSize);
|
printCursor(instance, &cursorTheme, &cursorSize);
|
||||||
|
|
||||||
@@ -185,15 +193,21 @@ static bool printCursorFromEnv(FFinstance* instance)
|
|||||||
void ffPrintCursor(FFinstance* instance)
|
void ffPrintCursor(FFinstance* instance)
|
||||||
{
|
{
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey, &instance->config.cursorFormat, FF_CURSOR_NUM_FORMAT_ARGS, "Cursor detection is not supported on Android");
|
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "Cursor detection is not supported on Android");
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
||||||
|
|
||||||
|
if(ffStrbufCompS(&wmde->wmPrettyName, "WSLg") == 0)
|
||||||
|
{
|
||||||
|
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "WSLg uses native windows cursor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, "TTY") == 0)
|
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, "TTY") == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey, &instance->config.cursorFormat, FF_CURSOR_NUM_FORMAT_ARGS, "Cursor isn't supported in TTY");
|
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "Cursor isn't supported in TTY");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
void ffPrintCustom(FFinstance* instance, const char* key, const char* value)
|
void ffPrintCustom(FFinstance* instance, const char* key, const char* value)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, key, 0, NULL);
|
ffPrintLogoAndKey(instance, key, 0, NULL);
|
||||||
puts(value);
|
ffPrintUserString(value);
|
||||||
|
puts(FASTFETCH_TEXT_MODIFIER_RESET);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -1,17 +1,19 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "detection/datetime.h"
|
||||||
|
|
||||||
#define FF_DATE_MODULE_NAME "Date"
|
#define FF_DATE_MODULE_NAME "Date"
|
||||||
|
|
||||||
void ffPrintDate(FFinstance* instance)
|
void ffPrintDate(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(instance->config.dateFormat.length > 0)
|
if(instance->config.date.outputFormat.length > 0)
|
||||||
{
|
{
|
||||||
ffPrintDateTimeFormat(instance, FF_DATE_MODULE_NAME, &instance->config.dateKey, &instance->config.dateFormat);
|
ffPrintDateTimeFormat(instance, FF_DATE_MODULE_NAME, &instance->config.date);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FFDateTimeResult* datetime = ffDetectDateTime(instance);
|
const FFDateTimeResult* datetime = ffDetectDateTime(instance);
|
||||||
ffPrintLogoAndKey(instance, FF_DATE_MODULE_NAME, 0, &instance->config.dateKey);
|
ffPrintLogoAndKey(instance, FF_DATE_MODULE_NAME, 0, &instance->config.date.key);
|
||||||
|
|
||||||
//yyyy-mm-dd
|
//yyyy-mm-dd
|
||||||
printf("%u-%s-%u\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth);
|
printf("%u-%s-%u\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth);
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "detection/datetime.h"
|
||||||
|
|
||||||
#define FF_DATETIME_MODULE_NAME "Date & Time"
|
#define FF_DATETIME_MODULE_NAME "Date & Time"
|
||||||
#define FF_DATETIME_NUM_FORMAT_ARGS 20
|
#define FF_DATETIME_NUM_FORMAT_ARGS 20
|
||||||
|
|
||||||
void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFstrbuf* key, const FFstrbuf* format)
|
void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs)
|
||||||
{
|
{
|
||||||
const FFDateTimeResult* result = ffDetectDateTime(instance);
|
const FFDateTimeResult* result = ffDetectDateTime(instance);
|
||||||
ffPrintFormatString(instance, moduleName, 0, key, format, NULL, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
ffPrintFormat(instance, moduleName, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||||
{FF_FORMAT_ARG_TYPE_UINT16, &result->year},
|
{FF_FORMAT_ARG_TYPE_UINT16, &result->year},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT8, &result->yearShort},
|
{FF_FORMAT_ARG_TYPE_UINT8, &result->yearShort},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT8, &result->month},
|
{FF_FORMAT_ARG_TYPE_UINT8, &result->month},
|
||||||
@@ -32,14 +34,14 @@ void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const F
|
|||||||
|
|
||||||
void ffPrintDateTime(FFinstance* instance)
|
void ffPrintDateTime(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(instance->config.dateTimeFormat.length > 0)
|
if(instance->config.dateTime.outputFormat.length > 0)
|
||||||
{
|
{
|
||||||
ffPrintDateTimeFormat(instance, FF_DATETIME_MODULE_NAME, &instance->config.dateTimeKey, &instance->config.dateTimeFormat);
|
ffPrintDateTimeFormat(instance, FF_DATETIME_MODULE_NAME, &instance->config.dateTime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FFDateTimeResult* datetime = ffDetectDateTime(instance);
|
const FFDateTimeResult* datetime = ffDetectDateTime(instance);
|
||||||
ffPrintLogoAndKey(instance, FF_DATETIME_MODULE_NAME, 0, &instance->config.dateTimeKey);
|
ffPrintLogoAndKey(instance, FF_DATETIME_MODULE_NAME, 0, &instance->config.dateTime.key);
|
||||||
|
|
||||||
//yyyy-mm-dd hh:mm:ss
|
//yyyy-mm-dd hh:mm:ss
|
||||||
printf("%u-%s-%u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars);
|
printf("%u-%s-%u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars);
|
||||||
|
|||||||
+7
-7
@@ -1,6 +1,6 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
#include <string.h>
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
#define FF_DE_MODULE_NAME "DE"
|
#define FF_DE_MODULE_NAME "DE"
|
||||||
#define FF_DE_NUM_FORMAT_ARGS 3
|
#define FF_DE_NUM_FORMAT_ARGS 3
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
void ffPrintDesktopEnvironment(FFinstance* instance)
|
void ffPrintDesktopEnvironment(FFinstance* instance)
|
||||||
{
|
{
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.deKey, &instance->config.deFormat, FF_DE_NUM_FORMAT_ARGS, "DE detection is not supported on Android");
|
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, "DE detection is not supported on Android");
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -16,13 +16,13 @@ void ffPrintDesktopEnvironment(FFinstance* instance)
|
|||||||
|
|
||||||
if(result->dePrettyName.length == 0)
|
if(result->dePrettyName.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.deKey, &instance->config.deFormat, FF_DE_NUM_FORMAT_ARGS, "No DE found");
|
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, "No DE found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance->config.deFormat.length == 0)
|
if(instance->config.de.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &instance->config.deKey);
|
ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &instance->config.de.key);
|
||||||
|
|
||||||
ffStrbufWriteTo(&result->dePrettyName, stdout);
|
ffStrbufWriteTo(&result->dePrettyName, stdout);
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ void ffPrintDesktopEnvironment(FFinstance* instance)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_DE_MODULE_NAME, 0, &instance->config.deKey, &instance->config.deFormat, NULL, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_DE_MODULE_NAME, 0, &instance->config.de, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->deVersion}
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->deVersion}
|
||||||
|
|||||||
+31
-17
@@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
|
||||||
@@ -7,7 +8,7 @@
|
|||||||
|
|
||||||
static void getKey(FFinstance* instance, FFstrbuf* key, const char* folderPath, bool showFolderPath)
|
static void getKey(FFinstance* instance, FFstrbuf* key, const char* folderPath, bool showFolderPath)
|
||||||
{
|
{
|
||||||
if(instance->config.diskKey.length == 0)
|
if(instance->config.disk.key.length == 0)
|
||||||
{
|
{
|
||||||
if(showFolderPath)
|
if(showFolderPath)
|
||||||
ffStrbufAppendF(key, FF_DISK_MODULE_NAME" (%s)", folderPath);
|
ffStrbufAppendF(key, FF_DISK_MODULE_NAME" (%s)", folderPath);
|
||||||
@@ -16,7 +17,7 @@ static void getKey(FFinstance* instance, FFstrbuf* key, const char* folderPath,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffParseFormatString(key, &instance->config.diskKey, NULL, 1, (FFformatarg[]){
|
ffParseFormatString(key, &instance->config.disk.key, 1, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, folderPath}
|
{FF_FORMAT_ARG_TYPE_STRING, folderPath}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -24,26 +25,39 @@ static void getKey(FFinstance* instance, FFstrbuf* key, const char* folderPath,
|
|||||||
|
|
||||||
static void printStatvfs(FFinstance* instance, FFstrbuf* key, struct statvfs* fs)
|
static void printStatvfs(FFinstance* instance, FFstrbuf* key, struct statvfs* fs)
|
||||||
{
|
{
|
||||||
const uint32_t GB = 1024 * 1024 * 1024;
|
const double GB = 1024 * 1024 * 1024;
|
||||||
|
|
||||||
uint32_t total = (uint32_t) ((fs->f_blocks * fs->f_frsize) / GB);
|
double total = ((double) (fs->f_blocks * fs->f_frsize)) / GB;
|
||||||
uint32_t available = (uint32_t) ((fs->f_bfree * fs->f_frsize) / GB);
|
double available = ((double) (fs->f_bfree * fs->f_frsize)) / GB;
|
||||||
uint32_t used = total - available;
|
double used = total - available;
|
||||||
uint8_t percentage = (uint8_t) ((used / (double) total) * 100.0);
|
uint8_t percentage = (uint8_t) ((used / total) * 100.0);
|
||||||
|
|
||||||
uint32_t files = (uint32_t) (fs->f_files - fs->f_ffree);
|
uint32_t files = (uint32_t) (fs->f_files - fs->f_ffree);
|
||||||
|
|
||||||
if(instance->config.diskFormat.length == 0)
|
if(instance->config.disk.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, key->chars, 0, NULL);
|
ffPrintLogoAndKey(instance, key->chars, 0, NULL);
|
||||||
printf("%uGB / %uGB (%u%%)\n", used, total, percentage);
|
|
||||||
|
if(used >= 100.0)
|
||||||
|
printf("%.0f", used);
|
||||||
|
else
|
||||||
|
printf("%.1f", used);
|
||||||
|
|
||||||
|
fputs(" GB / ", stdout);
|
||||||
|
|
||||||
|
if(total >= 100.0)
|
||||||
|
printf("%.0f", total);
|
||||||
|
else
|
||||||
|
printf("%.1f", total);
|
||||||
|
|
||||||
|
printf("GiB (%u%%)\n", percentage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, key->chars, 0, NULL, &instance->config.diskFormat, NULL, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormatString(instance, key->chars, 0, NULL, &instance->config.disk.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &used},
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &used},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &total},
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &total},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &files},
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &files},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT8, &percentage}
|
{FF_FORMAT_ARG_TYPE_UINT8, &percentage}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -64,9 +78,9 @@ static void printFolder(FFinstance* instance, const char* folderPath)
|
|||||||
|
|
||||||
struct statvfs fs;
|
struct statvfs fs;
|
||||||
int ret = statvfs(folderPath, &fs);
|
int ret = statvfs(folderPath, &fs);
|
||||||
if(ret != 0 && instance->config.diskFormat.length == 0)
|
if(ret != 0 && instance->config.disk.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, key.chars, 0, NULL, &instance->config.diskFormat, FF_DISK_NUM_FORMAT_ARGS, "statvfs(\"%s\", &fs) != 0 (%i)", folderPath, ret);
|
ffPrintErrorString(instance, key.chars, 0, NULL, &instance->config.disk.errorFormat, "statvfs(\"%s\", &fs) != 0 (%i)", folderPath, ret);
|
||||||
ffStrbufDestroy(&key);
|
ffStrbufDestroy(&key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -89,7 +103,7 @@ void ffPrintDisk(FFinstance* instance)
|
|||||||
{
|
{
|
||||||
FF_STRBUF_CREATE(key);
|
FF_STRBUF_CREATE(key);
|
||||||
getKey(instance, &key, "", false);
|
getKey(instance, &key, "", false);
|
||||||
ffPrintError(instance, key.chars, 0, NULL, &instance->config.diskFormat, FF_DISK_NUM_FORMAT_ARGS, "statvfs failed for both / and " FASTFETCH_TARGET_DIR_HOME);
|
ffPrintErrorString(instance, key.chars, 0, NULL, &instance->config.disk.errorFormat, "statvfs failed for both / and " FASTFETCH_TARGET_DIR_HOME);
|
||||||
ffStrbufDestroy(&key);
|
ffStrbufDestroy(&key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -108,7 +122,7 @@ void ffPrintDisk(FFinstance* instance)
|
|||||||
{
|
{
|
||||||
FF_STRBUF_CREATE(key);
|
FF_STRBUF_CREATE(key);
|
||||||
getKey(instance, &key, "", false);
|
getKey(instance, &key, "", false);
|
||||||
ffPrintError(instance, key.chars, 0, NULL, &instance->config.diskFormat, FF_DISK_NUM_FORMAT_ARGS, "Custom disk folders string doesn't contain any folders");
|
ffPrintErrorString(instance, key.chars, 0, NULL, &instance->config.disk.errorFormat, "Custom disk folders string doesn't contain any folders");
|
||||||
ffStrbufDestroy(&key);
|
ffStrbufDestroy(&key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-8
@@ -1,4 +1,10 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/font.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
#include "detection/qt.h"
|
||||||
|
#include "detection/gtk.h"
|
||||||
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
#define FF_FONT_MODULE_NAME "Font"
|
#define FF_FONT_MODULE_NAME "Font"
|
||||||
#define FF_FONT_NUM_FORMAT_ARGS 21
|
#define FF_FONT_NUM_FORMAT_ARGS 21
|
||||||
@@ -6,7 +12,7 @@
|
|||||||
void ffPrintFont(FFinstance* instance)
|
void ffPrintFont(FFinstance* instance)
|
||||||
{
|
{
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.fontKey, &instance->config.fontFormat, FF_FONT_NUM_FORMAT_ARGS, "Font detection is not supported on Android");
|
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font, "Font detection is not supported on Android");
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -14,18 +20,18 @@ void ffPrintFont(FFinstance* instance)
|
|||||||
|
|
||||||
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, "TTY") == 0)
|
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, "TTY") == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.fontKey, &instance->config.fontFormat, FF_FONT_NUM_FORMAT_ARGS, "Font isn't supported in TTY");
|
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font, "Font isn't supported in TTY");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FFstrbuf* plasmaRaw = &ffDetectPlasma(instance)->font;
|
const FFstrbuf* plasmaRaw = &ffDetectQt(instance)->font;
|
||||||
const FFstrbuf* gtk2Raw = &ffDetectGTK2(instance)->font;
|
const FFstrbuf* gtk2Raw = &ffDetectGTK2(instance)->font;
|
||||||
const FFstrbuf* gtk3Raw = &ffDetectGTK3(instance)->font;
|
const FFstrbuf* gtk3Raw = &ffDetectGTK3(instance)->font;
|
||||||
const FFstrbuf* gtk4Raw = &ffDetectGTK4(instance)->font;
|
const FFstrbuf* gtk4Raw = &ffDetectGTK4(instance)->font;
|
||||||
|
|
||||||
if(plasmaRaw->length == 0 && gtk2Raw->length == 0 && gtk3Raw->length == 0 && gtk4Raw->length == 0)
|
if(plasmaRaw->length == 0 && gtk2Raw->length == 0 && gtk3Raw->length == 0 && gtk4Raw->length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.fontKey, &instance->config.fontFormat, FF_FONT_NUM_FORMAT_ARGS, "No fonts found");
|
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font, "No fonts found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,13 +51,13 @@ void ffPrintFont(FFinstance* instance)
|
|||||||
ffStrbufInitA(>k, 64);
|
ffStrbufInitA(>k, 64);
|
||||||
ffParseGTK(>k, >k2.pretty, >k3.pretty, >k4.pretty);
|
ffParseGTK(>k, >k2.pretty, >k3.pretty, >k4.pretty);
|
||||||
|
|
||||||
if(instance->config.fontFormat.length == 0)
|
if(instance->config.font.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &instance->config.fontKey);
|
ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font.key);
|
||||||
if(plasma.pretty.length > 0)
|
if(plasma.pretty.length > 0)
|
||||||
{
|
{
|
||||||
ffStrbufWriteTo(&plasma.pretty, stdout);
|
ffStrbufWriteTo(&plasma.pretty, stdout);
|
||||||
fputs(" [Plasma]", stdout);
|
fputs(" [QT]", stdout);
|
||||||
|
|
||||||
if(gtk.length > 0)
|
if(gtk.length > 0)
|
||||||
fputs(", ", stdout);
|
fputs(", ", stdout);
|
||||||
@@ -60,7 +66,7 @@ void ffPrintFont(FFinstance* instance)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_FONT_MODULE_NAME, 0, &instance->config.fontKey, &instance->config.fontFormat, NULL, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_FONT_MODULE_NAME, 0, &instance->config.font, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, plasmaRaw},
|
{FF_FORMAT_ARG_TYPE_STRBUF, plasmaRaw},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma.name},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma.name},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma.size},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma.size},
|
||||||
|
|||||||
+52
-9
@@ -1,9 +1,14 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/caching.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
#include "detection/temps.h"
|
||||||
|
#include "detection/vulkan.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define FF_GPU_MODULE_NAME "GPU"
|
#define FF_GPU_MODULE_NAME "GPU"
|
||||||
#define FF_GPU_NUM_FORMAT_ARGS 5
|
#define FF_GPU_NUM_FORMAT_ARGS 6
|
||||||
|
|
||||||
static void printGPUResult(FFinstance* instance, uint8_t index, FFcache* cache, FFGPUResult* result)
|
static void printGPUResult(FFinstance* instance, uint8_t index, FFcache* cache, FFGPUResult* result)
|
||||||
{
|
{
|
||||||
@@ -33,12 +38,13 @@ static void printGPUResult(FFinstance* instance, uint8_t index, FFcache* cache,
|
|||||||
|
|
||||||
ffStrbufAppend(&gpu, &namePretty);
|
ffStrbufAppend(&gpu, &namePretty);
|
||||||
|
|
||||||
ffPrintAndAppendToCache(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpuKey, cache, &gpu, &instance->config.gpuFormat, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintAndAppendToCache(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu, cache, &gpu, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->vendor},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->vendor},
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, vendorPretty},
|
{FF_FORMAT_ARG_TYPE_STRING, vendorPretty},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &namePretty},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &namePretty},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->driver},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result->driver},
|
||||||
|
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->temperature}
|
||||||
});
|
});
|
||||||
|
|
||||||
ffStrbufDestroy(&result->vendor);
|
ffStrbufDestroy(&result->vendor);
|
||||||
@@ -60,8 +66,10 @@ static void printGPUList(FFinstance* instance, const FFlist* list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FF_HAVE_LIBPCI
|
#ifdef FF_HAVE_LIBPCI
|
||||||
#include <pci/pci.h>
|
#include "common/library.h"
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <pci/pci.h>
|
||||||
|
|
||||||
//see https://github.com/pciutils/pciutils/blob/5bdf63b6b1bc35b59c4b3f47f7ca83ca1868155b/ls-kernel.c#L220
|
//see https://github.com/pciutils/pciutils/blob/5bdf63b6b1bc35b59c4b3f47f7ca83ca1868155b/ls-kernel.c#L220
|
||||||
static void pciGetDriver(struct pci_dev* dev, FFstrbuf* driver, char*(*ffpci_get_param)(struct pci_access*, char*))
|
static void pciGetDriver(struct pci_dev* dev, FFstrbuf* driver, char*(*ffpci_get_param)(struct pci_access*, char*))
|
||||||
@@ -89,6 +97,26 @@ static void pciGetDriver(struct pci_dev* dev, FFstrbuf* driver, char*(*ffpci_get
|
|||||||
ffStrbufDestroy(&path);
|
ffStrbufDestroy(&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double pciGetTemperatur(const FFinstance* instance, uint16_t deviceClass)
|
||||||
|
{
|
||||||
|
const FFTempsResult* tempsResult = ffDetectTemps(instance);
|
||||||
|
|
||||||
|
for(uint32_t i = 0; i < tempsResult->values.length; i++)
|
||||||
|
{
|
||||||
|
FFTempValue* tempValue = ffListGet(&tempsResult->values, i);
|
||||||
|
|
||||||
|
uint32_t tempClass;
|
||||||
|
if(sscanf(tempValue->deviceClass.chars, "%x", &tempClass) != 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//The kernel exposes the device class multiplied by 256 for some reason
|
||||||
|
if(tempClass == deviceClass * 256)
|
||||||
|
return tempValue->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0 / 0.0; //NaN
|
||||||
|
}
|
||||||
|
|
||||||
static bool pciPrintGPUs(FFinstance* instance)
|
static bool pciPrintGPUs(FFinstance* instance)
|
||||||
{
|
{
|
||||||
FF_LIBRARY_LOAD(pci, instance->config.libPCI, false, "libpci.so", 4)
|
FF_LIBRARY_LOAD(pci, instance->config.libPCI, false, "libpci.so", 4)
|
||||||
@@ -121,16 +149,22 @@ static bool pciPrintGPUs(FFinstance* instance)
|
|||||||
FFGPUResult* result = ffListAdd(&results);
|
FFGPUResult* result = ffListAdd(&results);
|
||||||
|
|
||||||
ffStrbufInitA(&result->vendor, 256);
|
ffStrbufInitA(&result->vendor, 256);
|
||||||
ffpci_lookup_name(pacc, result->vendor.chars, (int) result->vendor.allocated -1, PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id);
|
ffpci_lookup_name(pacc, result->vendor.chars, (int) ffStrbufGetFree(&result->vendor), PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id);
|
||||||
ffStrbufRecalculateLength(&result->vendor);
|
ffStrbufRecalculateLength(&result->vendor);
|
||||||
|
|
||||||
ffStrbufInitA(&result->name, 256);
|
ffStrbufInitA(&result->name, 256);
|
||||||
ffpci_lookup_name(pacc, result->name.chars, (int) result->name.allocated - 1, PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id);
|
ffpci_lookup_name(pacc, result->name.chars, (int) ffStrbufGetFree(&result->name), PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id);
|
||||||
ffStrbufRecalculateLength(&result->name);
|
ffStrbufRecalculateLength(&result->name);
|
||||||
|
|
||||||
ffStrbufInit(&result->driver);
|
ffStrbufInit(&result->driver);
|
||||||
if(instance->config.gpuFormat.length > 0) //We only need it for the format string, so don't detect it if it isn't needed
|
result->temperature = 0;
|
||||||
|
|
||||||
|
//We only need it for the format string, so don't detect it if it isn't needed
|
||||||
|
if(instance->config.gpu.outputFormat.length > 0)
|
||||||
|
{
|
||||||
pciGetDriver(dev, &result->driver, ffpci_get_param);
|
pciGetDriver(dev, &result->driver, ffpci_get_param);
|
||||||
|
result->temperature = pciGetTemperatur(instance, dev->device_class);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,9 +197,18 @@ static bool vulkanPrintGPUs(FFinstance* instance)
|
|||||||
|
|
||||||
void ffPrintGPU(FFinstance* instance)
|
void ffPrintGPU(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(ffPrintFromCache(instance, FF_GPU_MODULE_NAME, &instance->config.gpuKey, &instance->config.gpuFormat, FF_GPU_NUM_FORMAT_ARGS))
|
if(ffPrintFromCache(instance, FF_GPU_MODULE_NAME, &instance->config.gpu, FF_GPU_NUM_FORMAT_ARGS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(
|
||||||
|
getenv("WSLENV") != NULL ||
|
||||||
|
getenv("WSL_DISTRO") != NULL ||
|
||||||
|
getenv("WSL_INTEROP") != NULL
|
||||||
|
) {
|
||||||
|
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpu, "WSL doesn't expose senseful GPU names");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef FF_HAVE_LIBPCI
|
#ifdef FF_HAVE_LIBPCI
|
||||||
if(pciPrintGPUs(instance))
|
if(pciPrintGPUs(instance))
|
||||||
return;
|
return;
|
||||||
@@ -174,5 +217,5 @@ void ffPrintGPU(FFinstance* instance)
|
|||||||
if(vulkanPrintGPUs(instance))
|
if(vulkanPrintGPUs(instance))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpuKey, &instance->config.gpuFormat, FF_GPU_NUM_FORMAT_ARGS, "No GPUs found.");
|
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpu, "No GPUs found.");
|
||||||
}
|
}
|
||||||
|
|||||||
+119
-54
@@ -1,10 +1,19 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/caching.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define FF_HOST_MODULE_NAME "Host"
|
#define FF_HOST_MODULE_NAME "Host"
|
||||||
#define FF_HOST_NUM_FORMAT_ARGS 3
|
#define FF_HOST_NUM_FORMAT_ARGS 15
|
||||||
|
|
||||||
|
#ifndef __ANDROID__
|
||||||
|
#include "common/io.h"
|
||||||
|
#else
|
||||||
|
#include <ctype.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ANDROID__
|
||||||
static bool hostValueSet(FFstrbuf* value)
|
static bool hostValueSet(FFstrbuf* value)
|
||||||
{
|
{
|
||||||
ffStrbufTrimRight(value, '\n');
|
ffStrbufTrimRight(value, '\n');
|
||||||
@@ -32,100 +41,156 @@ static bool hostValueSet(FFstrbuf* value)
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __ANDROID__
|
|
||||||
static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer)
|
static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer)
|
||||||
{
|
{
|
||||||
ffGetFileContent(devicesPath, buffer);
|
ffReadFileBuffer(devicesPath, buffer);
|
||||||
|
|
||||||
if(buffer->length == 0)
|
if(buffer->length == 0)
|
||||||
ffGetFileContent(classPath, buffer);
|
ffReadFileBuffer(classPath, buffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ffPrintHost(FFinstance* instance)
|
void ffPrintHost(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(ffPrintFromCache(instance, FF_HOST_MODULE_NAME, &instance->config.hostKey, &instance->config.hostFormat, FF_HOST_NUM_FORMAT_ARGS))
|
if(ffPrintFromCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, FF_HOST_NUM_FORMAT_ARGS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FFstrbuf family;
|
FFstrbuf product_family;
|
||||||
ffStrbufInit(&family);
|
ffStrbufInit(&product_family);
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
getHostValue("/sys/devices/virtual/dmi/id/product_family", "/sys/class/dmi/id/product_family", &family);
|
getHostValue("/sys/devices/virtual/dmi/id/product_family", "/sys/class/dmi/id/product_family", &product_family);
|
||||||
|
if(!hostValueSet(&product_family))
|
||||||
|
ffStrbufClear(&product_family);
|
||||||
#else
|
#else
|
||||||
ffSettingsGetAndroidProperty("ro.product.device", &family);
|
ffSettingsGetAndroidProperty("ro.product.device", &product_family);
|
||||||
#endif
|
#endif
|
||||||
bool familySet = hostValueSet(&family);
|
|
||||||
|
|
||||||
FFstrbuf name;
|
FFstrbuf product_name;
|
||||||
ffStrbufInit(&name);
|
ffStrbufInit(&product_name);
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
getHostValue("/sys/devices/virtual/dmi/id/product_name", "/sys/class/dmi/id/product_name", &name);
|
getHostValue("/sys/devices/virtual/dmi/id/product_name", "/sys/class/dmi/id/product_name", &product_name);
|
||||||
|
|
||||||
if(name.length == 0)
|
if(product_name.length == 0)
|
||||||
ffGetFileContent("/sys/firmware/devicetree/base/model", &name);
|
ffReadFileBuffer("/sys/firmware/devicetree/base/model", &product_name);
|
||||||
|
|
||||||
if(name.length == 0)
|
if(product_name.length == 0)
|
||||||
ffGetFileContent("/tmp/sysinfo/model", &name);
|
ffReadFileBuffer("/tmp/sysinfo/model", &product_name);
|
||||||
|
|
||||||
if(ffStrbufStartsWithS(&name, "Standard PC"))
|
if(ffStrbufStartsWithS(&product_name, "Standard PC"))
|
||||||
{
|
{
|
||||||
FFstrbuf copy;
|
FFstrbuf copy;
|
||||||
ffStrbufInitCopy(©, &name);
|
ffStrbufInitCopy(©, &product_name);
|
||||||
ffStrbufSetS(&name, "KVM/QEMU ");
|
ffStrbufSetS(&product_name, "KVM/QEMU ");
|
||||||
ffStrbufAppend(&name, ©);
|
ffStrbufAppend(&product_name, ©);
|
||||||
ffStrbufDestroy(©);
|
ffStrbufDestroy(©);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!hostValueSet(&product_name))
|
||||||
|
ffStrbufClear(&product_name);
|
||||||
|
|
||||||
|
//On WSL, the real host can't be detected. Instead use WSL as host.
|
||||||
|
if(product_name.length == 0 && product_family.length == 0 && (
|
||||||
|
getenv("WSLENV") != NULL ||
|
||||||
|
getenv("WSL_DISTRO") != NULL ||
|
||||||
|
getenv("WSL_INTEROP") != NULL
|
||||||
|
)) ffStrbufAppendS(&product_name, "Windows Subsystem for Linux");
|
||||||
#else
|
#else
|
||||||
ffSettingsGetAndroidProperty("ro.product.brand", &name);
|
ffSettingsGetAndroidProperty("ro.product.brand", &product_name);
|
||||||
if(name.length > 0){
|
if(product_name.length > 0){
|
||||||
name.chars[0] = (char) toupper(name.chars[0]);
|
product_name.chars[0] = (char) toupper(product_name.chars[0]);
|
||||||
ffStrbufAppendC(&name, ' ');
|
ffStrbufAppendC(&product_name, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ffSettingsGetAndroidProperty("ro.product.model", &name))
|
if(!ffSettingsGetAndroidProperty("ro.product.model", &product_name))
|
||||||
ffSettingsGetAndroidProperty("ro.product.name", &name);
|
ffSettingsGetAndroidProperty("ro.product.name", &product_name);
|
||||||
|
|
||||||
ffStrbufTrimRight(&name, ' ');
|
ffStrbufTrimRight(&product_name, ' ');
|
||||||
#endif
|
#endif
|
||||||
bool nameSet = hostValueSet(&name);
|
|
||||||
|
|
||||||
FFstrbuf version;
|
if(product_family.length == 0 && product_name.length == 0)
|
||||||
ffStrbufInit(&version);
|
|
||||||
#ifndef __ANDROID__
|
|
||||||
getHostValue("/sys/devices/virtual/dmi/id/product_version", "/sys/class/dmi/id/product_version", &version);
|
|
||||||
#endif
|
|
||||||
bool versionSet = hostValueSet(&version);
|
|
||||||
|
|
||||||
if(!familySet && !nameSet)
|
|
||||||
{
|
{
|
||||||
ffStrbufDestroy(&family);
|
ffStrbufDestroy(&product_family);
|
||||||
ffStrbufDestroy(&name);
|
ffStrbufDestroy(&product_name);
|
||||||
ffStrbufDestroy(&version);
|
ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host, "neither product_family nor product_name is set by O.E.M.");
|
||||||
ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &instance->config.hostKey, &instance->config.hostFormat, FF_HOST_NUM_FORMAT_ARGS, "neither family nor name is set by O.E.M.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
#define FF_HOST_DATA(name) \
|
||||||
|
FFstrbuf name; \
|
||||||
|
ffStrbufInitA(&name, 0);
|
||||||
|
#else
|
||||||
|
#define FF_HOST_DATA(name) \
|
||||||
|
FFstrbuf name; \
|
||||||
|
ffStrbufInit(&name); \
|
||||||
|
getHostValue("/sys/devices/virtual/dmi/id/"#name, "/sys/class/dmi/id/"#name, &name); \
|
||||||
|
if(!hostValueSet(&name)) \
|
||||||
|
ffStrbufClear(&name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FF_HOST_DATA(product_version)
|
||||||
|
FF_HOST_DATA(product_sku)
|
||||||
|
FF_HOST_DATA(bios_date)
|
||||||
|
FF_HOST_DATA(bios_release)
|
||||||
|
FF_HOST_DATA(bios_vendor)
|
||||||
|
FF_HOST_DATA(bios_version)
|
||||||
|
FF_HOST_DATA(board_name)
|
||||||
|
FF_HOST_DATA(board_vendor)
|
||||||
|
FF_HOST_DATA(board_version)
|
||||||
|
FF_HOST_DATA(chassis_type)
|
||||||
|
FF_HOST_DATA(chassis_vendor)
|
||||||
|
FF_HOST_DATA(chassis_version)
|
||||||
|
FF_HOST_DATA(sys_vendor)
|
||||||
|
|
||||||
FFstrbuf host;
|
FFstrbuf host;
|
||||||
ffStrbufInit(&host);
|
ffStrbufInit(&host);
|
||||||
|
|
||||||
if(nameSet)
|
if(product_name.length > 0)
|
||||||
ffStrbufAppend(&host, &name);
|
ffStrbufAppend(&host, &product_name);
|
||||||
else
|
else
|
||||||
ffStrbufAppend(&host, &family);
|
ffStrbufAppend(&host, &product_family);
|
||||||
|
|
||||||
if(versionSet)
|
if(product_version.length > 0)
|
||||||
{
|
{
|
||||||
ffStrbufAppendC(&host, ' ');
|
ffStrbufAppendC(&host, ' ');
|
||||||
ffStrbufAppend(&host, &version);
|
ffStrbufAppend(&host, &product_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
ffPrintAndWriteToCache(instance, FF_HOST_MODULE_NAME, &instance->config.hostKey, &host, &instance->config.hostFormat, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
ffPrintAndWriteToCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, &host, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &family},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &product_family},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &name},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &product_name},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &version}
|
{FF_FORMAT_ARG_TYPE_STRBUF, &product_version},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &product_sku},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &bios_date},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &bios_release},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &bios_vendor},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &bios_version},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &board_name},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &board_vendor},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &board_version},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &chassis_type},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &chassis_vendor},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &chassis_version},
|
||||||
|
{FF_FORMAT_ARG_TYPE_STRBUF, &sys_vendor}
|
||||||
});
|
});
|
||||||
|
|
||||||
ffStrbufDestroy(&family);
|
ffStrbufDestroy(&product_family);
|
||||||
ffStrbufDestroy(&name);
|
ffStrbufDestroy(&product_name);
|
||||||
ffStrbufDestroy(&version);
|
|
||||||
|
//On Android, all of them get initialized without heap, so no need to destroy them.
|
||||||
|
#ifndef __ANDROID__
|
||||||
|
ffStrbufDestroy(&product_version);
|
||||||
|
ffStrbufDestroy(&product_sku);
|
||||||
|
ffStrbufDestroy(&bios_date);
|
||||||
|
ffStrbufDestroy(&bios_release);
|
||||||
|
ffStrbufDestroy(&bios_vendor);
|
||||||
|
ffStrbufDestroy(&bios_version);
|
||||||
|
ffStrbufDestroy(&board_name);
|
||||||
|
ffStrbufDestroy(&board_vendor);
|
||||||
|
ffStrbufDestroy(&board_version);
|
||||||
|
ffStrbufDestroy(&chassis_type);
|
||||||
|
ffStrbufDestroy(&chassis_vendor);
|
||||||
|
ffStrbufDestroy(&chassis_version);
|
||||||
|
ffStrbufDestroy(&sys_vendor);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-8
@@ -1,4 +1,9 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
#include "detection/qt.h"
|
||||||
|
#include "detection/gtk.h"
|
||||||
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
#define FF_ICONS_MODULE_NAME "Icons"
|
#define FF_ICONS_MODULE_NAME "Icons"
|
||||||
#define FF_ICONS_NUM_FORMAT_ARGS 5
|
#define FF_ICONS_NUM_FORMAT_ARGS 5
|
||||||
@@ -6,7 +11,7 @@
|
|||||||
void ffPrintIcons(FFinstance* instance)
|
void ffPrintIcons(FFinstance* instance)
|
||||||
{
|
{
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.iconsKey, &instance->config.iconsFormat, FF_ICONS_NUM_FORMAT_ARGS, "Icons detection is not supported on Android");
|
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, "Icons detection is not supported on Android");
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -14,32 +19,32 @@ void ffPrintIcons(FFinstance* instance)
|
|||||||
|
|
||||||
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, "TTY") == 0)
|
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, "TTY") == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.fontKey, &instance->config.fontFormat, FF_ICONS_NUM_FORMAT_ARGS, "Icons aren't supported in TTY");
|
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, "Icons aren't supported in TTY");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FFstrbuf* plasma = &ffDetectPlasma(instance)->icons;
|
const FFstrbuf* plasma = &ffDetectQt(instance)->icons;
|
||||||
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons;
|
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons;
|
||||||
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons;
|
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons;
|
||||||
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons;
|
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons;
|
||||||
|
|
||||||
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.iconsKey, &instance->config.iconsFormat, FF_ICONS_NUM_FORMAT_ARGS, "No icons could be found");
|
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, "No icons could be found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FF_STRBUF_CREATE(gtkPretty);
|
FF_STRBUF_CREATE(gtkPretty);
|
||||||
ffParseGTK(>kPretty, gtk2, gtk3, gtk4);
|
ffParseGTK(>kPretty, gtk2, gtk3, gtk4);
|
||||||
|
|
||||||
if(instance->config.iconsFormat.length == 0)
|
if(instance->config.icons.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.iconsKey);
|
ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons.key);
|
||||||
|
|
||||||
if(plasma->length > 0)
|
if(plasma->length > 0)
|
||||||
{
|
{
|
||||||
ffStrbufWriteTo(plasma, stdout);
|
ffStrbufWriteTo(plasma, stdout);
|
||||||
fputs(" [Plasma]", stdout);
|
fputs(" [QT]", stdout);
|
||||||
|
|
||||||
if(gtkPretty.length > 0)
|
if(gtkPretty.length > 0)
|
||||||
fputs(", ", stdout);
|
fputs(", ", stdout);
|
||||||
@@ -49,7 +54,7 @@ void ffPrintIcons(FFinstance* instance)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.iconsKey, &instance->config.iconsFormat, NULL, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, plasma},
|
{FF_FORMAT_ARG_TYPE_STRBUF, plasma},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
|
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
|
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
#define FF_KERNEL_MODULE_NAME "Kernel"
|
#define FF_KERNEL_MODULE_NAME "Kernel"
|
||||||
#define FF_KERNEL_NUM_FORMAT_ARGS 3
|
#define FF_KERNEL_NUM_FORMAT_ARGS 3
|
||||||
|
|
||||||
void ffPrintKernel(FFinstance* instance)
|
void ffPrintKernel(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(instance->config.kernelFormat.length == 0)
|
if(instance->config.kernel.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernelKey);
|
ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernel.key);
|
||||||
puts(instance->state.utsname.release);
|
puts(instance->state.utsname.release);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernelKey, &instance->config.kernelFormat, NULL, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernel, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.sysname},
|
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.sysname},
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.release},
|
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.release},
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.version}
|
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.version}
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/caching.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define FF_LOCALE_MODULE_NAME "Locale"
|
#define FF_LOCALE_MODULE_NAME "Locale"
|
||||||
#define FF_LOCALE_NUM_FORMAT_ARGS 1
|
#define FF_LOCALE_NUM_FORMAT_ARGS 1
|
||||||
@@ -22,7 +27,7 @@ static void getLocaleFromEnv(FFstrbuf* locale)
|
|||||||
|
|
||||||
void ffPrintLocale(FFinstance* instance)
|
void ffPrintLocale(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(ffPrintFromCache(instance, FF_LOCALE_MODULE_NAME, &instance->config.localeKey, &instance->config.localeFormat, FF_LOCALE_NUM_FORMAT_ARGS))
|
if(ffPrintFromCache(instance, FF_LOCALE_MODULE_NAME, &instance->config.locale, FF_LOCALE_NUM_FORMAT_ARGS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FFstrbuf locale;
|
FFstrbuf locale;
|
||||||
@@ -45,11 +50,11 @@ void ffPrintLocale(FFinstance* instance)
|
|||||||
|
|
||||||
if(locale.length == 0)
|
if(locale.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.localeKey, &instance->config.localeFormat, FF_LOCALE_NUM_FORMAT_ARGS, "No locale found");
|
ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale, "No locale found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ffPrintAndWriteToCache(instance, FF_LOCALE_MODULE_NAME, &instance->config.localeKey, &locale, &instance->config.localeFormat, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintAndWriteToCache(instance, FF_LOCALE_MODULE_NAME, &instance->config.locale, &locale, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &locale}
|
{FF_FORMAT_ARG_TYPE_STRBUF, &locale}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+18
-11
@@ -1,31 +1,38 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
#define FF_LOCALIP_MODULE_NAME "Local IP"
|
#define FF_LOCALIP_MODULE_NAME "Local IP"
|
||||||
#define FF_LOCALIP_NUM_FORMAT_ARGS 1
|
#define FF_LOCALIP_NUM_FORMAT_ARGS 1
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <string.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <string.h>
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
static void printValue(FFinstance* instance, const char* ifaName, const char* addressBuffer)
|
static void printValue(FFinstance* instance, const char* ifaName, const char* addressBuffer)
|
||||||
{
|
{
|
||||||
FF_STRBUF_CREATE(key);
|
FFstrbuf key;
|
||||||
|
ffStrbufInit(&key);
|
||||||
|
|
||||||
if (instance->config.localIpKey.length == 0) {
|
if (instance->config.localIP.key.length == 0)
|
||||||
|
{
|
||||||
ffStrbufAppendF(&key, FF_LOCALIP_MODULE_NAME " (%s)", ifaName);
|
ffStrbufAppendF(&key, FF_LOCALIP_MODULE_NAME " (%s)", ifaName);
|
||||||
} else {
|
}
|
||||||
ffParseFormatString(&key, &instance->config.localIpKey, NULL, 1, (FFformatarg[]){
|
else
|
||||||
|
{
|
||||||
|
ffParseFormatString(&key, &instance->config.localIP.key, 1, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, ifaName}
|
{FF_FORMAT_ARG_TYPE_STRING, ifaName}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance->config.localIpFormat.length == 0) {
|
if (instance->config.localIP.outputFormat.length == 0)
|
||||||
ffPrintLogoAndKey(instance, FF_LOCALIP_MODULE_NAME, 0, &key);
|
{
|
||||||
|
ffPrintLogoAndKey(instance, key.chars, 0, NULL);
|
||||||
puts(addressBuffer);
|
puts(addressBuffer);
|
||||||
} else {
|
}
|
||||||
ffPrintFormatString(instance, FF_LOCALIP_MODULE_NAME, 0, &key, &instance->config.localIpFormat, NULL, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){
|
else
|
||||||
|
{
|
||||||
|
ffPrintFormatString(instance, key.chars, 0, NULL, &instance->config.localIP.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, addressBuffer}
|
{FF_FORMAT_ARG_TYPE_STRING, addressBuffer}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -38,7 +45,7 @@ void ffPrintLocalIp(FFinstance* instance)
|
|||||||
struct ifaddrs* ifAddrStruct = NULL;
|
struct ifaddrs* ifAddrStruct = NULL;
|
||||||
int ret = getifaddrs(&ifAddrStruct);
|
int ret = getifaddrs(&ifAddrStruct);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ffPrintError(instance, FF_LOCALIP_MODULE_NAME, 0, &instance->config.localIpKey, &instance->config.localIpFormat, FF_LOCALIP_NUM_FORMAT_ARGS, "getifaddrs(&ifAddrStruct) < 0 (%i)", ret);
|
ffPrintError(instance, FF_LOCALIP_MODULE_NAME, 0, &instance->config.localIP, "getifaddrs(&ifAddrStruct) < 0 (%i)", ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define FF_MEMORY_MODULE_NAME "Memory"
|
#define FF_MEMORY_MODULE_NAME "Memory"
|
||||||
#define FF_MEMORY_NUM_FORMAT_ARGS 3
|
#define FF_MEMORY_NUM_FORMAT_ARGS 3
|
||||||
@@ -8,7 +11,7 @@ void ffPrintMemory(FFinstance* instance)
|
|||||||
{
|
{
|
||||||
FILE* meminfo = fopen("/proc/meminfo", "r");
|
FILE* meminfo = fopen("/proc/meminfo", "r");
|
||||||
if(meminfo == NULL) {
|
if(meminfo == NULL) {
|
||||||
ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memoryKey, &instance->config.memoryFormat, FF_MEMORY_NUM_FORMAT_ARGS, "fopen(\"""/proc/meminfo\", \"r\") == NULL");
|
ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memory, "fopen(\"""/proc/meminfo\", \"r\") == NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,18 +45,18 @@ void ffPrintMemory(FFinstance* instance)
|
|||||||
|
|
||||||
if(used_mem == 0 && total_mem == 0 && percentage == 0)
|
if(used_mem == 0 && total_mem == 0 && percentage == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memoryKey, &instance->config.memoryFormat, FF_MEMORY_NUM_FORMAT_ARGS, "/proc/meminfo could't be parsed");
|
ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memory, "/proc/meminfo could't be parsed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance->config.memoryFormat.length == 0)
|
if(instance->config.memory.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memoryKey);
|
ffPrintLogoAndKey(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memory.key);
|
||||||
printf("%uMiB / %uMiB (%u%%)\n", used_mem, total_mem, percentage);
|
printf("%uMiB / %uMiB (%u%%)\n", used_mem, total_mem, percentage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memoryKey, &instance->config.memoryFormat, NULL, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_MEMORY_MODULE_NAME, 0, &instance->config.memory, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &used_mem},
|
{FF_FORMAT_ARG_TYPE_UINT, &used_mem},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &total_mem},
|
{FF_FORMAT_ARG_TYPE_UINT, &total_mem},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT8, &percentage}
|
{FF_FORMAT_ARG_TYPE_UINT8, &percentage}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
#define FF_OPENCL_MODULE_NAME "OpenCL"
|
#define FF_OPENCL_MODULE_NAME "OpenCL"
|
||||||
#define FF_OPENCL_NUM_FORMAT_ARGS 3
|
#define FF_OPENCL_NUM_FORMAT_ARGS 3
|
||||||
|
|
||||||
#ifdef FF_HAVE_OPENCL
|
#ifdef FF_HAVE_OPENCL
|
||||||
|
#include "common/library.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
|
||||||
#define CL_TARGET_OPENCL_VERSION 100
|
#define CL_TARGET_OPENCL_VERSION 100
|
||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
|
|
||||||
@@ -44,14 +48,14 @@ static const char* openCLHandelData(FFinstance* instance, OpenCLData* data)
|
|||||||
char vendor[32];
|
char vendor[32];
|
||||||
data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VENDOR, sizeof(vendor), vendor, NULL);
|
data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VENDOR, sizeof(vendor), vendor, NULL);
|
||||||
|
|
||||||
if(instance->config.openCLFormat.length == 0)
|
if(instance->config.openCL.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCLKey);
|
ffPrintLogoAndKey(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCL.key);
|
||||||
puts(version);
|
puts(version);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCLKey, &instance->config.openCLFormat, NULL, FF_OPENCL_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
ffPrintFormat(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCL, FF_OPENCL_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, version},
|
{FF_FORMAT_ARG_TYPE_STRING, version},
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, device},
|
{FF_FORMAT_ARG_TYPE_STRING, device},
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, vendor}
|
{FF_FORMAT_ARG_TYPE_STRING, vendor}
|
||||||
@@ -87,5 +91,5 @@ void ffPrintOpenCL(FFinstance* instance)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(error != NULL)
|
if(error != NULL)
|
||||||
ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCLKey, &instance->config.openCLFormat, FF_OPENCL_NUM_FORMAT_ARGS, error);
|
ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &instance->config.openCL, error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/parsing.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -7,6 +9,7 @@
|
|||||||
|
|
||||||
#if defined(FF_HAVE_EGL) || defined(FF_HAVE_GLX) || defined(FF_HAVE_OSMESA)
|
#if defined(FF_HAVE_EGL) || defined(FF_HAVE_GLX) || defined(FF_HAVE_OSMESA)
|
||||||
#define FF_HAVE_GL 1
|
#define FF_HAVE_GL 1
|
||||||
|
#include "common/library.h"
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
|
||||||
#define FF_OPENGL_BUFFER_WIDTH 1
|
#define FF_OPENGL_BUFFER_WIDTH 1
|
||||||
@@ -27,14 +30,14 @@ static const char* glHandlePrint(FFinstance* instance, const GLData* data)
|
|||||||
const char* vendor = (const char*) data->ffglGetString(GL_VENDOR);
|
const char* vendor = (const char*) data->ffglGetString(GL_VENDOR);
|
||||||
const char* slv = (const char*) data->ffglGetString(GL_SHADING_LANGUAGE_VERSION);
|
const char* slv = (const char*) data->ffglGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||||
|
|
||||||
if(instance->config.openGLFormat.length == 0)
|
if(instance->config.openGL.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGLKey);
|
ffPrintLogoAndKey(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGL.key);
|
||||||
puts(version);
|
puts(version);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGLKey, &instance->config.openGLFormat, NULL, FF_OPENGL_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
ffPrintFormat(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGL, FF_OPENGL_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, version},
|
{FF_FORMAT_ARG_TYPE_STRING, version},
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, renderer},
|
{FF_FORMAT_ARG_TYPE_STRING, renderer},
|
||||||
{FF_FORMAT_ARG_TYPE_STRING, vendor},
|
{FF_FORMAT_ARG_TYPE_STRING, vendor},
|
||||||
@@ -388,5 +391,5 @@ void ffPrintOpenGL(FFinstance* instance)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(error != NULL)
|
if(error != NULL)
|
||||||
ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGLKey, &instance->config.openGLFormat, FF_OPENGL_NUM_FORMAT_ARGS, error);
|
ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGL, error);
|
||||||
}
|
}
|
||||||
|
|||||||
+92
-61
@@ -1,93 +1,124 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "detection/os.h"
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#define FF_OS_MODULE_NAME "OS"
|
#define FF_OS_MODULE_NAME "OS"
|
||||||
#define FF_OS_NUM_FORMAT_ARGS 12
|
#define FF_OS_NUM_FORMAT_ARGS 12
|
||||||
|
|
||||||
void ffPrintOS(FFinstance* instance)
|
static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
|
||||||
{
|
{
|
||||||
const FFOSResult* result = ffDetectOS(instance);
|
|
||||||
|
|
||||||
if(result->name.length == 0 && result->prettyName.length == 0)
|
|
||||||
{
|
|
||||||
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &instance->config.osKey, &instance->config.osFormat, FF_OS_NUM_FORMAT_ARGS, "Could not detect OS");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FFstrbuf os;
|
|
||||||
ffStrbufInit(&os);
|
|
||||||
|
|
||||||
//Create the basic output
|
//Create the basic output
|
||||||
|
if(os->name.length > 0)
|
||||||
if(result->name.length > 0)
|
ffStrbufAppend(result, &os->name);
|
||||||
ffStrbufAppend(&os, &result->name);
|
else if(os->prettyName.length > 0)
|
||||||
else if(result->prettyName.length > 0)
|
ffStrbufAppend(result, &os->name);
|
||||||
ffStrbufAppend(&os, &result->name);
|
else if(os->id.length > 0)
|
||||||
else if(result->id.length > 0)
|
ffStrbufAppend(result, &os->id);
|
||||||
ffStrbufAppend(&os, &result->id);
|
else if(os->systemName.length > 0)
|
||||||
else if(result->systemName.length > 0)
|
ffStrbufAppend(result, &os->systemName);
|
||||||
ffStrbufAppend(&os, &result->systemName);
|
|
||||||
else
|
else
|
||||||
ffStrbufAppendS(&os, "Linux");
|
ffStrbufAppendS(result, "Linux");
|
||||||
|
|
||||||
//Append version if it is missing
|
//Append version if it is missing
|
||||||
|
if(os->versionID.length > 0 && ffStrbufFirstIndex(result, &os->versionID) == result->length)
|
||||||
if(result->versionID.length > 0 && ffStrbufFirstIndex(&os, &result->versionID) == os.length)
|
|
||||||
{
|
{
|
||||||
ffStrbufAppendC(&os, ' ');
|
ffStrbufAppendC(result, ' ');
|
||||||
ffStrbufAppend(&os, &result->versionID);
|
ffStrbufAppend(result, &os->versionID);
|
||||||
}
|
}
|
||||||
else if(result->versionID.length == 0 && result->version.length > 0 && ffStrbufFirstIndex(&os, &result->version) == os.length)
|
else if(os->versionID.length == 0 && os->version.length > 0 && ffStrbufFirstIndex(result, &os->version) == result->length)
|
||||||
{
|
{
|
||||||
ffStrbufAppendC(&os, ' ');
|
ffStrbufAppendC(result, ' ');
|
||||||
ffStrbufAppend(&os, &result->version);
|
ffStrbufAppend(result, &os->version);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Append variant if it is missing
|
//Append variant if it is missing
|
||||||
|
if(os->variant.length > 0 && ffStrbufFirstIndex(result, &os->variant) == result->length)
|
||||||
if(result->variant.length > 0 && ffStrbufFirstIndex(&os, &result->variant) == os.length)
|
|
||||||
{
|
{
|
||||||
ffStrbufAppendS(&os, " (");
|
ffStrbufAppendS(result, " (");
|
||||||
ffStrbufAppend(&os, &result->variant);
|
ffStrbufAppend(result, &os->variant);
|
||||||
ffStrbufAppendC(&os, ')');
|
ffStrbufAppendC(result, ')');
|
||||||
}
|
}
|
||||||
else if(result->variant.length == 0 && result->variantID.length > 0 && ffStrbufFirstIndex(&os, &result->variantID) == os.length)
|
else if(os->variant.length == 0 && os->variantID.length > 0 && ffStrbufFirstIndex(result, &os->variantID) == result->length)
|
||||||
{
|
{
|
||||||
ffStrbufAppendS(&os, " (");
|
ffStrbufAppendS(result, " (");
|
||||||
ffStrbufAppend(&os, &result->variantID);
|
ffStrbufAppend(result, &os->variantID);
|
||||||
ffStrbufAppendC(&os, ')');
|
ffStrbufAppendC(result, ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Append architecture if it is missing
|
//Append architecture if it is missing
|
||||||
|
if(ffStrbufFirstIndex(result, &os->architecture) == result->length)
|
||||||
if(ffStrbufFirstIndex(&os, &result->architecture) == os.length)
|
|
||||||
{
|
{
|
||||||
ffStrbufAppendS(&os, " [");
|
ffStrbufAppendC(result, ' ');
|
||||||
ffStrbufAppend(&os, &result->architecture);
|
ffStrbufAppend(result, &os->architecture);
|
||||||
ffStrbufAppendC(&os, ']');
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void buildOutputNixOS(const FFOSResult* os, FFstrbuf* result)
|
||||||
|
{
|
||||||
|
ffStrbufAppendS(result, "NixOS");
|
||||||
|
|
||||||
|
if(os->buildID.length > 0)
|
||||||
|
{
|
||||||
|
ffStrbufAppendC(result, ' ');
|
||||||
|
ffStrbufAppend(result, &os->buildID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance->config.osFormat.length == 0)
|
if(os->codename.length > 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &instance->config.osKey);
|
ffStrbufAppendS(result, " (");
|
||||||
ffStrbufPutTo(&os, stdout);
|
ffStrbufAppendC(result, (char) toupper(os->codename.chars[0]));
|
||||||
|
ffStrbufAppendS(result, os->codename.chars + 1);
|
||||||
|
ffStrbufAppendC(result, ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(os->architecture.length > 0)
|
||||||
|
{
|
||||||
|
ffStrbufAppendC(result, ' ');
|
||||||
|
ffStrbufAppend(result, &os->architecture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffPrintOS(FFinstance* instance)
|
||||||
|
{
|
||||||
|
const FFOSResult* os = ffDetectOS(instance);
|
||||||
|
|
||||||
|
if(os->name.length == 0 && os->prettyName.length == 0)
|
||||||
|
{
|
||||||
|
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &instance->config.os, "Could not detect OS");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(instance->config.os.outputFormat.length == 0)
|
||||||
|
{
|
||||||
|
FFstrbuf result;
|
||||||
|
ffStrbufInit(&result);
|
||||||
|
|
||||||
|
if(ffStrbufIgnCaseCompS(&os->id, "nixos") == 0)
|
||||||
|
buildOutputNixOS(os, &result);
|
||||||
|
else
|
||||||
|
buildOutputDefault(os, &result);
|
||||||
|
|
||||||
|
ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &instance->config.os.key);
|
||||||
|
ffStrbufPutTo(&result, stdout);
|
||||||
|
ffStrbufDestroy(&result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_OS_MODULE_NAME, 0, &instance->config.osKey, &instance->config.osFormat, NULL, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_OS_MODULE_NAME, 0, &instance->config.os, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->systemName},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->systemName},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->name},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->prettyName},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->id},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->id},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->idLike},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->idLike},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->variant},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->variant},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->variantID},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->variantID},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->version},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->version},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->versionID},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->versionID},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->codename},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->codename},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->buildID},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->buildID},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->architecture}
|
{FF_FORMAT_ARG_TYPE_STRBUF, &os->architecture}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ffStrbufDestroy(&os);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+85
-17
@@ -1,10 +1,18 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/io.h"
|
||||||
|
#include "common/properties.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/settings.h"
|
||||||
|
#include "common/processing.h"
|
||||||
|
#include "detection/os.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define FF_PACKAGES_MODULE_NAME "Packages"
|
#define FF_PACKAGES_MODULE_NAME "Packages"
|
||||||
#define FF_PACKAGES_NUM_FORMAT_ARGS 11
|
#define FF_PACKAGES_NUM_FORMAT_ARGS 13
|
||||||
|
|
||||||
typedef struct PackageCounts
|
typedef struct PackageCounts
|
||||||
{
|
{
|
||||||
@@ -13,7 +21,9 @@ typedef struct PackageCounts
|
|||||||
uint32_t rpm;
|
uint32_t rpm;
|
||||||
uint32_t emerge;
|
uint32_t emerge;
|
||||||
uint32_t xbps;
|
uint32_t xbps;
|
||||||
|
uint32_t nixSystem;
|
||||||
uint32_t nixDefault;
|
uint32_t nixDefault;
|
||||||
|
uint32_t apk;
|
||||||
uint32_t flatpak;
|
uint32_t flatpak;
|
||||||
uint32_t snap;
|
uint32_t snap;
|
||||||
|
|
||||||
@@ -111,10 +121,17 @@ static uint32_t getNixPackages(char* path)
|
|||||||
FFstrbuf output;
|
FFstrbuf output;
|
||||||
ffStrbufInitA(&output, 128);
|
ffStrbufInitA(&output, 128);
|
||||||
|
|
||||||
|
//https://github.com/LinusDierheimer/fastfetch/issues/195#issuecomment-1191748222
|
||||||
|
FFstrbuf command;
|
||||||
|
ffStrbufInitA(&command, 255);
|
||||||
|
ffStrbufAppendS(&command, "for x in $(nix-store --query --requisites ");
|
||||||
|
ffStrbufAppendS(&command, path);
|
||||||
|
ffStrbufAppendS(&command, "); do if [ -d $x ]; then echo $x ; fi ; done | cut -d- -f2- | egrep '([0-9]{1,}\\.)+[0-9]{1,}' | egrep -v '\\-doc$|\\-man$|\\-info$|\\-dev$|\\-bin$|^nixos-system-nixos-' | uniq");
|
||||||
|
|
||||||
ffProcessAppendStdOut(&output, (char* const[]) {
|
ffProcessAppendStdOut(&output, (char* const[]) {
|
||||||
"nix-store",
|
"sh",
|
||||||
"-qR",
|
"-c",
|
||||||
path,
|
command.chars,
|
||||||
NULL
|
NULL
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -128,6 +145,7 @@ static uint32_t getNixPackages(char* path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FF_HAVE_RPM
|
#ifdef FF_HAVE_RPM
|
||||||
|
#include "common/library.h"
|
||||||
#include <rpm/rpmlib.h>
|
#include <rpm/rpmlib.h>
|
||||||
#include <rpm/rpmts.h>
|
#include <rpm/rpmts.h>
|
||||||
#include <rpm/rpmdb.h>
|
#include <rpm/rpmdb.h>
|
||||||
@@ -178,6 +196,30 @@ static uint32_t getRpmFromLibrpm(const FFinstance* instance)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static uint32_t getXBPS(FFstrbuf* baseDir)
|
||||||
|
{
|
||||||
|
DIR* dir = opendir(baseDir->chars);
|
||||||
|
if(dir == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint32_t result = 0;
|
||||||
|
|
||||||
|
struct dirent *entry;
|
||||||
|
while((entry = readdir(dir)) != NULL)
|
||||||
|
{
|
||||||
|
if(entry->d_type != DT_REG || strncasecmp(entry->d_name, "pkgdb-", 6) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ffStrbufAppendC(baseDir, '/');
|
||||||
|
ffStrbufAppendS(baseDir, entry->d_name);
|
||||||
|
result = getNumStrings(baseDir->chars, "<string>installed</string>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, PackageCounts* packageCounts)
|
static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, PackageCounts* packageCounts)
|
||||||
{
|
{
|
||||||
uint32_t baseDirLength = baseDir->length;
|
uint32_t baseDirLength = baseDir->length;
|
||||||
@@ -204,7 +246,22 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
|
|||||||
|
|
||||||
//xps
|
//xps
|
||||||
ffStrbufAppendS(baseDir, "/var/db/xbps");
|
ffStrbufAppendS(baseDir, "/var/db/xbps");
|
||||||
packageCounts->xbps += getNumElements(baseDir->chars, DT_REG);
|
packageCounts->xbps += getXBPS(baseDir);
|
||||||
|
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||||
|
|
||||||
|
//nix system
|
||||||
|
ffStrbufAppendS(baseDir, "/run/current-system");
|
||||||
|
packageCounts->nixSystem += getNixPackages(baseDir->chars);
|
||||||
|
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||||
|
|
||||||
|
//nix default
|
||||||
|
ffStrbufAppendS(baseDir, "/nix/var/nix/profiles/default");
|
||||||
|
packageCounts->nixDefault += getNixPackages(baseDir->chars);
|
||||||
|
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||||
|
|
||||||
|
//apk
|
||||||
|
ffStrbufAppendS(baseDir, "/lib/apk/db/installed");
|
||||||
|
packageCounts->apk += getNumStrings(baseDir->chars, "C:Q");
|
||||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||||
|
|
||||||
//flatpak
|
//flatpak
|
||||||
@@ -212,11 +269,6 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
|
|||||||
packageCounts->flatpak += getNumElements(baseDir->chars, DT_DIR);
|
packageCounts->flatpak += getNumElements(baseDir->chars, DT_DIR);
|
||||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||||
|
|
||||||
//nix default
|
|
||||||
ffStrbufAppendS(baseDir, "/var/nix/profiles/default");
|
|
||||||
packageCounts->nixDefault += getNixPackages(baseDir->chars);
|
|
||||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
|
||||||
|
|
||||||
//snap
|
//snap
|
||||||
ffStrbufAppendS(baseDir, "/snap");
|
ffStrbufAppendS(baseDir, "/snap");
|
||||||
uint32_t snap = getNumElements(baseDir->chars, DT_DIR);
|
uint32_t snap = getNumElements(baseDir->chars, DT_DIR);
|
||||||
@@ -233,15 +285,20 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
|
|||||||
|
|
||||||
static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDir, PackageCounts* packageCounts)
|
static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDir, PackageCounts* packageCounts)
|
||||||
{
|
{
|
||||||
|
uint32_t baseDirLength = baseDir->length;
|
||||||
|
|
||||||
ffStrbufAppendS(baseDir, "/bedrock/strata");
|
ffStrbufAppendS(baseDir, "/bedrock/strata");
|
||||||
|
|
||||||
DIR* dir = opendir(baseDir->chars);
|
DIR* dir = opendir(baseDir->chars);
|
||||||
if(dir == NULL)
|
if(dir == NULL)
|
||||||
|
{
|
||||||
|
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||||
|
getPackageCounts(instance, baseDir, packageCounts);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ffStrbufAppendC(baseDir, '/');
|
ffStrbufAppendC(baseDir, '/');
|
||||||
|
baseDirLength = baseDir->length;
|
||||||
uint32_t baseDirLength = baseDir->length;
|
|
||||||
|
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
while((entry = readdir(dir)) != NULL)
|
while((entry = readdir(dir)) != NULL)
|
||||||
@@ -286,16 +343,16 @@ void ffPrintPackages(FFinstance* instance)
|
|||||||
|
|
||||||
ffStrbufDestroy(&baseDir);
|
ffStrbufDestroy(&baseDir);
|
||||||
|
|
||||||
uint32_t all = counts.dpkg + counts.emerge + counts.flatpak + counts.nixDefault + nixUser + counts.pacman + counts.rpm + counts.snap + counts.xbps;
|
uint32_t all = counts.pacman + counts.dpkg + counts.rpm + counts.emerge + counts.xbps + counts.nixSystem + nixUser + counts.nixDefault + counts.apk + counts.flatpak + counts.snap;
|
||||||
if(all == 0)
|
if(all == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packagesKey, &instance->config.packagesFormat, FF_PACKAGES_NUM_FORMAT_ARGS, "No packages from known package managers found");
|
ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packages, "No packages from known package managers found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance->config.packagesFormat.length == 0)
|
if(instance->config.packages.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packagesKey);
|
ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packages.key);
|
||||||
|
|
||||||
#define FF_PRINT_PACKAGE(name) \
|
#define FF_PRINT_PACKAGE(name) \
|
||||||
if(counts.name > 0) \
|
if(counts.name > 0) \
|
||||||
@@ -317,6 +374,14 @@ void ffPrintPackages(FFinstance* instance)
|
|||||||
FF_PRINT_PACKAGE(dpkg)
|
FF_PRINT_PACKAGE(dpkg)
|
||||||
FF_PRINT_PACKAGE(rpm)
|
FF_PRINT_PACKAGE(rpm)
|
||||||
FF_PRINT_PACKAGE(emerge)
|
FF_PRINT_PACKAGE(emerge)
|
||||||
|
FF_PRINT_PACKAGE(xbps)
|
||||||
|
|
||||||
|
if(counts.nixSystem > 0)
|
||||||
|
{
|
||||||
|
printf("%u (nix-system)", counts.nixSystem);
|
||||||
|
if((all = all - counts.nixSystem) > 0)
|
||||||
|
printf(", ");
|
||||||
|
}
|
||||||
|
|
||||||
if(nixUser > 0)
|
if(nixUser > 0)
|
||||||
{
|
{
|
||||||
@@ -332,6 +397,7 @@ void ffPrintPackages(FFinstance* instance)
|
|||||||
printf(", ");
|
printf(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FF_PRINT_PACKAGE(apk)
|
||||||
FF_PRINT_PACKAGE(flatpak)
|
FF_PRINT_PACKAGE(flatpak)
|
||||||
FF_PRINT_PACKAGE(snap)
|
FF_PRINT_PACKAGE(snap)
|
||||||
|
|
||||||
@@ -344,7 +410,7 @@ void ffPrintPackages(FFinstance* instance)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packagesKey, &instance->config.packagesFormat, NULL, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packages, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &all},
|
{FF_FORMAT_ARG_TYPE_UINT, &all},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.pacman},
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.pacman},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &counts.pacmanBranch},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &counts.pacmanBranch},
|
||||||
@@ -352,8 +418,10 @@ void ffPrintPackages(FFinstance* instance)
|
|||||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.rpm},
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.rpm},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.emerge},
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.emerge},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.xbps},
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.xbps},
|
||||||
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.nixSystem},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &nixUser},
|
{FF_FORMAT_ARG_TYPE_UINT, &nixUser},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.nixDefault},
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.nixDefault},
|
||||||
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.apk},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.flatpak},
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.flatpak},
|
||||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.snap}
|
{FF_FORMAT_ARG_TYPE_UINT, &counts.snap}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "detection/media.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -11,7 +13,7 @@ void ffPrintPlayer(FFinstance* instance)
|
|||||||
|
|
||||||
if(media->player.length == 0)
|
if(media->player.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.playerKey, &instance->config.playerFormat, FF_PLAYER_NUM_FORMAT_ARGS, "No media player found");
|
ffPrintError(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.player, "No media player found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,14 +52,14 @@ void ffPrintPlayer(FFinstance* instance)
|
|||||||
if(playerPrettyIsCustom)
|
if(playerPrettyIsCustom)
|
||||||
ffStrbufAppendC(&playerPretty, ')');
|
ffStrbufAppendC(&playerPretty, ')');
|
||||||
|
|
||||||
if(instance->config.playerFormat.length == 0)
|
if(instance->config.player.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.playerKey);
|
ffPrintLogoAndKey(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.player.key);
|
||||||
ffStrbufPutTo(&playerPretty, stdout);
|
ffStrbufPutTo(&playerPretty, stdout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.playerKey, &instance->config.playerFormat, NULL, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.player, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &playerPretty},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &playerPretty},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->player},
|
{FF_FORMAT_ARG_TYPE_STRBUF, &media->player},
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->busNameShort}
|
{FF_FORMAT_ARG_TYPE_STRBUF, &media->busNameShort}
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
|
||||||
#define FF_PROCESSES_MODULE_NAME "Processes"
|
#define FF_PROCESSES_MODULE_NAME "Processes"
|
||||||
#define FF_PROCESSES_NUM_FORMAT_ARGS 1
|
#define FF_PROCESSES_NUM_FORMAT_ARGS 1
|
||||||
|
|
||||||
void ffPrintProcesses(FFinstance* instance)
|
void ffPrintProcesses(FFinstance* instance)
|
||||||
{
|
{
|
||||||
if(instance->config.processesFormat.length == 0)
|
if(instance->config.processes.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processesKey);
|
ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processes.key);
|
||||||
|
|
||||||
printf("%hu\n", instance->state.sysinfo.procs);
|
printf("%hu\n", instance->state.sysinfo.procs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processesKey, &instance->config.processesFormat, NULL, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){
|
ffPrintFormat(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processes, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||||
{FF_FORMAT_ARG_TYPE_UINT16, &instance->state.sysinfo.procs}
|
{FF_FORMAT_ARG_TYPE_UINT16, &instance->state.sysinfo.procs}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "common/networking.h"
|
||||||
|
|
||||||
#define FF_PUBLICIP_MODULE_NAME "Public IP"
|
#define FF_PUBLICIP_MODULE_NAME "Public IP"
|
||||||
#define FF_PUBLICIP_NUM_FORMAT_ARGS 1
|
#define FF_PUBLICIP_NUM_FORMAT_ARGS 1
|
||||||
@@ -12,18 +14,18 @@ void ffPrintPublicIp(FFinstance* instance)
|
|||||||
|
|
||||||
if(result.length == 0)
|
if(result.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintError(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIpKey, &instance->config.publicIpFormat, FF_PUBLICIP_NUM_FORMAT_ARGS, "Failed to connect to an IP detection server");
|
ffPrintError(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIP, "Failed to connect to an IP detection server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance->config.publicIpFormat.length == 0)
|
if(instance->config.publicIP.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIpKey);
|
ffPrintLogoAndKey(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIP.key);
|
||||||
ffStrbufPutTo(&result, stdout);
|
ffStrbufPutTo(&result, stdout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIpKey, &instance->config.publicIpFormat, NULL, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
ffPrintFormat(instance, FF_PUBLICIP_MODULE_NAME, 0, &instance->config.publicIP, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result}
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/printing.h"
|
||||||
|
#include "detection/displayserver.h"
|
||||||
|
|
||||||
#define FF_RESOLUTION_MODULE_NAME "Resolution"
|
#define FF_RESOLUTION_MODULE_NAME "Resolution"
|
||||||
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
|
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
|
||||||
@@ -6,7 +8,7 @@
|
|||||||
void ffPrintResolution(FFinstance* instance)
|
void ffPrintResolution(FFinstance* instance)
|
||||||
{
|
{
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
ffPrintError(instance, FF_RESOLUTION_MODULE_NAME, 0, &instance->config.resolutionKey, &instance->config.resolutionFormat, FF_RESOLUTION_NUM_FORMAT_ARGS, "Resolution detection is not supported on Android");
|
ffPrintError(instance, FF_RESOLUTION_MODULE_NAME, 0, &instance->config.resolution, "Resolution detection is not supported on Android");
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -17,9 +19,9 @@ void ffPrintResolution(FFinstance* instance)
|
|||||||
FFResolutionResult* result = ffListGet(&dsResult->resolutions, i);
|
FFResolutionResult* result = ffListGet(&dsResult->resolutions, i);
|
||||||
uint8_t moduleIndex = dsResult->resolutions.length == 1 ? 0 : (uint8_t) (i + 1);
|
uint8_t moduleIndex = dsResult->resolutions.length == 1 ? 0 : (uint8_t) (i + 1);
|
||||||
|
|
||||||
if(instance->config.resolutionFormat.length == 0)
|
if(instance->config.resolution.outputFormat.length == 0)
|
||||||
{
|
{
|
||||||
ffPrintLogoAndKey(instance, FF_RESOLUTION_MODULE_NAME, moduleIndex, &instance->config.resolutionKey);
|
ffPrintLogoAndKey(instance, FF_RESOLUTION_MODULE_NAME, moduleIndex, &instance->config.resolution.key);
|
||||||
printf("%ix%i", result->width, result->height);
|
printf("%ix%i", result->width, result->height);
|
||||||
|
|
||||||
if(result->refreshRate > 0)
|
if(result->refreshRate > 0)
|
||||||
@@ -29,7 +31,7 @@ void ffPrintResolution(FFinstance* instance)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffPrintFormatString(instance, FF_RESOLUTION_MODULE_NAME, moduleIndex, &instance->config.resolutionKey, &instance->config.resolutionFormat, NULL, FF_RESOLUTION_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
ffPrintFormat(instance, FF_RESOLUTION_MODULE_NAME, moduleIndex, &instance->config.resolution, FF_RESOLUTION_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||||
{FF_FORMAT_ARG_TYPE_INT, &result->width},
|
{FF_FORMAT_ARG_TYPE_INT, &result->width},
|
||||||
{FF_FORMAT_ARG_TYPE_INT, &result->height},
|
{FF_FORMAT_ARG_TYPE_INT, &result->height},
|
||||||
{FF_FORMAT_ARG_TYPE_INT, &result->refreshRate}
|
{FF_FORMAT_ARG_TYPE_INT, &result->refreshRate}
|
||||||
@@ -38,5 +40,5 @@ void ffPrintResolution(FFinstance* instance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(dsResult->resolutions.length == 0)
|
if(dsResult->resolutions.length == 0)
|
||||||
ffPrintError(instance, FF_RESOLUTION_MODULE_NAME, 0, &instance->config.resolutionKey, &instance->config.resolutionFormat, FF_RESOLUTION_NUM_FORMAT_ARGS, "Couldn't detect resolution");
|
ffPrintError(instance, FF_RESOLUTION_MODULE_NAME, 0, &instance->config.resolution, "Couldn't detect resolution");
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user