mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 18:32:10 +02:00
Compare commits
168 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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`:
|
||||
<!--
|
||||
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
|
||||
```
|
||||
@@ -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 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
|
||||
# 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.
|
||||
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
|
||||
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
|
||||
|
||||
- name: build project
|
||||
run: cmake --build . -j$(nproc) --target package
|
||||
|
||||
@@ -5,5 +5,3 @@
|
||||
cscope.*
|
||||
tags
|
||||
fastfetch.kdev4
|
||||
**/*.deb
|
||||
packaging/deb/fastfetch
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# 1.6.3
|
||||
|
||||
Fixes installing presets in their own directory (#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
|
||||
VERSION 1.5.3
|
||||
VERSION 1.6.3
|
||||
LANGUAGES C
|
||||
)
|
||||
|
||||
@@ -115,7 +115,8 @@ function(fastfetch_load_text FILENAME OUTVAR)
|
||||
endfunction(fastfetch_load_text)
|
||||
|
||||
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/help.txt DATATEXT_HELP)
|
||||
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 #
|
||||
#######################
|
||||
|
||||
add_library(libfastfetch STATIC
|
||||
add_library(libfastfetch OBJECT
|
||||
src/util/FFstrbuf.c
|
||||
src/util/FFlist.c
|
||||
src/util/FFvaluestore.c
|
||||
src/common/init.c
|
||||
src/common/threading.c
|
||||
src/common/io.c
|
||||
src/common/printing.c
|
||||
src/common/caching.c
|
||||
@@ -155,12 +155,14 @@ add_library(libfastfetch STATIC
|
||||
src/logo/image/im7.c
|
||||
src/logo/image/im6.c
|
||||
src/detection/os.c
|
||||
src/detection/plasma.c
|
||||
src/detection/qt.c
|
||||
src/detection/gtk.c
|
||||
src/detection/terminalShell.c
|
||||
src/detection/vulkan.c
|
||||
src/detection/media.c
|
||||
src/detection/datetime.c
|
||||
src/detection/temps.c
|
||||
src/detection/title.c
|
||||
src/detection/displayserver/displayServer.c
|
||||
src/detection/displayserver/wayland.c
|
||||
src/detection/displayserver/xcb.c
|
||||
@@ -453,10 +455,6 @@ target_link_libraries(libfastfetch
|
||||
PRIVATE Threads::Threads
|
||||
)
|
||||
|
||||
set_target_properties(libfastfetch PROPERTIES
|
||||
OUTPUT_NAME "fastfetch"
|
||||
)
|
||||
|
||||
######################
|
||||
# Executable targets #
|
||||
######################
|
||||
@@ -480,13 +478,6 @@ target_link_libraries(flashfetch
|
||||
###################
|
||||
|
||||
if (BUILD_TESTS)
|
||||
add_executable(fastfetch-test-performance
|
||||
tests/performance.c
|
||||
)
|
||||
target_link_libraries(fastfetch-test-performance
|
||||
PRIVATE libfastfetch
|
||||
)
|
||||
|
||||
add_executable(fastfetch-test-strbuf
|
||||
tests/strbuf.c
|
||||
)
|
||||
@@ -502,32 +493,42 @@ endif()
|
||||
# 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)
|
||||
|
||||
install(
|
||||
TARGETS fastfetch
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
TARGETS fastfetch flashfetch
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS flashfetch
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
FILES "${CMAKE_SOURCE_DIR}/src/data/config_system.txt"
|
||||
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}"
|
||||
RENAME "config.conf"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES completions/bash
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions
|
||||
RENAME ${CMAKE_PROJECT_NAME}
|
||||
FILES "${CMAKE_SOURCE_DIR}/completions/bash"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions"
|
||||
RENAME "${CMAKE_PROJECT_NAME}"
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY presets
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}
|
||||
DIRECTORY "${CMAKE_SOURCE_DIR}/presets"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES ./LICENSE
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}
|
||||
FILES "${CMAKE_SOURCE_DIR}/LICENSE"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}"
|
||||
)
|
||||
|
||||
##################
|
||||
@@ -535,6 +536,7 @@ install(
|
||||
##################
|
||||
|
||||
set(CPACK_GENERATOR "DEB;RPM;TGZ;ZIP")
|
||||
set(CPACK_SET_DESTDIR ON)
|
||||
|
||||
set(CPACK_PACKAGE_CONTACT "Linus Dierheimer <Linus@Dierheimer.de>")
|
||||
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
|
||||
- `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.
|
||||
- [ ] 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}
|
||||
- [ ] Make LocalIP module more configurable
|
||||
- [ ] Automatic migrate old config files to newer versions
|
||||
|
||||
@@ -50,7 +50,7 @@ Title, Separator, OS, Host, Kernel, Uptime, Processes, Packages, Shell, Resoluti
|
||||
|
||||
##### 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
|
||||
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.
|
||||
* Some logos have an old variant. Access it by appending _old to the logo name.
|
||||
@@ -75,7 +75,7 @@ KDE Plasma, Gnome, Cinnamon, Mate, XFCE4, LXQt
|
||||
|
||||
##### Terminal fonts
|
||||
```
|
||||
konsole, gnome-terminal-server, tilix, xfce4-terminal, lxterminal, TTY
|
||||
konsole, gnome-terminal-server, tilix, xfce4-terminal, alacritty, lxterminal, TTY
|
||||
```
|
||||
|
||||
## Building
|
||||
@@ -98,10 +98,8 @@ If pkg-config fails to find the headers for a library listed in [dependencies](#
|
||||
|
||||
### Manual
|
||||
|
||||
Build: Follow the [build instructions](#building).
|
||||
|
||||
* Create DEB / RPM: Run `cmake --build . --target package`.
|
||||
* Install directly: Run `sudo cmake --install . --prefix /usr/local`
|
||||
* DEB / RPM package: `cmake --build . --target package`
|
||||
* Install directly: `cmake --install . --prefix /usr/local`
|
||||
|
||||
## FAQ
|
||||
|
||||
|
||||
+38
-1
@@ -108,7 +108,8 @@ __fastfetch_completion()
|
||||
"--list-presets"
|
||||
"--list-features"
|
||||
"--print-logos"
|
||||
"--print-config"
|
||||
"--print-config-system"
|
||||
"--print-config-user"
|
||||
"--print-structure"
|
||||
)
|
||||
|
||||
@@ -132,6 +133,7 @@ __fastfetch_completion()
|
||||
"--localip-show-loop"
|
||||
"--escape-bedrock"
|
||||
"--pipe"
|
||||
"--title-fqdn"
|
||||
)
|
||||
|
||||
local FF_OPTIONS_STRING=(
|
||||
@@ -225,6 +227,41 @@ __fastfetch_completion()
|
||||
"--opengl-format"
|
||||
"--opencl-key"
|
||||
"--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=(
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
--load-config all
|
||||
|
||||
--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: {}"
|
||||
--uptime-format "Days: {}; Hours: {}; Minutes: {}; Seconds: {}"
|
||||
--processes-format "Count: {}"
|
||||
@@ -17,9 +17,9 @@
|
||||
--cursor-format "Theme: {}; Size: {}"
|
||||
--terminal-format "Process: {}; Path: {}; Exe: {}"
|
||||
--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: {}"
|
||||
--gpu-format "Vendor: {}; Vendor pretty: {}; Name: {}; Name pretty: {}; Driver: {}"
|
||||
--gpu-format "Vendor: {}; Vendor pretty: {}; Name: {}; Name pretty: {}; Driver: {}; Temperature: {}"
|
||||
--memory-format "Used: {}; Total: {}; Percentage: {}"
|
||||
--disk-format "Used: {}; Total: {}; Files: {}; Percentage: {}"
|
||||
--battery-format "Manufactor: {}; Model: {}; Technology: {}; Capacaty: {}; Status: {}"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
#!/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/
|
||||
cd build/
|
||||
cmake ..
|
||||
|
||||
+46
-17
@@ -1,9 +1,16 @@
|
||||
#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_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);
|
||||
ffStrbufAppendS(buffer, moduleName);
|
||||
@@ -20,7 +27,7 @@ static void readCacheFile(FFinstance* instance, const char* moduleName, const ch
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
getCacheFilePath(instance, moduleName, extension, &path);
|
||||
ffAppendFileContent(path.chars, buffer);
|
||||
ffAppendFileBuffer(path.chars, buffer);
|
||||
ffStrbufDestroy(&path);
|
||||
}
|
||||
|
||||
@@ -29,7 +36,7 @@ static void writeCacheFile(FFinstance* instance, const char* moduleName, const c
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
getCacheFilePath(instance, moduleName, extension, &path);
|
||||
ffWriteFileContent(path.chars, content);
|
||||
ffWriteFileBuffer(path.chars, content);
|
||||
ffStrbufDestroy(&path);
|
||||
}
|
||||
|
||||
@@ -77,7 +84,7 @@ void ffCacheClose(FFcache* cache)
|
||||
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;
|
||||
ffStrbufInitA(&content, 512);
|
||||
@@ -95,7 +102,7 @@ static bool printCachedValue(FFinstance* instance, const char* moduleName, const
|
||||
{
|
||||
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
|
||||
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);
|
||||
startIndex = nullByteIndex + 1;
|
||||
++moduleCounter;
|
||||
@@ -106,7 +113,7 @@ static bool printCachedValue(FFinstance* instance, const char* moduleName, const
|
||||
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;
|
||||
ffStrbufInitA(&content, 512);
|
||||
@@ -134,7 +141,7 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
|
||||
if(argumentCounter == numArgs)
|
||||
{
|
||||
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;
|
||||
argumentCounter = 0;
|
||||
}
|
||||
@@ -148,27 +155,27 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
|
||||
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)
|
||||
return false;
|
||||
|
||||
if(formatString == NULL || formatString->length == 0)
|
||||
return printCachedValue(instance, moduleName, customKeyFormat);
|
||||
if(moduleArgs->outputFormat.length == 0)
|
||||
return printCachedValue(instance, moduleName, moduleArgs);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, formatString, NULL, numArgs, arguments);
|
||||
ffPrintFormat(instance, moduleName, moduleIndex, moduleArgs, numArgs, arguments);
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
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 "common/font.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -188,13 +189,21 @@ void ffFontInitPango(FFfont* font, const char* data)
|
||||
fontInitPretty(font);
|
||||
}
|
||||
|
||||
void ffFontInitCopy(FFfont* font, const char* name)
|
||||
void ffFontInitValues(FFfont* font, const char* name, const char* size)
|
||||
{
|
||||
fontInit(font);
|
||||
|
||||
ffStrbufAppendS(&font->name, name);
|
||||
ffStrbufAppendS(&font->size, size);
|
||||
|
||||
fontInitPretty(font);
|
||||
}
|
||||
|
||||
void ffFontInitCopy(FFfont* font, const char* name)
|
||||
{
|
||||
ffFontInitValues(font, name, NULL);
|
||||
}
|
||||
|
||||
void ffFontDestroy(FFfont* font)
|
||||
{
|
||||
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 "common/format.h"
|
||||
|
||||
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)
|
||||
{
|
||||
uint32_t result = UINT32_MAX;
|
||||
@@ -72,6 +64,7 @@ static inline bool formatArgSet(const FFformatarg* arg)
|
||||
{
|
||||
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 == *(double*)arg->value) || //NaN
|
||||
(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_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;
|
||||
|
||||
@@ -128,13 +121,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
|
||||
while(i < formatstr->length && 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
|
||||
if(placeholderValue.length == 1 && placeholderValue.chars[0] == '-')
|
||||
{
|
||||
@@ -186,14 +172,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
|
||||
{
|
||||
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);
|
||||
|
||||
// testing for an invalid index
|
||||
@@ -223,14 +201,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
|
||||
{
|
||||
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);
|
||||
|
||||
// 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 "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 <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <pthread.h>
|
||||
|
||||
static bool strbufEqualsAdapter(const void* first, const void* second)
|
||||
{
|
||||
@@ -14,18 +21,14 @@ static void initConfigDirs(FFstate* state)
|
||||
ffListInit(&state->configDirs, sizeof(FFstrbuf));
|
||||
|
||||
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
|
||||
if(xdgConfigHome != NULL)
|
||||
if(ffStrSet(xdgConfigHome))
|
||||
{
|
||||
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
|
||||
ffStrbufInitA(buffer, 64);
|
||||
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) \
|
||||
if(ffListFirstIndexComp(&state->configDirs, element, strbufEqualsAdapter) < state->configDirs.length - 1) \
|
||||
--state->configDirs.length;
|
||||
@@ -33,24 +36,35 @@ static void initConfigDirs(FFstate* state)
|
||||
FFstrbuf* userConfigHome = ffListAdd(&state->configDirs);
|
||||
ffStrbufInitA(userConfigHome, 64);
|
||||
ffStrbufAppendS(userConfigHome, state->passwd->pw_dir);
|
||||
ffStrbufAppendS(userConfigHome, "/.config");
|
||||
ffStrbufAppendS(userConfigHome, "/.config/");
|
||||
FF_ENSURE_ONLY_ONCE_IN_LIST(userConfigHome)
|
||||
|
||||
FFstrbuf* userHome = ffListAdd(&state->configDirs);
|
||||
ffStrbufInitA(userHome, 64);
|
||||
ffStrbufAppendS(userHome, state->passwd->pw_dir);
|
||||
ffStrbufEnsureEndsWithC(userHome, '/');
|
||||
FF_ENSURE_ONLY_ONCE_IN_LIST(userHome)
|
||||
|
||||
FFstrbuf xdgConfigDirs;
|
||||
ffStrbufInitA(&xdgConfigDirs, 64);
|
||||
ffStrbufAppendS(&xdgConfigDirs, getenv("XDG_CONFIG_DIRS"));
|
||||
|
||||
uint32_t startIndex = 0;
|
||||
while (startIndex < xdgConfigDirs.length)
|
||||
{
|
||||
uint32_t colonIndex = ffStrbufNextIndexC(&xdgConfigDirs, startIndex, ':');
|
||||
xdgConfigDirs.chars[colonIndex] = '\0';
|
||||
|
||||
if(!ffStrSet(xdgConfigDirs.chars + startIndex))
|
||||
{
|
||||
startIndex = colonIndex + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
|
||||
ffStrbufInitA(buffer, 64);
|
||||
ffStrbufAppendS(buffer, xdgConfigDirs.chars + startIndex);
|
||||
ffStrbufTrimRight(buffer, '/');
|
||||
ffStrbufEnsureEndsWithC(buffer, '/');
|
||||
FF_ENSURE_ONLY_ONCE_IN_LIST(buffer);
|
||||
|
||||
startIndex = colonIndex + 1;
|
||||
@@ -58,12 +72,12 @@ static void initConfigDirs(FFstate* state)
|
||||
|
||||
FFstrbuf* systemConfigHome = ffListAdd(&state->configDirs);
|
||||
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)
|
||||
|
||||
FFstrbuf* systemConfig = ffListAdd(&state->configDirs);
|
||||
ffStrbufInitA(systemConfig, 64);
|
||||
ffStrbufAppendS(systemConfig, FASTFETCH_TARGET_DIR_ROOT"/etc");
|
||||
ffStrbufAppendS(systemConfig, FASTFETCH_TARGET_DIR_ROOT"/etc/");
|
||||
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfig)
|
||||
|
||||
#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, "/.cache/");
|
||||
}
|
||||
else if(!ffStrbufEndsWithC(&state->cacheDir, '/'))
|
||||
ffStrbufAppendC(&state->cacheDir, '/');
|
||||
else
|
||||
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
|
||||
|
||||
@@ -102,17 +116,24 @@ static void initState(FFstate* 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)
|
||||
{
|
||||
ffStrbufInit(&instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_AUTO;
|
||||
ffStrbufInit(&instance->config.logo.source);
|
||||
instance->config.logo.type = FF_LOGO_TYPE_AUTO;
|
||||
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
|
||||
ffStrbufInit(&instance->config.logoColors[i]);
|
||||
instance->config.logoWidth = 0;
|
||||
instance->config.logoHeight = 0; //preserve aspect ratio
|
||||
instance->config.logoPaddingLeft = 0;
|
||||
instance->config.logoPaddingRight = 4;
|
||||
instance->config.logoPrintRemaining = true;
|
||||
ffStrbufInit(&instance->config.logo.colors[i]);
|
||||
instance->config.logo.width = 0;
|
||||
instance->config.logo.height = 0; //preserve aspect ratio
|
||||
instance->config.logo.paddingLeft = 0;
|
||||
instance->config.logo.paddingRight = 4;
|
||||
instance->config.logo.printRemaining = true;
|
||||
|
||||
ffStrbufInit(&instance->config.mainColor);
|
||||
ffStrbufInit(&instance->config.separator);
|
||||
@@ -127,75 +148,42 @@ static void defaultConfig(FFinstance* instance)
|
||||
instance->config.escapeBedrock = true;
|
||||
instance->config.glType = FF_GL_TYPE_AUTO;
|
||||
instance->config.pipe = false;
|
||||
instance->config.multithreading = true;
|
||||
|
||||
ffStrbufInitA(&instance->config.osFormat, 0);
|
||||
ffStrbufInitA(&instance->config.osKey, 0);
|
||||
ffStrbufInitA(&instance->config.hostFormat, 0);
|
||||
ffStrbufInitA(&instance->config.hostKey, 0);
|
||||
ffStrbufInitA(&instance->config.kernelFormat, 0);
|
||||
ffStrbufInitA(&instance->config.kernelKey, 0);
|
||||
ffStrbufInitA(&instance->config.uptimeFormat, 0);
|
||||
ffStrbufInitA(&instance->config.uptimeKey, 0);
|
||||
ffStrbufInitA(&instance->config.processesFormat, 0);
|
||||
ffStrbufInitA(&instance->config.processesKey, 0);
|
||||
ffStrbufInitA(&instance->config.packagesFormat, 0);
|
||||
ffStrbufInitA(&instance->config.packagesKey, 0);
|
||||
ffStrbufInitA(&instance->config.shellFormat, 0);
|
||||
ffStrbufInitA(&instance->config.shellKey, 0);
|
||||
ffStrbufInitA(&instance->config.resolutionFormat, 0);
|
||||
ffStrbufInitA(&instance->config.resolutionKey, 0);
|
||||
ffStrbufInitA(&instance->config.deFormat, 0);
|
||||
ffStrbufInitA(&instance->config.deKey, 0);
|
||||
ffStrbufInitA(&instance->config.wmFormat, 0);
|
||||
ffStrbufInitA(&instance->config.wmKey, 0);
|
||||
ffStrbufInitA(&instance->config.wmThemeFormat, 0);
|
||||
ffStrbufInitA(&instance->config.wmThemeKey, 0);
|
||||
ffStrbufInitA(&instance->config.themeFormat, 0);
|
||||
ffStrbufInitA(&instance->config.themeKey, 0);
|
||||
ffStrbufInitA(&instance->config.iconsFormat, 0);
|
||||
ffStrbufInitA(&instance->config.iconsKey, 0);
|
||||
ffStrbufInitA(&instance->config.fontFormat, 0);
|
||||
ffStrbufInitA(&instance->config.fontKey, 0);
|
||||
ffStrbufInitA(&instance->config.cursorKey, 0);
|
||||
ffStrbufInitA(&instance->config.cursorFormat, 0);
|
||||
ffStrbufInitA(&instance->config.terminalFormat, 0);
|
||||
ffStrbufInitA(&instance->config.terminalKey, 0);
|
||||
ffStrbufInitA(&instance->config.termFontFormat, 0);
|
||||
ffStrbufInitA(&instance->config.termFontKey, 0);
|
||||
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);
|
||||
initModuleArg(&instance->config.os);
|
||||
initModuleArg(&instance->config.host);
|
||||
initModuleArg(&instance->config.kernel);
|
||||
initModuleArg(&instance->config.uptime);
|
||||
initModuleArg(&instance->config.processes);
|
||||
initModuleArg(&instance->config.packages);
|
||||
initModuleArg(&instance->config.shell);
|
||||
initModuleArg(&instance->config.resolution);
|
||||
initModuleArg(&instance->config.de);
|
||||
initModuleArg(&instance->config.wm);
|
||||
initModuleArg(&instance->config.wmTheme);
|
||||
initModuleArg(&instance->config.theme);
|
||||
initModuleArg(&instance->config.icons);
|
||||
initModuleArg(&instance->config.font);
|
||||
initModuleArg(&instance->config.cursor);
|
||||
initModuleArg(&instance->config.terminal);
|
||||
initModuleArg(&instance->config.terminalFont);
|
||||
initModuleArg(&instance->config.cpu);
|
||||
initModuleArg(&instance->config.cpuUsage);
|
||||
initModuleArg(&instance->config.gpu);
|
||||
initModuleArg(&instance->config.memory);
|
||||
initModuleArg(&instance->config.disk);
|
||||
initModuleArg(&instance->config.battery);
|
||||
initModuleArg(&instance->config.locale);
|
||||
initModuleArg(&instance->config.localIP);
|
||||
initModuleArg(&instance->config.publicIP);
|
||||
initModuleArg(&instance->config.player);
|
||||
initModuleArg(&instance->config.song);
|
||||
initModuleArg(&instance->config.dateTime);
|
||||
initModuleArg(&instance->config.date);
|
||||
initModuleArg(&instance->config.time);
|
||||
initModuleArg(&instance->config.vulkan);
|
||||
initModuleArg(&instance->config.openGL);
|
||||
initModuleArg(&instance->config.openCL);
|
||||
|
||||
ffStrbufInitA(&instance->config.libPCI, 0);
|
||||
ffStrbufInitA(&instance->config.libVulkan, 0);
|
||||
@@ -218,6 +206,8 @@ static void defaultConfig(FFinstance* instance)
|
||||
ffStrbufInitA(&instance->config.libOSMesa, 0);
|
||||
ffStrbufInitA(&instance->config.libOpenCL, 0);
|
||||
|
||||
instance->config.titleFQDN = false;
|
||||
|
||||
ffStrbufInitA(&instance->config.diskFolders, 0);
|
||||
|
||||
ffStrbufInitA(&instance->config.batteryDir, 0);
|
||||
@@ -241,6 +231,75 @@ void ffInitInstance(FFinstance* 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 ffHideCursor = true;
|
||||
|
||||
@@ -262,6 +321,9 @@ static void exitSignalHandler(int signal)
|
||||
|
||||
void ffStart(FFinstance* instance)
|
||||
{
|
||||
if(instance->config.multithreading)
|
||||
startDetectionThreads(instance);
|
||||
|
||||
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
|
||||
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
|
||||
|
||||
@@ -291,7 +353,7 @@ void ffStart(FFinstance* instance)
|
||||
|
||||
void ffFinish(FFinstance* instance)
|
||||
{
|
||||
if(instance->config.logoPrintRemaining)
|
||||
if(instance->config.logo.printRemaining)
|
||||
ffLogoPrintRemaining(instance);
|
||||
|
||||
resetConsole();
|
||||
|
||||
+37
-15
@@ -1,17 +1,12 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <termios.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)
|
||||
{
|
||||
FFstrbuf path;
|
||||
@@ -28,7 +23,13 @@ static void createSubfolders(const char* fileName)
|
||||
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 openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
@@ -42,14 +43,19 @@ bool ffWriteFileContent(const char* fileName, const FFstrbuf* content)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = ffWriteFDContent(fd, content);
|
||||
bool ret = write(fd, data, dataSize) != -1;
|
||||
|
||||
close(fd);
|
||||
|
||||
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;
|
||||
|
||||
@@ -73,24 +79,40 @@ void ffAppendFDContent(int fd, FFstrbuf* buffer)
|
||||
|
||||
ffStrbufTrimRight(buffer, '\n');
|
||||
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);
|
||||
if(fd == -1)
|
||||
return false;
|
||||
|
||||
ffAppendFDContent(fd, buffer);
|
||||
bool ret = ffAppendFDBuffer(fd, buffer);
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ffGetFileContent(const char* fileName, FFstrbuf* buffer)
|
||||
bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer)
|
||||
{
|
||||
ffStrbufClear(buffer);
|
||||
return ffAppendFileContent(fileName, buffer);
|
||||
return ffAppendFileBuffer(fileName, buffer);
|
||||
}
|
||||
|
||||
// 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 "common/library.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 "common/networking.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
||||
|
||||
@@ -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 "common/parsing.h"
|
||||
|
||||
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
|
||||
+58
-35
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
|
||||
{
|
||||
@@ -10,6 +11,7 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod
|
||||
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)
|
||||
{
|
||||
fputs(moduleName, stdout);
|
||||
@@ -21,7 +23,7 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod
|
||||
{
|
||||
FFstrbuf key;
|
||||
ffStrbufInit(&key);
|
||||
ffParseFormatString(&key, customKeyFormat, NULL, 1, (FFformatarg[]){
|
||||
ffParseFormatString(&key, customKeyFormat, 1, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
|
||||
});
|
||||
ffStrbufWriteTo(&key, stdout);
|
||||
@@ -37,44 +39,12 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod
|
||||
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, ...)
|
||||
{
|
||||
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)
|
||||
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments)
|
||||
{
|
||||
FFstrbuf buffer;
|
||||
ffStrbufInitA(&buffer, 256);
|
||||
|
||||
ffParseFormatString(&buffer, formatString, error, numArgs, arguments);
|
||||
ffParseFormatString(&buffer, format, numArgs, arguments);
|
||||
|
||||
if(buffer.length > 0)
|
||||
{
|
||||
@@ -85,6 +55,59 @@ void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t m
|
||||
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)
|
||||
{
|
||||
//If the color is not set, this would reset in \033[m, which resets everything.
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#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);
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/processing.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
@@ -29,6 +31,6 @@ void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
|
||||
//Parent
|
||||
close(pipes[1]);
|
||||
waitpid(childPid, NULL, 0);
|
||||
ffAppendFDContent(pipes[0], buffer);
|
||||
ffAppendFDBuffer(pipes[0], buffer);
|
||||
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 "common/properties.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
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
|
||||
// Buffers which already contain content are not overwritten
|
||||
// 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)
|
||||
{
|
||||
FILE* file = fopen(filename, "r");
|
||||
if(file == NULL)
|
||||
return false;
|
||||
|
||||
bool valueStorage[4];
|
||||
bool* unsetValues;
|
||||
|
||||
@@ -105,17 +111,8 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
|
||||
allSet = false;
|
||||
}
|
||||
|
||||
FILE* file = fopen(filename, "r");
|
||||
if(file == NULL)
|
||||
return false;
|
||||
|
||||
if(allSet)
|
||||
{
|
||||
fclose(file);
|
||||
if(unsetValues != valueStorage)
|
||||
free(unsetValues);
|
||||
return true;
|
||||
}
|
||||
goto done;
|
||||
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
@@ -137,11 +134,10 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
done:
|
||||
fclose(file);
|
||||
|
||||
if(unsetValues != valueStorage)
|
||||
free(unsetValues);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -174,21 +170,18 @@ bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativ
|
||||
{
|
||||
bool foundAFile = false;
|
||||
|
||||
FFstrbuf baseDir;
|
||||
ffStrbufInitA(&baseDir, 64);
|
||||
|
||||
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
||||
{
|
||||
FFstrbuf* baseDir = (FFstrbuf*) ffListGet(&instance->state.configDirs, i);
|
||||
uint32_t baseDirLength = baseDir->length;
|
||||
//We need to copy the config dir each time, because it used by multiple threads, so we can't directly write to it.
|
||||
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
|
||||
ffStrbufAppendS(&baseDir, relativeFile);
|
||||
|
||||
if(*relativeFile != '/')
|
||||
ffStrbufAppendC(baseDir, '/');
|
||||
|
||||
ffStrbufAppendS(baseDir, relativeFile);
|
||||
|
||||
if(ffParsePropFileValues(baseDir->chars, numQueries, queries))
|
||||
if(ffParsePropFileValues(baseDir.chars, numQueries, queries))
|
||||
foundAFile = true;
|
||||
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
|
||||
bool allSet = true;
|
||||
for(uint32_t k = 0; k < numQueries; k++)
|
||||
{
|
||||
@@ -203,6 +196,8 @@ bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativ
|
||||
break;
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&baseDir);
|
||||
|
||||
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 "common/settings.h"
|
||||
#include "common/library.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <pthread.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, ...) \
|
||||
static dataObject data; \
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; \
|
||||
@@ -270,6 +280,7 @@ FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, con
|
||||
|
||||
#ifdef FF_HAVE_SQLITE3
|
||||
#include <sqlite3.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
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)
|
||||
{
|
||||
if(!ffFileExists(dbPath, S_IFREG))
|
||||
return 0;
|
||||
|
||||
const SQLiteData* data = getSQLiteData(instance);
|
||||
if(data == NULL)
|
||||
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.
|
||||
|
||||
# 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.
|
||||
# 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.
|
||||
#--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:
|
||||
# Sets the string placed between a key and its value.
|
||||
# Can be any string.
|
||||
@@ -237,6 +243,44 @@
|
||||
#--opengl-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:
|
||||
# Sets an user specific path to a library to load.
|
||||
# Must be a valid path to a library.
|
||||
+22
-80
@@ -1,16 +1,17 @@
|
||||
Usage: fastfetch <options>
|
||||
|
||||
Informative options:
|
||||
-h,--help: shows this message and exits
|
||||
-h,--help <command>: shows help for a specific command and exits
|
||||
-v,--version: prints the version of fastfetch and exits
|
||||
--list-logos: list available logos 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-features: list the supported features fastfetch was compiled with and exits. Mainly for development.
|
||||
--print-logos: show available logos and exits
|
||||
--print-config: prints the default config and exits
|
||||
--print-structure: prints the default stucture and exits
|
||||
-h,--help: shows this message and exits
|
||||
-h,--help <command>: shows help for a specific command and exits
|
||||
-v,--version: prints the version of fastfetch and exits
|
||||
--list-logos: list available logos 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-features: list the supported features fastfetch was compiled with and exits. Mainly for development.
|
||||
--print-logos: show available logos and exits
|
||||
--print-config-system: prints the default system config and exits
|
||||
--print-config-user: prints the default user config and exits
|
||||
--print-structure: prints the default stucture and exits
|
||||
|
||||
General options:
|
||||
-r,--recache <?value>: generate new cached values
|
||||
@@ -46,77 +47,17 @@ Display options:
|
||||
--disable-linewrap <?value>: weather to disable linewrap 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.
|
||||
--os-format <format>
|
||||
--host-format <format>
|
||||
--kernel-format <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>
|
||||
General module options:
|
||||
--<module>-format <format>: Sets the format string to use for each specific module.
|
||||
To see how a format string works, use fastfetch --help format.
|
||||
To see help about a specific format string, use fastfetch --help <module>-format.
|
||||
|
||||
Key options: Provide a custom key for an output
|
||||
--os-key <key>
|
||||
--host-key <key>
|
||||
--kernel-key <key>
|
||||
--uptime-key <key>
|
||||
--processes-key <key>
|
||||
--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>
|
||||
--<module>-key <key>: Sets the key to use for each specific module.
|
||||
For modules which print multiple lines, the string is parsed as a format string with the index as first character.
|
||||
|
||||
--<module>-error <format>: Sets the error format string to use for each specific module.
|
||||
The error is given as the first and only argument.
|
||||
Setting this for a module will cause it to appear, even if --show-errors is not given.
|
||||
|
||||
Library options: Set the path of a library to load
|
||||
--lib-PCI <path>
|
||||
@@ -141,6 +82,7 @@ Library options: Set the path of a library to load
|
||||
--lib-opencl <path>
|
||||
|
||||
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
|
||||
--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"
|
||||
|
||||
@@ -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 '!'.
|
||||
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 "{-}".
|
||||
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.
|
||||
"\\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.
|
||||
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
|
||||
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.
|
||||
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
|
||||
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.
|
||||
For example when running in headless mode, you could use "--resolution-format "Preferred".
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/datetime.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
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 <pthread.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define FASTFETCH_INCLUDED_DISPLAYSERVER
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "detection/displayserver.h"
|
||||
|
||||
#define FF_DISPLAYSERVER_PROTOCOL_WAYLAND "Wayland"
|
||||
#define FF_DISPLAYSERVER_PROTOCOL_X11 "X11"
|
||||
|
||||
@@ -1,50 +1,53 @@
|
||||
#define _GNU_SOURCE //required for struct ucred
|
||||
|
||||
#include "displayServer.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef FF_HAVE_WAYLAND
|
||||
#include <wayland-client.h>
|
||||
#include "common/library.h"
|
||||
#include "common/io.h"
|
||||
#include <pthread.h>
|
||||
#include <wayland-client.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
typedef struct WaylandData
|
||||
{
|
||||
const FFinstance* instance;
|
||||
FFlist* results;
|
||||
FF_LIBRARY_SYMBOL(wl_proxy_marshal_constructor_versioned)
|
||||
FF_LIBRARY_SYMBOL(wl_proxy_add_listener)
|
||||
FF_LIBRARY_SYMBOL(wl_proxy_destroy)
|
||||
const struct wl_interface* ffwl_output_interface;
|
||||
struct wl_output_listener output_listener;
|
||||
} WaylandData;
|
||||
|
||||
static void waylandGlobalRemoveListener(void* data, struct wl_registry* wl_registry, uint32_t name){
|
||||
FF_UNUSED(data, wl_registry, name);
|
||||
static void waylandDetectWM(int fd, FFDisplayServerResult* result)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
(void) data;
|
||||
}
|
||||
|
||||
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))
|
||||
return;
|
||||
FF_UNUSED(output);
|
||||
|
||||
WaylandData* wldata = (WaylandData*) data;
|
||||
WaylandData* wldata = data;
|
||||
|
||||
wldata->ffwl_proxy_destroy((struct wl_proxy*) output);
|
||||
|
||||
if(width <= 0 || height <= 0)
|
||||
if(!(flags & WL_OUTPUT_MODE_CURRENT) || width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
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)
|
||||
{
|
||||
if(strcmp(interface, "wl_output") == 0)
|
||||
{
|
||||
WaylandData* wldata = (WaylandData*) data;
|
||||
WaylandData* wldata = 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)
|
||||
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)
|
||||
return;
|
||||
FF_LIBRARY_LOAD(wayland, instance->config.libWayland, false, "libwayland-client.so", 1)
|
||||
|
||||
FF_LIBRARY_LOAD(wayland, instance->config.libWayland, , "libwayland-client.so", 1)
|
||||
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_connect,)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_dispatch,)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_roundtrip,)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_proxy_marshal_constructor,)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_disconnect,)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_registry_interface,)
|
||||
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_dispatch, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_roundtrip, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_proxy_marshal_constructor, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_disconnect, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_registry_interface, false)
|
||||
|
||||
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_add_listener, wl_proxy_add_listener,)
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_output_interface, wl_output_interface,)
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_destroy, wl_proxy_destroy,)
|
||||
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, false)
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_output_interface, wl_output_interface, false)
|
||||
|
||||
struct wl_display* display = ffwl_display_connect(NULL);
|
||||
if(display == NULL)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ffwl_display_disconnect(display);
|
||||
dlclose(wayland);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
data.instance = instance;
|
||||
data.results = &result->resolutions;
|
||||
|
||||
struct wl_registry_listener regestry_listener;
|
||||
regestry_listener.global = waylandGlobalAddListener;
|
||||
regestry_listener.global_remove = waylandGlobalRemoveListener;
|
||||
struct wl_registry_listener registry_listener = {
|
||||
.global = waylandGlobalAddListener,
|
||||
.global_remove = (void*) stubListener
|
||||
};
|
||||
|
||||
data.output_listener.geometry = waylandOutputGeometryListener;
|
||||
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);
|
||||
data.ffwl_proxy_add_listener(registry, (void(**)(void)) ®istry_listener, &data);
|
||||
ffwl_display_dispatch(display);
|
||||
ffwl_display_roundtrip(display);
|
||||
|
||||
data.ffwl_proxy_destroy((struct wl_proxy*) registry);
|
||||
ffwl_display_disconnect(display);
|
||||
ffwl_display_disconnect(display); //This will also destroy our wl_registry and wl_output proxies
|
||||
dlclose(wayland);
|
||||
|
||||
//We successfully connected to wayland and detected the resolution.
|
||||
//So we can set set the session type to wayland.
|
||||
//This is used as an indicator that we are running wayland by the x11 backends.
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND);
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif
|
||||
|
||||
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
|
||||
if(getenv("XDG_RUNTIME_DIR") == NULL)
|
||||
return;
|
||||
|
||||
#ifdef FF_HAVE_WAYLAND
|
||||
if(detectWayland(instance, result))
|
||||
return;
|
||||
#else
|
||||
FF_UNUSED(instance);
|
||||
#endif
|
||||
|
||||
const char* xdgSessionType = getenv("XDG_SESSION_TYPE");
|
||||
|
||||
//If XDG_SESSION_TYPE is set, and doesn't contain "wayland", we are probably not running in a wayland session.
|
||||
@@ -158,9 +175,7 @@ void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* resul
|
||||
if(xdgSessionType == NULL && getenv("WAYLAND_DISPLAY") == NULL && getenv("WAYLAND_SOCKET") == NULL)
|
||||
return;
|
||||
|
||||
//We are probably running a wayland compositor at this point, but fastfetch was compiled without the required library.
|
||||
//Set the protocol name and use DRM for resolution detection.
|
||||
//We are probably running a wayland compositor at this point,
|
||||
//but fastfetch was compiled without the required library, or loading the library failed.
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
#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 <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static const char* parseEnv()
|
||||
{
|
||||
@@ -40,6 +47,11 @@ static const char* parseEnv()
|
||||
if(getenv("TDE_FULL_SESSION") != NULL)
|
||||
return "Trinity";
|
||||
|
||||
if(
|
||||
getenv("WAYLAND_DISPLAY") != NULL &&
|
||||
ffFileExists("/mnt/wslg/", S_IFDIR)
|
||||
) return "WSLg";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -48,8 +60,23 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* proce
|
||||
if(!ffStrSet(processName))
|
||||
return;
|
||||
|
||||
if(strcasecmp(processName, "kwin_wayland") == 0 || strcasecmp(processName, "kwin_x11") == 0 || strcasecmp(processName, "kwin") == 0)
|
||||
ffStrbufSetS(&result->wmPrettyName, "KWin");
|
||||
if(
|
||||
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)
|
||||
ffStrbufSetS(&result->wmPrettyName, "Sway");
|
||||
else if(strcasecmp(processName, "weston") == 0)
|
||||
@@ -64,10 +91,6 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* proce
|
||||
ffStrbufSetS(&result->wmPrettyName, "Marco");
|
||||
else if(strcasecmp(processName, "xmonad") == 0)
|
||||
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
|
||||
strcasecmp(processName, "dwm") == 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.
|
||||
ffStrbufAppendS(&procPath, "/loginuid");
|
||||
ffGetFileContent(procPath.chars, &loginuid);
|
||||
ffReadFileBuffer(procPath.chars, &loginuid);
|
||||
if(ffStrbufComp(&userID, &loginuid) != 0)
|
||||
{
|
||||
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.
|
||||
ffStrbufAppendS(&procPath, "/cmdline");
|
||||
ffGetFileContent(procPath.chars, &processName);
|
||||
ffReadFileBuffer(procPath.chars, &processName);
|
||||
ffStrbufSubstrBeforeFirstC(&processName, '\0'); //Trim the arguments
|
||||
ffStrbufSubstrAfterLastC(&processName, '/');
|
||||
|
||||
@@ -371,7 +394,7 @@ void ffdsDetectWMDE(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
getWMProtocolNameFromEnv(result);
|
||||
|
||||
//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)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "displayServer.h"
|
||||
|
||||
#ifdef FF_HAVE_XCB
|
||||
#include <xcb/xcb.h>
|
||||
#include "common/library.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
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)
|
||||
{
|
||||
if(result->wmProcessName.length > 0)
|
||||
if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND) == 0)
|
||||
return;
|
||||
|
||||
xcb_window_t* wmWindow = (xcb_window_t*) xcbGetProperty(data, connection, rootWindow, "_NET_SUPPORTING_WM_CHECK");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "displayServer.h"
|
||||
|
||||
#ifdef FF_HAVE_X11
|
||||
#include "common/library.h"
|
||||
#include "common/parsing.h"
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
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)
|
||||
{
|
||||
if(result->wmProcessName.length > 0)
|
||||
if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND) == 0)
|
||||
return;
|
||||
|
||||
Window* wmWindow = (Window*) x11GetProperty(data, display, DefaultRootWindow(display), "_NET_SUPPORTING_WM_CHECK");
|
||||
|
||||
+34
-29
@@ -1,4 +1,8 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/gtk.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/settings.h"
|
||||
#include "detection/displayserver.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -10,7 +14,7 @@ static inline bool allPropertiesSet(FFGTKResult* result)
|
||||
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)
|
||||
ffStrbufAppendS(&result->theme, themeName);
|
||||
@@ -28,7 +32,7 @@ static inline void applyGTKDConfSettings(FFGTKResult* result, const char* themeN
|
||||
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;
|
||||
|
||||
@@ -45,7 +49,7 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
||||
if(init)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
applyGTKDConfSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
|
||||
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,7 +57,15 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
applyGTKDConfSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
|
||||
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
//In case of an empty env variable
|
||||
ffStrbufTrim(configDir, ' ');
|
||||
if(configDir->length == 0)
|
||||
return;
|
||||
|
||||
uint32_t configDirLength = configDir->length;
|
||||
|
||||
// <configdir>/gtk-<version>.0/settings.ini
|
||||
ffStrbufAppendS(configDir, "/gtk-");
|
||||
ffStrbufAppendS(configDir, "gtk-");
|
||||
ffStrbufAppendS(configDir, version);
|
||||
ffStrbufAppendS(configDir, ".0/settings.ini");
|
||||
detectGTKFromConfigFile(configDir->chars, result);
|
||||
@@ -112,7 +119,7 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
|
||||
return;
|
||||
|
||||
// <configdir>/gtk-<version>.0/gtkrc
|
||||
ffStrbufAppendS(configDir, "/gtk-");
|
||||
ffStrbufAppendS(configDir, "gtk-");
|
||||
ffStrbufAppendS(configDir, version);
|
||||
ffStrbufAppendS(configDir, ".0/gtkrc");
|
||||
detectGTKFromConfigFile(configDir->chars, result);
|
||||
@@ -121,7 +128,7 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
|
||||
return;
|
||||
|
||||
// <configdir>/gtkrc-<version>.0
|
||||
ffStrbufAppendS(configDir, "/gtkrc-");
|
||||
ffStrbufAppendS(configDir, "gtkrc-");
|
||||
ffStrbufAppendS(configDir, version);
|
||||
ffStrbufAppendS(configDir, ".0");
|
||||
detectGTKFromConfigFile(configDir->chars, result);
|
||||
@@ -130,7 +137,7 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
|
||||
return;
|
||||
|
||||
// <configdir>/.gtkrc-<version>.0
|
||||
ffStrbufAppendS(configDir, "/.gtkrc-");
|
||||
ffStrbufAppendS(configDir, ".gtkrc-");
|
||||
ffStrbufAppendS(configDir, version);
|
||||
ffStrbufAppendS(configDir, ".0");
|
||||
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)
|
||||
{
|
||||
//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
|
||||
FFstrbuf baseDirCopy;
|
||||
ffStrbufInitA(&baseDirCopy, 64);
|
||||
FFstrbuf baseDir;
|
||||
ffStrbufInitA(&baseDir, 64);
|
||||
|
||||
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
||||
{
|
||||
FFstrbuf* baseDir = (FFstrbuf*) ffListGet(&instance->state.configDirs, i);
|
||||
ffStrbufSet(&baseDirCopy, baseDir);
|
||||
detectGTKFromConfigDir(&baseDirCopy, version, result);
|
||||
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
|
||||
detectGTKFromConfigDir(&baseDir, version, result);
|
||||
if(allPropertiesSet(result))
|
||||
{
|
||||
ffStrbufDestroy(&baseDirCopy);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&baseDirCopy);
|
||||
|
||||
//Mate, Cinnamon and Gnome use dconf to save theme config
|
||||
//On other DEs, this will do nothing
|
||||
detectGTKFromDConf(instance, result);
|
||||
ffStrbufDestroy(&baseDir);
|
||||
}
|
||||
|
||||
#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 "detection/media.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
@@ -7,6 +8,8 @@
|
||||
#define FF_DBUS_TIMEOUT_MILLISECONDS 35
|
||||
|
||||
#ifdef FF_HAVE_DBUS
|
||||
#include "common/library.h"
|
||||
#include "common/parsing.h"
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#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 "detection/os.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/parsing.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#if !defined(__ANDROID__)
|
||||
#if __ANDROID__
|
||||
#include "common/settings.h"
|
||||
#else
|
||||
|
||||
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 "detection/qt.h"
|
||||
#include "common/properties.h"
|
||||
#include "detection/displayserver.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.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
|
||||
{
|
||||
PLASMA_CATEGORY_GENERAL,
|
||||
@@ -11,9 +24,9 @@ typedef enum PlasmaCategory
|
||||
PLASMA_CATEGORY_OTHER
|
||||
} 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)
|
||||
return false;
|
||||
|
||||
@@ -67,10 +80,62 @@ static bool detectFromConfigFile(const FFstrbuf* filename, FFPlasmaResult* resul
|
||||
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 FFPlasmaResult result;
|
||||
static bool init = false;
|
||||
pthread_mutex_lock(&mutex);
|
||||
if(init)
|
||||
@@ -86,57 +151,11 @@ const FFPlasmaResult* ffDetectPlasma(FFinstance* instance)
|
||||
ffStrbufInit(&result.font);
|
||||
|
||||
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
||||
if(ffStrbufIgnCaseCompS(&wmde->deProcessName, "plasmashell") != 0)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return &result;
|
||||
}
|
||||
|
||||
bool foundAFile = false;
|
||||
|
||||
//We need to do this because we use multiple threads on configDirs
|
||||
FFstrbuf baseDirCopy;
|
||||
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");
|
||||
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "KDE Plasma") == 0)
|
||||
detectPlasma(instance, &result);
|
||||
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "LXQt") == 0)
|
||||
detectLXQt(instance, &result);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
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 "detection/temps.h"
|
||||
#include "common/io.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
static bool isTempFile(const char* name)
|
||||
{
|
||||
return
|
||||
name[0] == 't' &&
|
||||
name[1] == 'e' &&
|
||||
name[2] == 'm' &&
|
||||
name[3] == 'p' &&
|
||||
strncmp(name, "temp", 4) == 0 &&
|
||||
name[4] >= '0' &&
|
||||
name[4] <= '9' &&
|
||||
strncmp(name + 5, "_input", 6) == 0;
|
||||
@@ -23,30 +22,42 @@ static bool parseHwmonDir(FFstrbuf* dir, FFTempValue* value)
|
||||
return false;
|
||||
|
||||
uint32_t dirLength = dir->length;
|
||||
value->value = 0.0 / 0.0; //use NaN as error value
|
||||
|
||||
FFstrbuf valueString;
|
||||
ffStrbufInit(&valueString);
|
||||
|
||||
struct dirent* dirent;
|
||||
while((dirent = readdir(dirp)) != NULL)
|
||||
{
|
||||
if(isTempFile(dirent->d_name))
|
||||
{
|
||||
ffStrbufAppendS(dir, dirent->d_name);
|
||||
ffGetFileContent(dir->chars, &value->value);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
break;
|
||||
}
|
||||
if(!isTempFile(dirent->d_name))
|
||||
continue;
|
||||
|
||||
ffStrbufAppendS(dir, dirent->d_name);
|
||||
ffReadFileBuffer(dir->chars, &valueString);
|
||||
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);
|
||||
ffStrbufDestroy(&valueString);
|
||||
|
||||
if(value->value.length == 0)
|
||||
if(value->value != value->value)
|
||||
return false;
|
||||
|
||||
ffStrbufAppendS(dir, "name");
|
||||
ffGetFileContent(dir->chars, &value->name);
|
||||
ffReadFileBuffer(dir->chars, &value->name);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
|
||||
ffStrbufAppendS(dir, "device/class");
|
||||
ffGetFileContent(dir->chars, &value->deviceClass);
|
||||
ffReadFileBuffer(dir->chars, &value->deviceClass);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
|
||||
return value->name.length > 0 || value->deviceClass.length > 0;
|
||||
@@ -95,12 +106,10 @@ const FFTempsResult* ffDetectTemps(const FFinstance* instance)
|
||||
FFTempValue* temp = ffListAdd(&result.values);
|
||||
ffStrbufInit(&temp->name);
|
||||
ffStrbufInit(&temp->deviceClass);
|
||||
ffStrbufInit(&temp->value);
|
||||
if(!parseHwmonDir(&baseDir, temp))
|
||||
{
|
||||
ffStrbufDestroy(&temp->name);
|
||||
ffStrbufDestroy(&temp->deviceClass);
|
||||
ffStrbufDestroy(&temp->value);
|
||||
--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 "detection/terminalshell.h"
|
||||
#include "common/io.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/processing.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -20,7 +25,7 @@ static void getProcessInformation(const char* pid, FFstrbuf* processName, FFstrb
|
||||
ffStrbufAppendS(&cmdlineFilePath, pid);
|
||||
ffStrbufAppendS(&cmdlineFilePath, "/cmdline");
|
||||
|
||||
ffGetFileContent(cmdlineFilePath.chars, exe);
|
||||
ffReadFileBuffer(cmdlineFilePath.chars, exe);
|
||||
ffStrbufSubstrBeforeFirstC(exe, '\0'); //Trim the arguments
|
||||
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
|
||||
if(
|
||||
strcasecmp(name, "sudo") == 0 ||
|
||||
strcasecmp(name, "su") == 0 ||
|
||||
strcasecmp(name, "doas") == 0 ||
|
||||
strcasecmp(name, "strace") == 0 ||
|
||||
strcasecmp(name, "sshd") == 0 ||
|
||||
strcasecmp(name, "gdb") == 0
|
||||
strcasecmp(name, "sudo") == 0 ||
|
||||
strcasecmp(name, "su") == 0 ||
|
||||
strcasecmp(name, "doas") == 0 ||
|
||||
strcasecmp(name, "strace") == 0 ||
|
||||
strcasecmp(name, "sshd") == 0 ||
|
||||
strcasecmp(name, "gdb") == 0 ||
|
||||
strcasecmp(name, "guake-wrapped") == 0
|
||||
) {
|
||||
getTerminalShell(result, ppid);
|
||||
return;
|
||||
@@ -119,8 +125,17 @@ static void getTerminalFromEnv(FFTerminalShellResult* result)
|
||||
term = getenv("SSH_TTY");
|
||||
|
||||
//Windows Terminal
|
||||
if(!ffStrSet(term) && getenv("WT_SESSION") != NULL)
|
||||
term = "Windows Terminal";
|
||||
if(!ffStrSet(term) && (
|
||||
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
|
||||
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,38 @@
|
||||
#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 hostent* host = gethostbyname(result.hostname.chars);
|
||||
if(host != NULL)
|
||||
ffStrbufAppendS(&result.fqdn, host->h_name);
|
||||
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 "detection/vulkan.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#ifdef FF_HAVE_VULKAN
|
||||
#include "common/library.h"
|
||||
#include "common/io.h"
|
||||
#include "common/parsing.h"
|
||||
#include <stdlib.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
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->name);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
gpu->temperature = 0.0 / 0.0; //NaN, no way to detect temperature using vulkan
|
||||
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
|
||||
+255
-149
@@ -1,18 +1,19 @@
|
||||
#include "fastfetch.h"
|
||||
#include "util/FFvaluestore.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/parsing.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
// Things only needed by fastfetch
|
||||
typedef struct FFdata
|
||||
{
|
||||
FFvaluestore valuestore;
|
||||
FFstrbuf structure;
|
||||
bool multithreading;
|
||||
bool loadUserConfig;
|
||||
} FFdata;
|
||||
|
||||
static void constructAndPrintCommandHelpFormat(const char* name, const char* def, uint32_t numArgs, ...)
|
||||
@@ -28,7 +29,7 @@ static void constructAndPrintCommandHelpFormat(const char* name, const char* def
|
||||
for(uint32_t i = 1; i <= numArgs; i++)
|
||||
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);
|
||||
}
|
||||
@@ -62,10 +63,22 @@ static inline void printCommandHelp(const char* command)
|
||||
}
|
||||
else if(strcasecmp(command, "host-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("host", "{2} {3}", 3,
|
||||
"Host family",
|
||||
"Host name",
|
||||
"Host version"
|
||||
constructAndPrintCommandHelpFormat("host", "{2} {3}", 15,
|
||||
"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"
|
||||
);
|
||||
}
|
||||
else if(strcasecmp(command, "kernel-format") == 0)
|
||||
@@ -101,6 +114,7 @@ static inline void printCommandHelp(const char* command)
|
||||
"Number of rpm packages",
|
||||
"Number of emerge packages",
|
||||
"Number of xbps packages",
|
||||
"Number of nix-system packages",
|
||||
"Number of nix-user packages",
|
||||
"Number of nix-default packages",
|
||||
"Number of flatpak packages",
|
||||
@@ -224,7 +238,7 @@ static inline void printCommandHelp(const char* command)
|
||||
}
|
||||
else if(strcasecmp(command, "cpu-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("cpu", "{2} ({7}) @ {14}GHz", 14,
|
||||
constructAndPrintCommandHelpFormat("cpu", "{2} ({7}) @ {15}GHz", 15,
|
||||
"CPU name",
|
||||
"Prettified CPU name",
|
||||
"CPU Vendor name (Vendor ID)",
|
||||
@@ -232,6 +246,7 @@ static inline void printCommandHelp(const char* command)
|
||||
"CPU logical core count configured",
|
||||
"CPU physical core count",
|
||||
"Always set core count",
|
||||
"CPU package temperature",
|
||||
"frequency bios limit",
|
||||
"frequency scaling max",
|
||||
"frequency scaling min",
|
||||
@@ -249,12 +264,13 @@ static inline void printCommandHelp(const char* command)
|
||||
}
|
||||
else if(strcasecmp(command, "gpu-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("gpu", "{2} {4}", 5,
|
||||
constructAndPrintCommandHelpFormat("gpu", "{2} {4}", 6,
|
||||
"GPU vendor",
|
||||
"GPU vendor pretty",
|
||||
"GPU name",
|
||||
"GPU name pretty",
|
||||
"GPU driver"
|
||||
"GPU driver",
|
||||
"GPU temperature"
|
||||
);
|
||||
}
|
||||
else if(strcasecmp(command, "memory-format") == 0)
|
||||
@@ -267,7 +283,7 @@ static inline void printCommandHelp(const char* command)
|
||||
}
|
||||
else if(strcasecmp(command, "disk-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("disk", "{}GB / {}GB ({4}%)", 4,
|
||||
constructAndPrintCommandHelpFormat("disk", "{}GiB / {}GiB ({4}%)", 4,
|
||||
"Used disk space",
|
||||
"Total disk space",
|
||||
"Number of files",
|
||||
@@ -336,7 +352,7 @@ static inline void printCommandHelp(const char* command)
|
||||
"day in month",
|
||||
"day in Week",
|
||||
"hour",
|
||||
"hout with leading zero",
|
||||
"hour with leading zero",
|
||||
"hour 12h format",
|
||||
"hour 12h format with leading zero",
|
||||
"minute",
|
||||
@@ -673,9 +689,14 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
puts(FASTFETCH_PROJECT_VERSION);
|
||||
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);
|
||||
}
|
||||
else if(strcasecmp(key, "--print-structure") == 0)
|
||||
@@ -732,13 +753,15 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
else if(strcasecmp(key, "--load-config") == 0)
|
||||
optionParseConfigFile(instance, data, key, value);
|
||||
else if(strcasecmp(key, "--multithreading") == 0)
|
||||
data->multithreading = optionParseBoolean(value);
|
||||
instance->config.multithreading = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--allow-slow-operations") == 0)
|
||||
instance->config.allowSlowOperations = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--escape-bedrock") == 0)
|
||||
instance->config.escapeBedrock = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--pipe") == 0)
|
||||
instance->config.pipe = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--load-user-config") == 0)
|
||||
data->loadUserConfig = optionParseBoolean(value);
|
||||
|
||||
////////////////
|
||||
//Logo options//
|
||||
@@ -746,13 +769,13 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
|
||||
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
|
||||
if(strcasecmp(value, "none") == 0)
|
||||
{
|
||||
instance->config.logoPaddingRight = 0;
|
||||
instance->config.logoPaddingLeft = 0;
|
||||
instance->config.logo.paddingRight = 0;
|
||||
instance->config.logo.paddingLeft = 0;
|
||||
}
|
||||
}
|
||||
else if(strcasecmp(key, "--logo-type") == 0)
|
||||
@@ -764,19 +787,19 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
}
|
||||
|
||||
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)
|
||||
instance->config.logoType = FF_LOGO_TYPE_BUILTIN;
|
||||
instance->config.logo.type = FF_LOGO_TYPE_BUILTIN;
|
||||
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)
|
||||
instance->config.logoType = FF_LOGO_TYPE_RAW;
|
||||
instance->config.logo.type = FF_LOGO_TYPE_RAW;
|
||||
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)
|
||||
instance->config.logoType = FF_LOGO_TYPE_KITTY;
|
||||
instance->config.logo.type = FF_LOGO_TYPE_KITTY;
|
||||
else if(strcasecmp(value, "chafa") == 0)
|
||||
instance->config.logoType = FF_LOGO_TYPE_CHAFA;
|
||||
instance->config.logo.type = FF_LOGO_TYPE_CHAFA;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Error: unknown logo type: %s\n", value);
|
||||
@@ -795,48 +818,48 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
exit(472);
|
||||
}
|
||||
|
||||
optionParseColor(key, value, &instance->config.logoColors[index]);
|
||||
optionParseColor(key, value, &instance->config.logo.colors[index]);
|
||||
}
|
||||
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)
|
||||
instance->config.logoHeight = optionParseUInt32(key, value);
|
||||
instance->config.logo.height = optionParseUInt32(key, value);
|
||||
else if(strcasecmp(key, "--logo-padding") == 0)
|
||||
{
|
||||
uint32_t padding = optionParseUInt32(key, value);
|
||||
instance->config.logoPaddingLeft = padding;
|
||||
instance->config.logoPaddingRight = padding;
|
||||
instance->config.logo.paddingLeft = padding;
|
||||
instance->config.logo.paddingRight = padding;
|
||||
}
|
||||
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)
|
||||
instance->config.logoPaddingRight = optionParseUInt32(key, value);
|
||||
instance->config.logo.paddingRight = optionParseUInt32(key, value);
|
||||
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)
|
||||
{
|
||||
optionParseString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_SIXEL;
|
||||
optionParseString(key, value, &instance->config.logo.source);
|
||||
instance->config.logo.type = FF_LOGO_TYPE_SIXEL;
|
||||
}
|
||||
else if(strcasecmp(key, "--kitty") == 0)
|
||||
{
|
||||
optionParseString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_KITTY;
|
||||
optionParseString(key, value, &instance->config.logo.source);
|
||||
instance->config.logo.type = FF_LOGO_TYPE_KITTY;
|
||||
}
|
||||
else if(strcasecmp(key, "--file") == 0)
|
||||
{
|
||||
optionCheckString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_FILE;
|
||||
optionCheckString(key, value, &instance->config.logo.source);
|
||||
instance->config.logo.type = FF_LOGO_TYPE_FILE;
|
||||
}
|
||||
else if(strcasecmp(key, "--raw") == 0)
|
||||
{
|
||||
optionParseString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_RAW;
|
||||
optionParseString(key, value, &instance->config.logo.source);
|
||||
instance->config.logo.type = FF_LOGO_TYPE_RAW;
|
||||
}
|
||||
else if(strcasecmp(key, "--chafa") == 0)
|
||||
{
|
||||
optionParseString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_CHAFA;
|
||||
optionParseString(key, value, &instance->config.logo.source);
|
||||
instance->config.logo.type = FF_LOGO_TYPE_CHAFA;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
@@ -876,146 +899,214 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
ffValuestoreSet(&data->valuestore, value, separator + 1);
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//Format + Key options//
|
||||
////////////////////////
|
||||
////////////////////////////////
|
||||
//Format + Key + Error options//
|
||||
////////////////////////////////
|
||||
|
||||
else if(strcasecmp(key, "--os-format") == 0)
|
||||
optionParseString(key, value, &instance->config.osFormat);
|
||||
else if(strcasecmp(key, "--os-key") == 0)
|
||||
optionParseString(key, value, &instance->config.osKey);
|
||||
else if(strcasecmp(key, "--host-format") == 0)
|
||||
optionParseString(key, value, &instance->config.hostFormat);
|
||||
optionParseString(key, value, &instance->config.os.key);
|
||||
else if(strcasecmp(key, "--os-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.hostKey);
|
||||
else if(strcasecmp(key, "--kernel-format") == 0)
|
||||
optionParseString(key, value, &instance->config.kernelFormat);
|
||||
optionParseString(key, value, &instance->config.host.key);
|
||||
else if(strcasecmp(key, "--host-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.kernelKey);
|
||||
else if(strcasecmp(key, "--uptime-format") == 0)
|
||||
optionParseString(key, value, &instance->config.uptimeFormat);
|
||||
optionParseString(key, value, &instance->config.kernel.key);
|
||||
else if(strcasecmp(key, "--kernel-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.uptimeKey);
|
||||
else if(strcasecmp(key, "--processes-format") == 0)
|
||||
optionParseString(key, value, &instance->config.processesFormat);
|
||||
optionParseString(key, value, &instance->config.uptime.key);
|
||||
else if(strcasecmp(key, "--uptime-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.processesKey);
|
||||
else if(strcasecmp(key, "--packages-format") == 0)
|
||||
optionParseString(key, value, &instance->config.packagesFormat);
|
||||
optionParseString(key, value, &instance->config.processes.key);
|
||||
else if(strcasecmp(key, "--processes-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.packagesKey);
|
||||
else if(strcasecmp(key, "--shell-format") == 0)
|
||||
optionParseString(key, value, &instance->config.shellFormat);
|
||||
optionParseString(key, value, &instance->config.packages.key);
|
||||
else if(strcasecmp(key, "--packages-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.shellKey);
|
||||
else if(strcasecmp(key, "--resolution-format") == 0)
|
||||
optionParseString(key, value, &instance->config.resolutionFormat);
|
||||
optionParseString(key, value, &instance->config.shell.key);
|
||||
else if(strcasecmp(key, "--shell-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.resolutionKey);
|
||||
else if(strcasecmp(key, "--de-format") == 0)
|
||||
optionParseString(key, value, &instance->config.deFormat);
|
||||
optionParseString(key, value, &instance->config.resolution.key);
|
||||
else if(strcasecmp(key, "--resolution-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.deKey);
|
||||
else if(strcasecmp(key, "--wm-format") == 0)
|
||||
optionParseString(key, value, &instance->config.wmFormat);
|
||||
optionParseString(key, value, &instance->config.de.key);
|
||||
else if(strcasecmp(key, "--de-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.wmKey);
|
||||
else if(strcasecmp(key, "--wm-theme-format") == 0)
|
||||
optionParseString(key, value, &instance->config.wmThemeFormat);
|
||||
optionParseString(key, value, &instance->config.wm.key);
|
||||
else if(strcasecmp(key, "--wm-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.wmThemeKey);
|
||||
else if(strcasecmp(key, "--theme-format") == 0)
|
||||
optionParseString(key, value, &instance->config.themeFormat);
|
||||
optionParseString(key, value, &instance->config.wmTheme.key);
|
||||
else if(strcasecmp(key, "--wm-theme-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.themeKey);
|
||||
else if(strcasecmp(key, "--icons-format") == 0)
|
||||
optionParseString(key, value, &instance->config.iconsFormat);
|
||||
optionParseString(key, value, &instance->config.theme.key);
|
||||
else if(strcasecmp(key, "--theme-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.iconsKey);
|
||||
else if(strcasecmp(key, "--font-format") == 0)
|
||||
optionParseString(key, value, &instance->config.fontFormat);
|
||||
optionParseString(key, value, &instance->config.icons.key);
|
||||
else if(strcasecmp(key, "--icons-format") == 0)
|
||||
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)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.cursorKey);
|
||||
optionParseString(key, value, &instance->config.cursor.key);
|
||||
else if(strcasecmp(key, "--cursor-format") == 0)
|
||||
optionParseString(key, value, &instance->config.cursorFormat);
|
||||
else if(strcasecmp(key, "--terminal-format") == 0)
|
||||
optionParseString(key, value, &instance->config.terminalFormat);
|
||||
optionParseString(key, value, &instance->config.cursor.outputFormat);
|
||||
else if(strcasecmp(key, "--cursor-error") == 0)
|
||||
optionParseString(key, value, &instance->config.cursor.errorFormat);
|
||||
else if(strcasecmp(key, "--terminal-key") == 0)
|
||||
optionParseString(key, value, &instance->config.terminalKey);
|
||||
else if(strcasecmp(key, "--terminal-font-format") == 0)
|
||||
optionParseString(key, value, &instance->config.termFontFormat);
|
||||
optionParseString(key, value, &instance->config.terminal.key);
|
||||
else if(strcasecmp(key, "--terminal-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.termFontKey);
|
||||
else if(strcasecmp(key, "--cpu-format") == 0)
|
||||
optionParseString(key, value, &instance->config.cpuFormat);
|
||||
else if(strcasecmp(key, "--cpu-usage-format") == 0)
|
||||
optionParseString(key, value, &instance->config.cpuUsageFormat);
|
||||
optionParseString(key, value, &instance->config.terminalFont.key);
|
||||
else if(strcasecmp(key, "--terminal-font-format") == 0)
|
||||
optionParseString(key, value, &instance->config.terminalFont.outputFormat);
|
||||
else if(strcasecmp(key, "--terminal-font-error") == 0)
|
||||
optionParseString(key, value, &instance->config.terminalFont.errorFormat);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.cpuUsageKey);
|
||||
else if(strcasecmp(key, "--gpu-format") == 0)
|
||||
optionParseString(key, value, &instance->config.gpuFormat);
|
||||
optionParseString(key, value, &instance->config.cpuUsage.key);
|
||||
else if(strcasecmp(key, "--cpu-usage-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.gpuKey);
|
||||
else if(strcasecmp(key, "--memory-format") == 0)
|
||||
optionParseString(key, value, &instance->config.memoryFormat);
|
||||
optionParseString(key, value, &instance->config.gpu.key);
|
||||
else if(strcasecmp(key, "--gpu-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.memoryKey);
|
||||
else if(strcasecmp(key, "--disk-format") == 0)
|
||||
optionParseString(key, value, &instance->config.diskFormat);
|
||||
optionParseString(key, value, &instance->config.memory.key);
|
||||
else if(strcasecmp(key, "--memory-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.diskKey);
|
||||
else if(strcasecmp(key, "--battery-format") == 0)
|
||||
optionParseString(key, value, &instance->config.batteryFormat);
|
||||
optionParseString(key, value, &instance->config.disk.key);
|
||||
else if(strcasecmp(key, "--disk-format") == 0)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.batteryKey);
|
||||
else if(strcasecmp(key, "--locale-format") == 0)
|
||||
optionParseString(key, value, &instance->config.localeFormat);
|
||||
optionParseString(key, value, &instance->config.battery.key);
|
||||
else if(strcasecmp(key, "--battery-format") == 0)
|
||||
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)
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.localIpKey);
|
||||
optionParseString(key, value, &instance->config.localIP.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.publicIpKey);
|
||||
optionParseString(key, value, &instance->config.publicIP.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.playerKey);
|
||||
optionParseString(key, value, &instance->config.player.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.songKey);
|
||||
optionParseString(key, value, &instance->config.song.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.dateTimeKey);
|
||||
optionParseString(key, value, &instance->config.dateTime.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.dateKey);
|
||||
optionParseString(key, value, &instance->config.date.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.timeKey);
|
||||
optionParseString(key, value, &instance->config.time.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.vulkanKey);
|
||||
optionParseString(key, value, &instance->config.vulkan.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.openGLKey);
|
||||
optionParseString(key, value, &instance->config.openGL.key);
|
||||
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)
|
||||
optionParseString(key, value, &instance->config.openCLKey);
|
||||
optionParseString(key, value, &instance->config.openCL.key);
|
||||
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//
|
||||
@@ -1066,6 +1157,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
//Module options//
|
||||
//////////////////
|
||||
|
||||
else if(strcasecmp(key, "--title-fqdn") == 0)
|
||||
instance->config.titleFQDN = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--disk-folders") == 0)
|
||||
optionParseString(key, value, &instance->config.diskFolders);
|
||||
else if(strcasecmp(key, "--battery-dir") == 0)
|
||||
@@ -1118,8 +1211,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);
|
||||
uint32_t filenameLength = filename->length;
|
||||
|
||||
@@ -1142,7 +1248,7 @@ static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
|
||||
file = fopen(filename->chars, "w");
|
||||
if(file != NULL)
|
||||
{
|
||||
fputs(FASTFETCH_DATATEXT_CONFIG, file);
|
||||
fputs(FASTFETCH_DATATEXT_CONFIG_USER, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
@@ -1151,6 +1257,9 @@ static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
|
||||
|
||||
static void parseArguments(FFinstance* instance, FFdata* data, int argc, const char** argv)
|
||||
{
|
||||
if(!data->loadUserConfig)
|
||||
return;
|
||||
|
||||
for(int i = 1; i < argc; i++)
|
||||
{
|
||||
if(i == argc - 1 || (
|
||||
@@ -1254,7 +1363,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
|
||||
else if(strcasecmp(line, "opencl") == 0)
|
||||
ffPrintOpenCL(instance);
|
||||
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)
|
||||
@@ -1266,15 +1375,12 @@ int main(int argc, const char** argv)
|
||||
FFdata data;
|
||||
ffValuestoreInit(&data.valuestore);
|
||||
ffStrbufInitA(&data.structure, 256);
|
||||
data.multithreading = true;
|
||||
data.loadUserConfig = true;
|
||||
|
||||
parseDefaultConfigFile(&instance, &data);
|
||||
parseConfigFileSystem(&instance, &data);
|
||||
parseConfigFileUser(&instance, &data);
|
||||
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(data.structure.length == 0)
|
||||
ffStrbufSetS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
|
||||
|
||||
+60
-431
@@ -3,24 +3,17 @@
|
||||
#ifndef FASTFETCH_INCLUDED
|
||||
#define FASTFETCH_INCLUDED
|
||||
|
||||
#include <stddef.h>
|
||||
#include "fastfetch_config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "fastfetch_config.h"
|
||||
|
||||
#include "util/FFstrbuf.h"
|
||||
#include "util/FFlist.h"
|
||||
#include "util/FFvaluestore.h"
|
||||
|
||||
static inline void ffUnused(int dummy, ...) { (void) dummy; }
|
||||
#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__);
|
||||
@@ -50,16 +43,26 @@ typedef enum FFGLType
|
||||
FF_GL_TYPE_OSMESA
|
||||
} FFGLType;
|
||||
|
||||
typedef struct FFModuleArgs
|
||||
{
|
||||
FFstrbuf key;
|
||||
FFstrbuf outputFormat;
|
||||
FFstrbuf errorFormat;
|
||||
} FFModuleArgs;
|
||||
|
||||
typedef struct FFconfig
|
||||
{
|
||||
FFstrbuf logoSource;
|
||||
FFLogoType logoType;
|
||||
FFstrbuf logoColors[FASTFETCH_LOGO_MAX_COLORS];
|
||||
uint32_t logoWidth;
|
||||
uint32_t logoHeight;
|
||||
uint32_t logoPaddingLeft;
|
||||
uint32_t logoPaddingRight;
|
||||
bool logoPrintRemaining;
|
||||
struct
|
||||
{
|
||||
FFstrbuf source;
|
||||
FFLogoType type;
|
||||
FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS];
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
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 separator;
|
||||
@@ -73,75 +76,42 @@ typedef struct FFconfig
|
||||
bool escapeBedrock;
|
||||
FFGLType glType;
|
||||
bool pipe; //disables logo and all escape sequences
|
||||
bool multithreading;
|
||||
|
||||
FFstrbuf osFormat;
|
||||
FFstrbuf osKey;
|
||||
FFstrbuf hostFormat;
|
||||
FFstrbuf hostKey;
|
||||
FFstrbuf kernelFormat;
|
||||
FFstrbuf kernelKey;
|
||||
FFstrbuf uptimeFormat;
|
||||
FFstrbuf uptimeKey;
|
||||
FFstrbuf processesFormat;
|
||||
FFstrbuf processesKey;
|
||||
FFstrbuf packagesFormat;
|
||||
FFstrbuf packagesKey;
|
||||
FFstrbuf shellFormat;
|
||||
FFstrbuf shellKey;
|
||||
FFstrbuf resolutionFormat;
|
||||
FFstrbuf resolutionKey;
|
||||
FFstrbuf deFormat;
|
||||
FFstrbuf deKey;
|
||||
FFstrbuf wmFormat;
|
||||
FFstrbuf wmKey;
|
||||
FFstrbuf wmThemeFormat;
|
||||
FFstrbuf wmThemeKey;
|
||||
FFstrbuf themeFormat;
|
||||
FFstrbuf themeKey;
|
||||
FFstrbuf iconsFormat;
|
||||
FFstrbuf iconsKey;
|
||||
FFstrbuf fontFormat;
|
||||
FFstrbuf fontKey;
|
||||
FFstrbuf cursorFormat;
|
||||
FFstrbuf cursorKey;
|
||||
FFstrbuf terminalFormat;
|
||||
FFstrbuf terminalKey;
|
||||
FFstrbuf termFontFormat;
|
||||
FFstrbuf termFontKey;
|
||||
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;
|
||||
FFModuleArgs os;
|
||||
FFModuleArgs host;
|
||||
FFModuleArgs kernel;
|
||||
FFModuleArgs uptime;
|
||||
FFModuleArgs processes;
|
||||
FFModuleArgs packages;
|
||||
FFModuleArgs shell;
|
||||
FFModuleArgs resolution;
|
||||
FFModuleArgs de;
|
||||
FFModuleArgs wm;
|
||||
FFModuleArgs wmTheme;
|
||||
FFModuleArgs theme;
|
||||
FFModuleArgs icons;
|
||||
FFModuleArgs font;
|
||||
FFModuleArgs cursor;
|
||||
FFModuleArgs terminal;
|
||||
FFModuleArgs terminalFont;
|
||||
FFModuleArgs cpu;
|
||||
FFModuleArgs cpuUsage;
|
||||
FFModuleArgs gpu;
|
||||
FFModuleArgs memory;
|
||||
FFModuleArgs disk;
|
||||
FFModuleArgs battery;
|
||||
FFModuleArgs locale;
|
||||
FFModuleArgs localIP;
|
||||
FFModuleArgs publicIP;
|
||||
FFModuleArgs player;
|
||||
FFModuleArgs song;
|
||||
FFModuleArgs dateTime;
|
||||
FFModuleArgs date;
|
||||
FFModuleArgs time;
|
||||
FFModuleArgs vulkan;
|
||||
FFModuleArgs openGL;
|
||||
FFModuleArgs openCL;
|
||||
|
||||
FFstrbuf libPCI;
|
||||
FFstrbuf libVulkan;
|
||||
@@ -164,6 +134,8 @@ typedef struct FFconfig
|
||||
FFstrbuf libOSMesa;
|
||||
FFstrbuf libOpenCL;
|
||||
|
||||
bool titleFQDN;
|
||||
|
||||
FFstrbuf diskFolders;
|
||||
|
||||
FFstrbuf batteryDir;
|
||||
@@ -201,236 +173,8 @@ typedef struct FFinstance
|
||||
FFstate state;
|
||||
} 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
|
||||
@@ -440,87 +184,6 @@ void ffFinish(FFinstance* instance);
|
||||
|
||||
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 //
|
||||
////////////////////
|
||||
@@ -533,47 +196,13 @@ void ffLogoBuiltinPrint(FFinstance* instance);
|
||||
void ffLogoBuiltinList();
|
||||
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 //
|
||||
//////////////////////
|
||||
|
||||
//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
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#define FASTFETCH_TARGET_DIR_HOME "@TARGET_DIR_HOME@"
|
||||
|
||||
#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_HELP "@DATATEXT_HELP@"
|
||||
#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@"
|
||||
|
||||
+1
-4
@@ -10,10 +10,7 @@ int main(int argc, char** argv)
|
||||
|
||||
//Modify instance.config here
|
||||
|
||||
//Multithreading --> better performance
|
||||
ffStartDetectionThreads(&instance);
|
||||
|
||||
//Does things like disabling line wrap
|
||||
//Does things like starting detection threads, disabling line wrap, etc
|
||||
ffStart(&instance);
|
||||
|
||||
//Printing
|
||||
|
||||
+173
-30
@@ -43,6 +43,56 @@ static const FFlogo* getLogoNone()
|
||||
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()
|
||||
{
|
||||
FF_LOGO_INIT
|
||||
@@ -155,18 +205,18 @@ static const FFlogo* getLogoArtix()
|
||||
" 'oookkxxoo'\n"
|
||||
" 'oiioxkkxxoo'\n"
|
||||
" ':;:iiiioxxxoo'\n"
|
||||
" `'.;::ioxxoo''\n"
|
||||
" `'.;::ioxxoo'\n"
|
||||
" '-. `':;jiooo'\n"
|
||||
" 'oooio-.. `'i:io'\n"
|
||||
" 'ooooxxxxoio:,. `'-;'\n"
|
||||
" 'ooooxxxxxkkxoooIi:-. `'\n"
|
||||
" 'ooooxxxxxkkkkxoiiiiiji'\n"
|
||||
" 'ooooxxxxxkxxoiiii:'` .i'\n"
|
||||
" 'ooooxxxxxoi:::'` .;ioxo'\n"
|
||||
" 'ooooxooi::'` .:iiixkxxo'\n"
|
||||
" 'ooooi:'` `'';ioxxo'\n"
|
||||
"'i:'` '':io'\n"
|
||||
"'` `'";
|
||||
" 'oooio-.. `'i:io'\n"
|
||||
" 'ooooxxxxoio:,. `'-;'\n"
|
||||
" 'ooooxxxxxkkxoooIi:-. `'\n"
|
||||
" 'ooooxxxxxkkkkxoiiiiiji'\n"
|
||||
" 'ooooxxxxxkxxoiiii:'` .i'\n"
|
||||
" 'ooooxxxxxoi:::'` .;ioxo'\n"
|
||||
" 'ooooxooi::'` .:iiixkxxo'\n"
|
||||
" 'ooooi:'` `'';ioxxo'\n"
|
||||
" 'i:'` '':io'\n"
|
||||
"'` `'";
|
||||
)
|
||||
FF_LOGO_COLORS(
|
||||
"36" //cyan
|
||||
@@ -725,6 +775,27 @@ static const FFlogo* getLogoKDENeon()
|
||||
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()
|
||||
{
|
||||
FF_LOGO_INIT
|
||||
@@ -758,6 +829,32 @@ static const FFlogo* getLogoKubuntu()
|
||||
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()
|
||||
{
|
||||
FF_LOGO_INIT
|
||||
@@ -948,25 +1045,34 @@ static const FFlogo* getLogoNixOsOld()
|
||||
FF_LOGO_INIT
|
||||
FF_LOGO_NAMES("nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old")
|
||||
FF_LOGO_LINES(
|
||||
"$1 ::::. $2'::::: ::::'\n"
|
||||
"$1 '::::: $2':::::. ::::'\n"
|
||||
"$1 ::::: $2'::::.:::::\n"
|
||||
"$1 .......:::::..... $2::::::::\n"
|
||||
"$1 ::::::::::::::::::. $2:::::: $1::::.\n"
|
||||
" ::::::::::::::::::::: $2:::::. $1.::::'\n"
|
||||
"$2 ..... ::::' $1:::::'\n"
|
||||
"$2 ::::: '::' $1:::::'\n"
|
||||
"$2 ........::::: ' $1:::::::::::.\n"
|
||||
"$2::::::::::::: $1:::::::::::::\n"
|
||||
"$2 ::::::::::: $1.. $1:::::\n"
|
||||
"$2 .::::: $1.::: $1:::::\n"
|
||||
"$2 .::::: $1::::: $1''''' $2.....\n"
|
||||
" ::::: $1':::::. $2......:::::::::::::'\n"
|
||||
" ::: $1::::::. $2':::::::::::::::::'\n"
|
||||
"$1 .:::::::: $2'::::::::::\n"
|
||||
"$1 .::::''::::. $2'::::.\n"
|
||||
"$1 .::::' ::::. $2'::::.\n"
|
||||
"$1 .:::: :::: $2'::::."
|
||||
"$1 ____ $2_______ ____\n"
|
||||
"$1 /####\\ $2\\######\\ /####\\\n"
|
||||
"$1 ######\\ $2\\######\\ /#####/\n"
|
||||
"$1 \\######\\ $2\\######\\ /#####/\n"
|
||||
"$1 \\######\\ $2\\######\\/#####/ $1/\\\n"
|
||||
"$1 \\######\\ $2\\###########/ $1/##\\\n"
|
||||
"$1 ________\\######\\______$2\\#########/ $1/####\\\n"
|
||||
"$1 /#######################$2\\#######/ $1/######\n"
|
||||
"$1 /#########################$2\\######\\ $1/######/\n"
|
||||
"$1 /###########################$2\\######\\ $1/######/\n"
|
||||
"$1 ¯¯¯¯¯¯¯¯¯¯¯¯$2/######/$1¯¯¯¯¯¯¯¯¯$2\\######$1/######/\n"
|
||||
"$2 /######/ $2\\####$1/######/________\n"
|
||||
"$2 _____________/######/ $2\\##$1/################\\\n"
|
||||
"$2 /###################/ $2\\$1/##################\\\n"
|
||||
"$2 \\##################/$1\\ /###################/\n"
|
||||
"$2 \\################/$1##\\ /######/¯¯¯¯¯¯¯¯¯¯¯¯¯\n"
|
||||
"$2 ¯¯¯¯¯¯¯¯/######/$1####\\ /######/\n"
|
||||
"$2 /######/$1######\\$2_________$1/######/$2____________\n"
|
||||
"$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(
|
||||
"34", //blue
|
||||
@@ -1299,6 +1405,38 @@ static const FFlogo* getLogoRockyLinux()
|
||||
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()
|
||||
{
|
||||
FF_LOGO_INIT
|
||||
@@ -1434,6 +1572,8 @@ GetLogoMethod* ffLogoBuiltinGetAll()
|
||||
static GetLogoMethod logoMethods[] = {
|
||||
ffLogoBuiltinGetUnknown,
|
||||
getLogoNone,
|
||||
getLogoAlpine,
|
||||
getLogoAlpineSmall,
|
||||
getLogoAndroid,
|
||||
getLogoAndroidSmall,
|
||||
getLogoArch,
|
||||
@@ -1459,7 +1599,9 @@ GetLogoMethod* ffLogoBuiltinGetAll()
|
||||
getLogoGentoo,
|
||||
getLogoGentooSmall,
|
||||
getLogoKDENeon,
|
||||
getLogoKISSLinux,
|
||||
getLogoKubuntu,
|
||||
getLogoLangitKetujuh,
|
||||
getLogoLinux,
|
||||
getLogoManjaro,
|
||||
getLogoManjaroSmall,
|
||||
@@ -1480,6 +1622,7 @@ GetLogoMethod* ffLogoBuiltinGetAll()
|
||||
getLogoRedHatEnterpriseLinux,
|
||||
getLogoRedstarOS,
|
||||
getLogoRockyLinux,
|
||||
getLogoRosaLinux,
|
||||
getLogoUbuntu,
|
||||
getLogoUbuntuSmall,
|
||||
getLogoVoid,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifdef FF_HAVE_IMAGEMAGICK6
|
||||
|
||||
#include "image.h"
|
||||
#include "common/library.h"
|
||||
|
||||
#include <magick/MagickCore.h>
|
||||
|
||||
static FF_LIBRARY_SYMBOL(ResizeImage);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifdef FF_HAVE_IMAGEMAGICK7
|
||||
|
||||
#include "image.h"
|
||||
#include "common/library.h"
|
||||
|
||||
#include <MagickCore/MagickCore.h>
|
||||
|
||||
static FF_LIBRARY_SYMBOL(ResizeImage);
|
||||
|
||||
+21
-18
@@ -1,4 +1,6 @@
|
||||
#include "image.h"
|
||||
#include "common/io.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#if defined(FF_HAVE_IMAGEMAGICK7) || defined(FF_HAVE_IMAGEMAGICK6)
|
||||
|
||||
@@ -17,6 +19,8 @@
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef FF_HAVE_ZLIB
|
||||
#include "common/library.h"
|
||||
#include <stdlib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
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;
|
||||
ffStrbufAppendS(&requestData->cacheDir, cacheFileName);
|
||||
ffWriteFileContent(requestData->cacheDir.chars, value);
|
||||
ffWriteFileBuffer(requestData->cacheDir.chars, value);
|
||||
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)
|
||||
{
|
||||
//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;
|
||||
if(requestData->type == FF_LOGO_TYPE_KITTY)
|
||||
@@ -116,16 +120,16 @@ static void printImagePixels(FFinstance* instance, FFLogoRequestData* requestDat
|
||||
//Write cache files
|
||||
writeCacheStrbuf(requestData, result, cacheFileName);
|
||||
|
||||
if(instance->config.logoWidth == 0)
|
||||
if(instance->config.logo.width == 0)
|
||||
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);
|
||||
|
||||
//Write result to stdout
|
||||
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
|
||||
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
|
||||
fflush(stdout);
|
||||
ffWriteFDContent(STDOUT_FILENO, result);
|
||||
ffWriteFDBuffer(STDOUT_FILENO, result);
|
||||
|
||||
//Go to upper left corner
|
||||
fputs("\033[9999999D", stdout);
|
||||
@@ -294,7 +298,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData*
|
||||
}
|
||||
|
||||
//+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);
|
||||
ffDestroyImageInfo(imageInfoIn);
|
||||
@@ -373,7 +377,7 @@ static void readCachedStrbuf(FFLogoRequestData* requestData, FFstrbuf* result, c
|
||||
{
|
||||
uint32_t cacheDirLength = requestData->cacheDir.length;
|
||||
ffStrbufAppendS(&requestData->cacheDir, cacheFileName);
|
||||
ffAppendFileContent(requestData->cacheDir.chars, result);
|
||||
ffAppendFileBuffer(requestData->cacheDir.chars, result);
|
||||
ffStrbufSubstrBefore(&requestData->cacheDir, cacheDirLength);
|
||||
}
|
||||
|
||||
@@ -419,7 +423,7 @@ static bool printCachedChars(FFinstance* instance, FFLogoRequestData* requestDat
|
||||
|
||||
static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestData)
|
||||
{
|
||||
requestData->logoCharacterWidth = instance->config.logoWidth;
|
||||
requestData->logoCharacterWidth = instance->config.logo.width;
|
||||
if(requestData->logoCharacterWidth == 0)
|
||||
{
|
||||
requestData->logoCharacterWidth = readCachedUint32(requestData, FF_CACHE_FILE_WIDTH);
|
||||
@@ -427,7 +431,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
|
||||
return false;
|
||||
}
|
||||
|
||||
requestData->logoCharacterHeight = instance->config.logoHeight;
|
||||
requestData->logoCharacterHeight = instance->config.logo.height;
|
||||
if(requestData->logoCharacterHeight == 0)
|
||||
{
|
||||
requestData->logoCharacterHeight = readCachedUint32(requestData, FF_CACHE_FILE_HEIGHT);
|
||||
@@ -448,7 +452,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
|
||||
if(fd == -1)
|
||||
return false;
|
||||
|
||||
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
|
||||
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
|
||||
fflush(stdout);
|
||||
|
||||
char buffer[32768];
|
||||
@@ -458,7 +462,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
|
||||
|
||||
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;
|
||||
|
||||
//Go to upper left corner
|
||||
@@ -513,28 +517,27 @@ bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type)
|
||||
requestData.characterPixelHeight = 1;
|
||||
|
||||
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)
|
||||
)
|
||||
return false;
|
||||
|
||||
requestData.logoPixelWidth = simpleCeil((double) instance->config.logoWidth * requestData.characterPixelWidth);
|
||||
requestData.logoPixelHeight = simpleCeil((double) instance->config.logoHeight * requestData.characterPixelHeight);
|
||||
requestData.logoPixelWidth = simpleCeil((double) instance->config.logo.width * requestData.characterPixelWidth);
|
||||
requestData.logoPixelHeight = simpleCeil((double) instance->config.logo.height * requestData.characterPixelHeight);
|
||||
|
||||
ffStrbufInitA(&requestData.cacheDir, PATH_MAX * 2);
|
||||
ffStrbufAppend(&requestData.cacheDir, &instance->state.cacheDir);
|
||||
ffStrbufAppendS(&requestData.cacheDir, "images");
|
||||
|
||||
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
|
||||
ffStrbufDestroy(&requestData.cacheDir);
|
||||
return false;
|
||||
}
|
||||
ffStrbufRecalculateLength(&requestData.cacheDir);
|
||||
if(!ffStrbufEndsWithC(&requestData.cacheDir, '/'))
|
||||
ffStrbufAppendC(&requestData.cacheDir, '/');
|
||||
ffStrbufEnsureEndsWithC(&requestData.cacheDir, '/');
|
||||
|
||||
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelWidth);
|
||||
ffStrbufAppendC(&requestData.cacheDir, '*');
|
||||
|
||||
+26
-22
@@ -1,4 +1,8 @@
|
||||
#include "logo.h"
|
||||
#include "common/io.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/os.h"
|
||||
#include "detection/terminalshell.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
@@ -8,18 +12,18 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
|
||||
uint32_t currentlineLength = 0;
|
||||
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
||||
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
|
||||
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
|
||||
|
||||
//Use logoColor[0] as the default color
|
||||
if(doColorReplacement)
|
||||
ffPrintColor(&instance->config.logoColors[0]);
|
||||
ffPrintColor(&instance->config.logo.colors[0]);
|
||||
|
||||
while(*data != '\0')
|
||||
{
|
||||
//We are at the end of a line. Print paddings and update max line length
|
||||
if(*data == '\n' || (*data == '\r' && *(data + 1) == '\n'))
|
||||
{
|
||||
ffPrintCharTimes(' ', instance->config.logoPaddingRight);
|
||||
ffPrintCharTimes(' ', instance->config.logo.paddingRight);
|
||||
|
||||
//We have \r\n, skip the \r
|
||||
if(*data == '\r')
|
||||
@@ -28,7 +32,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
|
||||
putchar('\n');
|
||||
++data;
|
||||
|
||||
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
|
||||
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
|
||||
|
||||
if(currentlineLength > instance->state.logoWidth)
|
||||
instance->state.logoWidth = currentlineLength;
|
||||
@@ -96,7 +100,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintColor(&instance->config.logoColors[index]);
|
||||
ffPrintColor(&instance->config.logo.colors[index]);
|
||||
++data;
|
||||
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);
|
||||
|
||||
//Happens if the last line is the longest
|
||||
if(currentlineLength > instance->state.logoWidth)
|
||||
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
|
||||
fputs("\033[9999999D", stdout);
|
||||
@@ -222,8 +226,8 @@ static void logoPrintStruct(FFinstance* instance, const FFlogo* logo)
|
||||
const char** colors = logo->builtinColors;
|
||||
for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++)
|
||||
{
|
||||
if(instance->config.logoColors[i].length == 0)
|
||||
ffStrbufAppendS(&instance->config.logoColors[i], *colors);
|
||||
if(instance->config.logo.colors[i].length == 0)
|
||||
ffStrbufAppendS(&instance->config.logo.colors[i], *colors);
|
||||
}
|
||||
|
||||
ffLogoPrintChars(instance, logo->data, true);
|
||||
@@ -249,7 +253,7 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement)
|
||||
FFstrbuf content;
|
||||
ffStrbufInitA(&content, 2047);
|
||||
|
||||
if(!ffAppendFileContent(instance->config.logoSource.chars, &content))
|
||||
if(!ffAppendFileBuffer(instance->config.logo.source.chars, &content))
|
||||
{
|
||||
ffStrbufDestroy(&content);
|
||||
return false;
|
||||
@@ -261,9 +265,9 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement)
|
||||
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;
|
||||
|
||||
logoApplyMainColorDetected(instance);
|
||||
@@ -274,14 +278,14 @@ static void logoPrintKnownType(FFinstance* instance)
|
||||
{
|
||||
bool successfull;
|
||||
|
||||
if(instance->config.logoType == FF_LOGO_TYPE_BUILTIN)
|
||||
successfull = logoPrintBuiltinIfExists(instance, instance->config.logoSource.chars);
|
||||
else if(instance->config.logoType == FF_LOGO_TYPE_FILE)
|
||||
if(instance->config.logo.type == FF_LOGO_TYPE_BUILTIN)
|
||||
successfull = logoPrintBuiltinIfExists(instance, instance->config.logo.source.chars);
|
||||
else if(instance->config.logo.type == FF_LOGO_TYPE_FILE)
|
||||
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);
|
||||
else //image
|
||||
successfull = logoPrintImageIfExists(instance, instance->config.logoType);
|
||||
successfull = logoPrintImageIfExists(instance, instance->config.logo.type);
|
||||
|
||||
if(!successfull)
|
||||
logoPrintDetected(instance);
|
||||
@@ -300,21 +304,21 @@ void ffLogoPrint(FFinstance* instance)
|
||||
}
|
||||
|
||||
//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);
|
||||
return;
|
||||
}
|
||||
|
||||
//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);
|
||||
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;
|
||||
|
||||
const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance);
|
||||
@@ -347,7 +351,7 @@ void ffLogoPrintLine(FFinstance* instance)
|
||||
|
||||
void ffLogoPrintRemaining(FFinstance* instance)
|
||||
{
|
||||
while(instance->state.keysHeight < instance->state.logoHeight)
|
||||
while(instance->state.keysHeight <= instance->state.logoHeight)
|
||||
{
|
||||
ffLogoPrintLine(instance);
|
||||
putchar('\n');
|
||||
@@ -369,7 +373,7 @@ void ffLogoBuiltinPrint(FFinstance* instance)
|
||||
instance->state.logoHeight = 0;
|
||||
instance->state.keysHeight = 0;
|
||||
for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++)
|
||||
ffStrbufClear(&instance->config.logoColors[i]);
|
||||
ffStrbufClear(&instance->config.logo.colors[i]);
|
||||
|
||||
puts("\n");
|
||||
++methods;
|
||||
|
||||
+15
-15
@@ -1,6 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/io.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#define FF_BATTERY_MODULE_NAME "Battery"
|
||||
@@ -24,7 +25,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
|
||||
|
||||
//type must exist and be "Battery"
|
||||
ffStrbufAppendS(dir, "/type");
|
||||
ffGetFileContent(dir->chars, &testBatteryBuffer);
|
||||
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
|
||||
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"
|
||||
ffStrbufAppendS(dir, "/scope");
|
||||
ffGetFileContent(dir->chars, &testBatteryBuffer);
|
||||
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Device") == 0)
|
||||
@@ -50,7 +51,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
|
||||
//capacity must exist and be not empty
|
||||
ffStrbufInit(&result->capacity);
|
||||
ffStrbufAppendS(dir, "/capacity");
|
||||
ffGetFileContent(dir->chars, &result->capacity);
|
||||
ffReadFileBuffer(dir->chars, &result->capacity);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
|
||||
if(result->capacity.length == 0)
|
||||
@@ -64,30 +65,30 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
|
||||
|
||||
ffStrbufInit(&result->manufacturer);
|
||||
ffStrbufAppendS(dir, "/manufacturer");
|
||||
ffGetFileContent(dir->chars, &result->manufacturer);
|
||||
ffReadFileBuffer(dir->chars, &result->manufacturer);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
|
||||
ffStrbufInit(&result->modelName);
|
||||
ffStrbufAppendS(dir, "/model_name");
|
||||
ffGetFileContent(dir->chars, &result->modelName);
|
||||
ffReadFileBuffer(dir->chars, &result->modelName);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
|
||||
ffStrbufInit(&result->technology);
|
||||
ffStrbufAppendS(dir, "/technology");
|
||||
ffGetFileContent(dir->chars, &result->technology);
|
||||
ffReadFileBuffer(dir->chars, &result->technology);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
|
||||
ffStrbufInit(&result->status);
|
||||
ffStrbufAppendS(dir, "/status");
|
||||
ffGetFileContent(dir->chars, &result->status);
|
||||
ffReadFileBuffer(dir->chars, &result->status);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
}
|
||||
|
||||
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 =
|
||||
result->status.length > 0 &&
|
||||
@@ -114,7 +115,7 @@ static void printBattery(FFinstance* instance, const BatteryResult* result, uint
|
||||
}
|
||||
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->modelName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology},
|
||||
@@ -131,8 +132,7 @@ void ffPrintBattery(FFinstance* instance)
|
||||
if(instance->config.batteryDir.length > 0)
|
||||
{
|
||||
ffStrbufAppend(&baseDir, &instance->config.batteryDir);
|
||||
if(!ffStrbufEndsWithC(&baseDir, '/'))
|
||||
ffStrbufAppendC(&baseDir, '/');
|
||||
ffStrbufEndsWithC(&baseDir, '/');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -144,7 +144,7 @@ void ffPrintBattery(FFinstance* instance)
|
||||
DIR* dirp = opendir(baseDir.chars);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ void ffPrintBattery(FFinstance* instance)
|
||||
}
|
||||
|
||||
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);
|
||||
ffStrbufDestroy(&baseDir);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
void ffPrintBreak(FFinstance* instance)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
void ffPrintColors(FFinstance* instance)
|
||||
{
|
||||
|
||||
+47
-22
@@ -1,48 +1,63 @@
|
||||
#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_NUM_FORMAT_ARGS 14
|
||||
|
||||
static double parseHz(FFstrbuf* content)
|
||||
{
|
||||
if(content->length == 0)
|
||||
return 0;
|
||||
|
||||
double herz;
|
||||
if(sscanf(content->chars, "%lf", &herz) != 1)
|
||||
return 0;
|
||||
|
||||
return herz;
|
||||
}
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 15
|
||||
|
||||
static double getGhz(const char* policyFile, const char* cpuFile)
|
||||
{
|
||||
FFstrbuf content;
|
||||
ffStrbufInit(&content);
|
||||
|
||||
ffGetFileContent(policyFile, &content);
|
||||
ffReadFileBuffer(policyFile, &content);
|
||||
if(content.length == 0)
|
||||
ffGetFileContent(cpuFile, &content);
|
||||
ffReadFileBuffer(cpuFile, &content);
|
||||
|
||||
double herz = parseHz(&content);
|
||||
double herz = ffStrbufToDouble(&content);
|
||||
|
||||
ffStrbufDestroy(&content);
|
||||
|
||||
//ffStrbufToDouble failed
|
||||
if(herz != herz)
|
||||
return 0;
|
||||
|
||||
herz /= 1000.0; //to MHz
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
FILE* cpuinfo = fopen("/proc/cpuinfo", "r");
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -81,7 +96,12 @@ void ffPrintCPU(FFinstance* instance)
|
||||
|
||||
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);
|
||||
|
||||
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(&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;
|
||||
}
|
||||
|
||||
@@ -143,6 +163,10 @@ void ffPrintCPU(FFinstance* instance)
|
||||
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
|
||||
|
||||
double cpuTemp;
|
||||
if(instance->config.cpu.outputFormat.length > 0)
|
||||
cpuTemp = detectCPUTemp(instance);
|
||||
|
||||
FFstrbuf cpu;
|
||||
ffStrbufInitA(&cpu, 128);
|
||||
|
||||
@@ -164,7 +188,7 @@ void ffPrintCPU(FFinstance* instance)
|
||||
if(ghz > 0)
|
||||
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, &namePretty},
|
||||
{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, &physicalCores},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &numProcs},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpuTemp},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &biosLimit},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMaxFreq},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &scalingMinFreq},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define FF_CPU_USAGE_MODULE_NAME "CPU Usage"
|
||||
@@ -12,7 +12,7 @@ void ffPrintCPUUsage(FFinstance* instance)
|
||||
FILE* procStat = fopen("/proc/stat", "r");
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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);
|
||||
}
|
||||
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}
|
||||
});
|
||||
}
|
||||
|
||||
+22
-8
@@ -1,4 +1,12 @@
|
||||
#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_NUM_FORMAT_ARGS 2
|
||||
@@ -12,9 +20,9 @@ static void printCursor(FFinstance* instance, FFstrbuf* cursorTheme, const FFstr
|
||||
if(cursorTheme->length == 0)
|
||||
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);
|
||||
|
||||
if(cursorSize != NULL && cursorSize->length > 0)
|
||||
@@ -28,7 +36,7 @@ static void printCursor(FFinstance* instance, FFstrbuf* cursorTheme, const FFstr
|
||||
}
|
||||
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, cursorSize}
|
||||
});
|
||||
@@ -47,7 +55,7 @@ static void printCursorGTK(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -69,7 +77,7 @@ static void printCursorXFCE(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -105,7 +113,7 @@ static void printCursorFromConfigFile(FFinstance* instance, const char* relative
|
||||
}
|
||||
|
||||
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
|
||||
printCursor(instance, &cursorTheme, &cursorSize);
|
||||
|
||||
@@ -185,15 +193,21 @@ static bool printCursorFromEnv(FFinstance* instance)
|
||||
void ffPrintCursor(FFinstance* instance)
|
||||
{
|
||||
#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;
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
void ffPrintCustom(FFinstance* instance, const char* key, const char* value)
|
||||
{
|
||||
|
||||
+5
-3
@@ -1,17 +1,19 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/datetime.h"
|
||||
|
||||
#define FF_DATE_MODULE_NAME "Date"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
printf("%u-%s-%u\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth);
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/datetime.h"
|
||||
|
||||
#define FF_DATETIME_MODULE_NAME "Date & Time"
|
||||
#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);
|
||||
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_UINT8, &result->yearShort},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result->month},
|
||||
@@ -32,14 +34,14 @@ void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const F
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
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 <string.h>
|
||||
#include "common/printing.h"
|
||||
#include "detection/displayserver.h"
|
||||
|
||||
#define FF_DE_MODULE_NAME "DE"
|
||||
#define FF_DE_NUM_FORMAT_ARGS 3
|
||||
@@ -8,7 +8,7 @@
|
||||
void ffPrintDesktopEnvironment(FFinstance* instance)
|
||||
{
|
||||
#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;
|
||||
#endif
|
||||
|
||||
@@ -16,13 +16,13 @@ void ffPrintDesktopEnvironment(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -36,7 +36,7 @@ void ffPrintDesktopEnvironment(FFinstance* instance)
|
||||
}
|
||||
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->dePrettyName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->deVersion}
|
||||
|
||||
+31
-17
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
@@ -7,7 +8,7 @@
|
||||
|
||||
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)
|
||||
ffStrbufAppendF(key, FF_DISK_MODULE_NAME" (%s)", folderPath);
|
||||
@@ -16,7 +17,7 @@ static void getKey(FFinstance* instance, FFstrbuf* key, const char* folderPath,
|
||||
}
|
||||
else
|
||||
{
|
||||
ffParseFormatString(key, &instance->config.diskKey, NULL, 1, (FFformatarg[]){
|
||||
ffParseFormatString(key, &instance->config.disk.key, 1, (FFformatarg[]){
|
||||
{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)
|
||||
{
|
||||
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);
|
||||
uint32_t available = (uint32_t) ((fs->f_bfree * fs->f_frsize) / GB);
|
||||
uint32_t used = total - available;
|
||||
uint8_t percentage = (uint8_t) ((used / (double) total) * 100.0);
|
||||
double total = ((double) (fs->f_blocks * fs->f_frsize)) / GB;
|
||||
double available = ((double) (fs->f_bfree * fs->f_frsize)) / GB;
|
||||
double used = total - available;
|
||||
uint8_t percentage = (uint8_t) ((used / total) * 100.0);
|
||||
|
||||
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);
|
||||
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
|
||||
{
|
||||
ffPrintFormatString(instance, key->chars, 0, NULL, &instance->config.diskFormat, NULL, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &used},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &total},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &files},
|
||||
ffPrintFormatString(instance, key->chars, 0, NULL, &instance->config.disk.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &used},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &total},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &files},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &percentage}
|
||||
});
|
||||
}
|
||||
@@ -64,9 +78,9 @@ static void printFolder(FFinstance* instance, const char* folderPath)
|
||||
|
||||
struct statvfs 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);
|
||||
return;
|
||||
}
|
||||
@@ -89,7 +103,7 @@ void ffPrintDisk(FFinstance* instance)
|
||||
{
|
||||
FF_STRBUF_CREATE(key);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@@ -108,7 +122,7 @@ void ffPrintDisk(FFinstance* instance)
|
||||
{
|
||||
FF_STRBUF_CREATE(key);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
+14
-8
@@ -1,4 +1,10 @@
|
||||
#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_NUM_FORMAT_ARGS 21
|
||||
@@ -6,7 +12,7 @@
|
||||
void ffPrintFont(FFinstance* instance)
|
||||
{
|
||||
#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;
|
||||
#endif
|
||||
|
||||
@@ -14,18 +20,18 @@ void ffPrintFont(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
const FFstrbuf* plasmaRaw = &ffDetectPlasma(instance)->font;
|
||||
const FFstrbuf* plasmaRaw = &ffDetectQt(instance)->font;
|
||||
const FFstrbuf* gtk2Raw = &ffDetectGTK2(instance)->font;
|
||||
const FFstrbuf* gtk3Raw = &ffDetectGTK3(instance)->font;
|
||||
const FFstrbuf* gtk4Raw = &ffDetectGTK4(instance)->font;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -45,13 +51,13 @@ void ffPrintFont(FFinstance* instance)
|
||||
ffStrbufInitA(>k, 64);
|
||||
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)
|
||||
{
|
||||
ffStrbufWriteTo(&plasma.pretty, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
fputs(" [QT]", stdout);
|
||||
|
||||
if(gtk.length > 0)
|
||||
fputs(", ", stdout);
|
||||
@@ -60,7 +66,7 @@ void ffPrintFont(FFinstance* instance)
|
||||
}
|
||||
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, &plasma.name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma.size},
|
||||
|
||||
+52
-9
@@ -1,9 +1,14 @@
|
||||
#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_NUM_FORMAT_ARGS 5
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 6
|
||||
|
||||
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);
|
||||
|
||||
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_STRING, vendorPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &namePretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->driver},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->temperature}
|
||||
});
|
||||
|
||||
ffStrbufDestroy(&result->vendor);
|
||||
@@ -60,8 +66,10 @@ static void printGPUList(FFinstance* instance, const FFlist* list)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_LIBPCI
|
||||
#include <pci/pci.h>
|
||||
#include "common/library.h"
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
//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*))
|
||||
@@ -89,6 +97,26 @@ static void pciGetDriver(struct pci_dev* dev, FFstrbuf* driver, char*(*ffpci_get
|
||||
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)
|
||||
{
|
||||
FF_LIBRARY_LOAD(pci, instance->config.libPCI, false, "libpci.so", 4)
|
||||
@@ -121,16 +149,22 @@ static bool pciPrintGPUs(FFinstance* instance)
|
||||
FFGPUResult* result = ffListAdd(&results);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
result->temperature = pciGetTemperatur(instance, dev->device_class);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -163,9 +197,18 @@ static bool vulkanPrintGPUs(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;
|
||||
|
||||
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
|
||||
if(pciPrintGPUs(instance))
|
||||
return;
|
||||
@@ -174,5 +217,5 @@ void ffPrintGPU(FFinstance* instance)
|
||||
if(vulkanPrintGPUs(instance))
|
||||
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 "common/printing.h"
|
||||
#include "common/caching.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ffGetFileContent(devicesPath, buffer);
|
||||
ffReadFileBuffer(devicesPath, buffer);
|
||||
|
||||
if(buffer->length == 0)
|
||||
ffGetFileContent(classPath, buffer);
|
||||
ffReadFileBuffer(classPath, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
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;
|
||||
|
||||
FFstrbuf family;
|
||||
ffStrbufInit(&family);
|
||||
FFstrbuf product_family;
|
||||
ffStrbufInit(&product_family);
|
||||
#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
|
||||
ffSettingsGetAndroidProperty("ro.product.device", &family);
|
||||
ffSettingsGetAndroidProperty("ro.product.device", &product_family);
|
||||
#endif
|
||||
bool familySet = hostValueSet(&family);
|
||||
|
||||
FFstrbuf name;
|
||||
ffStrbufInit(&name);
|
||||
FFstrbuf product_name;
|
||||
ffStrbufInit(&product_name);
|
||||
#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)
|
||||
ffGetFileContent("/sys/firmware/devicetree/base/model", &name);
|
||||
if(product_name.length == 0)
|
||||
ffReadFileBuffer("/sys/firmware/devicetree/base/model", &product_name);
|
||||
|
||||
if(name.length == 0)
|
||||
ffGetFileContent("/tmp/sysinfo/model", &name);
|
||||
if(product_name.length == 0)
|
||||
ffReadFileBuffer("/tmp/sysinfo/model", &product_name);
|
||||
|
||||
if(ffStrbufStartsWithS(&name, "Standard PC"))
|
||||
if(ffStrbufStartsWithS(&product_name, "Standard PC"))
|
||||
{
|
||||
FFstrbuf copy;
|
||||
ffStrbufInitCopy(©, &name);
|
||||
ffStrbufSetS(&name, "KVM/QEMU ");
|
||||
ffStrbufAppend(&name, ©);
|
||||
ffStrbufInitCopy(©, &product_name);
|
||||
ffStrbufSetS(&product_name, "KVM/QEMU ");
|
||||
ffStrbufAppend(&product_name, ©);
|
||||
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
|
||||
ffSettingsGetAndroidProperty("ro.product.brand", &name);
|
||||
if(name.length > 0){
|
||||
name.chars[0] = (char) toupper(name.chars[0]);
|
||||
ffStrbufAppendC(&name, ' ');
|
||||
ffSettingsGetAndroidProperty("ro.product.brand", &product_name);
|
||||
if(product_name.length > 0){
|
||||
product_name.chars[0] = (char) toupper(product_name.chars[0]);
|
||||
ffStrbufAppendC(&product_name, ' ');
|
||||
}
|
||||
|
||||
if(!ffSettingsGetAndroidProperty("ro.product.model", &name))
|
||||
ffSettingsGetAndroidProperty("ro.product.name", &name);
|
||||
if(!ffSettingsGetAndroidProperty("ro.product.model", &product_name))
|
||||
ffSettingsGetAndroidProperty("ro.product.name", &product_name);
|
||||
|
||||
ffStrbufTrimRight(&name, ' ');
|
||||
ffStrbufTrimRight(&product_name, ' ');
|
||||
#endif
|
||||
bool nameSet = hostValueSet(&name);
|
||||
|
||||
FFstrbuf version;
|
||||
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)
|
||||
if(product_family.length == 0 && product_name.length == 0)
|
||||
{
|
||||
ffStrbufDestroy(&family);
|
||||
ffStrbufDestroy(&name);
|
||||
ffStrbufDestroy(&version);
|
||||
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.");
|
||||
ffStrbufDestroy(&product_family);
|
||||
ffStrbufDestroy(&product_name);
|
||||
ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host, "neither product_family nor product_name is set by O.E.M.");
|
||||
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;
|
||||
ffStrbufInit(&host);
|
||||
|
||||
if(nameSet)
|
||||
ffStrbufAppend(&host, &name);
|
||||
if(product_name.length > 0)
|
||||
ffStrbufAppend(&host, &product_name);
|
||||
else
|
||||
ffStrbufAppend(&host, &family);
|
||||
ffStrbufAppend(&host, &product_family);
|
||||
|
||||
if(versionSet)
|
||||
if(product_version.length > 0)
|
||||
{
|
||||
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[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &family},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &version}
|
||||
ffPrintAndWriteToCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, &host, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &product_family},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &product_name},
|
||||
{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(&name);
|
||||
ffStrbufDestroy(&version);
|
||||
ffStrbufDestroy(&product_family);
|
||||
ffStrbufDestroy(&product_name);
|
||||
|
||||
//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 "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_NUM_FORMAT_ARGS 5
|
||||
@@ -6,7 +11,7 @@
|
||||
void ffPrintIcons(FFinstance* instance)
|
||||
{
|
||||
#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;
|
||||
#endif
|
||||
|
||||
@@ -14,32 +19,32 @@ void ffPrintIcons(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
const FFstrbuf* plasma = &ffDetectPlasma(instance)->icons;
|
||||
const FFstrbuf* plasma = &ffDetectQt(instance)->icons;
|
||||
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons;
|
||||
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons;
|
||||
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
FF_STRBUF_CREATE(gtkPretty);
|
||||
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)
|
||||
{
|
||||
ffStrbufWriteTo(plasma, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
fputs(" [QT]", stdout);
|
||||
|
||||
if(gtkPretty.length > 0)
|
||||
fputs(", ", stdout);
|
||||
@@ -49,7 +54,7 @@ void ffPrintIcons(FFinstance* instance)
|
||||
}
|
||||
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, gtk2},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#define FF_KERNEL_MODULE_NAME "Kernel"
|
||||
#define FF_KERNEL_NUM_FORMAT_ARGS 3
|
||||
|
||||
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);
|
||||
}
|
||||
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.release},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.version}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
#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_NUM_FORMAT_ARGS 1
|
||||
@@ -22,7 +27,7 @@ static void getLocaleFromEnv(FFstrbuf* locale)
|
||||
|
||||
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;
|
||||
|
||||
FFstrbuf locale;
|
||||
@@ -45,11 +50,11 @@ void ffPrintLocale(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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}
|
||||
});
|
||||
|
||||
|
||||
+18
-11
@@ -1,31 +1,38 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#define FF_LOCALIP_MODULE_NAME "Local IP"
|
||||
#define FF_LOCALIP_NUM_FORMAT_ARGS 1
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
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);
|
||||
} else {
|
||||
ffParseFormatString(&key, &instance->config.localIpKey, NULL, 1, (FFformatarg[]){
|
||||
}
|
||||
else
|
||||
{
|
||||
ffParseFormatString(&key, &instance->config.localIP.key, 1, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRING, ifaName}
|
||||
});
|
||||
}
|
||||
|
||||
if (instance->config.localIpFormat.length == 0) {
|
||||
ffPrintLogoAndKey(instance, FF_LOCALIP_MODULE_NAME, 0, &key);
|
||||
if (instance->config.localIP.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, key.chars, 0, NULL);
|
||||
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}
|
||||
});
|
||||
}
|
||||
@@ -38,7 +45,7 @@ void ffPrintLocalIp(FFinstance* instance)
|
||||
struct ifaddrs* ifAddrStruct = NULL;
|
||||
int ret = getifaddrs(&ifAddrStruct);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FF_MEMORY_MODULE_NAME "Memory"
|
||||
#define FF_MEMORY_NUM_FORMAT_ARGS 3
|
||||
@@ -8,7 +11,7 @@ void ffPrintMemory(FFinstance* instance)
|
||||
{
|
||||
FILE* meminfo = fopen("/proc/meminfo", "r");
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -42,18 +45,18 @@ void ffPrintMemory(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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, &total_mem},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &percentage}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#define FF_OPENCL_MODULE_NAME "OpenCL"
|
||||
#define FF_OPENCL_NUM_FORMAT_ARGS 3
|
||||
|
||||
#ifdef FF_HAVE_OPENCL
|
||||
#include "common/library.h"
|
||||
#include "common/parsing.h"
|
||||
|
||||
#define CL_TARGET_OPENCL_VERSION 100
|
||||
#include <CL/cl.h>
|
||||
|
||||
@@ -44,14 +48,14 @@ static const char* openCLHandelData(FFinstance* instance, OpenCLData* data)
|
||||
char vendor[32];
|
||||
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);
|
||||
}
|
||||
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, device},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, vendor}
|
||||
@@ -87,5 +91,5 @@ void ffPrintOpenCL(FFinstance* instance)
|
||||
#endif
|
||||
|
||||
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 "common/printing.h"
|
||||
#include "common/parsing.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -7,6 +9,7 @@
|
||||
|
||||
#if defined(FF_HAVE_EGL) || defined(FF_HAVE_GLX) || defined(FF_HAVE_OSMESA)
|
||||
#define FF_HAVE_GL 1
|
||||
#include "common/library.h"
|
||||
#include <GL/gl.h>
|
||||
|
||||
#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* 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);
|
||||
}
|
||||
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, renderer},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, vendor},
|
||||
@@ -388,5 +391,5 @@ void ffPrintOpenGL(FFinstance* instance)
|
||||
#endif
|
||||
|
||||
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 "common/printing.h"
|
||||
#include "detection/os.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define FF_OS_MODULE_NAME "OS"
|
||||
#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
|
||||
|
||||
if(result->name.length > 0)
|
||||
ffStrbufAppend(&os, &result->name);
|
||||
else if(result->prettyName.length > 0)
|
||||
ffStrbufAppend(&os, &result->name);
|
||||
else if(result->id.length > 0)
|
||||
ffStrbufAppend(&os, &result->id);
|
||||
else if(result->systemName.length > 0)
|
||||
ffStrbufAppend(&os, &result->systemName);
|
||||
if(os->name.length > 0)
|
||||
ffStrbufAppend(result, &os->name);
|
||||
else if(os->prettyName.length > 0)
|
||||
ffStrbufAppend(result, &os->name);
|
||||
else if(os->id.length > 0)
|
||||
ffStrbufAppend(result, &os->id);
|
||||
else if(os->systemName.length > 0)
|
||||
ffStrbufAppend(result, &os->systemName);
|
||||
else
|
||||
ffStrbufAppendS(&os, "Linux");
|
||||
ffStrbufAppendS(result, "Linux");
|
||||
|
||||
//Append version if it is missing
|
||||
|
||||
if(result->versionID.length > 0 && ffStrbufFirstIndex(&os, &result->versionID) == os.length)
|
||||
if(os->versionID.length > 0 && ffStrbufFirstIndex(result, &os->versionID) == result->length)
|
||||
{
|
||||
ffStrbufAppendC(&os, ' ');
|
||||
ffStrbufAppend(&os, &result->versionID);
|
||||
ffStrbufAppendC(result, ' ');
|
||||
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, ' ');
|
||||
ffStrbufAppend(&os, &result->version);
|
||||
ffStrbufAppendC(result, ' ');
|
||||
ffStrbufAppend(result, &os->version);
|
||||
}
|
||||
|
||||
//Append variant if it is missing
|
||||
|
||||
if(result->variant.length > 0 && ffStrbufFirstIndex(&os, &result->variant) == os.length)
|
||||
if(os->variant.length > 0 && ffStrbufFirstIndex(result, &os->variant) == result->length)
|
||||
{
|
||||
ffStrbufAppendS(&os, " (");
|
||||
ffStrbufAppend(&os, &result->variant);
|
||||
ffStrbufAppendC(&os, ')');
|
||||
ffStrbufAppendS(result, " (");
|
||||
ffStrbufAppend(result, &os->variant);
|
||||
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, " (");
|
||||
ffStrbufAppend(&os, &result->variantID);
|
||||
ffStrbufAppendC(&os, ')');
|
||||
ffStrbufAppendS(result, " (");
|
||||
ffStrbufAppend(result, &os->variantID);
|
||||
ffStrbufAppendC(result, ')');
|
||||
}
|
||||
|
||||
//Append architecture if it is missing
|
||||
|
||||
if(ffStrbufFirstIndex(&os, &result->architecture) == os.length)
|
||||
if(ffStrbufFirstIndex(result, &os->architecture) == result->length)
|
||||
{
|
||||
ffStrbufAppendS(&os, " [");
|
||||
ffStrbufAppend(&os, &result->architecture);
|
||||
ffStrbufAppendC(&os, ']');
|
||||
ffStrbufAppendC(result, ' ');
|
||||
ffStrbufAppend(result, &os->architecture);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
ffStrbufPutTo(&os, stdout);
|
||||
ffStrbufAppendS(result, " (");
|
||||
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
|
||||
{
|
||||
ffPrintFormatString(instance, FF_OS_MODULE_NAME, 0, &instance->config.osKey, &instance->config.osFormat, NULL, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->systemName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->id},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->idLike},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->variant},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->variantID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->versionID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->codename},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->buildID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->architecture}
|
||||
ffPrintFormat(instance, FF_OS_MODULE_NAME, 0, &instance->config.os, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->systemName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->prettyName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->id},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->idLike},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->variant},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->variantID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->versionID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->codename},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->buildID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->architecture}
|
||||
});
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&os);
|
||||
}
|
||||
|
||||
+73
-13
@@ -1,10 +1,18 @@
|
||||
#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 <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define FF_PACKAGES_MODULE_NAME "Packages"
|
||||
#define FF_PACKAGES_NUM_FORMAT_ARGS 11
|
||||
#define FF_PACKAGES_NUM_FORMAT_ARGS 12
|
||||
|
||||
typedef struct PackageCounts
|
||||
{
|
||||
@@ -13,6 +21,7 @@ typedef struct PackageCounts
|
||||
uint32_t rpm;
|
||||
uint32_t emerge;
|
||||
uint32_t xbps;
|
||||
uint32_t nixSystem;
|
||||
uint32_t nixDefault;
|
||||
uint32_t flatpak;
|
||||
uint32_t snap;
|
||||
@@ -111,10 +120,17 @@ static uint32_t getNixPackages(char* path)
|
||||
FFstrbuf output;
|
||||
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[]) {
|
||||
"nix-store",
|
||||
"-qR",
|
||||
path,
|
||||
"sh",
|
||||
"-c",
|
||||
command.chars,
|
||||
NULL
|
||||
});
|
||||
|
||||
@@ -128,6 +144,7 @@ static uint32_t getNixPackages(char* path)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_RPM
|
||||
#include "common/library.h"
|
||||
#include <rpm/rpmlib.h>
|
||||
#include <rpm/rpmts.h>
|
||||
#include <rpm/rpmdb.h>
|
||||
@@ -178,6 +195,30 @@ static uint32_t getRpmFromLibrpm(const FFinstance* instance)
|
||||
}
|
||||
#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)
|
||||
{
|
||||
uint32_t baseDirLength = baseDir->length;
|
||||
@@ -204,7 +245,7 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
|
||||
|
||||
//xps
|
||||
ffStrbufAppendS(baseDir, "/var/db/xbps");
|
||||
packageCounts->xbps += getNumElements(baseDir->chars, DT_REG);
|
||||
packageCounts->xbps += getXBPS(baseDir);
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
|
||||
//flatpak
|
||||
@@ -212,8 +253,13 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
|
||||
packageCounts->flatpak += getNumElements(baseDir->chars, DT_DIR);
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
|
||||
//nix system
|
||||
ffStrbufAppendS(baseDir, "/run/current-system");
|
||||
packageCounts->nixSystem += getNixPackages(baseDir->chars);
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
|
||||
//nix default
|
||||
ffStrbufAppendS(baseDir, "/var/nix/profiles/default");
|
||||
ffStrbufAppendS(baseDir, "/nix/var/nix/profiles/default");
|
||||
packageCounts->nixDefault += getNixPackages(baseDir->chars);
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
|
||||
@@ -233,15 +279,20 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
|
||||
|
||||
static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDir, PackageCounts* packageCounts)
|
||||
{
|
||||
uint32_t baseDirLength = baseDir->length;
|
||||
|
||||
ffStrbufAppendS(baseDir, "/bedrock/strata");
|
||||
|
||||
DIR* dir = opendir(baseDir->chars);
|
||||
if(dir == NULL)
|
||||
{
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
getPackageCounts(instance, baseDir, packageCounts);
|
||||
return;
|
||||
}
|
||||
|
||||
ffStrbufAppendC(baseDir, '/');
|
||||
|
||||
uint32_t baseDirLength = baseDir->length;
|
||||
baseDirLength = baseDir->length;
|
||||
|
||||
struct dirent* entry;
|
||||
while((entry = readdir(dir)) != NULL)
|
||||
@@ -286,16 +337,16 @@ void ffPrintPackages(FFinstance* instance)
|
||||
|
||||
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.flatpak + counts.snap;
|
||||
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;
|
||||
}
|
||||
|
||||
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) \
|
||||
if(counts.name > 0) \
|
||||
@@ -317,6 +368,14 @@ void ffPrintPackages(FFinstance* instance)
|
||||
FF_PRINT_PACKAGE(dpkg)
|
||||
FF_PRINT_PACKAGE(rpm)
|
||||
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)
|
||||
{
|
||||
@@ -344,7 +403,7 @@ void ffPrintPackages(FFinstance* instance)
|
||||
}
|
||||
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, &counts.pacman},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &counts.pacmanBranch},
|
||||
@@ -352,6 +411,7 @@ void ffPrintPackages(FFinstance* instance)
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.rpm},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.emerge},
|
||||
{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, &counts.nixDefault},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &counts.flatpak},
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/media.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -11,7 +13,7 @@ void ffPrintPlayer(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -50,14 +52,14 @@ void ffPrintPlayer(FFinstance* instance)
|
||||
if(playerPrettyIsCustom)
|
||||
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);
|
||||
}
|
||||
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, &media->player},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->busNameShort}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#define FF_PROCESSES_MODULE_NAME "Processes"
|
||||
#define FF_PROCESSES_NUM_FORMAT_ARGS 1
|
||||
|
||||
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);
|
||||
}
|
||||
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}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/networking.h"
|
||||
|
||||
#define FF_PUBLICIP_MODULE_NAME "Public IP"
|
||||
#define FF_PUBLICIP_NUM_FORMAT_ARGS 1
|
||||
@@ -12,18 +14,18 @@ void ffPrintPublicIp(FFinstance* instance)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/displayserver.h"
|
||||
|
||||
#define FF_RESOLUTION_MODULE_NAME "Resolution"
|
||||
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
|
||||
@@ -6,7 +8,7 @@
|
||||
void ffPrintResolution(FFinstance* instance)
|
||||
{
|
||||
#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;
|
||||
#endif
|
||||
|
||||
@@ -17,9 +19,9 @@ void ffPrintResolution(FFinstance* instance)
|
||||
FFResolutionResult* result = ffListGet(&dsResult->resolutions, i);
|
||||
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);
|
||||
|
||||
if(result->refreshRate > 0)
|
||||
@@ -29,7 +31,7 @@ void ffPrintResolution(FFinstance* instance)
|
||||
}
|
||||
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->height},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &result->refreshRate}
|
||||
@@ -38,5 +40,5 @@ void ffPrintResolution(FFinstance* instance)
|
||||
}
|
||||
|
||||
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