mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 18:06:11 +02:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c3e5222bcd | |||
| c0c76292cb | |||
| 49840a8f70 | |||
| 44257b7ede | |||
| d7e9094297 | |||
| 1863bde916 | |||
| 7c1b6c6a10 | |||
| 7e8b204644 | |||
| e8dc500f24 | |||
| bb11cff700 | |||
| 90690ba315 | |||
| 3811bb1be4 | |||
| 1f3d18cdbc | |||
| 3ae2047364 | |||
| 66ba5d0a5f | |||
| 983e5c680f | |||
| 745865d66a | |||
| 8bdca1b1a8 | |||
| 5172a13b15 | |||
| 3ba899261f | |||
| 5fa18a8a1c | |||
| 81e0af8999 | |||
| a14a73b259 | |||
| c8451cab52 | |||
| 965777323e | |||
| ad709c4153 | |||
| 0869bfaeed | |||
| dee208f3e3 | |||
| 7e1c426e34 | |||
| 0ae2d389da | |||
| 20b433f40a | |||
| 152f5d3fa6 | |||
| b030bd6751 | |||
| e0d5a9024a | |||
| f83a31e0a6 | |||
| 099e2b5f8f | |||
| 374997b599 | |||
| f938f5e03b | |||
| d7098e728d | |||
| 5302a82444 | |||
| 64a3573c49 | |||
| 3d48de8c98 | |||
| 4b33e1b691 | |||
| 6326405c26 | |||
| b25e8c2721 | |||
| 81318f45bb | |||
| 2f6cabb839 |
@@ -7,23 +7,7 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## Before requesting a new feature
|
||||
|
||||
* A lot of features are not enabled by default. Please try `fastfetch --list-modules` and `fastfetch -c all.jsonc` to see if it has been supported
|
||||
* Fastfetch supports `Command` module, which can be used to grab output from a custom shell script. Please check if it fits your needs
|
||||
|
||||
```jsonc
|
||||
// ~/.config/fastfetch/fastfetch.jsonc
|
||||
{
|
||||
"modules": [
|
||||
{
|
||||
"type": "command",
|
||||
"text": "/path/to/your/script",
|
||||
"key": "Feature Title"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
Be sure to read [FAQ](https://github.com/fastfetch-cli/fastfetch?tab=readme-ov-file#faq) before submitting a new issue.
|
||||
|
||||
## Wanted features:
|
||||
|
||||
|
||||
@@ -8,3 +8,4 @@ cscope.*
|
||||
tags
|
||||
fastfetch.kdev4
|
||||
*.user
|
||||
*.user.*
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
# 2.14.0
|
||||
|
||||
Features:
|
||||
* Support monochrome bar type (#960)
|
||||
* Support editor version detection on Windows (Editor, Windows)
|
||||
* Apply default color palettes in `--file` and `--data` (Logo)
|
||||
* Print all presets in `--list-presets` for better Windows support (Windows)
|
||||
* Support for guix package manager detection (Packages, Linux)
|
||||
* Support named variable placeholders in custom module formattion string (#796)
|
||||
* `--title-format '{user-name-colored}{at-symbol-colored}{host-name-colored}'` is equivalent to `--title-format '{6}{7}{8}'`
|
||||
* Support named color placeholders in custom module formattion string
|
||||
* `--<module>-format '{#red}'` is equivalent to `--<module>-format '{#31}'`
|
||||
* `'{#red}'` or `'{#31}'` is preferred over `\u001b[31m` because is more readable and `--pipe` aware (will be ignored in pipe mode)
|
||||
* Supported in `Custom` module too
|
||||
* See `fastfetch -h format` for detail
|
||||
* Add option `--color-separator` to set the color of key-value separators
|
||||
* Support Guix package manager count (#792, Packages, Linux)
|
||||
* Improve python based shell detection (#977, Shell, macOS)
|
||||
* Print error reason when vulkan init fails (Vulkan)
|
||||
|
||||
Bugfixes:
|
||||
* Don't detect `.conf` files in `--list-config-paths`
|
||||
* Don't try to detect terminals in MSYS shell with process backtracing (Windows)
|
||||
* Fix `outputColor` doesn't work if module keys are disabled
|
||||
|
||||
Logos:
|
||||
* Add Cereus Linux
|
||||
* Re-add special handling of Loc-OS
|
||||
|
||||
# 2.13.2
|
||||
|
||||
Another hotfix release :(
|
||||
|
||||
+31
-3
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
|
||||
|
||||
project(fastfetch
|
||||
VERSION 2.13.2
|
||||
VERSION 2.14.0
|
||||
LANGUAGES C
|
||||
DESCRIPTION "Fast neofetch-like system information tool"
|
||||
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
|
||||
@@ -14,9 +14,9 @@ set(PROJECT_LICENSE "MIT license")
|
||||
###################
|
||||
if(ANDROID)
|
||||
set(LINUX FALSE)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Ll]inux.*")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
set(LINUX TRUE CACHE BOOL "..." FORCE) # LINUX means GNU/Linux, not just the kernel
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Bb][Ss][Dd].*")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
|
||||
set(BSD TRUE CACHE BOOL "..." FORCE)
|
||||
elseif(NOT APPLE AND NOT WIN32)
|
||||
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
|
||||
@@ -77,6 +77,13 @@ option(BUILD_TESTS "Build tests" OFF) # Also create test executables
|
||||
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
|
||||
option(IS_MUSL "Build with musl libc" OFF) # Used by Github Actions
|
||||
|
||||
set(BINARY_LINK_TYPE_OPTIONS dlopen dynamic static)
|
||||
set(BINARY_LINK_TYPE dlopen CACHE STRING "How to link fastfetch")
|
||||
set_property(CACHE BINARY_LINK_TYPE PROPERTY STRINGS ${BINARY_LINK_TYPE_OPTIONS})
|
||||
if(NOT BINARY_LINK_TYPE IN_LIST BINARY_LINK_TYPE_OPTIONS)
|
||||
message(FATAL_ERROR "BINARY_LINK_TYPE must be one of ${BINARY_LINK_TYPE_OPTIONS}")
|
||||
endif()
|
||||
|
||||
if (LINUX)
|
||||
set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`")
|
||||
set(CUSTOM_AMDGPU_IDS_PATH "" CACHE STRING "Custom path to file amdgpu.ids, defaults to `/usr/share/libdrm/amdgpu.ids`")
|
||||
@@ -336,6 +343,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/modules/gpu/gpu.c
|
||||
src/modules/host/host.c
|
||||
src/modules/icons/icons.c
|
||||
src/modules/initsystem/initsystem.c
|
||||
src/modules/gamepad/gamepad.c
|
||||
src/modules/kernel/kernel.c
|
||||
src/modules/lm/lm.c
|
||||
@@ -424,6 +432,7 @@ if(LINUX)
|
||||
src/detection/gtk_qt/gtk.c
|
||||
src/detection/host/host_linux.c
|
||||
src/detection/icons/icons_linux.c
|
||||
src/detection/initsystem/initsystem_linux.c
|
||||
src/detection/libc/libc_linux.c
|
||||
src/detection/lm/lm_linux.c
|
||||
src/detection/loadavg/loadavg_linux.c
|
||||
@@ -482,6 +491,7 @@ elseif(ANDROID)
|
||||
src/detection/gpu/gpu_nosupport.c
|
||||
src/detection/host/host_android.c
|
||||
src/detection/icons/icons_nosupport.c
|
||||
src/detection/initsystem/initsystem_linux.c
|
||||
src/detection/libc/libc_android.c
|
||||
src/detection/lm/lm_nosupport.c
|
||||
src/detection/loadavg/loadavg_linux.c
|
||||
@@ -552,6 +562,7 @@ elseif(BSD)
|
||||
src/detection/host/host_bsd.c
|
||||
src/detection/lm/lm_linux.c
|
||||
src/detection/icons/icons_linux.c
|
||||
src/detection/initsystem/initsystem_linux.c
|
||||
src/detection/libc/libc_bsd.c
|
||||
src/detection/loadavg/loadavg_bsd.c
|
||||
src/detection/locale/locale_linux.c
|
||||
@@ -611,6 +622,7 @@ elseif(APPLE)
|
||||
src/detection/gpu/gpu_apple.m
|
||||
src/detection/host/host_apple.c
|
||||
src/detection/icons/icons_nosupport.c
|
||||
src/detection/initsystem/initsystem_linux.c
|
||||
src/detection/lm/lm_nosupport.c
|
||||
src/detection/loadavg/loadavg_bsd.c
|
||||
src/detection/libc/libc_apple.c
|
||||
@@ -669,6 +681,7 @@ elseif(WIN32)
|
||||
src/detection/gpu/gpu_windows.c
|
||||
src/detection/host/host_windows.c
|
||||
src/detection/icons/icons_windows.c
|
||||
src/detection/initsystem/initsystem_nosupport.c
|
||||
src/detection/libc/libc_windows.cpp
|
||||
src/detection/lm/lm_nosupport.c
|
||||
src/detection/loadavg/loadavg_nosupport.c
|
||||
@@ -817,6 +830,11 @@ if(NOT "${CUSTOM_OS_RELEASE_PATH}" STREQUAL "")
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_OS_RELEASE_PATH=${CUSTOM_OS_RELEASE_PATH})
|
||||
endif()
|
||||
|
||||
if(NOT BINARY_LINK_TYPE STREQUAL "dlopen")
|
||||
message(STATUS "Enabling custom link type: ${BINARY_LINK_TYPE}")
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_DISABLE_DLOPEN=1)
|
||||
endif()
|
||||
|
||||
function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
|
||||
if(NOT ENABLE_${VARNAME})
|
||||
return()
|
||||
@@ -845,6 +863,11 @@ function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_${VARNAME}=1)
|
||||
target_include_directories(libfastfetch PRIVATE ${${VARNAME}_INCLUDE_DIRS})
|
||||
|
||||
if(NOT BINARY_LINK_TYPE STREQUAL "dlopen")
|
||||
target_link_directories(libfastfetch PUBLIC ${${VARNAME}_LIBRARY_DIRS})
|
||||
target_link_libraries(libfastfetch PRIVATE ${${VARNAME}_LIBRARIES})
|
||||
endif()
|
||||
|
||||
foreach(FLAG ${${VARNAME}_CFLAGS_OTHER})
|
||||
if(FLAG MATCHES "-D.*")
|
||||
string(SUBSTRING ${FLAG} 2 -1 FLAG)
|
||||
@@ -1093,6 +1116,11 @@ elseif(APPLE)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(BINARY_LINK_TYPE STREQUAL "static")
|
||||
target_link_options(fastfetch PRIVATE "-static")
|
||||
target_link_options(flashfetch PRIVATE "-static")
|
||||
endif()
|
||||
|
||||
###################
|
||||
# Testing targets #
|
||||
###################
|
||||
|
||||
@@ -43,31 +43,28 @@ Replace sudo with doas depending on what you use.
|
||||
|
||||
[See also if fastfetch has been packaged for your favorite Linux distro](#Packaging).
|
||||
|
||||
If fastfetch is not packaged for your distro or an outdated version is packaged, [linuxbrew](https://brew.sh/) is a good alternate: `brew install fastfetch`
|
||||
If fastfetch is not packaged for your distro or an outdated version is packaged, [linuxbrew](https://brew.sh/) is a good alternative: `brew install fastfetch`
|
||||
|
||||
### macOS
|
||||
|
||||
...via [HomeBrew](https://brew.sh):
|
||||
|
||||
`brew install fastfetch`
|
||||
|
||||
...via [MacPorts](https://www.macports.org):
|
||||
|
||||
`sudo port install fastfetch`
|
||||
* [HomeBrew](https://formulae.brew.sh/formula/fastfetch#default): `brew install fastfetch`
|
||||
* [MacPorts](https://ports.macports.org/port/fastfetch/): `sudo port install fastfetch`
|
||||
|
||||
### Windows
|
||||
|
||||
`scoop install fastfetch`
|
||||
* [scoop](https://scoop.sh/#/apps?q=fastfetch): `scoop install fastfetch`
|
||||
* [winget](https://github.com/microsoft/winget-pkgs/tree/master/manifests/f/Fastfetch-cli/Fastfetch): `winget install fastfetch`
|
||||
* [MSYS2 MinGW](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-fastfetch): `pacman -S mingw-w64-<subsystem>-<arch>-fastfetch`
|
||||
|
||||
You may also download it directly from [GitHub releases page](https://github.com/fastfetch-cli/fastfetch/releases/latest) and extract the archive.
|
||||
|
||||
### FreeBSD
|
||||
|
||||
`pkg install fastfetch`
|
||||
* `pkg install fastfetch`
|
||||
|
||||
### Android (Termux)
|
||||
|
||||
`pkg install fastfetch`
|
||||
* `pkg install fastfetch`
|
||||
|
||||
## Build from source
|
||||
|
||||
@@ -155,6 +152,15 @@ See `fastfetch -h format` for basic usage. For module specific formattion, see `
|
||||
|
||||
Try `fastfetch -l /path/to/logo`. See [logo documentation](https://github.com/fastfetch-cli/fastfetch/wiki/Logo-options) for detail.
|
||||
|
||||
If you just want to display distro name in [FIGlet text](https://github.com/pwaller/pyfiglet)
|
||||
|
||||
```bash
|
||||
# install pyfiglet and jq first
|
||||
pyfiglet -s -f small_slant $(fastfetch -s os --format json | jq -r '.[0].result.name') && fastfetch -l none
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Q: Fastfetch runs in white and black on shell startup. Why?
|
||||
|
||||
This issue usually happens when using fastfetch with `p10k`. There are known incompatibility between fastfetch and p10k instant prompt.
|
||||
|
||||
Vendored
+42
@@ -1,3 +1,45 @@
|
||||
fastfetch (2.13.2) jammy; urgency=medium
|
||||
|
||||
* Update to 2.13.2
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Fri, 24 May 2024 13:48:59 +0800
|
||||
|
||||
fastfetch (2.13.1) jammy; urgency=medium
|
||||
|
||||
* Update to 2.13.1
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Tue, 21 May 2024 15:10:37 +0800
|
||||
|
||||
fastfetch (2.12.0) jammy; urgency=medium
|
||||
|
||||
* Update to 2.12.0
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Tue, 14 May 2024 16:33:33 +0800
|
||||
|
||||
fastfetch (2.11.5) jammy; urgency=medium
|
||||
|
||||
* Update to 2.11.5
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Tue, 07 May 2024 09:30:05 +0800
|
||||
|
||||
fastfetch (2.11.3) jammy; urgency=medium
|
||||
|
||||
* Update to 2.11.3
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Mon, 06 May 2024 08:46:45 +0800
|
||||
|
||||
fastfetch (2.10.2) jammy; urgency=medium
|
||||
|
||||
* Update to 2.10.2
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Tue, 23 Apr 2024 15:18:23 +0800
|
||||
|
||||
fastfetch (2.10.1) jammy; urgency=medium
|
||||
|
||||
* Update to 2.10.1
|
||||
|
||||
-- Carter Li <zhangsongcui@live.cn> Tue, 23 Apr 2024 09:55:02 +0800
|
||||
|
||||
fastfetch (2.9.2) jammy; urgency=medium
|
||||
|
||||
* Update to 2.9.2
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
fastfetch_2.9.2_source.buildinfo universe/utils optional
|
||||
fastfetch_2.13.2_source.buildinfo universe/utils optional
|
||||
|
||||
@@ -387,6 +387,10 @@
|
||||
"output": {
|
||||
"description": "Set the color of the module output",
|
||||
"$ref": "#/$defs/colors"
|
||||
},
|
||||
"separator": {
|
||||
"description": "Set the color of the key-value separator",
|
||||
"$ref": "#/$defs/colors"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -515,7 +519,7 @@
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "number",
|
||||
"description": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number",
|
||||
"description": "Set the percentage output type. 1 for percentage number, 2 for multi-color bar, 3 for both, 6 for bar only, 9 for colored number, 10 for monochrome bar",
|
||||
"minimum": 0,
|
||||
"maximum": 255,
|
||||
"default": 9
|
||||
@@ -778,7 +782,7 @@
|
||||
},
|
||||
{
|
||||
"const": "board",
|
||||
"description": "Print mather board name and other info"
|
||||
"description": "Print motherboard name and other info"
|
||||
},
|
||||
{
|
||||
"const": "bootmgr",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"board",
|
||||
"chassis",
|
||||
"kernel",
|
||||
"initsystem",
|
||||
"uptime",
|
||||
"loadavg",
|
||||
"processes",
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
},
|
||||
{
|
||||
"type": "terminal",
|
||||
"format": "{5} {6} \u001b[37m█\u001b[97m█ \u001b[36m█\u001b[96m█ \u001b[35m█\u001b[95m█ \u001b[34m█\u001b[94m█ \u001b[33m█\u001b[93m█ \u001b[32m█\u001b[92m█ \u001b[31m█\u001b[91m█ \u001b[30m█\u001b[90m█"
|
||||
"format": "{5} {6} {#37}█{#97}█ {#36}█{#96}█ {#35}█{#95}█ {#34}█{#94}█ {#33}█{#93}█ {#32}█{#92}█ {#31}█{#91}█ {#30}█{#90}█"
|
||||
},
|
||||
{
|
||||
"type": "packages",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"board",
|
||||
"chassis",
|
||||
"kernel",
|
||||
"initsystem",
|
||||
"uptime",
|
||||
"loadavg",
|
||||
"processes",
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"modules": [
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "\u001b[90m┌────────────────────────────────────────────────────────────┐"
|
||||
"format": "┌────────────────────────────────────────────────────────────┐",
|
||||
"outputColor": "90"
|
||||
},
|
||||
{
|
||||
"type": "title",
|
||||
@@ -22,15 +23,17 @@
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "\u001b[90m└────────────────────────────────────────────────────────────┘"
|
||||
"format": "└────────────────────────────────────────────────────────────┘",
|
||||
"outputColor": "90"
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"format": " \u001b[90m \u001b[31m \u001b[32m \u001b[33m \u001b[34m \u001b[35m \u001b[36m \u001b[37m \u001b[38m \u001b[39m \u001b[38m \u001b[37m \u001b[36m \u001b[35m \u001b[34m \u001b[33m \u001b[32m \u001b[31m \u001b[90m"
|
||||
"format": " {#90} {#31} {#32} {#33} {#34} {#35} {#36} {#37} {#38} {#39} {#38} {#37} {#36} {#35} {#34} {#33} {#32} {#31} {#90}"
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "\u001b[90m┌────────────────────────────────────────────────────────────┐"
|
||||
"format": "┌────────────────────────────────────────────────────────────┐",
|
||||
"outputColor": "90"
|
||||
},
|
||||
{
|
||||
"type": "os",
|
||||
@@ -139,12 +142,13 @@
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "\u001b[90m└────────────────────────────────────────────────────────────┘"
|
||||
"format": "└────────────────────────────────────────────────────────────┘",
|
||||
"outputColor": "90"
|
||||
},
|
||||
"break",
|
||||
{
|
||||
"type": "custom",
|
||||
"format": " \u001b[90m \u001b[31m \u001b[32m \u001b[33m \u001b[34m \u001b[35m \u001b[36m \u001b[37m \u001b[38m \u001b[39m \u001b[38m \u001b[37m \u001b[36m \u001b[35m \u001b[34m \u001b[33m \u001b[32m \u001b[31m \u001b[90m"
|
||||
"format": " {#90} {#31} {#32} {#33} {#34} {#35} {#36} {#37} {#38} {#39} {#38} {#37} {#36} {#35} {#34} {#33} {#32} {#31} {#90}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
"type": "small"
|
||||
},
|
||||
"display": {
|
||||
"separator": "\u001b[31m-> "
|
||||
"separator": "-> ",
|
||||
"color": {
|
||||
"separator": "red"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
"type": "none"
|
||||
},
|
||||
"display": {
|
||||
"separator": "-> "
|
||||
"separator": "-> ",
|
||||
"color": {
|
||||
"separator": "1"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
@@ -14,7 +17,7 @@
|
||||
"break",
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "┌───────────────────────────── \u001b[1mSystem Information\u001b[0m ─────────────────────────────┐" // `\u001b` is `\033`, or `\e`
|
||||
"format": "┌───────────────────────────── {#1}System Information{#} ─────────────────────────────┐"
|
||||
},
|
||||
"break",
|
||||
{
|
||||
@@ -92,7 +95,7 @@
|
||||
"break",
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "└──────────────────────────────────────────────────────────────────────────────┘" // `\u001b` is `\033`, or `\e`
|
||||
"format": "└──────────────────────────────────────────────────────────────────────────────┘"
|
||||
},
|
||||
"break",
|
||||
{
|
||||
|
||||
+15
-14
@@ -17,54 +17,55 @@
|
||||
},
|
||||
{
|
||||
// draw borders first to make colors of left and right border consistant
|
||||
"key": "│ │\u001b[11D\u001b[31m user",
|
||||
"key": "│ │\u001b[11D{#31} user",
|
||||
"type": "title",
|
||||
"format": "{1}"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[32m hname",
|
||||
"key": "│ │\u001b[11D{#32} hname",
|
||||
"type": "title",
|
||||
"format": "{2}"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[33m uptime",
|
||||
"key": "│ │\u001b[11D{#33} uptime",
|
||||
"type": "uptime"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[34m distro",
|
||||
"key": "│ │\u001b[11D{#34} distro",
|
||||
"type": "os"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[35m kernel",
|
||||
"key": "│ │\u001b[11D{#35} kernel",
|
||||
"type": "kernel"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[36m desktop",
|
||||
"key": "│ │\u001b[11D{#36} desktop",
|
||||
"type": "de"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[31m term",
|
||||
"key": "│ │\u001b[11D{#31} term",
|
||||
"type": "terminal"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[32m shell",
|
||||
"key": "│ │\u001b[11D{#32} shell",
|
||||
"type": "shell"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[33m cpu",
|
||||
"type": "cpu"
|
||||
"key": "│ │\u001b[11D{#33} cpu",
|
||||
"type": "cpu",
|
||||
"showPeCoreCount": true
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[34m disk",
|
||||
"key": "│ │\u001b[11D{#34} disk",
|
||||
"type": "disk",
|
||||
"folders": "/"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[35m memory",
|
||||
"key": "│ │\u001b[11D{#35} memory",
|
||||
"type": "memory"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[36m network",
|
||||
"key": "│ │\u001b[11D{#36} network",
|
||||
"type": "localip",
|
||||
"format": "{1} ({4})"
|
||||
},
|
||||
@@ -73,7 +74,7 @@
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"key": "│ │\u001b[11D\u001b[m colors",
|
||||
"key": "│ │\u001b[11D{#39} colors",
|
||||
"type": "colors",
|
||||
"symbol": "circle"
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"modules": [
|
||||
{
|
||||
"type": "custom", // HardwareStart
|
||||
"format": "┌─────────── \u001b[1mHardware Information\u001b[0m ───────────┐" // `\u001b` is `\033`, or `\e`
|
||||
"format": "┌─────────── {#1}Hardware Information{#} ───────────┐" // {#1} is the same as `\u001b[1m`. {#} is `\u001b[m`
|
||||
},
|
||||
{
|
||||
"type": "host",
|
||||
@@ -71,7 +71,7 @@
|
||||
},
|
||||
{
|
||||
"type": "custom", // SoftwareStart
|
||||
"format": "├─────────── \u001b[1mSoftware Information\u001b[0m ───────────┤"
|
||||
"format": "├─────────── {#1}Software Information{#} ───────────┤"
|
||||
},
|
||||
{
|
||||
"type": "title",
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"type": "os",
|
||||
"key": "├", // Just get your distro's logo off nerdfonts.com
|
||||
"keyColor": "yellow",
|
||||
"format": "{6}{?6} {?}{10} {8}"
|
||||
"format": "{6}{?6} {?}{10}{?10} {?}{8}{?8} {?}{11}"
|
||||
},
|
||||
{
|
||||
"type": "kernel",
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
{
|
||||
"type": "custom",
|
||||
"key": "",
|
||||
"format": "\u001b[31m███\u001b[32m███\u001b[33m███\u001b[34m███\u001b[35m███\u001b[36m███"
|
||||
"format": "{#31}███{#32}███{#33}███{#34}███{#35}███{#36}███"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 341 KiB After Width: | Height: | Size: 285 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 133 KiB |
+78
-57
@@ -52,14 +52,29 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
|
||||
* @param placeholderValue the string to parse
|
||||
* @return uint32_t the parsed value
|
||||
*/
|
||||
static inline uint32_t getArgumentIndex(const FFstrbuf* placeholderValue)
|
||||
static uint32_t getArgumentIndex(const FFstrbuf* placeholderValue, uint32_t numArgs, const FFformatarg* arguments)
|
||||
{
|
||||
uint32_t result = UINT32_MAX;
|
||||
char firstChar = placeholderValue->chars[0];
|
||||
|
||||
if(placeholderValue->chars[0] != '-')
|
||||
sscanf(placeholderValue->chars, "%" PRIu32, &result);
|
||||
if(firstChar >= '1' && firstChar <= '9')
|
||||
{
|
||||
char* pEnd = NULL;
|
||||
unsigned long result = strtoul(placeholderValue->chars, &pEnd, 10);
|
||||
if (pEnd != placeholderValue->chars + placeholderValue->length || result > numArgs)
|
||||
return UINT32_MAX;
|
||||
return (uint32_t) result;
|
||||
}
|
||||
else if (ffCharIsEnglishAlphabet(firstChar))
|
||||
{
|
||||
for (uint32_t i = 0; i < numArgs; ++i)
|
||||
{
|
||||
const FFformatarg* arg = &arguments[i];
|
||||
if(arg->name && ffStrbufIgnCaseEqualS(placeholderValue, arg->name))
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return result == 0 ? UINT32_MAX : result;
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
static inline void appendInvalidPlaceholder(FFstrbuf* buffer, const char* start, const FFstrbuf* placeholderValue, uint32_t index, uint32_t formatStringLength)
|
||||
@@ -101,7 +116,8 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
|
||||
|
||||
uint32_t numOpenIfs = 0;
|
||||
uint32_t numOpenNotIfs = 0;
|
||||
uint32_t numOpenColors = 0;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY placeholderValue = ffStrbufCreate();
|
||||
|
||||
for(uint32_t i = 0; i < formatstr->length; ++i)
|
||||
{
|
||||
@@ -136,67 +152,70 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
|
||||
continue;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY placeholderValue = ffStrbufCreate();
|
||||
ffStrbufClear(&placeholderValue);
|
||||
|
||||
while(i < formatstr->length && formatstr->chars[i] != '}')
|
||||
ffStrbufAppendC(&placeholderValue, formatstr->chars[i++]);
|
||||
|
||||
// test if for stop, if so break the loop
|
||||
if(placeholderValue.length == 1 && placeholderValue.chars[0] == '-')
|
||||
break;
|
||||
|
||||
// test for end of an if, if so do nothing
|
||||
if(placeholderValue.length == 1 && placeholderValue.chars[0] == '?')
|
||||
{
|
||||
if(numOpenIfs == 0)
|
||||
appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length);
|
||||
else
|
||||
--numOpenIfs;
|
||||
|
||||
continue;
|
||||
uint32_t iEnd = ffStrbufNextIndexC(formatstr, i, '}');
|
||||
ffStrbufAppendNS(&placeholderValue, iEnd - i, &formatstr->chars[i]);
|
||||
i = iEnd;
|
||||
}
|
||||
|
||||
// test for end of a not if, if so do nothing
|
||||
if(placeholderValue.length == 1 && placeholderValue.chars[0] == '/')
|
||||
{
|
||||
if(numOpenNotIfs == 0)
|
||||
appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length);
|
||||
else
|
||||
--numOpenNotIfs;
|
||||
char firstChar = placeholderValue.chars[0];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// test for end of a color, if so do nothing
|
||||
if(placeholderValue.length == 1 && placeholderValue.chars[0] == '#')
|
||||
if (placeholderValue.length == 1)
|
||||
{
|
||||
if(numOpenColors == 0)
|
||||
appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length);
|
||||
else
|
||||
// test if for stop, if so break the loop
|
||||
if (firstChar == '-')
|
||||
break;
|
||||
|
||||
// test for end of an if, if so do nothing
|
||||
if (firstChar == '?')
|
||||
{
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
--numOpenColors;
|
||||
if(numOpenIfs == 0)
|
||||
appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length);
|
||||
else
|
||||
--numOpenIfs;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
// test for end of a not if, if so do nothing
|
||||
if (firstChar == '/')
|
||||
{
|
||||
if(numOpenNotIfs == 0)
|
||||
appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length);
|
||||
else
|
||||
--numOpenNotIfs;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// test for end of a color, if so do nothing
|
||||
if (firstChar == '#')
|
||||
{
|
||||
if (!instance.config.display.pipe)
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// test for if, if so evaluate it
|
||||
if(placeholderValue.chars[0] == '?')
|
||||
if (firstChar == '?')
|
||||
{
|
||||
ffStrbufSubstrAfter(&placeholderValue, 0);
|
||||
|
||||
uint32_t index = getArgumentIndex(&placeholderValue);
|
||||
uint32_t index = getArgumentIndex(&placeholderValue, numArgs, arguments);
|
||||
|
||||
// testing for an invalid index
|
||||
if(index > numArgs)
|
||||
if (index > numArgs)
|
||||
{
|
||||
appendInvalidPlaceholder(buffer, "{?", &placeholderValue, i, formatstr->length);
|
||||
continue;
|
||||
}
|
||||
|
||||
// continue normally if an format arg is set and the value is > 0
|
||||
if(formatArgSet(&arguments[index - 1]))
|
||||
if (formatArgSet(&arguments[index - 1]))
|
||||
{
|
||||
++numOpenIfs;
|
||||
continue;
|
||||
@@ -208,21 +227,21 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
|
||||
}
|
||||
|
||||
// test for not if, if so evaluate it
|
||||
if(placeholderValue.chars[0] == '/')
|
||||
if (firstChar == '/')
|
||||
{
|
||||
ffStrbufSubstrAfter(&placeholderValue, 0);
|
||||
|
||||
uint32_t index = getArgumentIndex(&placeholderValue);
|
||||
uint32_t index = getArgumentIndex(&placeholderValue, numArgs, arguments);
|
||||
|
||||
// testing for an invalid index
|
||||
if(index > numArgs)
|
||||
if (index > numArgs)
|
||||
{
|
||||
appendInvalidPlaceholder(buffer, "{/", &placeholderValue, i, formatstr->length);
|
||||
continue;
|
||||
}
|
||||
|
||||
//continue normally if an format arg is not set or the value is 0
|
||||
if(!formatArgSet(&arguments[index - 1]))
|
||||
if (!formatArgSet(&arguments[index - 1]))
|
||||
{
|
||||
++numOpenNotIfs;
|
||||
continue;
|
||||
@@ -234,20 +253,21 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
|
||||
}
|
||||
|
||||
//test for color, if so evaluate it
|
||||
if(placeholderValue.chars[0] == '#')
|
||||
if (firstChar == '#')
|
||||
{
|
||||
++numOpenColors;
|
||||
ffStrbufSubstrAfter(&placeholderValue, 0);
|
||||
ffStrbufAppendS(buffer, "\033[");
|
||||
ffStrbufAppend(buffer, &placeholderValue);
|
||||
ffStrbufAppendC(buffer, 'm');
|
||||
if (!instance.config.display.pipe)
|
||||
{
|
||||
ffStrbufAppendS(buffer, "\e[");
|
||||
ffOptionParseColorNoClear(placeholderValue.chars + 1, buffer);
|
||||
ffStrbufAppendC(buffer, 'm');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t index = getArgumentIndex(&placeholderValue);
|
||||
uint32_t index = getArgumentIndex(&placeholderValue, numArgs, arguments);
|
||||
|
||||
// test for invalid index
|
||||
if(index > numArgs)
|
||||
if (index > numArgs)
|
||||
{
|
||||
appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length);
|
||||
continue;
|
||||
@@ -256,5 +276,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
|
||||
ffFormatAppendFormatArg(buffer, &arguments[index - 1]);
|
||||
}
|
||||
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
if (!instance.config.display.pipe)
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ typedef struct FFformatarg
|
||||
{
|
||||
FFformatargtype type;
|
||||
const void* value;
|
||||
const char* name; // argument name, must start with an alphabet
|
||||
} FFformatarg;
|
||||
|
||||
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/library.h"
|
||||
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
//Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
|
||||
@@ -77,3 +79,5 @@ void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "fastfetch.h"
|
||||
#include "util/FFcheckmacros.h"
|
||||
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <libloaderapi.h>
|
||||
#define FF_DLOPEN_FLAGS 0
|
||||
@@ -71,3 +73,45 @@ static inline void ffLibraryUnload(void** handle)
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff ## symbolName, symbolName, returnValue);
|
||||
|
||||
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
|
||||
|
||||
#else
|
||||
|
||||
#define FF_LIBRARY_EXTENSION ""
|
||||
|
||||
#define FF_LIBRARY_SYMBOL(symbolName) \
|
||||
__typeof__(&symbolName) ff ## symbolName;
|
||||
|
||||
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
|
||||
FF_MAYBE_UNUSED void* libraryObjectName = NULL; // Placeholder
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
|
||||
symbolMapping = (__typeof__(&symbolName)) &symbolName
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, symbolMapping, symbolName, alternateName, returnValue) \
|
||||
symbolMapping = (__typeof__(&symbolName)) &symbolName
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
||||
FF_MAYBE_UNUSED __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, returnValue);
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
|
||||
FF_MAYBE_UNUSED __typeof__(&symbolName) ff ## symbolName = (__typeof__(&symbolName)) &symbolName;
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
|
||||
FF_MAYBE_UNUSED __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, "dlsym " #symbolName " failed");
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE2(library, symbolName, alternateName) \
|
||||
FF_MAYBE_UNUSED __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed");
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff ## symbolName, symbolName, returnValue);
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff ## symbolName, symbolName, "dlsym " #symbolName " failed");
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(library, varName, symbolName, alternateName) \
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, (varName).ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed");
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff ## symbolName, symbolName, returnValue);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,6 +59,7 @@ static FFModuleBaseInfo* H[] = {
|
||||
|
||||
static FFModuleBaseInfo* I[] = {
|
||||
(void*) &instance.config.modules.icons,
|
||||
(void*) &instance.config.modules.initSystem,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
+31
-32
@@ -145,47 +145,46 @@ bool ffOptionParseBoolean(const char* str)
|
||||
);
|
||||
}
|
||||
|
||||
void ffOptionParseColor(const char* value, FFstrbuf* buffer)
|
||||
void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer)
|
||||
{
|
||||
ffStrbufClear(buffer);
|
||||
ffStrbufEnsureFree(buffer, 63);
|
||||
|
||||
while(*value != '\0')
|
||||
{
|
||||
#define FF_APPEND_COLOR_CODE_COND(prefix, code) \
|
||||
if(ffStrStartsWithIgnCase(value, #prefix)) { ffStrbufAppendS(buffer, code); value += strlen(#prefix); }
|
||||
if(ffStrStartsWithIgnCase(value, #prefix)) { ffStrbufAppendS(buffer, code); value += strlen(#prefix); continue; }
|
||||
|
||||
FF_APPEND_COLOR_CODE_COND(reset_, FF_COLOR_MODE_RESET)
|
||||
else FF_APPEND_COLOR_CODE_COND(bright_, FF_COLOR_MODE_BOLD)
|
||||
else FF_APPEND_COLOR_CODE_COND(dim_, FF_COLOR_MODE_DIM)
|
||||
else FF_APPEND_COLOR_CODE_COND(italic_, FF_COLOR_MODE_ITALIC)
|
||||
else FF_APPEND_COLOR_CODE_COND(underline_, FF_COLOR_MODE_UNDERLINE)
|
||||
else FF_APPEND_COLOR_CODE_COND(blink_, FF_COLOR_MODE_BLINK)
|
||||
else FF_APPEND_COLOR_CODE_COND(inverse_, FF_COLOR_MODE_INVERSE)
|
||||
else FF_APPEND_COLOR_CODE_COND(hidden_, FF_COLOR_MODE_HIDDEN)
|
||||
else FF_APPEND_COLOR_CODE_COND(strike_, FF_COLOR_MODE_STRIKETHROUGH)
|
||||
else FF_APPEND_COLOR_CODE_COND(black, FF_COLOR_FG_BLACK)
|
||||
else FF_APPEND_COLOR_CODE_COND(red, FF_COLOR_FG_RED)
|
||||
else FF_APPEND_COLOR_CODE_COND(green, FF_COLOR_FG_GREEN)
|
||||
else FF_APPEND_COLOR_CODE_COND(yellow, FF_COLOR_FG_YELLOW)
|
||||
else FF_APPEND_COLOR_CODE_COND(blue, FF_COLOR_FG_BLUE)
|
||||
else FF_APPEND_COLOR_CODE_COND(magenta, FF_COLOR_FG_MAGENTA)
|
||||
else FF_APPEND_COLOR_CODE_COND(cyan, FF_COLOR_FG_CYAN)
|
||||
else FF_APPEND_COLOR_CODE_COND(white, FF_COLOR_FG_WHITE)
|
||||
else FF_APPEND_COLOR_CODE_COND(default, FF_COLOR_FG_DEFAULT)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_black, FF_COLOR_FG_LIGHT_BLACK)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_red, FF_COLOR_FG_LIGHT_RED)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_green, FF_COLOR_FG_LIGHT_GREEN)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_yellow, FF_COLOR_FG_LIGHT_YELLOW)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_blue, FF_COLOR_FG_LIGHT_BLUE)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_magenta, FF_COLOR_FG_LIGHT_MAGENTA)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_cyan, FF_COLOR_FG_LIGHT_CYAN)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_white, FF_COLOR_FG_LIGHT_WHITE)
|
||||
else
|
||||
if (ffCharIsEnglishAlphabet(value[0]))
|
||||
{
|
||||
ffStrbufAppendC(buffer, *value);
|
||||
++value;
|
||||
FF_APPEND_COLOR_CODE_COND(reset_, FF_COLOR_MODE_RESET)
|
||||
else FF_APPEND_COLOR_CODE_COND(bright_, FF_COLOR_MODE_BOLD)
|
||||
else FF_APPEND_COLOR_CODE_COND(dim_, FF_COLOR_MODE_DIM)
|
||||
else FF_APPEND_COLOR_CODE_COND(italic_, FF_COLOR_MODE_ITALIC)
|
||||
else FF_APPEND_COLOR_CODE_COND(underline_, FF_COLOR_MODE_UNDERLINE)
|
||||
else FF_APPEND_COLOR_CODE_COND(blink_, FF_COLOR_MODE_BLINK)
|
||||
else FF_APPEND_COLOR_CODE_COND(inverse_, FF_COLOR_MODE_INVERSE)
|
||||
else FF_APPEND_COLOR_CODE_COND(hidden_, FF_COLOR_MODE_HIDDEN)
|
||||
else FF_APPEND_COLOR_CODE_COND(strike_, FF_COLOR_MODE_STRIKETHROUGH)
|
||||
else FF_APPEND_COLOR_CODE_COND(black, FF_COLOR_FG_BLACK)
|
||||
else FF_APPEND_COLOR_CODE_COND(red, FF_COLOR_FG_RED)
|
||||
else FF_APPEND_COLOR_CODE_COND(green, FF_COLOR_FG_GREEN)
|
||||
else FF_APPEND_COLOR_CODE_COND(yellow, FF_COLOR_FG_YELLOW)
|
||||
else FF_APPEND_COLOR_CODE_COND(blue, FF_COLOR_FG_BLUE)
|
||||
else FF_APPEND_COLOR_CODE_COND(magenta, FF_COLOR_FG_MAGENTA)
|
||||
else FF_APPEND_COLOR_CODE_COND(cyan, FF_COLOR_FG_CYAN)
|
||||
else FF_APPEND_COLOR_CODE_COND(white, FF_COLOR_FG_WHITE)
|
||||
else FF_APPEND_COLOR_CODE_COND(default, FF_COLOR_FG_DEFAULT)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_black, FF_COLOR_FG_LIGHT_BLACK)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_red, FF_COLOR_FG_LIGHT_RED)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_green, FF_COLOR_FG_LIGHT_GREEN)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_yellow, FF_COLOR_FG_LIGHT_YELLOW)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_blue, FF_COLOR_FG_LIGHT_BLUE)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_magenta, FF_COLOR_FG_LIGHT_MAGENTA)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_cyan, FF_COLOR_FG_LIGHT_CYAN)
|
||||
else FF_APPEND_COLOR_CODE_COND(light_white, FF_COLOR_FG_LIGHT_WHITE)
|
||||
}
|
||||
ffStrbufAppendC(buffer, *value);
|
||||
++value;
|
||||
|
||||
#undef FF_APPEND_COLOR_CODE_COND
|
||||
}
|
||||
|
||||
+6
-1
@@ -67,6 +67,11 @@ FF_C_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char*
|
||||
FF_C_NODISCARD int32_t ffOptionParseInt32(const char* argumentKey, const char* value);
|
||||
FF_C_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]);
|
||||
FF_C_NODISCARD bool ffOptionParseBoolean(const char* str);
|
||||
void ffOptionParseColor(const char* value, FFstrbuf* buffer);
|
||||
void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer);
|
||||
static inline void ffOptionParseColor(const char* value, FFstrbuf* buffer)
|
||||
{
|
||||
ffStrbufClear(buffer);
|
||||
ffOptionParseColorNoClear(value, buffer);
|
||||
}
|
||||
void ffOptionInitModuleArg(FFModuleArgs* args);
|
||||
void ffOptionDestroyModuleArg(FFModuleArgs* args);
|
||||
|
||||
+28
-8
@@ -50,14 +50,34 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig con
|
||||
{
|
||||
if(!options->pipe)
|
||||
{
|
||||
uint32_t section1Begin = (uint32_t) ((green <= yellow ? green : yellow) / 100.0 * options->barWidth + 0.5);
|
||||
uint32_t section2Begin = (uint32_t) ((green > yellow ? green : yellow) / 100.0 * options->barWidth + 0.5);
|
||||
if (i == section2Begin)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", (green > yellow ? colorGreen : colorRed));
|
||||
else if (i == section1Begin)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", colorYellow);
|
||||
else if (i == 0)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", (green <= yellow ? colorGreen : colorRed));
|
||||
if (options->percentType & FF_PERCENTAGE_TYPE_BAR_MONOCHROME_BIT)
|
||||
{
|
||||
const char* color = NULL;
|
||||
if (green <= yellow)
|
||||
{
|
||||
if (percent < green) color = colorGreen;
|
||||
else if (percent < yellow) color = colorYellow;
|
||||
else color = colorRed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (percent < yellow) color = colorRed;
|
||||
else if (percent < green) color = colorYellow;
|
||||
else color = colorGreen;
|
||||
}
|
||||
ffStrbufAppendF(buffer, "\e[%sm", color);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t section1Begin = (uint32_t) ((green <= yellow ? green : yellow) / 100.0 * options->barWidth + 0.5);
|
||||
uint32_t section2Begin = (uint32_t) ((green > yellow ? green : yellow) / 100.0 * options->barWidth + 0.5);
|
||||
if (i == section2Begin)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", (green > yellow ? colorGreen : colorRed));
|
||||
else if (i == section1Begin)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", colorYellow);
|
||||
else if (i == 0)
|
||||
ffStrbufAppendF(buffer, "\e[%sm", (green <= yellow ? colorGreen : colorRed));
|
||||
}
|
||||
}
|
||||
ffStrbufAppend(buffer, &options->barCharElapsed);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
#include "common/parsing.h"
|
||||
#include "common/option.h"
|
||||
|
||||
enum
|
||||
enum FFPercentageTypeFlags
|
||||
{
|
||||
FF_PERCENTAGE_TYPE_NUM_BIT = 1 << 0,
|
||||
FF_PERCENTAGE_TYPE_BAR_BIT = 1 << 1,
|
||||
FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT = 1 << 2,
|
||||
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
|
||||
FF_PERCENTAGE_TYPE_BAR_MONOCHROME_BIT = FF_PERCENTAGE_TYPE_NUM_COLOR_BIT,
|
||||
};
|
||||
|
||||
// if (green <= yellow)
|
||||
|
||||
+47
-44
@@ -11,43 +11,56 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
return;
|
||||
|
||||
//This is used as a magic value for hiding keys
|
||||
if(moduleArgs && ffStrbufEqualS(&moduleArgs->key, " "))
|
||||
return;
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
if (!(moduleArgs && ffStrbufEqualS(&moduleArgs->key, " ")))
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
if (instance.config.display.brightColor)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
||||
if(!instance.config.display.pipe)
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
if (instance.config.display.brightColor)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
||||
|
||||
if(moduleArgs && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR) && moduleArgs->keyColor.length > 0)
|
||||
ffPrintColor(&moduleArgs->keyColor);
|
||||
if(moduleArgs && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR) && moduleArgs->keyColor.length > 0)
|
||||
ffPrintColor(&moduleArgs->keyColor);
|
||||
else
|
||||
ffPrintColor(&instance.config.display.colorKeys);
|
||||
}
|
||||
|
||||
//NULL check is required for modules with custom keys, e.g. disk with the folder path
|
||||
if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0)
|
||||
{
|
||||
fputs(moduleName, stdout);
|
||||
|
||||
if(moduleIndex > 0)
|
||||
printf(" %hhu", moduleIndex);
|
||||
}
|
||||
else
|
||||
ffPrintColor(&instance.config.display.colorKeys);
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 1, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex, "index"},
|
||||
}));
|
||||
ffStrbufWriteTo(&key, stdout);
|
||||
}
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
ffPrintColor(&instance.config.display.colorSeparator);
|
||||
}
|
||||
|
||||
ffStrbufWriteTo(&instance.config.display.keyValueSeparator, stdout);
|
||||
|
||||
if(!instance.config.display.pipe && instance.config.display.colorSeparator.length)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
|
||||
if (!(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
|
||||
{
|
||||
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.display.keyWidth;
|
||||
if (keyWidth > 0)
|
||||
printf("\e[%uG", (unsigned) (keyWidth + instance.state.logoWidth));
|
||||
}
|
||||
}
|
||||
|
||||
//NULL check is required for modules with custom keys, e.g. disk with the folder path
|
||||
if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0)
|
||||
{
|
||||
fputs(moduleName, stdout);
|
||||
|
||||
if(moduleIndex > 0)
|
||||
printf(" %hhu", moduleIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 1, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
|
||||
}));
|
||||
ffStrbufWriteTo(&key, stdout);
|
||||
}
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
|
||||
ffStrbufWriteTo(&instance.config.display.keyValueSeparator, stdout);
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
@@ -56,13 +69,6 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
else if (instance.config.display.colorOutput.length)
|
||||
ffPrintColor(&instance.config.display.colorOutput);
|
||||
}
|
||||
|
||||
if (!instance.config.display.pipe && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
|
||||
{
|
||||
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.display.keyWidth;
|
||||
if (keyWidth > 0)
|
||||
printf("\e[%uG", (unsigned) (keyWidth + instance.state.logoWidth));
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments)
|
||||
@@ -73,11 +79,8 @@ void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleAr
|
||||
else
|
||||
ffStrbufAppendS(&buffer, "unknown");
|
||||
|
||||
if(buffer.length > 0)
|
||||
{
|
||||
ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType);
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType);
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
|
||||
static void printError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, va_list arguments)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "util/FFstrbuf.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr);
|
||||
|
||||
static inline const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
|
||||
@@ -19,3 +21,10 @@ static inline const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const ar
|
||||
ffStrbufTrimRightSpace(buffer);
|
||||
return error;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
bool ffProcessGetInfoWindows(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrbuf* exe, const char** exeName, FFstrbuf* exePath, bool* gui);
|
||||
#else
|
||||
void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, const char** exeName, FFstrbuf* exePath);
|
||||
const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, int32_t* tty);
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "common/processing.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/time.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@@ -11,6 +13,15 @@
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#include <libproc.h>
|
||||
#endif
|
||||
|
||||
enum { FF_PIPE_BUFSIZ = 8192 };
|
||||
|
||||
static inline int ffPipe2(int *fds, int flags)
|
||||
@@ -101,3 +112,234 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
|
||||
|
||||
return "read(childPipeFd, str, FF_PIPE_BUFSIZ) failed";
|
||||
}
|
||||
|
||||
void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, const char** exeName, FFstrbuf* exePath)
|
||||
{
|
||||
assert(processName->length > 0);
|
||||
ffStrbufClear(exe);
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
char filePath[64];
|
||||
snprintf(filePath, sizeof(filePath), "/proc/%d/cmdline", (int)pid);
|
||||
|
||||
if(ffReadFileBuffer(filePath, exe))
|
||||
{
|
||||
ffStrbufRecalculateLength(exe); //Trim the arguments
|
||||
ffStrbufTrimRightSpace(exe);
|
||||
ffStrbufTrimLeft(exe, '-'); //Login shells start with a dash
|
||||
}
|
||||
|
||||
if (exePath)
|
||||
{
|
||||
snprintf(filePath, sizeof(filePath), "/proc/%d/exe", (int)pid);
|
||||
ffStrbufEnsureFixedLengthFree(exePath, PATH_MAX);
|
||||
ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1);
|
||||
if (length > 0) // doesn't contain trailing NUL
|
||||
{
|
||||
exePath->chars[length] = '\0';
|
||||
exePath->length = (uint32_t) length;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
size_t len = 0;
|
||||
int mibs[] = { CTL_KERN, KERN_PROCARGS2, pid };
|
||||
if (sysctl(mibs, sizeof(mibs) / sizeof(*mibs), NULL, &len, NULL, 0) == 0)
|
||||
{// try get arg0
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
//don't know why if don't let len longer, proArgs2 and len will change during the following sysctl() in old MacOS version.
|
||||
len++;
|
||||
#endif
|
||||
FF_AUTO_FREE char* const procArgs2 = malloc(len);
|
||||
if (sysctl(mibs, sizeof(mibs) / sizeof(*mibs), procArgs2, &len, NULL, 0) == 0)
|
||||
{
|
||||
// https://gist.github.com/nonowarn/770696#file-getargv-c-L46
|
||||
uint32_t argc = *(uint32_t*) procArgs2;
|
||||
const char* realExePath = procArgs2 + sizeof(argc);
|
||||
|
||||
const char* arg0 = memchr(realExePath, '\0', len - (size_t) (realExePath - procArgs2));
|
||||
if (exePath)
|
||||
ffStrbufSetNS(exePath, (uint32_t) (arg0 - realExePath), realExePath);
|
||||
|
||||
do arg0++; while (*arg0 == '\0');
|
||||
assert(arg0 < procArgs2 + len);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
// #977
|
||||
const char* p = strrchr(arg0, '/');
|
||||
if (p)
|
||||
p++;
|
||||
else
|
||||
p = arg0;
|
||||
if (ffStrStartsWithIgnCase(p, "python")) // /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python /Users/carter/.local/bin/xonsh
|
||||
arg0 = p + strlen(p) + 1;
|
||||
}
|
||||
|
||||
if (*arg0 == '-') arg0++; // Login shells
|
||||
|
||||
ffStrbufSetS(exe, arg0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ffStrbufEnsureFixedLengthFree(exe, PATH_MAX);
|
||||
int length = proc_pidpath(pid, exe->chars, exe->allocated);
|
||||
if (length > 0)
|
||||
{
|
||||
exe->length = (uint32_t) length;
|
||||
if (exePath)
|
||||
ffStrbufSet(exePath, exe);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
size_t size = ARG_MAX;
|
||||
FF_AUTO_FREE char* args = malloc(size);
|
||||
|
||||
static_assert(ARG_MAX > PATH_MAX, "");
|
||||
|
||||
if(exePath && sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, pid}, 4,
|
||||
args, &size,
|
||||
NULL, 0
|
||||
) == 0)
|
||||
ffStrbufSetNS(exePath, (uint32_t) (size - 1), args);
|
||||
|
||||
size = ARG_MAX;
|
||||
if(sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_ARGS, pid}, 4,
|
||||
args, &size,
|
||||
NULL, 0
|
||||
) == 0)
|
||||
{
|
||||
char* arg0 = args;
|
||||
size_t arg0Len = strlen(args);
|
||||
if (size > arg0Len + 1)
|
||||
{
|
||||
char* p = (char*) memrchr(args, '/', arg0Len);
|
||||
if (p)
|
||||
p++;
|
||||
else
|
||||
p = arg0;
|
||||
if (ffStrStartsWith(p, "python")) // /usr/local/bin/python3.9 /home/carter/.local/bin/xonsh
|
||||
{
|
||||
arg0 += arg0Len + 1;
|
||||
}
|
||||
}
|
||||
if (arg0[0] == '-') arg0++;
|
||||
ffStrbufSetS(exe, arg0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if(exe->length == 0)
|
||||
ffStrbufSet(exe, processName);
|
||||
|
||||
assert(exe->length > 0);
|
||||
uint32_t lastSlashIndex = ffStrbufLastIndexC(exe, '/');
|
||||
if(lastSlashIndex < exe->length)
|
||||
*exeName = exe->chars + lastSlashIndex + 1;
|
||||
}
|
||||
|
||||
const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, int32_t* tty)
|
||||
{
|
||||
if (pid <= 0)
|
||||
return "Invalid pid";
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
char procFilePath[64];
|
||||
if (ppid)
|
||||
{
|
||||
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/stat", (int)pid);
|
||||
char buf[PROC_FILE_BUFFSIZ];
|
||||
ssize_t nRead = ffReadFileData(procFilePath, sizeof(buf) - 1, buf);
|
||||
if(nRead <= 8)
|
||||
return "ffReadFileData(/proc/pid/stat, PROC_FILE_BUFFSIZ-1, buf) failed";
|
||||
buf[nRead] = '\0';
|
||||
|
||||
*ppid = 0;
|
||||
static_assert(sizeof(*ppid) == sizeof(int), "");
|
||||
|
||||
ffStrbufEnsureFixedLengthFree(name, 255);
|
||||
int tty_;
|
||||
if(
|
||||
sscanf(buf, "%*s (%255[^)]) %*c %d %*d %*d %d", name->chars, ppid, &tty_) < 2 || //stat (comm) state ppid pgrp session tty
|
||||
name->chars[0] == '\0'
|
||||
)
|
||||
return "sscanf(stat) failed";
|
||||
|
||||
ffStrbufRecalculateLength(name);
|
||||
if (tty)
|
||||
*tty = tty_ & 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int)pid);
|
||||
ssize_t nRead = ffReadFileBuffer(procFilePath, name);
|
||||
if(nRead <= 0)
|
||||
return "ffReadFileBuffer(/proc/pid/comm, name) failed";
|
||||
ffStrbufTrimRightSpace(name);
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
struct kinfo_proc proc;
|
||||
size_t size = sizeof(proc);
|
||||
if(sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}, 4,
|
||||
&proc, &size,
|
||||
NULL, 0
|
||||
))
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
|
||||
ffStrbufSetS(name, proc.kp_proc.p_comm); //trancated to 16 chars
|
||||
if (ppid)
|
||||
*ppid = (pid_t)proc.kp_eproc.e_ppid;
|
||||
if (tty)
|
||||
{
|
||||
*tty = ((proc.kp_eproc.e_tdev >> 24) & 0xFF) == 0x10
|
||||
? proc.kp_eproc.e_tdev & 0xFFFFFF
|
||||
: -1;
|
||||
}
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
struct kinfo_proc proc;
|
||||
size_t size = sizeof(proc);
|
||||
if(sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}, 4,
|
||||
&proc, &size,
|
||||
NULL, 0
|
||||
))
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
|
||||
ffStrbufSetS(name, proc.ki_comm);
|
||||
if (ppid)
|
||||
*ppid = (pid_t)proc.ki_ppid;
|
||||
if (tty)
|
||||
{
|
||||
if (proc.ki_tdev != NODEV && proc.ki_flag & P_CONTROLT)
|
||||
{
|
||||
const char* ttyName = devname(proc.ki_tdev, S_IFCHR);
|
||||
if (ffStrStartsWith(ttyName, "pts/"))
|
||||
*tty = (int32_t) strtol(ttyName + strlen("pts/"), NULL, 10);
|
||||
else
|
||||
*tty = -1;
|
||||
}
|
||||
else
|
||||
*tty = -1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
return "Unsupported platform";
|
||||
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <ntstatus.h>
|
||||
#include <winternl.h>
|
||||
|
||||
enum { FF_PIPE_BUFSIZ = 8192 };
|
||||
|
||||
@@ -124,3 +126,46 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ffProcessGetInfoWindows(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrbuf* exe, const char** exeName, FFstrbuf* exePath, bool* gui)
|
||||
{
|
||||
FF_AUTO_CLOSE_FD HANDLE hProcess = pid == 0
|
||||
? GetCurrentProcess()
|
||||
: OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
|
||||
|
||||
if (gui)
|
||||
*gui = GetGuiResources(hProcess, GR_GDIOBJECTS) > 0;
|
||||
|
||||
if(ppid)
|
||||
{
|
||||
PROCESS_BASIC_INFORMATION info = {};
|
||||
ULONG size;
|
||||
if(NT_SUCCESS(NtQueryInformationProcess(hProcess, ProcessBasicInformation, &info, sizeof(info), &size)))
|
||||
{
|
||||
assert(size == sizeof(info));
|
||||
*ppid = (uint32_t)info.InheritedFromUniqueProcessId;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
if(exe)
|
||||
{
|
||||
DWORD bufSize = exe->allocated;
|
||||
if(QueryFullProcessImageNameA(hProcess, 0, exe->chars, &bufSize))
|
||||
{
|
||||
// We use full path here
|
||||
// Querying command line of remote processes in Windows requires either WMI or ReadProcessMemory
|
||||
exe->length = bufSize;
|
||||
if (exePath) ffStrbufSet(exePath, exe);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
if(pname && exeName)
|
||||
{
|
||||
*exeName = exe->chars + ffStrbufLastIndexC(exe, '\\') + 1;
|
||||
ffStrbufSetS(pname, *exeName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+88
-90
@@ -6,45 +6,6 @@
|
||||
|
||||
#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 FFInitState initState = FF_INITSTATE_UNINITIALIZED; \
|
||||
if(initState != FF_INITSTATE_UNINITIALIZED) {\
|
||||
return initState == FF_INITSTATE_SUCCESSFUL ? &data : NULL; \
|
||||
} \
|
||||
initState = FF_INITSTATE_SUCCESSFUL; \
|
||||
void* libraryHandle = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL); \
|
||||
if(libraryHandle == NULL) { \
|
||||
initState = FF_INITSTATE_FAILED; \
|
||||
return NULL; \
|
||||
} \
|
||||
|
||||
#define FF_LIBRARY_DATA_LOAD_SYMBOL(symbolName) \
|
||||
data.ff ## symbolName = dlsym(libraryHandle, #symbolName); \
|
||||
if(data.ff ## symbolName == NULL) { \
|
||||
dlclose(libraryHandle); \
|
||||
initState = FF_INITSTATE_FAILED; \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
#define FF_LIBRARY_DATA_LOAD_RETURN \
|
||||
initState = FF_INITSTATE_SUCCESSFUL; \
|
||||
return &data;
|
||||
|
||||
#define FF_LIBRARY_DATA_LOAD_ERROR \
|
||||
{ \
|
||||
dlclose(libraryHandle); \
|
||||
initState = FF_INITSTATE_FAILED; \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_GIO
|
||||
#include <gio/gio.h>
|
||||
|
||||
@@ -88,32 +49,39 @@ typedef struct GSettingsData
|
||||
FF_LIBRARY_SYMBOL(g_settings_schema_source_get_default)
|
||||
GSettingsSchemaSource* schemaSource;
|
||||
GVariantGetters variantGetters;
|
||||
|
||||
bool inited;
|
||||
} GSettingsData;
|
||||
|
||||
static const GSettingsData* getGSettingsData(void)
|
||||
{
|
||||
FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance.config.library.libGIO, "libgio-2.0" FF_LIBRARY_EXTENSION, 1);
|
||||
static GSettingsData data;
|
||||
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_source_lookup)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_has_key)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_new_full)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_get_value)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_get_user_value)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_get_default_value)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_source_get_default)
|
||||
if (!data.inited)
|
||||
{
|
||||
data.inited = true;
|
||||
FF_LIBRARY_LOAD(libgsettings, &instance.config.library.libGIO, NULL, "libgio-2.0" FF_LIBRARY_EXTENSION, 1);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_source_lookup, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_has_key, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_new_full, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_value, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_user_value, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_get_default_value, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_source_get_default, NULL)
|
||||
|
||||
#define data data.variantGetters
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_dup_string)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_boolean)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_int32)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_unref);
|
||||
#undef data
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_dup_string, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_get_boolean, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_get_int32, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data.variantGetters, g_variant_unref, NULL);
|
||||
|
||||
data.schemaSource = data.ffg_settings_schema_source_get_default();
|
||||
if(data.schemaSource == NULL)
|
||||
FF_LIBRARY_DATA_LOAD_ERROR
|
||||
data.schemaSource = data.ffg_settings_schema_source_get_default();
|
||||
if (data.schemaSource)
|
||||
libgsettings = NULL;
|
||||
}
|
||||
if(!data.schemaSource)
|
||||
return NULL;
|
||||
|
||||
FF_LIBRARY_DATA_LOAD_RETURN
|
||||
return &data;
|
||||
}
|
||||
|
||||
FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const char* key, FFvarianttype type)
|
||||
@@ -161,27 +129,34 @@ typedef struct DConfData
|
||||
FF_LIBRARY_SYMBOL(dconf_client_new)
|
||||
GVariantGetters variantGetters;
|
||||
DConfClient* client;
|
||||
|
||||
bool inited;
|
||||
} DConfData;
|
||||
|
||||
static const DConfData* getDConfData(void)
|
||||
{
|
||||
FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance.config.library.libDConf, "libdconf" FF_LIBRARY_EXTENSION, 2);
|
||||
static DConfData data;
|
||||
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_read_full)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_new)
|
||||
if (!data.inited)
|
||||
{
|
||||
data.inited = true;
|
||||
|
||||
#define data data.variantGetters
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_dup_string)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_boolean)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_get_int32)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(g_variant_unref)
|
||||
#undef data
|
||||
FF_LIBRARY_LOAD(libdconf, &instance.config.library.libDConf, NULL, "libdconf" FF_LIBRARY_EXTENSION, 2);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_read_full, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_new, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_dup_string, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_get_boolean, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_get_int32, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_unref, NULL)
|
||||
|
||||
data.client = data.ffdconf_client_new();
|
||||
if(data.client == NULL)
|
||||
FF_LIBRARY_DATA_LOAD_ERROR
|
||||
data.client = data.ffdconf_client_new();
|
||||
if (data.client)
|
||||
libdconf = NULL;
|
||||
}
|
||||
if(!data.client)
|
||||
return NULL;
|
||||
|
||||
FF_LIBRARY_DATA_LOAD_RETURN
|
||||
return &data;
|
||||
}
|
||||
|
||||
FFvariant ffSettingsGetDConf(const char* key, FFvarianttype type)
|
||||
@@ -232,23 +207,35 @@ typedef struct XFConfData
|
||||
FF_LIBRARY_SYMBOL(xfconf_channel_get_bool)
|
||||
FF_LIBRARY_SYMBOL(xfconf_channel_get_int)
|
||||
FF_LIBRARY_SYMBOL(xfconf_init)
|
||||
|
||||
bool inited;
|
||||
} XFConfData;
|
||||
|
||||
static const XFConfData* getXFConfData(void)
|
||||
{
|
||||
FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance.config.library.libXFConf, "libxfconf-0" FF_LIBRARY_EXTENSION, 4);
|
||||
static XFConfData data;
|
||||
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_get)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_has_property)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_get_string)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_get_bool)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_get_int)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_init)
|
||||
if (!data.inited)
|
||||
{
|
||||
data.inited = true;
|
||||
FF_LIBRARY_LOAD(libxfconf, &instance.config.library.libXFConf, NULL, "libxfconf-0" FF_LIBRARY_EXTENSION, 4);
|
||||
|
||||
if(data.ffxfconf_init(NULL) == false)
|
||||
FF_LIBRARY_DATA_LOAD_ERROR
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_get, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_has_property, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_get_string, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_get_bool, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_get_int, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_init, NULL)
|
||||
if(!data.ffxfconf_init(NULL))
|
||||
data.ffxfconf_init = NULL;
|
||||
else
|
||||
libxfconf = NULL;
|
||||
}
|
||||
|
||||
FF_LIBRARY_DATA_LOAD_RETURN
|
||||
if(!data.ffxfconf_init)
|
||||
return NULL;
|
||||
|
||||
return &data;
|
||||
}
|
||||
|
||||
FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvarianttype type)
|
||||
@@ -294,22 +281,33 @@ typedef struct SQLiteData
|
||||
FF_LIBRARY_SYMBOL(sqlite3_column_text)
|
||||
FF_LIBRARY_SYMBOL(sqlite3_finalize)
|
||||
FF_LIBRARY_SYMBOL(sqlite3_close)
|
||||
|
||||
bool inited;
|
||||
} SQLiteData;
|
||||
|
||||
static const SQLiteData* getSQLiteData(void)
|
||||
{
|
||||
FF_LIBRARY_DATA_LOAD_INIT(SQLiteData, instance.config.library.libSQLite3, "libsqlite3" FF_LIBRARY_EXTENSION, 1);
|
||||
static SQLiteData data;
|
||||
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_open_v2)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_prepare_v2)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_step)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_data_count)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_column_int)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_column_text)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_finalize)
|
||||
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_close)
|
||||
if (!data.inited)
|
||||
{
|
||||
data.inited = true;
|
||||
FF_LIBRARY_LOAD(libsqlite, &instance.config.library.libSQLite3, NULL, "libsqlite3" FF_LIBRARY_EXTENSION, 1);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_open_v2, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_prepare_v2, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_step, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_data_count, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_column_int, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_column_text, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_finalize, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_close, NULL)
|
||||
libsqlite = NULL;
|
||||
}
|
||||
|
||||
FF_LIBRARY_DATA_LOAD_RETURN
|
||||
if (!data.ffsqlite3_close)
|
||||
return NULL;
|
||||
|
||||
return &data;
|
||||
}
|
||||
|
||||
int ffSettingsGetSQLite3Int(const char* dbPath, const char* query)
|
||||
|
||||
+11
-2
@@ -457,6 +457,14 @@
|
||||
"type": "color"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "color-separator",
|
||||
"desc": "Set the color of the key-value separator",
|
||||
"remark": "See `-h color` for the list of available colors",
|
||||
"arg": {
|
||||
"type": "color"
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "color",
|
||||
"desc": "Set the color of both the keys and title",
|
||||
@@ -534,10 +542,11 @@
|
||||
"desc": "Set the percentage output type",
|
||||
"remark": [
|
||||
"1 for percentage number",
|
||||
"2 for bar",
|
||||
"2 for multi-color bar",
|
||||
"3 for both",
|
||||
"6 for bar only",
|
||||
"9 for colored number"
|
||||
"9 for colored number",
|
||||
"10 for monochrome bar"
|
||||
],
|
||||
"arg": {
|
||||
"type": "num",
|
||||
|
||||
@@ -4,6 +4,10 @@ For example the format string "Values: {1} ({2})", with the values "First" and "
|
||||
The format string can contain placeholders in any order and have multiple occurrences.
|
||||
To include spaces when setting from the command line, surround the whole string with double quotes (").
|
||||
|
||||
In 2.14.0 or newer, the value indices can be meaningful named tags.
|
||||
For example: "--title-format '{user-name-colored}{at-symbol-colored}{host-name-colored}'" is equivalent to "--title-format '{6}{7}{8}'"
|
||||
See "fastfetch -h title-format" for all supported tags.
|
||||
|
||||
If the value index is missing, meaning the placeholder is "{}", an internal counter sets the value index.
|
||||
This means that the format string "Values: {1} ({2})" is equivalent to "Values: {} ({})".
|
||||
Note that this counter only counts empty placeholders, so the format string "{2} {} {}" will contain the second value, then the first, and then the second again.
|
||||
@@ -16,7 +20,7 @@ To only print something if a variable is set, use "{?<index>} ... {?}".
|
||||
For example, to only print a second value if it is set, use "{?2} Second value: {2}{?}".
|
||||
If a "{?}" is found without an opener, it is printed as is.
|
||||
|
||||
To only print something if a variable is not set, do the same as with if, just replace every '?' with a '!'.
|
||||
To only print something if a variable is not set, do the same as with if, just replace every '?' with a '/'.
|
||||
For example to print a fallback for a second value if it is not set, use "{?2}{2}{?}{/2}Second value fallback{/}".
|
||||
|
||||
To stop formatting at any point in the format string, use "{-}".
|
||||
@@ -24,7 +28,7 @@ To stop formatting at any point in the format string, use "{-}".
|
||||
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}...{#}".
|
||||
For example to print something pink and underline, use "{#4;35}...{#}". "{#underline_magenta}" is also supported. See `fastfetch -h color` for detail.
|
||||
Information about what the numbers mean can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters.
|
||||
Which escape codes are supported and how they look is defined by your terminal.
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
static const char* detectWithBacklight(FFlist* result)
|
||||
@@ -58,14 +57,14 @@ static const char* detectWithBacklight(FFlist* result)
|
||||
{
|
||||
ffStrbufSubstrBeforeLastC(&brightness->name, '/'); // remove "/edid"
|
||||
ffStrbufSubstrAfterLastC(&brightness->name, '/'); // try getting DRM connector name
|
||||
if(isdigit(brightness->name.chars[0]))
|
||||
if(ffCharIsDigit(brightness->name.chars[0]))
|
||||
{
|
||||
// PCI address or some unknown path, give up
|
||||
ffStrbufSetS(&brightness->name, entry->d_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ffStrbufStartsWithS(&brightness->name, "card") && isdigit(brightness->name.chars[4]))
|
||||
if(ffStrbufStartsWithS(&brightness->name, "card") && ffCharIsDigit(brightness->name.chars[4]))
|
||||
ffStrbufSubstrAfterFirstC(&brightness->name, '-');
|
||||
}
|
||||
}
|
||||
@@ -109,14 +108,19 @@ static const char* detectWithDdcci(FFBrightnessOptions* options, FFlist* result)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_free_any_vcp_value)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_close_display)
|
||||
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
__typeof__(&ddca_init) ffddca_init = dlsym(libddcutil, "ddca_init");
|
||||
if (ffddca_init)
|
||||
#else
|
||||
__typeof__(&ddca_init) ffddca_init = ddca_init;
|
||||
#endif
|
||||
{
|
||||
FF_SUPPRESS_IO();
|
||||
// Ref: https://github.com/rockowitz/ddcutil/issues/344
|
||||
if (ffddca_init(NULL, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0)
|
||||
return "ddca_init() failed";
|
||||
}
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
else
|
||||
{
|
||||
__typeof__(&ddca_set_default_sleep_multiplier) ffddca_set_default_sleep_multiplier = dlsym(libddcutil, "ddca_set_default_sleep_multiplier");
|
||||
@@ -125,6 +129,7 @@ static const char* detectWithDdcci(FFBrightnessOptions* options, FFlist* result)
|
||||
|
||||
libddcutil = NULL; // Don't dlclose libddcutil. See https://github.com/rockowitz/ddcutil/issues/330
|
||||
}
|
||||
#endif
|
||||
|
||||
FF_AUTO_FREE DDCA_Display_Info_List* infoList = NULL;
|
||||
if (ffddca_get_display_info_list2(false, &infoList) < 0)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <sys/sysinfo.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "common/settings.h"
|
||||
@@ -139,7 +138,7 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options)
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if (ffStrStartsWith(entry->d_name, "policy") && isdigit(entry->d_name[strlen("policy")]))
|
||||
if (ffStrStartsWith(entry->d_name, "policy") && ffCharIsDigit(entry->d_name[strlen("policy")]))
|
||||
{
|
||||
ffStrbufAppendS(&path, entry->d_name);
|
||||
uint32_t fbase = getFrequency(&path, "/base_frequency", NULL, &buffer);
|
||||
|
||||
@@ -106,11 +106,16 @@ static void getMate(FFstrbuf* result, FFDEOptions* options)
|
||||
|
||||
static const char* getXfce4ByLib(FFstrbuf* result)
|
||||
{
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
const char* xfce_version_string(void); // from `xfce4/libxfce4util/xfce-misutils.h
|
||||
FF_LIBRARY_LOAD(xfce4util, NULL, "dlopen libxfce4util" FF_LIBRARY_EXTENSION "failed", "libxfce4util" FF_LIBRARY_EXTENSION, 7);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xfce4util, xfce_version_string);
|
||||
ffStrbufSetS(result, ffxfce_version_string());
|
||||
return NULL;
|
||||
#else
|
||||
FF_UNUSED(result);
|
||||
return "dlopen is disabled";
|
||||
#endif
|
||||
}
|
||||
|
||||
static void getXFCE4(FFstrbuf* result, FFDEOptions* options)
|
||||
|
||||
@@ -194,7 +194,7 @@ static const char* drmGetNameByConnId(uint32_t connId, FFstrbuf* name)
|
||||
|
||||
static const char* drmConnectLibdrm(FFDisplayServerResult* result)
|
||||
{
|
||||
FF_LIBRARY_LOAD(libdrm, &instance.config.library.libdrm, "dlopen(libdrm)" FF_LIBRARY_EXTENSION " failed", "libdrm" FF_LIBRARY_EXTENSION, 2)
|
||||
FF_LIBRARY_LOAD(libdrm, &instance.config.library.libdrm, "dlopen libdrm" FF_LIBRARY_EXTENSION " failed", "libdrm" FF_LIBRARY_EXTENSION, 2)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmGetDevices)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetResources)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetConnectorCurrent)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -320,7 +319,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
|
||||
while((dirent = readdir(procdir)) != NULL)
|
||||
{
|
||||
//Match only folders starting with a number (the pid folders)
|
||||
if(dirent->d_type != DT_DIR || !isdigit(dirent->d_name[0]))
|
||||
if(dirent->d_type != DT_DIR || !ffCharIsDigit(dirent->d_name[0]))
|
||||
continue;
|
||||
|
||||
ffStrbufAppendS(&procPath, dirent->d_name);
|
||||
|
||||
@@ -4,13 +4,27 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
static inline char* realpath(const char* restrict file_name, char* restrict resolved_name)
|
||||
{
|
||||
return _fullpath(resolved_name, file_name, _MAX_PATH);
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* ffDetectEditor(FFEditorResult* result)
|
||||
{
|
||||
ffStrbufSetS(&result->name, getenv("VISUAL"));
|
||||
if (result->name.length == 0)
|
||||
if (result->name.length)
|
||||
result->type = "Visual";
|
||||
else
|
||||
{
|
||||
ffStrbufSetS(&result->name, getenv("EDITOR"));
|
||||
if (result->name.length == 0)
|
||||
return "$VISUAL or $EDITOR not set";
|
||||
if (result->name.length)
|
||||
result->type = "Editor";
|
||||
else
|
||||
return "$VISUAL or $EDITOR not set";
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
if (result->name.chars[0] != '/')
|
||||
@@ -22,6 +36,21 @@ const char* ffDetectEditor(FFEditorResult* result)
|
||||
}) != NULL || result->path.length == 0)
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if (!(result->name.length > 3 && ffCharIsEnglishAlphabet(result->name.chars[0]) && result->name.chars[1] == ':' && result->name.chars[2] == '\\'))
|
||||
{
|
||||
char buf[32];
|
||||
uint32_t len = GetSystemDirectoryA(buf, sizeof(buf));
|
||||
if (len < strlen("C:\\WINDOWS\\system32")) return NULL;
|
||||
strncpy(buf + len, "\\where.exe", sizeof(buf) - len);
|
||||
if (ffProcessAppendStdOut(&result->path, (char* const[]){
|
||||
buf,
|
||||
result->name.chars,
|
||||
NULL,
|
||||
}) != NULL || result->path.length == 0)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
ffStrbufSet(&result->path, &result->name);
|
||||
|
||||
@@ -30,29 +59,45 @@ const char* ffDetectEditor(FFEditorResult* result)
|
||||
return NULL;
|
||||
|
||||
ffStrbufSetS(&result->path, buf);
|
||||
const char* exe = &result->path.chars[ffStrbufLastIndexC(&result->path, '/')];
|
||||
if (!*exe) return NULL;
|
||||
++exe;
|
||||
result->exe = exe;
|
||||
|
||||
{
|
||||
uint32_t index = ffStrbufLastIndexC(&result->path,
|
||||
#ifndef _WIN32
|
||||
'/'
|
||||
#else
|
||||
'\\'
|
||||
#endif
|
||||
);
|
||||
if (index == result->path.length)
|
||||
return NULL;
|
||||
ffStrbufSetS(&result->exe, &result->path.chars[index + 1]);
|
||||
if (!result->exe.length)
|
||||
return NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (ffStrbufEndsWithS(&result->exe, ".exe"))
|
||||
ffStrbufSubstrBefore(&result->exe, result->exe.length - 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* param = NULL;
|
||||
if (
|
||||
ffStrEquals(exe, "nano") ||
|
||||
ffStrEquals(exe, "vim") ||
|
||||
ffStrEquals(exe, "nvim") ||
|
||||
ffStrEquals(exe, "micro") ||
|
||||
ffStrEquals(exe, "emacs") ||
|
||||
ffStrStartsWith(exe, "emacs-") || // emacs-29.3
|
||||
ffStrEquals(exe, "hx") ||
|
||||
ffStrEquals(exe, "code") ||
|
||||
ffStrEquals(exe, "sublime_text")
|
||||
ffStrbufEqualS(&result->exe, "nano") ||
|
||||
ffStrbufEqualS(&result->exe, "vim") ||
|
||||
ffStrbufEqualS(&result->exe, "nvim") ||
|
||||
ffStrbufEqualS(&result->exe, "micro") ||
|
||||
ffStrbufEqualS(&result->exe, "emacs") ||
|
||||
ffStrbufStartsWithS(&result->exe, "emacs-") || // emacs-29.3
|
||||
ffStrbufEqualS(&result->exe, "hx") ||
|
||||
ffStrbufEqualS(&result->exe, "code") ||
|
||||
ffStrbufEqualS(&result->exe, "sublime_text")
|
||||
) param = "--version";
|
||||
else if (
|
||||
ffStrEquals(exe, "kak") ||
|
||||
ffStrEquals(exe, "pico")
|
||||
ffStrbufEqualS(&result->exe, "kak") ||
|
||||
ffStrbufEqualS(&result->exe, "pico")
|
||||
) param = "-version";
|
||||
else if (
|
||||
ffStrEquals(exe, "ne")
|
||||
ffStrbufEqualS(&result->exe, "ne")
|
||||
) param = "-h";
|
||||
else return NULL;
|
||||
|
||||
@@ -69,7 +114,7 @@ const char* ffDetectEditor(FFEditorResult* result)
|
||||
for (uint32_t iStart = 0; iStart < result->version.length; ++iStart)
|
||||
{
|
||||
char c = result->version.chars[iStart];
|
||||
if (c >= '0' && c <= '9')
|
||||
if (ffCharIsDigit(c))
|
||||
{
|
||||
for (uint32_t iEnd = iStart + 1; iEnd < result->version.length; ++iEnd)
|
||||
{
|
||||
@@ -85,7 +130,6 @@ const char* ffDetectEditor(FFEditorResult* result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
typedef struct FFEditorResult
|
||||
{
|
||||
const char* type;
|
||||
FFstrbuf name;
|
||||
const char* exe;
|
||||
FFstrbuf exe;
|
||||
FFstrbuf path;
|
||||
FFstrbuf version;
|
||||
} FFEditorResult;
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include "common/io/io.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path)
|
||||
{
|
||||
uint32_t baseLen = path->length;
|
||||
@@ -71,7 +68,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
|
||||
{
|
||||
if (!ffStrStartsWith(entry->d_name, "js"))
|
||||
continue;
|
||||
if (!isdigit(entry->d_name[2]))
|
||||
if (!ffCharIsDigit(entry->d_name[2]))
|
||||
continue;
|
||||
|
||||
ffStrbufAppendS(&path, entry->d_name);
|
||||
|
||||
@@ -19,6 +19,8 @@ struct FFNvmlData {
|
||||
|
||||
const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName)
|
||||
{
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
|
||||
if (!nvmlData.inited)
|
||||
{
|
||||
nvmlData.inited = true;
|
||||
@@ -127,4 +129,11 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
#else
|
||||
|
||||
FF_UNUSED(cond, result, soName);
|
||||
return "dlopen is disabled";
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -31,8 +31,13 @@ const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FF
|
||||
FF_LIBRARY_LOAD(libdxcore, nullptr, "dlopen libdxcore.so failed. Make sure WSLg is enabled", "/usr/lib/wsl/lib/libdxcore" FF_LIBRARY_EXTENSION, 4)
|
||||
// DXCoreCreateAdapterFactory is a reloaded function, so we can't use FF_LIBRARY_LOAD_SYMBOL_MESSAGE here
|
||||
typedef HRESULT (*DXCoreCreateAdapterFactory_t)(REFIID riid, void** ppvFactory);
|
||||
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) dlsym(libdxcore, "DXCoreCreateAdapterFactory");
|
||||
if(ffDXCoreCreateAdapterFactory == nullptr) return "dlsym DXCoreCreateAdapterFactory failed";
|
||||
#else
|
||||
auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) DXCoreCreateAdapterFactory;
|
||||
#endif
|
||||
|
||||
IDXCoreAdapterFactory *factory = nullptr;
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFInitSystemResult
|
||||
{
|
||||
FFstrbuf name;
|
||||
FFstrbuf exe;
|
||||
FFstrbuf version;
|
||||
uint32_t pid;
|
||||
} FFInitSystemResult;
|
||||
|
||||
const char* ffDetectInitSystem(FFInitSystemResult* result);
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "initsystem.h"
|
||||
#include "common/processing.h"
|
||||
|
||||
const char* ffDetectInitSystem(FFInitSystemResult* result)
|
||||
{
|
||||
const char* error = ffProcessGetBasicInfoLinux((int) result->pid, &result->name, NULL, NULL);
|
||||
if (error) return error;
|
||||
|
||||
const char* _;
|
||||
// In linux /proc/1/exe is not readable
|
||||
ffProcessGetInfoLinux((int) result->pid, &result->name, &result->exe, &_, NULL);
|
||||
if (result->exe.chars[0] == '/')
|
||||
{
|
||||
// In some old system, /sbin/init is a symlink
|
||||
char buf[PATH_MAX];
|
||||
if (realpath(result->exe.chars, buf))
|
||||
ffStrbufSetS(&result->exe, buf);
|
||||
}
|
||||
|
||||
if (ffStrbufEqualS(&result->name, "systemd"))
|
||||
{
|
||||
if (ffProcessAppendStdOut(&result->version, (char* const[]) {
|
||||
ffStrbufEndsWithS(&result->exe, "/systemd") ? result->exe.chars : "systemctl", // use exe path in case users have another systemd installed
|
||||
"--version",
|
||||
NULL,
|
||||
}) == NULL && result->version.length)
|
||||
{
|
||||
uint32_t iStart = ffStrbufFirstIndexC(&result->version, '(');
|
||||
if (iStart < result->version.length)
|
||||
{
|
||||
uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ')');
|
||||
ffStrbufSubstrBefore(&result->version, iEnd);
|
||||
ffStrbufSubstrAfter(&result->version, iStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ffStrbufEqualS(&result->name, "launchd"))
|
||||
{
|
||||
if (ffProcessAppendStdOut(&result->version, (char* const[]) {
|
||||
"/bin/launchctl",
|
||||
"version",
|
||||
NULL,
|
||||
}) == NULL && result->version.length)
|
||||
{
|
||||
uint32_t iStart = ffStrbufFirstIndexS(&result->version, "Version ");
|
||||
if (iStart < result->version.length)
|
||||
{
|
||||
iStart += strlen("Version");
|
||||
uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ':');
|
||||
ffStrbufSubstrBefore(&result->version, iEnd);
|
||||
ffStrbufSubstrAfter(&result->version, iStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "initsystem.h"
|
||||
|
||||
const char* ffDetectInitSystem(FF_MAYBE_UNUSED FFInitSystemResult* result)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -157,6 +157,12 @@ static bool detectDebianDerived(FFOSResult* result)
|
||||
ffStrbufSetNS(&result->versionID, versionEnd - versionStart, result->prettyName.chars + versionStart);
|
||||
return true;
|
||||
}
|
||||
else if (ffStrbufStartsWithS(&result->name, "Loc-OS"))
|
||||
{
|
||||
ffStrbufSetS(&result->id, "locos");
|
||||
ffStrbufSetS(&result->idLike, "debian");
|
||||
return true;
|
||||
}
|
||||
else if (ffPathExists("/usr/bin/pveversion", FF_PATHTYPE_FILE))
|
||||
{
|
||||
ffStrbufSetS(&result->id, "pve");
|
||||
|
||||
@@ -4,6 +4,7 @@ extern "C" {
|
||||
}
|
||||
#include "util/windows/unicode.hpp"
|
||||
#include "util/windows/wmi.hpp"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
static const char* getOsNameByWmi(FFstrbuf* osName)
|
||||
{
|
||||
@@ -73,8 +74,8 @@ void ffDetectOSImpl(FFOSResult* os)
|
||||
if(ffStrbufEndsWithC(&os->prettyName, 'r'))
|
||||
{
|
||||
if(os->variant.chars[0] == 'R' &&
|
||||
isdigit(os->variant.chars[1]) &&
|
||||
(os->variant.chars[2] == '\0' || os->variant.chars[2] == ' '))
|
||||
ffCharIsDigit(os->variant.chars[1]) &&
|
||||
(os->variant.chars[2] == '\0' || os->variant.chars[2] == ' '))
|
||||
{
|
||||
ffStrbufAppendF(&os->version, " R%c", os->variant.chars[1]);
|
||||
ffStrbufSubstrAfter(&os->variant, strlen("Rx ") - 1);
|
||||
|
||||
@@ -14,6 +14,9 @@ typedef struct FFPackagesResult
|
||||
uint32_t eopkg;
|
||||
uint32_t flatpakSystem;
|
||||
uint32_t flatpakUser;
|
||||
uint32_t guixHome;
|
||||
uint32_t guixSystem;
|
||||
uint32_t guixUser;
|
||||
uint32_t lpkg;
|
||||
uint32_t lpkgbuild;
|
||||
uint32_t nixDefault;
|
||||
|
||||
@@ -141,11 +141,11 @@ static bool isValidNixPkg(FFstrbuf* pkg)
|
||||
switch (state)
|
||||
{
|
||||
case START:
|
||||
if (c >= '0' && c <= '9')
|
||||
if (ffCharIsDigit(c))
|
||||
state = DIGIT;
|
||||
break;
|
||||
case DIGIT:
|
||||
if (c >= '0' && c <= '9')
|
||||
if (ffCharIsDigit(c))
|
||||
continue;
|
||||
if (c == '.')
|
||||
state = DOT;
|
||||
@@ -153,7 +153,7 @@ static bool isValidNixPkg(FFstrbuf* pkg)
|
||||
state = START;
|
||||
break;
|
||||
case DOT:
|
||||
if (c >= '0' && c <= '9')
|
||||
if (ffCharIsDigit(c))
|
||||
state = MATCH;
|
||||
else
|
||||
state = START;
|
||||
@@ -408,6 +408,39 @@ static uint32_t getAM(FFstrbuf* baseDir)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t getGuixPackagesImpl(char* path)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(1024);
|
||||
|
||||
ffProcessAppendStdOut(&output, (char* const[]) {
|
||||
"guix",
|
||||
"package",
|
||||
"-p",
|
||||
path,
|
||||
"-I",
|
||||
NULL
|
||||
});
|
||||
|
||||
|
||||
//Each package is a new line in the output.
|
||||
// If at least one line is found, add 1 for the last line.
|
||||
uint32_t count = ffStrbufCountC(&output, '\n');
|
||||
if(count > 0)
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static uint32_t getGuixPackages(FFstrbuf* baseDir, const char* dirname)
|
||||
{
|
||||
uint32_t baseDirLength = baseDir->length;
|
||||
ffStrbufAppendS(baseDir, dirname);
|
||||
uint32_t num_elements = getGuixPackagesImpl(baseDir->chars);
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLength);
|
||||
return num_elements;
|
||||
}
|
||||
|
||||
static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts, FFPackagesOptions* options)
|
||||
{
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_APK_BIT)) packageCounts->apk += getNumStrings(baseDir, "/lib/apk/db/installed", "C:Q");
|
||||
@@ -436,6 +469,10 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts,
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_OPKG_BIT)) packageCounts->opkg += getNumStrings(baseDir, "/usr/lib/opkg/status", "Package:"); // openwrt
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_AM_BIT)) packageCounts->am = getAM(baseDir);
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_SORCERY_BIT)) packageCounts->sorcery += getNumStrings(baseDir, "/var/state/sorcery/packages", ":installed:");
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_GUIX_BIT))
|
||||
{
|
||||
packageCounts->guixSystem += getGuixPackages(baseDir, "/run/current-system/profile");
|
||||
}
|
||||
}
|
||||
|
||||
static void getPackageCountsRegular(FFstrbuf* baseDir, FFPackagesResult* packageCounts, FFPackagesOptions* options)
|
||||
@@ -532,6 +569,12 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
|
||||
result->nixUser += getNixPackages(&stateDir, "nix/profile");
|
||||
}
|
||||
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_GUIX_BIT))
|
||||
{
|
||||
result->guixUser += getGuixPackages(&baseDir, ".guix-profile");
|
||||
result->guixHome += getGuixPackages(&baseDir, ".guix-home/profile");
|
||||
}
|
||||
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_FLATPAK_BIT))
|
||||
result->flatpakUser = getFlatpak(&baseDir, "/.local/share/flatpak");
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "processes.h"
|
||||
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result)
|
||||
{
|
||||
@@ -15,7 +14,7 @@ const char* ffDetectProcesses(uint32_t* result)
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if (entry->d_type == DT_DIR && isdigit(entry->d_name[0]))
|
||||
if (entry->d_type == DT_DIR && ffCharIsDigit(entry->d_name[0]))
|
||||
++num;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,11 @@
|
||||
#include "common/processing.h"
|
||||
#include "common/thread.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
static void setExeName(FFstrbuf* exe, const char** exeName)
|
||||
{
|
||||
assert(exe->length > 0);
|
||||
@@ -24,197 +17,8 @@ static void setExeName(FFstrbuf* exe, const char** exeName)
|
||||
*exeName = exe->chars + lastSlashIndex + 1;
|
||||
}
|
||||
|
||||
static void getProcessInformation(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, const char** exeName, FFstrbuf* exePath)
|
||||
{
|
||||
assert(processName->length > 0);
|
||||
ffStrbufClear(exe);
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
char filePath[64];
|
||||
snprintf(filePath, sizeof(filePath), "/proc/%d/cmdline", (int)pid);
|
||||
|
||||
if(ffAppendFileBuffer(filePath, exe))
|
||||
{
|
||||
ffStrbufTrimRightSpace(exe);
|
||||
ffStrbufRecalculateLength(exe); //Trim the arguments
|
||||
ffStrbufTrimLeft(exe, '-'); //Login shells start with a dash
|
||||
}
|
||||
|
||||
snprintf(filePath, sizeof(filePath), "/proc/%d/exe", (int)pid);
|
||||
ffStrbufEnsureFixedLengthFree(exePath, PATH_MAX);
|
||||
ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1);
|
||||
if (length > 0) // doesn't contain trailing NUL
|
||||
{
|
||||
exePath->chars[length] = '\0';
|
||||
exePath->length = (uint32_t) length;
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
size_t len = 0;
|
||||
int mibs[] = { CTL_KERN, KERN_PROCARGS2, pid };
|
||||
if (sysctl(mibs, sizeof(mibs) / sizeof(*mibs), NULL, &len, NULL, 0) == 0)
|
||||
{
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
//don't know why if don't let len longer, proArgs2 and len will change during the following sysctl() in old MacOS version.
|
||||
len++;
|
||||
#endif
|
||||
FF_AUTO_FREE char* const procArgs2 = malloc(len);
|
||||
if (sysctl(mibs, sizeof(mibs) / sizeof(*mibs), procArgs2, &len, NULL, 0) == 0)
|
||||
{
|
||||
// https://gist.github.com/nonowarn/770696#file-getargv-c-L46
|
||||
uint32_t argc = *(uint32_t*) procArgs2;
|
||||
const char* realExePath = procArgs2 + sizeof(argc);
|
||||
|
||||
const char* arg0 = memchr(realExePath, '\0', len - (size_t) (realExePath - procArgs2));
|
||||
ffStrbufSetNS(exePath, (uint32_t) (arg0 - realExePath), realExePath);
|
||||
|
||||
do arg0++; while (*arg0 == '\0');
|
||||
assert(arg0 < procArgs2 + len);
|
||||
if (*arg0 == '-') arg0++; // Login shells
|
||||
|
||||
ffStrbufSetS(exe, arg0);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
size_t size = ARG_MAX;
|
||||
FF_AUTO_FREE char* args = malloc(size);
|
||||
|
||||
static_assert(ARG_MAX > PATH_MAX, "");
|
||||
|
||||
if(sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, pid}, 4,
|
||||
args, &size,
|
||||
NULL, 0
|
||||
) == 0)
|
||||
ffStrbufSetNS(exePath, (uint32_t) (size - 1), args);
|
||||
|
||||
size = ARG_MAX;
|
||||
if(sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_ARGS, pid}, 4,
|
||||
args, &size,
|
||||
NULL, 0
|
||||
) == 0)
|
||||
{
|
||||
char* arg0 = args;
|
||||
size_t arg0Len = strlen(args);
|
||||
if (size > arg0Len + 1)
|
||||
{
|
||||
char* p = (char*) memrchr(args, '/', arg0Len);
|
||||
if (p)
|
||||
{
|
||||
p++;
|
||||
if (ffStrStartsWith(p, "python")) // /usr/local/bin/python3.9 /home/carter/.local/bin/xonsh
|
||||
{
|
||||
arg0 += arg0Len + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (arg0[0] == '-') arg0++;
|
||||
ffStrbufSetS(exe, arg0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if(exe->length == 0)
|
||||
ffStrbufSet(exe, processName);
|
||||
|
||||
setExeName(exe, exeName);
|
||||
}
|
||||
|
||||
static const char* getProcessNameAndPpid(pid_t pid, char* name, pid_t* ppid, int32_t* tty)
|
||||
{
|
||||
if (pid <= 0)
|
||||
return "Invalid pid";
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
char statFilePath[64];
|
||||
snprintf(statFilePath, sizeof(statFilePath), "/proc/%d/stat", (int)pid);
|
||||
char buf[PROC_FILE_BUFFSIZ];
|
||||
ssize_t nRead = ffReadFileData(statFilePath, sizeof(buf) - 1, buf);
|
||||
if(nRead < 0)
|
||||
return "ffReadFileData(statFilePath, sizeof(buf)-1, buf) failed";
|
||||
buf[nRead] = '\0';
|
||||
|
||||
*ppid = 0;
|
||||
static_assert(sizeof(*ppid) == sizeof(int), "");
|
||||
|
||||
int tty_;
|
||||
if(
|
||||
sscanf(buf, "%*s (%255[^)]) %*c %d %*d %*d %d", name, ppid, &tty_) < 2 || //stat (comm) state ppid pgrp session tty
|
||||
!ffStrSet(name) ||
|
||||
*ppid == 0
|
||||
)
|
||||
return "sscanf(stat) failed";
|
||||
|
||||
if (tty)
|
||||
*tty = tty_ & 0xFF;
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
struct kinfo_proc proc;
|
||||
size_t size = sizeof(proc);
|
||||
if(sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}, 4,
|
||||
&proc, &size,
|
||||
NULL, 0
|
||||
))
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
|
||||
*ppid = (pid_t)proc.kp_eproc.e_ppid;
|
||||
strcpy(name, proc.kp_proc.p_comm); //trancated to 16 chars
|
||||
if (tty)
|
||||
{
|
||||
*tty = ((proc.kp_eproc.e_tdev >> 24) & 0xFF) == 0x10
|
||||
? proc.kp_eproc.e_tdev & 0xFFFFFF
|
||||
: -1;
|
||||
}
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
struct kinfo_proc proc;
|
||||
size_t size = sizeof(proc);
|
||||
if(sysctl(
|
||||
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}, 4,
|
||||
&proc, &size,
|
||||
NULL, 0
|
||||
))
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
|
||||
*ppid = (pid_t)proc.ki_ppid;
|
||||
strcpy(name, proc.ki_comm);
|
||||
if (tty)
|
||||
{
|
||||
if (proc.ki_tdev != NODEV && proc.ki_flag & P_CONTROLT)
|
||||
{
|
||||
const char* ttyName = devname(proc.ki_tdev, S_IFCHR);
|
||||
if (ffStrStartsWith(ttyName, "pts/"))
|
||||
*tty = (int32_t) strtol(ttyName + strlen("pts/"), NULL, 10);
|
||||
else
|
||||
*tty = -1;
|
||||
}
|
||||
else
|
||||
*tty = -1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
return "Unsupported platform";
|
||||
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static pid_t getShellInfo(FFShellResult* result, pid_t pid)
|
||||
{
|
||||
char name[256];
|
||||
name[0] = '\0';
|
||||
|
||||
pid_t ppid = 0;
|
||||
int32_t tty = -1;
|
||||
|
||||
@@ -227,35 +31,36 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
|
||||
userShellName = instance.state.platform.userShell.chars + index + 1;
|
||||
}
|
||||
|
||||
while (getProcessNameAndPpid(pid, name, &ppid, &tty) == NULL)
|
||||
while (ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, &tty) == NULL)
|
||||
{
|
||||
if (!ffStrEquals(userShellName, name))
|
||||
if (!ffStrbufEqualS(&result->processName, userShellName))
|
||||
{
|
||||
//Common programs that are between terminal and own process, but are not the shell
|
||||
if(
|
||||
// tty < 0 || //A shell should connect to a tty
|
||||
ffStrEquals(name, "sh") || //This prevents us from detecting things like pipes and redirects, i hope nobody uses plain `sh` as shell
|
||||
ffStrEquals(name, "sudo") ||
|
||||
ffStrEquals(name, "su") ||
|
||||
ffStrEquals(name, "strace") ||
|
||||
ffStrEquals(name, "sshd") ||
|
||||
ffStrEquals(name, "gdb") ||
|
||||
ffStrEquals(name, "lldb") ||
|
||||
ffStrEquals(name, "lldb-mi") ||
|
||||
ffStrEquals(name, "login") ||
|
||||
ffStrEquals(name, "ltrace") ||
|
||||
ffStrEquals(name, "perf") ||
|
||||
ffStrEquals(name, "guake-wrapped") ||
|
||||
ffStrEquals(name, "time") ||
|
||||
ffStrEquals(name, "hyfetch") || //when hyfetch uses fastfetch as backend
|
||||
ffStrEquals(name, "clifm") || //https://github.com/leo-arch/clifm/issues/289
|
||||
ffStrEquals(name, "valgrind") ||
|
||||
ffStrContainsIgnCase(name, "debug") ||
|
||||
ffStrContainsIgnCase(name, "not-found") ||
|
||||
ffStrEndsWith(name, ".sh")
|
||||
ffStrbufEqualS(&result->processName, "sh") || //This prevents us from detecting things like pipes and redirects, i hope nobody uses plain `sh` as shell
|
||||
ffStrbufEqualS(&result->processName, "sudo") ||
|
||||
ffStrbufEqualS(&result->processName, "su") ||
|
||||
ffStrbufEqualS(&result->processName, "strace") ||
|
||||
ffStrbufEqualS(&result->processName, "sshd") ||
|
||||
ffStrbufEqualS(&result->processName, "gdb") ||
|
||||
ffStrbufEqualS(&result->processName, "lldb") ||
|
||||
ffStrbufEqualS(&result->processName, "lldb-mi") ||
|
||||
ffStrbufEqualS(&result->processName, "login") ||
|
||||
ffStrbufEqualS(&result->processName, "ltrace") ||
|
||||
ffStrbufEqualS(&result->processName, "perf") ||
|
||||
ffStrbufEqualS(&result->processName, "guake-wrapped") ||
|
||||
ffStrbufEqualS(&result->processName, "time") ||
|
||||
ffStrbufEqualS(&result->processName, "hyfetch") || //when hyfetch uses fastfetch as backend
|
||||
ffStrbufEqualS(&result->processName, "clifm") || //https://github.com/leo-arch/clifm/issues/289
|
||||
ffStrbufEqualS(&result->processName, "valgrind") ||
|
||||
ffStrbufContainS(&result->processName, "debug") ||
|
||||
ffStrbufContainS(&result->processName, "not-found") ||
|
||||
ffStrbufEndsWithS(&result->processName, ".sh")
|
||||
)
|
||||
{
|
||||
pid = ppid;
|
||||
ffStrbufClear(&result->processName);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -263,8 +68,7 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
|
||||
result->pid = (uint32_t) pid;
|
||||
result->ppid = (uint32_t) ppid;
|
||||
result->tty = tty;
|
||||
ffStrbufSetS(&result->processName, name);
|
||||
getProcessInformation(pid, &result->processName, &result->exe, &result->exeName, &result->exePath);
|
||||
ffProcessGetInfoLinux(pid, &result->processName, &result->exe, &result->exeName, &result->exePath);
|
||||
break;
|
||||
}
|
||||
return ppid;
|
||||
@@ -272,49 +76,47 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
|
||||
|
||||
static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
|
||||
{
|
||||
char name[256];
|
||||
name[0] = '\0';
|
||||
|
||||
pid_t ppid = 0;
|
||||
|
||||
while (getProcessNameAndPpid(pid, name, &ppid, NULL) == NULL)
|
||||
while (ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, NULL) == NULL)
|
||||
{
|
||||
//Known shells
|
||||
if (
|
||||
ffStrEquals(name, "sh") ||
|
||||
ffStrEquals(name, "ash") ||
|
||||
ffStrEquals(name, "bash") ||
|
||||
ffStrEquals(name, "zsh") ||
|
||||
ffStrEquals(name, "ksh") ||
|
||||
ffStrEquals(name, "mksh") ||
|
||||
ffStrEquals(name, "oksh") ||
|
||||
ffStrEquals(name, "csh") ||
|
||||
ffStrEquals(name, "tcsh") ||
|
||||
ffStrEquals(name, "fish") ||
|
||||
ffStrEquals(name, "dash") ||
|
||||
ffStrEquals(name, "pwsh") ||
|
||||
ffStrEquals(name, "nu") ||
|
||||
ffStrEquals(name, "git-shell") ||
|
||||
ffStrEquals(name, "elvish") ||
|
||||
ffStrEquals(name, "oil.ovm") ||
|
||||
ffStrEquals(name, "xonsh") || // works in Linux but not in macOS because kernel returns `Python` in this case
|
||||
ffStrEquals(name, "login") ||
|
||||
ffStrEquals(name, "sshd") ||
|
||||
ffStrEquals(name, "clifm") || // https://github.com/leo-arch/clifm/issues/289
|
||||
ffStrEquals(name, "chezmoi") || // #762
|
||||
ffStrbufEqualS(&result->processName, "sh") ||
|
||||
ffStrbufEqualS(&result->processName, "ash") ||
|
||||
ffStrbufEqualS(&result->processName, "bash") ||
|
||||
ffStrbufEqualS(&result->processName, "zsh") ||
|
||||
ffStrbufEqualS(&result->processName, "ksh") ||
|
||||
ffStrbufEqualS(&result->processName, "mksh") ||
|
||||
ffStrbufEqualS(&result->processName, "oksh") ||
|
||||
ffStrbufEqualS(&result->processName, "csh") ||
|
||||
ffStrbufEqualS(&result->processName, "tcsh") ||
|
||||
ffStrbufEqualS(&result->processName, "fish") ||
|
||||
ffStrbufEqualS(&result->processName, "dash") ||
|
||||
ffStrbufEqualS(&result->processName, "pwsh") ||
|
||||
ffStrbufEqualS(&result->processName, "nu") ||
|
||||
ffStrbufEqualS(&result->processName, "git-shell") ||
|
||||
ffStrbufEqualS(&result->processName, "elvish") ||
|
||||
ffStrbufEqualS(&result->processName, "oil.ovm") ||
|
||||
ffStrbufEqualS(&result->processName, "xonsh") || // works in Linux but not in macOS because kernel returns `Python` in this case
|
||||
ffStrbufEqualS(&result->processName, "login") ||
|
||||
ffStrbufEqualS(&result->processName, "sshd") ||
|
||||
ffStrbufEqualS(&result->processName, "clifm") || // https://github.com/leo-arch/clifm/issues/289
|
||||
ffStrbufEqualS(&result->processName, "chezmoi") || // #762
|
||||
#ifdef __linux__
|
||||
ffStrStartsWith(name, "flatpak-") || // #707
|
||||
ffStrbufStartsWithS(&result->processName, "flatpak-") || // #707
|
||||
#endif
|
||||
ffStrEndsWith(name, ".sh")
|
||||
ffStrbufEndsWithS(&result->processName, ".sh")
|
||||
)
|
||||
{
|
||||
pid = ppid;
|
||||
ffStrbufClear(&result->processName);
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// https://github.com/fastfetch-cli/fastfetch/discussions/501
|
||||
const char* pLeft = strstr(name, " (");
|
||||
const char* pLeft = strstr(result->processName.chars, " (");
|
||||
if (pLeft)
|
||||
{
|
||||
pLeft += 2;
|
||||
@@ -324,7 +126,7 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
|
||||
for (; pLeft < pRight; ++pLeft)
|
||||
if (*pLeft < 'a' || *pLeft > 'z')
|
||||
break;
|
||||
if (pLeft == pRight && getProcessNameAndPpid(ppid, name, &ppid, NULL) != NULL)
|
||||
if (pLeft == pRight && ffProcessGetBasicInfoLinux(ppid, &result->processName, &ppid, NULL) != NULL)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -332,8 +134,7 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
|
||||
|
||||
result->pid = (uint32_t) pid;
|
||||
result->ppid = (uint32_t) ppid;
|
||||
ffStrbufSetS(&result->processName, name);
|
||||
getProcessInformation(pid, &result->processName, &result->exe, &result->exeName, &result->exePath);
|
||||
ffProcessGetInfoLinux(pid, &result->processName, &result->exe, &result->exeName, &result->exePath);
|
||||
break;
|
||||
}
|
||||
return ppid;
|
||||
@@ -347,11 +148,9 @@ static bool getTerminalInfoByPidEnv(FFTerminalResult* result, const char* pidEnv
|
||||
|
||||
pid_t pid = (pid_t) strtol(envStr, NULL, 10);
|
||||
result->pid = (uint32_t) pid;
|
||||
char name[256];
|
||||
if (getProcessNameAndPpid(pid, name, (pid_t*) &result->ppid, NULL) == NULL)
|
||||
if (ffProcessGetBasicInfoLinux(pid, &result->processName, (pid_t*) &result->ppid, NULL) == NULL)
|
||||
{
|
||||
ffStrbufSetS(&result->processName, name);
|
||||
getProcessInformation(pid, &result->processName, &result->exe, &result->exeName, &result->exePath);
|
||||
ffProcessGetInfoLinux(pid, &result->processName, &result->exe, &result->exeName, &result->exePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <ntstatus.h>
|
||||
#include <winternl.h>
|
||||
|
||||
static bool getProductVersion(const wchar_t* filePath, FFstrbuf* version)
|
||||
{
|
||||
@@ -39,56 +37,13 @@ static bool getProductVersion(const wchar_t* filePath, FFstrbuf* version)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool getProcessInfo(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrbuf* exe, const char** exeName, FFstrbuf* exePath, bool* gui)
|
||||
{
|
||||
FF_AUTO_CLOSE_FD HANDLE hProcess = pid == 0
|
||||
? GetCurrentProcess()
|
||||
: OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, TRUE, pid);
|
||||
|
||||
if (gui)
|
||||
*gui = GetGuiResources(hProcess, GR_GDIOBJECTS) > 0;
|
||||
|
||||
if(ppid)
|
||||
{
|
||||
PROCESS_BASIC_INFORMATION info = {};
|
||||
ULONG size;
|
||||
if(NT_SUCCESS(NtQueryInformationProcess(hProcess, ProcessBasicInformation, &info, sizeof(info), &size)))
|
||||
{
|
||||
assert(size == sizeof(info));
|
||||
*ppid = (uint32_t)info.InheritedFromUniqueProcessId;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
if(exe)
|
||||
{
|
||||
DWORD bufSize = exe->allocated;
|
||||
if(QueryFullProcessImageNameA(hProcess, 0, exe->chars, &bufSize))
|
||||
{
|
||||
// We use full path here
|
||||
// Querying command line of remote processes in Windows requires either WMI or ReadProcessMemory
|
||||
exe->length = bufSize;
|
||||
if (exePath) ffStrbufSet(exePath, exe);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
if(pname && exeName)
|
||||
{
|
||||
*exeName = exe->chars + ffStrbufLastIndexC(exe, '\\') + 1;
|
||||
ffStrbufSetS(pname, *exeName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version);
|
||||
|
||||
static uint32_t getShellInfo(FFShellResult* result, uint32_t pid)
|
||||
{
|
||||
uint32_t ppid = 0;
|
||||
|
||||
while (pid != 0 && getProcessInfo(pid, &ppid, &result->processName, &result->exe, &result->exeName, &result->exePath, NULL))
|
||||
while (pid != 0 && ffProcessGetInfoWindows(pid, &ppid, &result->processName, &result->exe, &result->exeName, &result->exePath, NULL))
|
||||
{
|
||||
ffStrbufSet(&result->prettyName, &result->processName);
|
||||
if(ffStrbufEndsWithIgnCaseS(&result->prettyName, ".exe"))
|
||||
@@ -183,7 +138,7 @@ static bool getTerminalFromEnv(FFTerminalResult* result)
|
||||
//ConEmu
|
||||
uint32_t pid = (uint32_t) strtoul(term, NULL, 10);
|
||||
result->pid = pid;
|
||||
if(getProcessInfo(pid, NULL, &result->processName, &result->exe, &result->exeName, &result->exePath, NULL))
|
||||
if(ffProcessGetInfoWindows(pid, NULL, &result->processName, &result->exe, &result->exeName, &result->exePath, NULL))
|
||||
{
|
||||
ffStrbufSet(&result->prettyName, &result->processName);
|
||||
if(ffStrbufEndsWithIgnCaseS(&result->prettyName, ".exe"))
|
||||
@@ -289,10 +244,17 @@ conhost:
|
||||
|
||||
static uint32_t getTerminalInfo(FFTerminalResult* result, uint32_t pid)
|
||||
{
|
||||
if (getenv("MSYSTEM"))
|
||||
{
|
||||
// Don't try to detect terminals in MSYS shell
|
||||
// It won't work because MSYS doesn't follow process tree of native Windows programs
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t ppid = 0;
|
||||
bool hasGui;
|
||||
|
||||
while (pid != 0 && getProcessInfo(pid, &ppid, &result->processName, &result->exe, &result->exeName, &result->exePath, &hasGui))
|
||||
while (pid != 0 && ffProcessGetInfoWindows(pid, &ppid, &result->processName, &result->exe, &result->exeName, &result->exePath, &hasGui))
|
||||
{
|
||||
if(!hasGui || ffStrbufIgnCaseEqualS(&result->processName, "far.exe")) // Far includes GUI objects...
|
||||
{
|
||||
@@ -373,7 +335,7 @@ const FFShellResult* ffDetectShell(void)
|
||||
result.tty = -1;
|
||||
|
||||
uint32_t ppid;
|
||||
if(!getProcessInfo(0, &ppid, NULL, NULL, NULL, NULL, NULL))
|
||||
if(!ffProcessGetInfoWindows(0, &ppid, NULL, NULL, NULL, NULL, NULL))
|
||||
return &result;
|
||||
|
||||
ppid = getShellInfo(&result, ppid);
|
||||
|
||||
@@ -76,7 +76,7 @@ static const char* detectVulkan(FFVulkanResult* result)
|
||||
);
|
||||
|
||||
VkInstance vkInstance;
|
||||
if(ffvkCreateInstance(&(VkInstanceCreateInfo) {
|
||||
VkResult res = ffvkCreateInstance(&(VkInstanceCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
.pApplicationInfo = &(VkApplicationInfo) {
|
||||
@@ -95,8 +95,27 @@ static const char* detectVulkan(FFVulkanResult* result)
|
||||
.enabledExtensionCount = 0,
|
||||
.ppEnabledExtensionNames = NULL,
|
||||
.flags = 0
|
||||
}, NULL, &vkInstance) != VK_SUCCESS)
|
||||
return "ffvkCreateInstance() failed";
|
||||
}, NULL, &vkInstance);
|
||||
if(res != VK_SUCCESS)
|
||||
{
|
||||
switch (res)
|
||||
{
|
||||
case VK_ERROR_OUT_OF_HOST_MEMORY:
|
||||
return "ffvkCreateInstance() failed: VK_ERROR_OUT_OF_HOST_MEMORY";
|
||||
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
|
||||
return "ffvkCreateInstance() failed: VK_ERROR_OUT_OF_DEVICE_MEMORY";
|
||||
case VK_ERROR_INITIALIZATION_FAILED:
|
||||
return "ffvkCreateInstance() failed: VK_ERROR_INITIALIZATION_FAILED";
|
||||
case VK_ERROR_LAYER_NOT_PRESENT:
|
||||
return "ffvkCreateInstance() failed: VK_ERROR_LAYER_NOT_PRESENT";
|
||||
case VK_ERROR_EXTENSION_NOT_PRESENT:
|
||||
return "ffvkCreateInstance() failed: VK_ERROR_EXTENSION_NOT_PRESENT";
|
||||
case VK_ERROR_INCOMPATIBLE_DRIVER:
|
||||
return "ffvkCreateInstance() failed: VK_ERROR_INCOMPATIBLE_DRIVER";
|
||||
default:
|
||||
return "ffvkCreateInstance() failed: unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
//if instance creation succeeded, but vkEnumerateInstanceVersion didn't, this means we are running against a vulkan 1.0 implementation
|
||||
//explicitly set this version, if no device is found, so we still have at least this info
|
||||
@@ -105,10 +124,23 @@ static const char* detectVulkan(FFVulkanResult* result)
|
||||
|
||||
VkPhysicalDevice physicalDevices[128];
|
||||
uint32_t physicalDeviceCount = (uint32_t) (sizeof(physicalDevices) / sizeof(*physicalDevices));
|
||||
if(ffvkEnumeratePhysicalDevices(vkInstance, &physicalDeviceCount, physicalDevices) != VK_SUCCESS)
|
||||
res = ffvkEnumeratePhysicalDevices(vkInstance, &physicalDeviceCount, physicalDevices);
|
||||
if(res != VK_SUCCESS)
|
||||
{
|
||||
ffvkDestroyInstance(vkInstance, NULL);
|
||||
return "ffvkEnumeratePhysicalDevices() failed";
|
||||
switch (res)
|
||||
{
|
||||
case VK_ERROR_OUT_OF_HOST_MEMORY:
|
||||
return "ffvkEnumeratePhysicalDevices() failed: VK_ERROR_OUT_OF_HOST_MEMORY";
|
||||
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
|
||||
return "ffvkEnumeratePhysicalDevices() failed: VK_ERROR_OUT_OF_DEVICE_MEMORY";
|
||||
case VK_ERROR_INITIALIZATION_FAILED:
|
||||
return "ffvkEnumeratePhysicalDevices() failed: VK_ERROR_INITIALIZATION_FAILED";
|
||||
case VK_INCOMPLETE:
|
||||
return "ffvkEnumeratePhysicalDevices() failed: VK_INCOMPLETE";
|
||||
default:
|
||||
return "ffvkEnumeratePhysicalDevices() failed";
|
||||
}
|
||||
}
|
||||
|
||||
PFN_vkGetPhysicalDeviceProperties ffvkGetPhysicalDeviceProperties = NULL;
|
||||
|
||||
+5
-6
@@ -265,6 +265,11 @@ static void listAvailablePresets(bool pretty)
|
||||
ffStrbufAppendS(path, "fastfetch/presets/");
|
||||
ffListFilesRecursively(path->chars, pretty);
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateCopy(&instance.state.platform.exePath);
|
||||
ffStrbufSubstrBeforeLastC(&absolutePath, '/');
|
||||
ffStrbufAppendS(&absolutePath, "/presets/");
|
||||
ffListFilesRecursively(absolutePath.chars, pretty);
|
||||
}
|
||||
|
||||
static void listAvailableLogos(void)
|
||||
@@ -284,12 +289,6 @@ static void listConfigPaths(void)
|
||||
uint32_t length = folder->length + (uint32_t) strlen("fastfetch") + 1 /* trailing slash */;
|
||||
ffStrbufAppendS(folder, "fastfetch/config.jsonc");
|
||||
exists = ffPathExists(folder->chars, FF_PATHTYPE_FILE);
|
||||
if (!exists)
|
||||
{
|
||||
ffStrbufSubstrBefore(folder, folder->length - (uint32_t) strlen("jsonc"));
|
||||
ffStrbufAppendS(folder, "conf");
|
||||
exists = ffPathExists(folder->chars, FF_PATHTYPE_FILE);
|
||||
}
|
||||
ffStrbufSubstrBefore(folder, length);
|
||||
printf("%s%s\n", folder->chars, exists ? " (*)" : "");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
..
|
||||
'::,.....
|
||||
.,;:llll;. $4 ...
|
||||
$2...... $1''''.$4 ':::;.
|
||||
$2 ..,::lll::;,..$4 ::::;.
|
||||
$2 ':llllllllllll:' $4 ;:::;
|
||||
$2 .;llllllllllllllll' $4 ;::;.
|
||||
$3 .... $2 .;lllllllllllllllll:. $4 ;::;.
|
||||
$3 .;::::, $2 ,lllllllllllllllllll. $4 .
|
||||
$3 .::::::.$2 .lllllllllllllllllll:.
|
||||
$3 .::::::. $2 ,lllllllllllllllllll:.$3 ......
|
||||
$3 .;:::::'$2 .;lllllllllllllllllll,$3 .,::::::,.
|
||||
$3 .;::::;.$2.:lllllllllllllllllll.$3 .,::::::::;.
|
||||
$3 .,;::;$2;lllllllllllllllllll;$3 .:::::::::;.
|
||||
$3 ...$2,lllllllllllllllllll.$3 ':::::::::,.
|
||||
$2 .:lllllllllllllllll, $3 .;::::::::;.
|
||||
$2 .:llllllllllllllll:.$3 .;::::::::,.
|
||||
$2 ,llllllllllllllll'$3 .';:::::::;.
|
||||
$5 ... $2 .llllllllllllllll;$3,,,,;:::::::;,.
|
||||
$5.:l:. $2 ,llllllllllllll;$3,,:::::::;,'..
|
||||
$5.;::, $2 .;lllllllllllll,$3 '''''''''''
|
||||
$5 .:::. $2 ':lllllllllll:.
|
||||
$5 .;::' $2 .,:llllllllll,
|
||||
$5 .,::;. $2 .';lllllllll'
|
||||
$5 .,::;'.. $2 .';lllllll,.
|
||||
$5 ..,;::;,. $2 ...,;lll:.
|
||||
$5 ...''. $2 ..',;'.
|
||||
@@ -860,6 +860,20 @@ static const FFlogo C[] = {
|
||||
.colorKeys = FF_COLOR_FG_GREEN,
|
||||
.colorTitle = FF_COLOR_FG_YELLOW,
|
||||
},
|
||||
// Cereus
|
||||
{
|
||||
.names = {"cereus", "Cereus Linux"},
|
||||
.lines = FASTFETCH_DATATEXT_LOGO_CEREUS,
|
||||
.colors = {
|
||||
FF_COLOR_FG_256 "173",
|
||||
FF_COLOR_FG_256 "108",
|
||||
FF_COLOR_FG_256 "71",
|
||||
FF_COLOR_FG_256 "151",
|
||||
FF_COLOR_FG_256 "72"
|
||||
},
|
||||
.colorKeys = FF_COLOR_FG_256 "108",
|
||||
.colorTitle = FF_COLOR_MODE_BOLD FF_COLOR_FG_WHITE,
|
||||
},
|
||||
// Chakra
|
||||
{
|
||||
.names = {"Chakra"},
|
||||
|
||||
+20
-22
@@ -113,7 +113,7 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement)
|
||||
ffStrbufAppendS(&result, "\e[");
|
||||
data += 2;
|
||||
|
||||
while(isdigit(*data) || *data == ';')
|
||||
while(ffCharIsDigit(*data) || *data == ';')
|
||||
ffStrbufAppendC(&result, *data++); // number
|
||||
|
||||
//We have a valid control sequence, print it and continue with next char
|
||||
@@ -219,13 +219,25 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement)
|
||||
ffWriteFDBuffer(FFUnixFD2NativeFD(STDOUT_FILENO), &result);
|
||||
}
|
||||
|
||||
static void logoApplyColors(const FFlogo* logo)
|
||||
static void logoApplyColors(const FFlogo* logo, bool replacement)
|
||||
{
|
||||
if(instance.config.display.colorTitle.length == 0)
|
||||
ffStrbufAppendS(&instance.config.display.colorTitle, logo->colorTitle ? logo->colorTitle : logo->colors[0]);
|
||||
|
||||
if(instance.config.display.colorKeys.length == 0)
|
||||
ffStrbufAppendS(&instance.config.display.colorKeys, logo->colorKeys ? logo->colorKeys : logo->colors[1]);
|
||||
|
||||
if (replacement)
|
||||
{
|
||||
FFOptionsLogo* options = &instance.config.logo;
|
||||
|
||||
const char* const* colors = logo->colors;
|
||||
for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++)
|
||||
{
|
||||
if(options->colors[i].length == 0)
|
||||
ffStrbufAppendS(&options->colors[i], *colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small)
|
||||
@@ -301,30 +313,16 @@ static const FFlogo* logoGetBuiltinDetected(FFLogoSize size)
|
||||
return &ffLogoUnknown;
|
||||
}
|
||||
|
||||
static inline void logoApplyColorsDetected(void)
|
||||
{
|
||||
logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL));
|
||||
}
|
||||
|
||||
static void logoPrintStruct(const FFlogo* logo)
|
||||
{
|
||||
logoApplyColors(logo);
|
||||
|
||||
FFOptionsLogo* options = &instance.config.logo;
|
||||
|
||||
const char* const* colors = logo->colors;
|
||||
for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++)
|
||||
{
|
||||
if(options->colors[i].length == 0)
|
||||
ffStrbufAppendS(&options->colors[i], *colors);
|
||||
}
|
||||
logoApplyColors(logo, true);
|
||||
|
||||
ffLogoPrintChars(logo->lines, true);
|
||||
}
|
||||
|
||||
static void logoPrintNone(void)
|
||||
{
|
||||
logoApplyColorsDetected();
|
||||
logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL), false);
|
||||
instance.state.logoHeight = 0;
|
||||
instance.state.logoWidth = 0;
|
||||
}
|
||||
@@ -357,8 +355,8 @@ static bool logoPrintData(bool doColorReplacement)
|
||||
if(options->source.length == 0)
|
||||
return false;
|
||||
|
||||
logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL), doColorReplacement);
|
||||
ffLogoPrintChars(options->source.chars, doColorReplacement);
|
||||
logoApplyColorsDetected();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -407,7 +405,7 @@ static bool logoPrintFileIfExists(bool doColorReplacement, bool raw)
|
||||
return false;
|
||||
}
|
||||
|
||||
logoApplyColorsDetected();
|
||||
logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL), doColorReplacement);
|
||||
if(raw)
|
||||
ffLogoPrintCharsRaw(content.chars, content.length);
|
||||
else
|
||||
@@ -421,7 +419,7 @@ static bool logoPrintImageIfExists(FFLogoType logo, bool printError)
|
||||
if(!ffLogoPrintImageIfExists(logo, printError))
|
||||
return false;
|
||||
|
||||
logoApplyColorsDetected();
|
||||
logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -431,7 +429,7 @@ static bool logoTryKnownType(void)
|
||||
|
||||
if(options->type == FF_LOGO_TYPE_NONE)
|
||||
{
|
||||
logoApplyColorsDetected();
|
||||
logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,15 +62,15 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BATTERY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->status},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->serial},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufactureDate},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer, "manufacturer"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName, "model-name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology, "technology"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityStr, "capacity"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->status, "status"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr, "temperature"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount, "cycle-count"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->serial, "serial"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufactureDate, "manufacture-date"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -222,15 +222,15 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
|
||||
void ffPrintBatteryHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BATTERY_MODULE_NAME, "{4}, {5}", FF_BATTERY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Battery manufactor",
|
||||
"Battery model",
|
||||
"Battery technology",
|
||||
"Battery capacity (percentage)",
|
||||
"Battery status",
|
||||
"Battery temperature (formatted)",
|
||||
"Battery cycle count",
|
||||
"Battery serial number",
|
||||
"Battery manufactor date",
|
||||
"Battery manufacturer - manufacturer",
|
||||
"Battery model name - model-name",
|
||||
"Battery technology - technology",
|
||||
"Battery capacity (percentage) - capacity",
|
||||
"Battery status - status",
|
||||
"Battery temperature (formatted) - temperature",
|
||||
"Battery cycle count - cycle-count",
|
||||
"Battery serial number - serial",
|
||||
"Battery manufactor date - manufacture-date",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -44,7 +44,7 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 1, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.type},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.type, "type"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BIOS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{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, &bios.type},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.date, "date"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.release, "release"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor, "vendor"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.version, "version"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.type, "type"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -146,11 +146,11 @@ exit:
|
||||
void ffPrintBiosHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BIOS_MODULE_NAME, "{4} ({2})", FF_BIOS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"bios date",
|
||||
"bios release",
|
||||
"bios vendor",
|
||||
"bios version",
|
||||
"firmware type",
|
||||
"bios date - date",
|
||||
"bios release - release",
|
||||
"bios vendor - vendor",
|
||||
"bios version - version",
|
||||
"firmware type - type",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "modules/bluetooth/bluetooth.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 4
|
||||
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 5
|
||||
|
||||
static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* device, uint8_t index)
|
||||
{
|
||||
@@ -33,10 +33,11 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
|
||||
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->address},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->type},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->address, "address"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->type, "type"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr, "battery-percentage"},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &device->connected, "connected"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -174,10 +175,11 @@ void ffGenerateBluetoothJsonResult(FF_MAYBE_UNUSED FFBluetoothOptions* options,
|
||||
void ffPrintBluetoothHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTH_MODULE_NAME, "{1} ({4})", FF_BLUETOOTH_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name",
|
||||
"Address",
|
||||
"Type",
|
||||
"Battery percentage"
|
||||
"Name - name",
|
||||
"Address - address",
|
||||
"Type - type",
|
||||
"Battery percentage - battery-percentage",
|
||||
"Is connected - connected",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ void ffPrintBoard(FFBoardOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOARD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.serial},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor, "vendor"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.serial, "serial"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -125,10 +125,10 @@ exit:
|
||||
void ffPrintBoardHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOARD_MODULE_NAME, "{1} ({3})", FF_BOARD_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"board name",
|
||||
"board vendor",
|
||||
"board version",
|
||||
"board serial number",
|
||||
"board name - name",
|
||||
"board vendor - vendor",
|
||||
"board version - version",
|
||||
"board serial number - serial",
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ void ffInitBoardOptions(FFBoardOptions* options)
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BOARD_MODULE_NAME,
|
||||
"Print mather board name and other info",
|
||||
"Print motherboard name and other info",
|
||||
ffParseBoardCommandOptions,
|
||||
ffParseBoardJsonObject,
|
||||
ffPrintBoard,
|
||||
|
||||
@@ -40,10 +40,10 @@ void ffPrintBootmgr(FFBootmgrOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOOTMGR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bootmgr.name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bootmgr.firmware},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &firmwareName},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &bootmgr.secureBoot},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bootmgr.name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bootmgr.firmware, "firmware-path"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &firmwareName, "firmware-name"},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &bootmgr.secureBoot, "secure-boot"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -114,10 +114,10 @@ exit:
|
||||
void ffPrintBootmgrHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOOTMGR_MODULE_NAME, "{4} ({2})", FF_BOOTMGR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name / description",
|
||||
"Firmware file path",
|
||||
"Firmware file name",
|
||||
"Is secure boot enabled",
|
||||
"Name / description - name",
|
||||
"Firmware file path - firmware-path",
|
||||
"Firmware file name - firmware-name",
|
||||
"Is secure boot enabled - secure-boot",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
{
|
||||
uint32_t moduleIndex = result.length == 1 ? 0 : index + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name}
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex, "index"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name, "name"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY valueStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&valueStr, percent, options->percent, false, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &valueStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->max},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->min},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->current},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &valueStr, "percentage"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->max, "max"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->min, "min"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->current, "current"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -175,11 +175,11 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options
|
||||
void ffPrintBrightnessHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BRIGHTNESS_MODULE_NAME, "{1}", FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Screen brightness (percentage)",
|
||||
"Screen name",
|
||||
"Maximum brightness value",
|
||||
"Minimum brightness value",
|
||||
"Current brightness value",
|
||||
"Screen brightness (percentage) - percentage",
|
||||
"Screen name - name",
|
||||
"Maximum brightness value - max",
|
||||
"Minimum brightness value - min",
|
||||
"Current brightness value - current",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -28,12 +28,12 @@ static void printDevice(FFCameraOptions* options, const FFCameraResult* device,
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CAMERA_NUM_FORMAT_ARGS, (((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->colorspace},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->id},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &device->width},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &device->height},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor, "vendor"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->colorspace, "colorspace"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->id, "id"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &device->width, "width"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &device->height, "height"},
|
||||
})));
|
||||
}
|
||||
}
|
||||
@@ -139,12 +139,12 @@ void ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson
|
||||
void ffPrintCameraHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CAMERA_MODULE_NAME, "{1} ({4}px x {5}px)", FF_CAMERA_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Device name",
|
||||
"Vendor",
|
||||
"Color space",
|
||||
"Identifier",
|
||||
"Width (in px)",
|
||||
"Height (in px)",
|
||||
"Device name - name",
|
||||
"Vendor - vendor",
|
||||
"Color space - colorspace",
|
||||
"Identifier - id",
|
||||
"Width (in px) - width",
|
||||
"Height (in px) - height",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ void ffPrintChassis(FFChassisOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CHASSIS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.type},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.serial},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.type, "type"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor, "vendor"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.serial, "serial"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -126,10 +126,10 @@ exit:
|
||||
void ffPrintChassisHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CHASSIS_MODULE_NAME, "{1}", FF_CHASSIS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"chassis type",
|
||||
"chassis vendor",
|
||||
"chassis version",
|
||||
"chassis serial number",
|
||||
"chassis type - type",
|
||||
"chassis vendor - vendor",
|
||||
"chassis version - version",
|
||||
"chassis serial number - serial",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+15
-10
@@ -25,7 +25,7 @@ void ffPrintColors(FFColorsOptions* options)
|
||||
// 3%d: Set the foreground color
|
||||
for(uint8_t i = options->block.range[0]; i <= min(options->block.range[1], 7); i++)
|
||||
{
|
||||
if(!instance.config.display.pipe)
|
||||
if (!instance.config.display.pipe)
|
||||
ffStrbufAppendF(&result, "\e[3%dm", i);
|
||||
for (uint8_t j = 0; j < options->block.width; j++)
|
||||
ffStrbufAppendS(&result, "█");
|
||||
@@ -35,10 +35,10 @@ void ffPrintColors(FFColorsOptions* options)
|
||||
ffPrintLogoAndKey(FF_COLORS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
flag = true;
|
||||
|
||||
if(options->paddingLeft > 0)
|
||||
if (options->paddingLeft > 0)
|
||||
ffPrintCharTimes(' ', options->paddingLeft);
|
||||
|
||||
if(!instance.config.display.pipe)
|
||||
if (!instance.config.display.pipe)
|
||||
ffStrbufAppendS(&result, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
ffStrbufPutTo(&result, stdout);
|
||||
ffStrbufClear(&result);
|
||||
@@ -59,15 +59,20 @@ void ffPrintColors(FFColorsOptions* options)
|
||||
const char* symbol;
|
||||
switch (options->symbol)
|
||||
{
|
||||
case FF_COLORS_SYMBOL_CIRCLE: symbol = "●"; break;
|
||||
case FF_COLORS_SYMBOL_DIAMOND: symbol = "◆"; break;
|
||||
case FF_COLORS_SYMBOL_TRIANGLE: symbol = "▲"; break;
|
||||
case FF_COLORS_SYMBOL_SQUARE: symbol = "■"; break;
|
||||
case FF_COLORS_SYMBOL_STAR: symbol = "★"; break;
|
||||
default: symbol = "███"; break;
|
||||
case FF_COLORS_SYMBOL_CIRCLE: symbol = "● "; break;
|
||||
case FF_COLORS_SYMBOL_DIAMOND: symbol = "◆ "; break;
|
||||
case FF_COLORS_SYMBOL_TRIANGLE: symbol = "▲ "; break;
|
||||
case FF_COLORS_SYMBOL_SQUARE: symbol = "■ "; break;
|
||||
case FF_COLORS_SYMBOL_STAR: symbol = "★ "; break;
|
||||
default: symbol = "███ "; break;
|
||||
}
|
||||
for (int i = 8; i >= 1; --i)
|
||||
ffStrbufAppendF(&result, "\e[3%dm%s ", i, symbol);
|
||||
{
|
||||
if (!instance.config.display.pipe)
|
||||
ffStrbufAppendF(&result, "\e[3%dm", i);
|
||||
ffStrbufAppendS(&result, symbol);
|
||||
}
|
||||
ffStrbufTrimRight(&result, ' ');
|
||||
}
|
||||
|
||||
if (result.length > 0)
|
||||
|
||||
@@ -40,7 +40,7 @@ void ffPrintCommand(FFCommandOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_COMMAND_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result, "result"}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ void ffGenerateCommandJsonResult(FF_MAYBE_UNUSED FFCommandOptions* options, yyjs
|
||||
void ffPrintCommandHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_COMMAND_MODULE_NAME, "{1}", FF_COMMAND_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Command result"
|
||||
"Command result - result"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+20
-20
@@ -107,16 +107,16 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPU_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqBase},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqMax},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &coreTypes},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqBioslimit},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor, "vendor"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical, "cores-physical"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical, "cores-logical"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline, "cores-online"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqBase, "freq-base"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqMax, "freq-max"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr, "temperature"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &coreTypes, "core-types"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, freqBioslimit, "freq-bios-limit"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -255,16 +255,16 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
void ffPrintCPUHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPU_MODULE_NAME, "{1} ({5}) @ {7} GHz", FF_CPU_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name",
|
||||
"Vendor",
|
||||
"Physical core count",
|
||||
"Logical core count",
|
||||
"Online core count",
|
||||
"Base frequency",
|
||||
"Max frequency",
|
||||
"Temperature (formatted)",
|
||||
"Logical core count grouped by frequency",
|
||||
"Bios limited frequency",
|
||||
"Name - name",
|
||||
"Vendor - vendor",
|
||||
"Physical core count - cores-physical",
|
||||
"Logical core count - cores-logical",
|
||||
"Online core count - cores-online",
|
||||
"Base frequency - freq-base",
|
||||
"Max frequency - freq-max",
|
||||
"Temperature (formatted) - temperature",
|
||||
"Logical core count grouped by frequency - core-types",
|
||||
"Bios limited frequency - freq-bios-limit",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -80,11 +80,11 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY maxStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&maxStr, maxValue, options->percent, false, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUUSAGE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &avgStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &maxStr},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &maxIndex},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &minStr},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &minIndex},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &avgStr, "avg"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &maxStr, "max"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &maxIndex, "max-index"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &minStr, "min"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &minIndex, "min-index"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -167,11 +167,11 @@ void ffGenerateCPUUsageJsonResult(FF_MAYBE_UNUSED FFCPUUsageOptions* options, yy
|
||||
void ffPrintCPUUsageHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUUSAGE_MODULE_NAME, "{1}", FF_CPUUSAGE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"CPU usage (percentage, average)",
|
||||
"CPU usage (percentage, maximum)",
|
||||
"CPU core index of maximum usage",
|
||||
"CPU usage (percentage, minimum)",
|
||||
"CPU core index of minimum usage",
|
||||
"CPU usage (percentage, average) - avg",
|
||||
"CPU usage (percentage, maximum) - max",
|
||||
"CPU core index of maximum usage - max-index",
|
||||
"CPU usage (percentage, minimum) - min",
|
||||
"CPU core index of minimum usage - min-index",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ void ffPrintCursor(FFCursorOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CURSOR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.theme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.size}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.theme, "theme"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.size, "size"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -113,8 +113,8 @@ void ffGenerateCursorJsonResult(FF_MAYBE_UNUSED FFCursorOptions* options, yyjson
|
||||
void ffPrintCursorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CURSOR_MODULE_NAME, "{1} ({2}px)", FF_CURSOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Cursor theme",
|
||||
"Cursor size"
|
||||
"Cursor theme - theme",
|
||||
"Cursor size - size"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,7 @@
|
||||
|
||||
void ffPrintCustom(FFCustomOptions* options)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&options->moduleArgs.outputFormat, stdout);
|
||||
if(!instance.config.display.pipe)
|
||||
puts(FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
ffPrintFormat(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, 0, ((FFformatarg[]) {}));
|
||||
}
|
||||
|
||||
bool ffParseCustomCommandOptions(FFCustomOptions* options, const char* key, const char* value)
|
||||
|
||||
@@ -66,28 +66,28 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
|
||||
strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DATETIME_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &result.year}, // 1
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.yearShort}, // 2
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.month}, // 3
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.monthPretty}, // 4
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.monthName}, // 5
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.monthNameShort}, // 6
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.week}, // 7
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.weekday}, // 8
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.weekdayShort}, // 9
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &result.dayInYear}, // 10
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.dayInMonth}, // 11
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.dayInWeek}, // 12
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.hour}, // 13
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.hourPretty}, // 14
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.hour12}, // 15
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.hour12Pretty}, // 16
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.minute}, // 17
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.minutePretty}, // 18
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.second}, // 19
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.secondPretty}, // 20
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.offsetFromUtc}, // 21
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.timezoneName}, // 22
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &result.year, "year"}, // 1
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.yearShort, "year-short"}, // 2
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.month, "month"}, // 3
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.monthPretty, "month-pretty"}, // 4
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.monthName, "month-name"}, // 5
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.monthNameShort, "month-name-short"}, // 6
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.week, "week"}, // 7
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.weekday, "weekday"}, // 8
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.weekdayShort, "weekday-short"}, // 9
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &result.dayInYear, "day-in-year"}, // 10
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.dayInMonth, "day-in-month"}, // 11
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.dayInWeek, "day-in-week"}, // 12
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.hour, "hour"}, // 13
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.hourPretty, "hour-pretty"}, // 14
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.hour12, "hour-12"}, // 15
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.hour12Pretty, "hour-12-pretty"}, // 16
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.minute, "minute"}, // 17
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.minutePretty, "minute-pretty"}, // 18
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &result.second, "second"}, // 19
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.secondPretty, "second-pretty"}, // 20
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.offsetFromUtc, "offset-from-utc"}, // 21
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.timezoneName, "timezone-name"}, // 22
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -158,28 +158,28 @@ void ffGenerateDateTimeJsonResult(FF_MAYBE_UNUSED FFDateTimeOptions* options, yy
|
||||
void ffPrintDateTimeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DATETIME_MODULE_NAME, "{1}-{4}-{11} {14}:{18}:{20}", FF_DATETIME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"year",
|
||||
"last two digits of year",
|
||||
"month",
|
||||
"month with leading zero",
|
||||
"month name",
|
||||
"month name short",
|
||||
"week number on year",
|
||||
"weekday",
|
||||
"weekday short",
|
||||
"day in year",
|
||||
"day in month",
|
||||
"day in Week",
|
||||
"hour",
|
||||
"hour with leading zero",
|
||||
"hour 12h format",
|
||||
"hour 12h format with leading zero",
|
||||
"minute",
|
||||
"minute with leading zero",
|
||||
"second",
|
||||
"second with leading zero",
|
||||
"offset from UTC in the ISO 8601 format",
|
||||
"locale-dependent timezone name or abbreviation",
|
||||
"year - year",
|
||||
"last two digits of year - year-short",
|
||||
"month - month",
|
||||
"month with leading zero - month-pretty",
|
||||
"month name - month-name",
|
||||
"month name short - month-name-short",
|
||||
"week number on year - week",
|
||||
"weekday - weekday",
|
||||
"weekday short - weekday-short",
|
||||
"day in year - day-in-year",
|
||||
"day in month - day-in-month",
|
||||
"day in week - day-in-week",
|
||||
"hour - hour",
|
||||
"hour with leading zero - hour-pretty",
|
||||
"hour 12h format - hour-12",
|
||||
"hour 12h format with leading zero - hour-12-pretty",
|
||||
"minute - minute",
|
||||
"minute with leading zero - minute-pretty",
|
||||
"second - second",
|
||||
"second with leading zero - second-pretty",
|
||||
"offset from UTC in the ISO 8601 format - offset-from-utc",
|
||||
"locale-dependent timezone name or abbreviation - timezone-name",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -37,9 +37,9 @@ void ffPrintDE(FFDEOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, 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, &version}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName, "process-name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName, "pretty-name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &version, "version"}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -116,9 +116,9 @@ void ffGenerateDEJsonResult(FF_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc
|
||||
void ffPrintDEHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DE_MODULE_NAME, "{2} {3}", FF_DE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"DE process name",
|
||||
"DE pretty name",
|
||||
"DE version"
|
||||
"DE process name - process-name",
|
||||
"DE pretty name - pretty-name",
|
||||
"DE version - version"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+27
-27
@@ -36,9 +36,9 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
else
|
||||
{
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountFrom},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint, "mountpoint"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountFrom, "mount-from"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -115,18 +115,18 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageStr},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &filesPercentageStr},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isExternal},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isHidden},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, ffTimeToShortStr(disk->createTime)},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "size-used"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "size-total"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageStr, "size-percentage"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed, "files-used"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal, "files-total"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &filesPercentageStr, "files-percentage"},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isExternal, "is-external"},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isHidden, "is-hidden"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem, "filesystem"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly, "is-readonly"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, ffTimeToShortStr(disk->createTime), "create-time"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -428,18 +428,18 @@ void ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso
|
||||
void ffPrintDiskHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISK_MODULE_NAME, "{1} / {2} ({3}) - {9}", FF_DISK_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size used",
|
||||
"Size total",
|
||||
"Size percentage",
|
||||
"Files used",
|
||||
"Files total",
|
||||
"Files percentage",
|
||||
"True if external volume",
|
||||
"True if hidden volume",
|
||||
"Filesystem",
|
||||
"Label / name",
|
||||
"True if read-only",
|
||||
"Create time in local timezone",
|
||||
"Size used - size-used",
|
||||
"Size total - size-total",
|
||||
"Size percentage - size-percentage",
|
||||
"Files used - files-used",
|
||||
"Files total - files-total",
|
||||
"Files percentage - files-percentage",
|
||||
"True if external volume - is-external",
|
||||
"True if hidden volume - is-hidden",
|
||||
"Filesystem - filesystem",
|
||||
"Label / name - name",
|
||||
"True if read-only - is-readonly",
|
||||
"Create time in local timezone - create-time",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -23,9 +23,9 @@ static void formatKey(const FFDiskIOOptions* options, FFDiskIOResult* dev, uint3
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &index},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &index, "index"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath, "dev-path"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -75,14 +75,14 @@ void ffPrintDiskIO(FFDiskIOOptions* options)
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISKIO_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer2},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &dev->bytesRead},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &dev->bytesWritten},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &dev->readCount},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &dev->writeCount},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "size-read"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer2, "size-written"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath, "dev-path"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &dev->bytesRead, "bytes-read"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &dev->bytesWritten, "bytes-written"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &dev->readCount, "read-count"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &dev->writeCount, "write-count"},
|
||||
}));
|
||||
}
|
||||
++index;
|
||||
@@ -193,14 +193,14 @@ void ffGenerateDiskIOJsonResult(FFDiskIOOptions* options, yyjson_mut_doc* doc, y
|
||||
void ffPrintDiskIOHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISKIO_MODULE_NAME, "{1} (R) - {2} (W)", FF_DISKIO_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size of data read [per second] (formatted)",
|
||||
"Size of data written [per second] (formatted)",
|
||||
"Device name",
|
||||
"Device raw file path",
|
||||
"Size of data read [per second] (in bytes)",
|
||||
"Size of data written [per second] (in bytes)",
|
||||
"Number of reads",
|
||||
"Number of writes",
|
||||
"Size of data read [per second] (formatted) - size-read",
|
||||
"Size of data written [per second] (formatted) - size-written",
|
||||
"Device name - name",
|
||||
"Device raw file path - dev-path",
|
||||
"Size of data read [per second] (in bytes) - bytes-read",
|
||||
"Size of data written [per second] (in bytes) - bytes-written",
|
||||
"Number of reads - read-count",
|
||||
"Number of writes - write-count",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -90,9 +90,9 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, displayType},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex, "index"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, displayType, "type"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -126,15 +126,15 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISPLAY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->width},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->height},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->scaledWidth},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, displayType},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->rotation},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &result->primary},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->width, "width"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->height, "height"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate, "refresh-rate"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->scaledWidth, "scaled-width"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight, "scaled-height"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, displayType, "type"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->rotation, "rotation"},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &result->primary, "is-primary"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -311,15 +311,15 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs
|
||||
void ffPrintDisplayHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISPLAY_MODULE_NAME, "{1}x{2} @ {3}Hz (as {4}x{5}) [{7}]", FF_DISPLAY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Screen width (in pixels)",
|
||||
"Screen height (in pixels)",
|
||||
"Screen refresh rate (in Hz)",
|
||||
"Screen scaled width (in pixels)",
|
||||
"Screen scaled height (in pixels)",
|
||||
"Screen name",
|
||||
"Screen type (builtin, external or unknown)",
|
||||
"Screen rotation (in degrees)",
|
||||
"True if being the primary screen",
|
||||
"Screen width (in pixels) - width",
|
||||
"Screen height (in pixels) - height",
|
||||
"Screen refresh rate (in Hz) - refresh-rate",
|
||||
"Screen scaled width (in pixels) - scaled-width",
|
||||
"Screen scaled height (in pixels) - scaled-height",
|
||||
"Screen name - name",
|
||||
"Screen type (builtin, external or unknown) - type",
|
||||
"Screen rotation (in degrees) - rotation",
|
||||
"True if being the primary screen - is-primary",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+30
-16
@@ -5,13 +5,14 @@
|
||||
#include "modules/editor/editor.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_EDITOR_NUM_FORMAT_ARGS 4
|
||||
#define FF_EDITOR_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintEditor(FFEditorOptions* options)
|
||||
{
|
||||
FFEditorResult result = {
|
||||
.name = ffStrbufCreate(),
|
||||
.path = ffStrbufCreate(),
|
||||
.exe = ffStrbufCreate(),
|
||||
.version = ffStrbufCreate(),
|
||||
};
|
||||
const char* error = ffDetectEditor(&result);
|
||||
@@ -22,21 +23,35 @@ void ffPrintEditor(FFEditorOptions* options)
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
if (result.exe)
|
||||
if (options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
fputs(result.exe, stdout);
|
||||
if (result.version.length)
|
||||
printf(" (%s)", result.version.chars);
|
||||
ffPrintLogoAndKey(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
if (result.exe.length)
|
||||
{
|
||||
ffStrbufWriteTo(&result.exe, stdout);
|
||||
if (result.version.length)
|
||||
printf(" (%s)", result.version.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffStrbufWriteTo(&result.name, stdout);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffStrbufWriteTo(&result.name, stdout);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_EDITOR_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRING, &result.type, "type"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.exe, "exe-name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.path, "path"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"},
|
||||
}));
|
||||
}
|
||||
putchar('\n');
|
||||
|
||||
ffStrbufDestroy(&result.name);
|
||||
ffStrbufDestroy(&result.path);
|
||||
ffStrbufDestroy(&result.exe);
|
||||
ffStrbufDestroy(&result.version);
|
||||
}
|
||||
|
||||
@@ -94,24 +109,23 @@ void ffGenerateEditorJsonResult(FF_MAYBE_UNUSED FFEditorOptions* options, yyjson
|
||||
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "name", &result.name);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "path", &result.path);
|
||||
if (result.exe)
|
||||
yyjson_mut_obj_add_strcpy(doc, obj, "exe", result.exe);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "exe");
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "exe", &result.exe);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "version", &result.version);
|
||||
|
||||
ffStrbufDestroy(&result.name);
|
||||
ffStrbufDestroy(&result.path);
|
||||
ffStrbufDestroy(&result.exe);
|
||||
ffStrbufDestroy(&result.version);
|
||||
}
|
||||
|
||||
void ffPrintEditorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_EDITOR_MODULE_NAME, "{2} ({4})", FF_EDITOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name",
|
||||
"Exe name",
|
||||
"Full path",
|
||||
"Version",
|
||||
"Type (Visual / Editor) - type",
|
||||
"Name - name",
|
||||
"Exe name of real path - exe-name",
|
||||
"Full path of real path - full-path",
|
||||
"Version - version",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -29,11 +29,11 @@ void ffPrintFont(FFFontOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_FONT_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[0]},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[1]},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[2]},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[3]},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.display},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[0], "font1"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[1], "font2"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[2], "font3"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[3], "font4"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &font.display, "combined"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -107,11 +107,11 @@ void ffGenerateFontJsonResult(FF_MAYBE_UNUSED FFFontOptions* options, yyjson_mut
|
||||
void ffPrintFontHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_FONT_MODULE_NAME, "{5}", FF_FONT_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Font 1",
|
||||
"Font 2",
|
||||
"Font 3",
|
||||
"Font 4",
|
||||
"Combined fonts"
|
||||
"Font 1 - font1",
|
||||
"Font 2 - font2",
|
||||
"Font 3 - font3",
|
||||
"Font 4 - font4",
|
||||
"Combined fonts for display - combined"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device
|
||||
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GAMEPAD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->serial},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->serial, "serial"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr, "battery-percentage"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -136,9 +136,9 @@ void ffGenerateGamepadJsonResult(FF_MAYBE_UNUSED FFGamepadOptions* options, yyjs
|
||||
void ffPrintGamepadHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GAMEPAD_MODULE_NAME, "{1} ({3})", FF_GAMEPAD_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name",
|
||||
"Serial number",
|
||||
"Battery percentage",
|
||||
"Name - name",
|
||||
"Serial number - serial",
|
||||
"Battery percentage - battery-percentage",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -76,18 +76,18 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(gpu->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GPU_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, type},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->dedicated.total},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->dedicated.used},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->shared.total},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->shared.used},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->platformApi},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->frequency},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor, "vendor"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver, "driver"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr, "temperature"},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount, "core-count"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, type, "type"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->dedicated.total, "dedicated-total"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->dedicated.used, "dedicated-used"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->shared.total, "shared-total"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->shared.used, "shared-used"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->platformApi, "platform-api"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->frequency, "frequency"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -368,18 +368,18 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
void ffPrintGPUHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GPU_MODULE_NAME, "{1} {2}", FF_GPU_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"GPU vendor",
|
||||
"GPU name",
|
||||
"GPU driver",
|
||||
"GPU temperature",
|
||||
"GPU core count",
|
||||
"GPU type",
|
||||
"GPU total dedicated memory",
|
||||
"GPU used dedicated memory",
|
||||
"GPU total shared memory",
|
||||
"GPU used shared memory",
|
||||
"The platform API that GPU supports",
|
||||
"Current frequency in GHz",
|
||||
"GPU vendor - vendor",
|
||||
"GPU name - name",
|
||||
"GPU driver - driver",
|
||||
"GPU temperature - temperature",
|
||||
"GPU core count - core-count",
|
||||
"GPU type - type",
|
||||
"GPU total dedicated memory - dedicated-total",
|
||||
"GPU used dedicated memory - dedicated-used",
|
||||
"GPU total shared memory - shared-total",
|
||||
"GPU used shared memory - shared-used",
|
||||
"The platform API used when detecting the GPU - platform-api",
|
||||
"Current frequency in GHz - frequency",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -49,13 +49,13 @@ void ffPrintHost(FFHostOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_HOST_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.family},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.sku},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.serial},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.uuid},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.family, "family"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.version, "version"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.sku, "sku"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.vendor, "vendor"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.serial, "serial"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.uuid, "uuid"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -150,13 +150,13 @@ exit:
|
||||
void ffPrintHostHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_HOST_MODULE_NAME, "{2} {3}", FF_HOST_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"product family",
|
||||
"product name",
|
||||
"product version",
|
||||
"product sku",
|
||||
"product vendor",
|
||||
"product serial number",
|
||||
"product uuid",
|
||||
"product family - family",
|
||||
"product name - name",
|
||||
"product version - version",
|
||||
"product sku - sku",
|
||||
"product vendor - vendor",
|
||||
"product serial number - serial",
|
||||
"product uuid - uuid",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ void ffPrintIcons(FFIconsOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_ICONS_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &icons}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &icons, "combined"}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ void ffGenerateIconsJsonResult(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_m
|
||||
void ffPrintIconsHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ICONS_MODULE_NAME, "{1}", FF_ICONS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Combined icons"
|
||||
"Combined icons - combined"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/initsystem/initsystem.h"
|
||||
#include "modules/initsystem/initsystem.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_INITSYSTEM_NUM_FORMAT_ARGS 4
|
||||
#define FF_INITSYSTEM_DISPLAY_NAME "Init System"
|
||||
|
||||
void ffPrintInitSystem(FFInitSystemOptions* options)
|
||||
{
|
||||
FFInitSystemResult result = {
|
||||
.name = ffStrbufCreate(),
|
||||
.exe = ffStrbufCreate(),
|
||||
.version = ffStrbufCreate(),
|
||||
.pid = 1,
|
||||
};
|
||||
|
||||
const char* error = ffDetectInitSystem(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufWriteTo(&result.name, stdout);
|
||||
if (result.version.length)
|
||||
printf(" (%s)\n", result.version.chars);
|
||||
else
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_INITSYSTEM_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.exe, "exe"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result.pid, "pid"},
|
||||
}));
|
||||
}
|
||||
|
||||
exit:
|
||||
ffStrbufDestroy(&result.name);
|
||||
ffStrbufDestroy(&result.exe);
|
||||
}
|
||||
|
||||
bool ffParseInitSystemCommandOptions(FFInitSystemOptions* options, const char* key, const char* value)
|
||||
{
|
||||
const char* subKey = ffOptionTestPrefix(key, FF_INITSYSTEM_MODULE_NAME);
|
||||
if (!subKey) return false;
|
||||
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffParseInitSystemJsonObject(FFInitSystemOptions* options, yyjson_val* module)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateInitSystemJsonConfig(FFInitSystemOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
__attribute__((__cleanup__(ffDestroyInitSystemOptions))) FFInitSystemOptions defaultOptions;
|
||||
ffInitInitSystemOptions(&defaultOptions);
|
||||
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffGenerateInitSystemJsonResult(FF_MAYBE_UNUSED FFInitSystemOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
FFInitSystemResult result = {
|
||||
.name = ffStrbufCreate(),
|
||||
.exe = ffStrbufCreate(),
|
||||
.version = ffStrbufCreate(),
|
||||
.pid = 1,
|
||||
};
|
||||
|
||||
const char* error = ffDetectInitSystem(&result);
|
||||
|
||||
if (error)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "name", &result.name);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "exe", &result.exe);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "version", &result.version);
|
||||
yyjson_mut_obj_add_uint(doc, obj, "pid", result.pid);
|
||||
|
||||
exit:
|
||||
ffStrbufDestroy(&result.name);
|
||||
ffStrbufDestroy(&result.exe);
|
||||
}
|
||||
|
||||
void ffPrintInitSystemHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, "{1}", FF_INITSYSTEM_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"init system name - name",
|
||||
"init system exe path - exe",
|
||||
"init system version path - version",
|
||||
"init system pid - pid",
|
||||
}));
|
||||
}
|
||||
|
||||
void ffInitInitSystemOptions(FFInitSystemOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_INITSYSTEM_MODULE_NAME,
|
||||
"Print init system (pid 1) name and version",
|
||||
ffParseInitSystemCommandOptions,
|
||||
ffParseInitSystemJsonObject,
|
||||
ffPrintInitSystem,
|
||||
ffGenerateInitSystemJsonResult,
|
||||
ffPrintInitSystemHelpFormat,
|
||||
ffGenerateInitSystemJsonConfig
|
||||
);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffDestroyInitSystemOptions(FFInitSystemOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_INITSYSTEM_MODULE_NAME "InitSystem"
|
||||
|
||||
void ffPrintInitSystem(FFInitSystemOptions* options);
|
||||
void ffInitInitSystemOptions(FFInitSystemOptions* options);
|
||||
void ffDestroyInitSystemOptions(FFInitSystemOptions* options);
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef struct FFInitSystemOptions
|
||||
{
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFInitSystemOptions;
|
||||
+10
-10
@@ -21,11 +21,11 @@ void ffPrintKernel(FFKernelOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_KERNEL_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemRelease},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemArchitecture},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemDisplayVersion}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemName, "sysname"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemRelease, "release"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemVersion, "version"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemArchitecture, "arch"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemDisplayVersion, "display-version"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -78,11 +78,11 @@ void ffGenerateKernelJsonResult(FF_MAYBE_UNUSED FFKernelOptions* options, yyjson
|
||||
void ffPrintKernelHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KERNEL_MODULE_NAME, "{1} {2}", FF_KERNEL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Sysname",
|
||||
"Release",
|
||||
"Version",
|
||||
"Architecture",
|
||||
"Display version",
|
||||
"Sysname - sysname",
|
||||
"Release - release",
|
||||
"Version - version",
|
||||
"Architecture - arch",
|
||||
"Display version - display-version",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -39,9 +39,9 @@ void ffPrintLM(FFLMOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LM_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.service},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.type},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.service, "service"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.type, "type"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"},
|
||||
}));
|
||||
}
|
||||
ffStrbufDestroy(&result.service);
|
||||
@@ -118,9 +118,9 @@ exit:
|
||||
void ffPrintLMHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LM_MODULE_NAME, "{1} {3} ({2})", FF_LM_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"LM service",
|
||||
"LM type",
|
||||
"LM version"
|
||||
"LM service - service",
|
||||
"LM type - type",
|
||||
"LM version - version"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ void ffPrintLoadavg(FFLoadavgOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOADAVG_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOADAVG_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result[0]},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result[1]},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result[2]},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result[0], "loadavg1"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result[1], "loadavg2"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &result[2], "loadavg3"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -101,9 +101,9 @@ void ffGenerateLoadavgJsonResult(FF_MAYBE_UNUSED FFLoadavgOptions* options, yyjs
|
||||
void ffPrintLoadavgHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOADAVG_MODULE_NAME, "{1}, {2}, {3}", FF_LOADAVG_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Load average over 1min",
|
||||
"Load average over 5min",
|
||||
"Load average over 15min",
|
||||
"Load average over 1min - loadavg1",
|
||||
"Load average over 5min - loadavg2",
|
||||
"Load average over 15min - loadavg3",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ void ffPrintLocale(FFLocaleOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOCALE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &locale}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &locale, "result"}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ void ffGenerateLocaleJsonResult(FF_MAYBE_UNUSED FFLocaleOptions* options, yyjson
|
||||
void ffPrintLocaleHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALE_MODULE_NAME, "{1}", FF_LOCALE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Locale code"
|
||||
"Locale code - result"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ static void formatKey(const FFLocalIpOptions* options, FFLocalIpResult* ip, uint
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &index},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &index, "index"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac, "mac"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -111,11 +111,11 @@ void ffPrintLocalIp(FFLocalIpOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_LOCALIP_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->name},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &ip->defaultRoute},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4, "ipv4"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6, "ipv6"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac, "mac"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->name, "ifname"},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &ip->defaultRoute, "is-default-route"},
|
||||
}));
|
||||
}
|
||||
++index;
|
||||
@@ -387,11 +387,11 @@ void ffGenerateLocalIpJsonResult(FF_MAYBE_UNUSED FFLocalIpOptions* options, yyjs
|
||||
void ffPrintLocalIpHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALIP_MODULE_NAME, "{1}", FF_LOCALIP_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Local IPv4 address",
|
||||
"Local IPv6 address",
|
||||
"Physical (MAC) address",
|
||||
"Interface name",
|
||||
"Is default route"
|
||||
"Local IPv4 address - ipv4",
|
||||
"Local IPv6 address - ipv6",
|
||||
"Physical (MAC) address - mac",
|
||||
"Interface name - ifname",
|
||||
"Is default route - is-default-route"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -96,11 +96,11 @@ void ffPrintMedia(FFMediaOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEDIA_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &songPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->song},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->artist},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->album},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->status}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &songPretty, "combined"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->song, "title"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->artist, "artist"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->album, "album"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &media->status, "status"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -160,11 +160,11 @@ void ffGenerateMediaJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_m
|
||||
void ffPrintMediaHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEDIA_MODULE_NAME, "{3} - {1} ({5})", FF_MEDIA_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Pretty media name",
|
||||
"Media name",
|
||||
"Artist name",
|
||||
"Album name",
|
||||
"Status",
|
||||
"Pretty media name - combined",
|
||||
"Media name - title",
|
||||
"Artist name - artist",
|
||||
"Album name - album",
|
||||
"Status - status",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&percentageStr, percentage, options->percent, false, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "used"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "total"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr, "percentage"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -128,9 +128,9 @@ void ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson
|
||||
void ffPrintMemoryHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEMORY_MODULE_NAME, "{1} / {2} ({3})", FF_MEMORY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Used size",
|
||||
"Total size",
|
||||
"Percentage used",
|
||||
"Used size - used",
|
||||
"Total size - total",
|
||||
"Percentage used - percentage",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "modules/gpu/gpu.h"
|
||||
#include "modules/host/host.h"
|
||||
#include "modules/icons/icons.h"
|
||||
#include "modules/initsystem/initsystem.h"
|
||||
#include "modules/kernel/kernel.h"
|
||||
#include "modules/lm/lm.h"
|
||||
#include "modules/loadavg/loadavg.h"
|
||||
|
||||
@@ -42,8 +42,8 @@ void ffPrintMonitor(FFMonitorOptions* options)
|
||||
{
|
||||
uint32_t moduleIndex = result.length == 1 ? 0 : index + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex, "index"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name, "name"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -69,16 +69,16 @@ void ffPrintMonitor(FFMonitorOptions* options)
|
||||
buf[0] = '\0';
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_MONITOR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->width},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->height},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->physicalWidth},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->physicalHeight},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &inch},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &ppi},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureYear},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureWeek},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, buf},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name, "name"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->width, "width"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->height, "height"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->physicalWidth, "physical-width"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->physicalHeight, "physical-height"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &inch, "inch"},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &ppi, "ppi"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureYear, "manufacture-year"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureWeek, "manufacture-week"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, buf, "serial"},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -180,16 +180,16 @@ void ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjs
|
||||
void ffPrintMonitorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MONITOR_MODULE_NAME, "{2}x{3} px - {4}x{5} mm ({6} inches, {7} ppi)", FF_MONITOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Display name",
|
||||
"Native resolution width in pixels",
|
||||
"Native resolution height in pixels",
|
||||
"Physical width in millimeters",
|
||||
"Physical height in millimeters",
|
||||
"Physical diagonal length in inches",
|
||||
"Pixels per inch (PPI)",
|
||||
"Year of manufacturing",
|
||||
"Nth week of manufacturing in the year",
|
||||
"Serial number",
|
||||
"Display name - name",
|
||||
"Native resolution width in pixels - width",
|
||||
"Native resolution height in pixels - height",
|
||||
"Physical width in millimeters - physical-width",
|
||||
"Physical height in millimeters - physical-height",
|
||||
"Physical diagonal length in inches - inch",
|
||||
"Pixels per inch (PPI) - ppi",
|
||||
"Year of manufacturing - manufacture-year",
|
||||
"Nth week of manufacturing in the year - manufacture-week",
|
||||
"Serial number - serial",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+26
-26
@@ -26,8 +26,8 @@ static void formatKey(const FFNetIOOptions* options, FFNetIOResult* inf, uint32_
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 2, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &index},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &inf->name},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &index, "index"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &inf->name, "name"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -80,18 +80,18 @@ void ffPrintNetIO(FFNetIOOptions* options)
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s");
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_NETIO_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer2},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &inf->name},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &inf->defaultRoute},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txBytes},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxBytes},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txPackets},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxPackets},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxErrors},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txErrors},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxDrops},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txDrops},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "rx-size"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer2, "tx-size"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &inf->name, "ifname"},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &inf->defaultRoute, "is-default-route"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txBytes, "tx-bytes"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxBytes, "rx-bytes"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txPackets, "tx-packets"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxPackets, "rx-packets"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxErrors, "rx-errors"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txErrors, "tx-errors"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxDrops, "rx-drops"},
|
||||
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txDrops, "tx-drops"},
|
||||
}));
|
||||
}
|
||||
++index;
|
||||
@@ -219,18 +219,18 @@ void ffGenerateNetIOJsonResult(FFNetIOOptions* options, yyjson_mut_doc* doc, yyj
|
||||
void ffPrintNetIOHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_NETIO_MODULE_NAME, "{1} (IN) - {2} (OUT)", FF_NETIO_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size of data received [per second] (formatted)",
|
||||
"Size of data sent [per second] (formatted)",
|
||||
"Interface name",
|
||||
"Is default route",
|
||||
"Size of data received [per second] (in bytes)",
|
||||
"Size of data sent [per second] (in bytes)",
|
||||
"Number of packets received [per second]",
|
||||
"Number of packets sent [per second]",
|
||||
"Number of errors received [per second]",
|
||||
"Number of errors sent [per second]",
|
||||
"Number of packets dropped when receiving [per second]",
|
||||
"Number of packets dropped when sending [per second]",
|
||||
"Size of data received [per second] (formatted) - rx-size",
|
||||
"Size of data sent [per second] (formatted) - tx-size",
|
||||
"Interface name - ifname",
|
||||
"Is default route - is-default-route",
|
||||
"Size of data received [per second] (in bytes) - rx-bytes",
|
||||
"Size of data sent [per second] (in bytes) - tx-bytes",
|
||||
"Number of packets received [per second] - rx-packets",
|
||||
"Number of packets sent [per second] - tx-packets",
|
||||
"Number of errors received [per second] - rx-errors",
|
||||
"Number of errors sent [per second] - tx-errors",
|
||||
"Number of packets dropped when receiving [per second] - rx-drops",
|
||||
"Number of packets dropped when sending [per second] - tx-drops",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ void ffPrintOpenCL(FFOpenCLOptions* options)
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENCL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &opencl.version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &opencl.device},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &opencl.vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &opencl.version, "version"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &opencl.device, "device"},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &opencl.vendor, "vendor"},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -103,9 +103,9 @@ void ffGenerateOpenCLJsonResult(FF_MAYBE_UNUSED FFOpenCLOptions* options, yyjson
|
||||
void ffPrintOpenCLHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENCL_MODULE_NAME, "{1}", FF_OPENCL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"version",
|
||||
"device",
|
||||
"vendor"
|
||||
"version - version",
|
||||
"device - device",
|
||||
"vendor - vendor"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user