Merge pull request #1001 from fastfetch-cli/dev

Release: v2.15.0
This commit is contained in:
Carter Li
2024-06-07 03:42:06 +00:00
committed by GitHub
83 changed files with 1680 additions and 8239 deletions
+12 -12
View File
@@ -7,9 +7,9 @@ assignees: ''
---
Be sure to read [FAQ](https://github.com/fastfetch-cli/fastfetch?tab=readme-ov-file#faq) before submitting a new issue.
Be sure to read the [FAQ](https://github.com/fastfetch-cli/fastfetch?tab=readme-ov-file#faq) before submitting a new issue.
<!-- We will try hard to solve the issue. However since platforms and hardwares vary greatly, it can be hard to find the root cause is. Providing following information may help us greatly. Thanks in advance -->
<!-- We will try hard to solve the issue. However since platforms and hardwares vary greatly, it can be hard to find the root cause of an issue. Providing the following information may help us greatly. Thanks in advance! -->
# General description of bug:
@@ -17,8 +17,8 @@ Be sure to read [FAQ](https://github.com/fastfetch-cli/fastfetch?tab=readme-ov-f
* What should happen:
* Fastfetch version used: <!-- please use the latest version, if possible -->
* Did it work in an older version: <!-- if yes, which version -->
* Where did you get the binary: <!-- Github Release / Github Actions / Installed with a package manager (What package manager) / Built from source yourself -->
* Does this issue still occurs in [the latest dev build](https://github.com/fastfetch-cli/fastfetch/actions/)?
* Where did you get the binary: <!-- GitHub release / GitHub Actions / installed with a package manager (please tell us which package manager you used!) / built from source yourself -->
* Does this issue still occur in [the latest dev build](https://github.com/fastfetch-cli/fastfetch/actions/)?
# Often helpful information:
@@ -27,7 +27,7 @@ Screenshot:
The content of the configuration file you use (if any):
```
//paste here
// Paste here
```
Output of `fastfetch -c ci.jsonc --format json`:
@@ -36,15 +36,15 @@ Note that this output will contain you public IP. If it is not relevant for the
-->
```
//paste here
// Paste here
```
Output of `fastfetch --list-features`:
```
//paste here
// Paste here
```
## If fastfatch crashed or freezed
## If fastfatch crashed or froze
Paste the stacktrace here. You may get it with:
@@ -65,16 +65,16 @@ If you cannot do the instructions above, please upload the core dump file:
Use `time fastfetch --stat` to show time usage for each module.
## If my image logo didn't show / work
## If an image or logo didn't show
<!-- Please make sure the terminal does support the image protocol you used. Note Gnome terminal doesn't support any image protocols -->
<!-- Please make sure your terminal supports the image protocol you used. Note that GNOME Terminal doesn't support any image protocols. -->
* The image protocol you used:
* The terminal you used:
* Upload the image file here, or paste the image URL:
* Does it work with `--logo-width {WIDTH} --logo-height {HEIGHT}`?
## If fastfetch behaves incorrectly on shell starting
## If fastfetch behaves incorrectly on shell startup
* The bug is reproduceable with fresh / clean shell configuration (i.e. `fastfetch` is the single line of `.zshrc` or `~/.config/fish/config.fish`):
* The bug is reproducible with a clean shell configuration (i.e. `fastfetch` is the only line in `.zshrc` or `~/.config/fish/config.fish`):
* Does `sleep 1` before running `fastfetch` work?
+31 -5
View File
@@ -1,3 +1,27 @@
# 2.15.0
Changes:
* `--bar-border <?bool>` has been changed to `--bar-border-left <string>` and `--bar-border-right <string>`, which are used for customizing the style of bar border.
* `--bar-border-left '' --bar-border-right ''` can be used to disable the border
Features:
* Add ability to skip installing license with INSTALL_LICENSE option (CMake)
* Make it possible to shorten the theme and icons output (Theme / Icons)
* Support `-l '?'` to show a question mark
* Add new module `CPUCache` to display CPU cache sizes (CPUCache)
* In `--<module>-format`, `{#keys}` and `{#title}` can be used to reference the color of keys and title
* Improve speed of Guix package detection (Packages, Linux)
* Assume wm plugins are daemon processes to improve performance (WM, macOS)
Bugfixes:
* Remove shebangs from completions (#980)
* Fix while chars not visible in terminal of light theme (Logo)
* Normalize bright colors to fix color display in Apple Terminal (#991, Colors)
* Correctly capitalize GNOME (#997, DE, Linux)
* Fix segfault on system using turkish language (#995, InitSystem, Linux)
* Fix kubuntu detection (#1000, OS, Linux)
* Don't display duplicate entries (OS, Linux)
# 2.14.0
Features:
@@ -7,12 +31,14 @@ Features:
* 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}'`
* `--title-format '{user-name-colored}{at-symbol-colored}{host-name-colored}'` is now 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}'`
* `--<module>-format '{#red}'` is now 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 new module `InitSystem`, which detects the name of init system
* i.e. process name of pid1. `init`, `systemd`, etc
* 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)
@@ -254,7 +280,7 @@ Features:
* Improve GPU detection on Linux (GPU, Linux)
* Support GPU memory usage detection for AMD GPUs
* Support GPU frequency detection for Intel GPUs
* Improve performance of Gnome version detection (DE, Linux)
* Improve performance of GNOME version detection (DE, Linux)
* Improve performance of kitty version detection (Terminal, Linux)
* Detect refresh rate when using `--ds-force-drm sysfs-only` (Display, Linux)
* Add option `--ts-version` to disable terminal and shell version detection. Mainly for benchmarking purposes
@@ -961,7 +987,7 @@ Bugfixes:
* Fix Windows drives detection in WSL (Linux, Disk)
* Fix CPU temp detection (FreeBSD, CPU)
* Fix disk detection (Android, Disk)
* Fix Gnome Terminal version and font detection (FreeBSD, TerminalFont)
* Fix GNOME Terminal version and font detection (FreeBSD, TerminalFont)
* Fix crash on newer wayland desktops (Linux, Display, #477)
* Fix vendor detection for Intel GPU (macOS, GPU)
* Fix possible crashes on Windows Server (Windows, GPU, #484)
@@ -987,7 +1013,7 @@ Features:
* Add mac address detection `--localip-show-mac` (LocalIP, #451)
Bugfixes:
* Fix Gnome version detection on Fedora (DE)
* Fix GNOME version detection on Fedora (DE)
* Fix Windows drives detection in WSL (Disk)
Changes:
+16 -7
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 2.14.0
VERSION 2.15.0
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
@@ -76,6 +76,7 @@ option(ENABLE_PROPRIETARY_GPU_DRIVER_API "Enable proprietary GPU driver API (NVM
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
option(INSTALL_LICENSE "Install license into /usr/share/licenses" ON)
set(BINARY_LINK_TYPE_OPTIONS dlopen dynamic static)
set(BINARY_LINK_TYPE dlopen CACHE STRING "How to link fastfetch")
@@ -330,6 +331,7 @@ set(LIBFASTFETCH_SRC
src/modules/chassis/chassis.c
src/modules/colors/colors.c
src/modules/cpu/cpu.c
src/modules/cpucache/cpucache.c
src/modules/cpuusage/cpuusage.c
src/modules/cursor/cursor.c
src/modules/custom/custom.c
@@ -410,6 +412,7 @@ if(LINUX)
src/detection/brightness/brightness_linux.c
src/detection/chassis/chassis_linux.c
src/detection/cpu/cpu_linux.c
src/detection/cpucache/cpucache_linux.c
src/detection/cpuusage/cpuusage_linux.c
src/detection/cursor/cursor_linux.c
src/detection/bluetooth/bluetooth_linux.c
@@ -480,6 +483,7 @@ elseif(ANDROID)
src/detection/brightness/brightness_nosupport.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_linux.c
src/detection/cpucache/cpucache_linux.c
src/detection/cursor/cursor_nosupport.c
src/detection/cpuusage/cpuusage_linux.c
src/detection/disk/disk_linux.c
@@ -540,6 +544,7 @@ elseif(BSD)
src/detection/brightness/brightness_bsd.c
src/detection/chassis/chassis_bsd.c
src/detection/cpu/cpu_bsd.c
src/detection/cpucache/cpucache_nosupport.c
src/detection/cpuusage/cpuusage_bsd.c
src/detection/cursor/cursor_linux.c
src/detection/disk/disk_bsd.c
@@ -610,6 +615,7 @@ elseif(APPLE)
src/detection/brightness/brightness_apple.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_apple.c
src/detection/cpucache/cpucache_apple.c
src/detection/cpuusage/cpuusage_apple.c
src/detection/cursor/cursor_apple.m
src/detection/disk/disk_bsd.c
@@ -671,6 +677,7 @@ elseif(WIN32)
src/detection/brightness/brightness_windows.cpp
src/detection/chassis/chassis_windows.c
src/detection/cpu/cpu_windows.c
src/detection/cpucache/cpucache_windows.c
src/detection/cpuusage/cpuusage_windows.c
src/detection/cursor/cursor_windows.c
src/detection/disk/disk_windows.c
@@ -1157,13 +1164,13 @@ install(
)
install(
FILES "${CMAKE_SOURCE_DIR}/completions/bash"
FILES "${CMAKE_SOURCE_DIR}/completions/${CMAKE_PROJECT_NAME}.bash"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions"
RENAME "${CMAKE_PROJECT_NAME}"
)
install(
FILES "${CMAKE_SOURCE_DIR}/completions/fish"
FILES "${CMAKE_SOURCE_DIR}/completions/${CMAKE_PROJECT_NAME}.fish"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d"
RENAME "${CMAKE_PROJECT_NAME}.fish"
)
@@ -1173,10 +1180,12 @@ install(
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}"
)
install(
FILES "${CMAKE_SOURCE_DIR}/LICENSE"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}"
)
if(INSTALL_LICENSE)
install(
FILES "${CMAKE_SOURCE_DIR}/LICENSE"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}"
)
endif()
install(
FILES "${PROJECT_BINARY_DIR}/fastfetch.1"
@@ -1,5 +1,3 @@
#!/usr/bin/env bash
__fastfetch_complete_help()
{
local __ff_helps=(
@@ -1,5 +1,3 @@
#!/usr/bin/env fish
if not type -q fastfetch
exit
end
+28 -18
View File
@@ -26,7 +26,7 @@ the exit code will be non\-zero.
.SS "Informative Options"
.TP
.B \-h, \-\-help \fI [command]
.B \-h, \-\-help \fI[command]
Show help output, displaying all available options or help for given command
.TP
@@ -43,7 +43,7 @@ List search paths of presets and logos
.TP
.B \-\-list\-logos
List available logos, they can be loaded with \fI \-\-logo
List available logos, they can be loaded with \fI\-\-logo
.TP
.B \-\-list\-modules
@@ -51,7 +51,7 @@ List available modules
.TP
.B \-\-list\-presets
List available presets, they can be loaded with \fI \-\-config
List available presets, they can be loaded with \fI\-\-config
.TP
.B \-\-list\-features
@@ -64,16 +64,24 @@ Print available logos
.B \-\-print\-structure
Print the default structure
.TP
.B \-\-format \fI<type>
Set the output format. Besides the
.I default
format, only
.I json
is supported currently.
.SS "Display Options"
.TP
.B \-l, \-\-logo \fI <logo>
.B \-l, \-\-logo \fI<logo>
Set the logo to display
.TP
.B \-s, \-\-structure \fI <structure>
.B \-s, \-\-structure \fI<structure>
Set the structure of the fetch. For details about the structure,
see the CONFIGURATION section.
@@ -81,38 +89,40 @@ see the CONFIGURATION section.
.SS "Config Options"
.TP
.B \-c, \-\-config \fI <config>
Use the specified config file or preset. If "none", disable further config
loading. For details about config files, see the CONFIGURATION section
.B \-c, \-\-config \fI<config>
Use the specified config file or preset. If
.I none
is specified, disable further config loading. For details about
config files, see the CONFIGURATION section
.TP
.B \-\-gen\-config \fI [file]
.B \-\-gen\-config \fI[file]
Generate a config file with options specified on the command line.
If \fI file \fR is specified, the configuration will written to the
If \fIfile\fR is specified, the configuration will written to the
file, otherwise it will be written to stdout.
.TP
.B \-\-gen\-config\-force \fI [file]
Same as \fB \-\-gen\-config\fR, but overwrites existing config
.B \-\-gen\-config\-force \fI[file]
Same as \fB\-\-gen\-config\fR, but overwrites existing config
.TP
To list all options, use \fB \-\-help\fR this will also print all available module options.
To list all options, use \fB\-\-help\fR. It will also print all available module options.
.SH CONFIGURATION
.SS "Fetch Structure"
The structure of a fetch describes the modules that should be included in
the output. It consists of a string of modules, separated by a colon (:).
To list all available modules, use \fB \-\-list\-modules \fR
To list all available modules, use \fB\-\-list\-modules\fR
.SS "Config Files"
Fastfetch uses JSONC based format for configuration. Fastfetch doesn't generate
config file automatically; it should be generated manually by \fB \-\-gen\-config\fR.
config file automatically; it should be generated manually by \fB\-\-gen\-config\fR.
The config file will be saved in \fB~/.config/fastfetch/config.jsonc\fR by default.
A JSONC config file is a JSON file that also supports comments with (//). Those
files must have the extension '.jsonc'.
A JSONC config file is a JSON file that also supports comments with (// and /* */).
Those files must have the extension '.jsonc'.
The specified configuration/preset files are searched in the following order:
@@ -128,4 +138,4 @@ Fastfetch provides some default presets. List them with \fB\-\-list\-presets\fR.
.BR neofetch (1)
.SH BUGS
Please report bugs to:\fI https://github.com/fastfetch\-cli/fastfetch/issues \fR
Please report bugs to: \fIhttps://github.com/fastfetch\-cli/fastfetch/issues\fR
+19 -4
View File
@@ -499,10 +499,15 @@
"description": "Set the character to use in total part",
"default": "-"
},
"border": {
"type": "boolean",
"description": "Whether to show a border around the bar",
"default": true
"borderLeft": {
"type": "string",
"description": "Set the string to use at left border",
"default": "[ "
},
"borderRight": {
"type": "string",
"description": "Set the string to use at right border",
"default": " ]"
},
"width": {
"type": "integer",
@@ -690,6 +695,7 @@
"camera",
"chassis",
"cpu",
"cpucache",
"cpuusage",
"command",
"colors",
@@ -705,6 +711,7 @@
"gpu",
"host",
"icons",
"initsystem",
"kernel",
"lm",
"loadavg",
@@ -792,6 +799,10 @@
"const": "camera",
"description": "Print available cameras"
},
{
"const": "cpucache",
"description": "Print CPU cache sizes"
},
{
"const": "cursor",
"description": "Print cursor style name"
@@ -816,6 +827,10 @@
"const": "icons",
"description": "Print icon style name"
},
{
"const": "initsystem",
"description": "Print init system (pid 1) name and version"
},
{
"const": "kernel",
"description": "Print system kernel version"
+21 -5
View File
@@ -1,5 +1,10 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"padding": {
"top": 2
}
},
"modules": [
"title",
"separator",
@@ -35,10 +40,15 @@
"terminaltheme",
{
"type": "cpu",
"showPeCoreCount": true
"showPeCoreCount": true,
"temp": true
},
"cpucache",
"cpuusage",
"gpu",
{
"type": "gpu",
"temp": true
},
"memory",
"physicalmemory",
"swap",
@@ -50,7 +60,7 @@
"publicip",
{
"type": "localip",
"showIpV6": true,
"showIpv6": true,
"showMac": true
},
"wifi",
@@ -64,10 +74,16 @@
"sound",
"camera",
"gamepad",
"weather",
{
"type": "weather",
"timeout": 1000
},
"netio",
"diskio",
"physicaldisk",
{
"type": "physicaldisk",
"temp": true
},
"version",
"break",
"colors"
+12 -4
View File
@@ -42,10 +42,15 @@
"terminaltheme",
{
"type": "cpu",
"showPeCoreCount": true
"showPeCoreCount": true,
"temp": true
},
"cpucache",
"cpuusage",
"gpu",
{
"type": "gpu",
"temp": true
},
"memory",
"physicalmemory",
"swap",
@@ -57,7 +62,7 @@
"publicip",
{
"type": "localip",
"showIpV6": true,
"showIpv6": true,
"showMac": true
},
"wifi",
@@ -77,7 +82,10 @@
},
"netio",
"diskio",
"physicaldisk",
{
"type": "physicaldisk",
"temp": true
},
"version",
"break",
"colors"
+85
View File
@@ -0,0 +1,85 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small"
},
"display": {
"separator": "",
"keyWidth": 12
},
"modules": [
{
// draw borders first to make colors of left and right border consistant
"key": " user",
"type": "title",
"format": "{1}",
"keyColor": "31"
},
{
"key": "󰇅 hname",
"type": "title",
"format": "{2}",
"keyColor": "32"
},
{
"key": "󰅐 uptime",
"type": "uptime",
"keyColor": "33"
},
{
"key": "󰟾 distro",
"type": "os",
"keyColor": "34"
},
{
"key": " kernel",
"type": "kernel",
"keyColor": "35"
},
{
"key": "󰇄 desktop",
"type": "de",
"keyColor": "36"
},
{
"key": " term",
"type": "terminal",
"keyColor": "31"
},
{
"key": " shell",
"type": "shell",
"keyColor": "32"
},
{
"key": "󰍛 cpu",
"type": "cpu",
"showPeCoreCount": true,
"keyColor": "33"
},
{
"key": "󰉉 disk",
"type": "disk",
"folders": "/",
"keyColor": "34"
},
{
"key": " memory",
"type": "memory",
"keyColor": "35"
},
{
"key": "󰩟 network",
"type": "localip",
"format": "{1} ({4})",
"keyColor": "36"
},
{
"key": " colors",
"type": "colors",
"symbol": "circle",
"keyColor": "39"
}
]
}
+86
View File
@@ -0,0 +1,86 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small",
"padding": {
"top": 1
}
},
"display": {
"separator": "",
"keyWidth": 15
},
"modules": [
{
"key": "•••••••••••••",
"type": "custom"
},
{
// draw borders first to make colors of left and right border consistant
"key": "• •\u001b[11D{#31} user",
"type": "title",
"format": "{1}"
},
{
"key": "• •\u001b[11D{#32}󰇅 hname",
"type": "title",
"format": "{2}"
},
{
"key": "• •\u001b[11D{#33}󰅐 uptime",
"type": "uptime"
},
{
"key": "• •\u001b[11D{#34}󰟾 distro",
"type": "os"
},
{
"key": "• •\u001b[11D{#35} kernel",
"type": "kernel"
},
{
"key": "• •\u001b[11D{#36}󰇄 desktop",
"type": "de"
},
{
"key": "• •\u001b[11D{#31} term",
"type": "terminal"
},
{
"key": "• •\u001b[11D{#32} shell",
"type": "shell"
},
{
"key": "• •\u001b[11D{#33}󰍛 cpu",
"type": "cpu",
"showPeCoreCount": true
},
{
"key": "• •\u001b[11D{#34}󰉉 disk",
"type": "disk",
"folders": "/"
},
{
"key": "• •\u001b[11D{#35} memory",
"type": "memory"
},
{
"key": "• •\u001b[11D{#36}󰩟 network",
"type": "localip",
"format": "{1} ({4})"
},
{
"key": "•••••••••••••",
"type": "custom"
},
{
"key": "• •\u001b[11D{#39} colors",
"type": "colors",
"symbol": "circle"
},
{
"key": "•••••••••••••",
"type": "custom"
}
]
}
+84
View File
@@ -0,0 +1,84 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small",
"padding": {
"top": 1
}
},
"display": {
"separator": " "
},
"modules": [
{
"key": "╔═══════════╗",
"type": "custom"
},
{
"key": "║ {#31} user {#keys}║",
"type": "title",
"format": "{1}"
},
{
"key": "║ {#32}󰇅 hname {#keys}║",
"type": "title",
"format": "{2}"
},
{
"key": "║ {#33}󰅐 uptime {#keys}║",
"type": "uptime"
},
{
"key": "║ {#34}󰟾 distro {#keys}║",
"type": "os"
},
{
"key": "║ {#35} kernel {#keys}║",
"type": "kernel"
},
{
"key": "║ {#36}󰇄 desktop {#keys}║",
"type": "de"
},
{
"key": "║ {#31} term {#keys}║",
"type": "terminal"
},
{
"key": "║ {#32} shell {#keys}║",
"type": "shell"
},
{
"key": "║ {#33}󰍛 cpu {#keys}║",
"type": "cpu",
"showPeCoreCount": true
},
{
"key": "║ {#34}󰉉 disk {#keys}║",
"type": "disk",
"folders": "/"
},
{
"key": "║ {#35} memory {#keys}║",
"type": "memory"
},
{
"key": "║ {#36}󰩟 network {#keys}║",
"type": "localip",
"format": "{1} ({4})"
},
{
"key": "╠═══════════╣",
"type": "custom"
},
{
"key": "║ {#39} colors {#keys}║",
"type": "colors",
"symbol": "circle"
},
{
"key": "╚═══════════╝",
"type": "custom"
}
]
}
+83
View File
@@ -0,0 +1,83 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small",
"padding": {
"top": 1,
"right": 2
}
},
"display": {
"separator": "> ",
"color": {
"separator": "red"
}
},
"modules": [
{
"format": "{#1}{#keys}╭───────────────────────────────────────────────────────────────────────────╮\u001b[76D {6}{7}{8} 🖥 ",
"type": "title"
},
{
"key": "│\u001b[75C│\u001b[75D{#31} kernel ",
"type": "kernel"
},
{
"key": "│\u001b[75C│\u001b[75D{#32}󰅐 uptime ",
"type": "uptime"
},
{
"key": "│\u001b[75C│\u001b[75D{#33}󰟾 distro ",
"type": "os"
},
{
"key": "│\u001b[75C│\u001b[75D{#34}󰇄 desktop ",
"type": "de"
},
{
"key": "│\u001b[75C│\u001b[75D{#35} term ",
"type": "terminal"
},
{
"key": "│\u001b[75C│\u001b[75D{#36} shell ",
"type": "shell"
},
{
"key": "│\u001b[75C│\u001b[75D{#35}󰍛 cpu ",
"type": "cpu",
"showPeCoreCount": true,
"temp": true
},
{
"key": "│\u001b[75C│\u001b[75D{#34}󰍛 gpu ",
"type": "gpu"
},
{
"key": "│\u001b[75C│\u001b[75D{#33}󰉉 disk ",
"type": "disk",
"folders": "/"
},
{
"key": "│\u001b[75C│\u001b[75D{#32} memory ",
"type": "memory"
},
{
"key": "│\u001b[75C│\u001b[75D{#31}󰩟 network ",
"type": "localip",
"format": "{1} ({4})"
},
{
"format": "{#1}{#keys}├───────────────────────────────────────────────────────────────────────────┤",
"type": "custom"
},
{
"key": "│\u001b[75C│\u001b[75D{#39} colors ",
"type": "colors",
"symbol": "circle"
},
{
"format": "{#1}{#keys}╰───────────────────────────────────────────────────────────────────────────╯",
"type": "custom"
}
]
}
+83
View File
@@ -0,0 +1,83 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small",
"padding": {
"top": 1,
"right": 2
}
},
"display": {
"separator": "> ",
"color": {
"separator": "red"
}
},
"modules": [
{
"format": "{#1}{#keys}╔═══════════════════════════════════════════════════════════════════════════╗\u001b[76D {6}{7}{8} 💻 ",
"type": "title"
},
{
"key": "║\u001b[75C║\u001b[75D{#31} kernel ",
"type": "kernel"
},
{
"key": "║\u001b[75C║\u001b[75D{#32}󰅐 uptime ",
"type": "uptime"
},
{
"key": "║\u001b[75C║\u001b[75D{#33}󰟾 distro ",
"type": "os"
},
{
"key": "║\u001b[75C║\u001b[75D{#34}󰇄 desktop ",
"type": "de"
},
{
"key": "║\u001b[75C║\u001b[75D{#35} term ",
"type": "terminal"
},
{
"key": "║\u001b[75C║\u001b[75D{#36} shell ",
"type": "shell"
},
{
"key": "║\u001b[75C║\u001b[75D{#35}󰍛 cpu ",
"type": "cpu",
"showPeCoreCount": true,
"temp": true
},
{
"key": "║\u001b[75C║\u001b[75D{#34}󰍛 gpu ",
"type": "gpu"
},
{
"key": "║\u001b[75C║\u001b[75D{#33}󰉉 disk ",
"type": "disk",
"folders": "/"
},
{
"key": "║\u001b[75C║\u001b[75D{#32} memory ",
"type": "memory"
},
{
"key": "║\u001b[75C║\u001b[75D{#31}󰩟 network ",
"type": "localip",
"format": "{1} ({4})"
},
{
"format": "{#1}{#keys}╠═══════════════════════════════════════════════════════════════════════════╣",
"type": "custom"
},
{
"key": "║\u001b[75C║\u001b[75D{#39} colors ",
"type": "colors",
"symbol": "circle"
},
{
"format": "{#1}{#keys}╚═══════════════════════════════════════════════════════════════════════════╝",
"type": "custom"
}
]
}
+3 -2
View File
@@ -5,7 +5,7 @@
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
// "logo": {
// "type": "iterm",
// "source": "/Users/carter/Desktop/apple1.png",
// "source": "~/Desktop/apple1.png",
// "width": 28,
// "height": 12
// },
@@ -15,7 +15,8 @@
"modules": [
{
"type": "custom", // HardwareStart
"format": "┌─────────── {#1}Hardware Information{#} ───────────┐" // {#1} is the same as `\u001b[1m`. {#} is `\u001b[m`
// {#1} is equivalent to `\u001b[1m`. {#} is equivalent to `\u001b[m`
"format": "┌─────────── {#1}Hardware Information{#} ───────────┐"
},
{
"type": "host",
+8 -2
View File
@@ -9,6 +9,9 @@
"charElapsed": "=",
"charTotal": "-",
"width": 13
},
"percent": {
"type": 2
}
},
"modules": [
@@ -16,11 +19,14 @@
"separator",
"memory",
"swap",
"disk",
{
"type": "disk",
"folders": "/"
},
"battery",
{
"type": "colors",
"paddingLeft": 11,
"paddingLeft": 10,
"symbol": "circle"
}
]
+1 -4
View File
@@ -17,10 +17,7 @@
"break",
"packages",
"shell",
{
"type": "display",
"key": "Display"
},
"display",
"terminal",
"break",
"cpu",
+37
View File
@@ -0,0 +1,37 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"modules": [
"title",
"os",
"kernel",
"uptime",
{
"type": "packages",
"format": "{all}"
},
"shell",
{
"type": "display",
"key": "Resolution",
"compactType": "original"
},
"de",
"wm",
"wmtheme",
{
"type": "terminalfont",
"key": "font"
},
{
"type": "disk",
"folders": "/",
"key": "Disk"
},
"cpu",
"gpu",
{
"type": "memory",
"key": "RAM"
}
]
}
-27
View File
@@ -1,27 +0,0 @@
Intel Software License Agreement
10.07.21
Use and Redistribution. You may use and redistribute Intels Control API software and the header files for the Intel® Graphics Control Library (collectively, the “Software”), solely for use on Intel platforms, provided the following conditions are met:
* Redistributions must reproduce the above copyright notice and the following terms of use in the Software and in the documentation and/or other materials provided with the distribution.
* Neither the name of Intel nor the names of its suppliers may be used to endorse or promote products derived from this Software without specific prior written permission.
* No reverse engineering, decompilation, or disassembly of Software provided to you in binary form is permitted.
Third Party Software. The Software may contain Third Party Software. “Third Party Software” is third party software, open source software or other Intel software listed in the “third-party-software.txt” or other similarly named text file that is included with the Software. Third Party Software, even if included with the distribution of the Software, may be governed by separate license terms, including without limitation, third party license terms, open source software notices and terms, and/or other Intel software license terms. These separate license terms solely govern your use of the Third Party Software.
Ownership. Title to the Software and all copies remain with Intel or its suppliers.
DISCLAIMER. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED. THIS SOFTWARE IS NOT INTENDED FOR USE IN SYSTEMS OR APPLICATIONS WHERE FAILURE OF THE SOFTWARE MAY CAUSE PERSONAL INJURY OR DEATH AND YOU AGREE THAT YOU ARE FULLY RESPONSIBLE FOR ANY CLAIMS, COSTS, DAMAGES, EXPENSES, AND ATTORNEYS FEES ARISING OUT OF ANY SUCH USE, EVEN IF ANY CLAIM ALLEGES THAT INTEL WAS NEGLIGENT REGARDING THE DESIGN OR MANUFACTURE OF THE SOFTWARE.
LIMITATION OF LIABILITY; INDEMNITY. IN NO EVENT WILL INTEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. YOU AGREE TO INDEMNIFY, DEFEND, AND HOLD INTEL HARMLESS AGAINST ANY CLAIMS, DAMAGES, AND EXPENSES RESULTING FROM YOUR USE OR UNAUTHORIZED USE OF THE SOFTWARE.
No support. Intel may make changes to the Software, at any time without notice, and is not obligated to support, update or provide training for the Software.
Termination. Your right to use the Software is terminated immediately in the event of your breach of this agreement.
Feedback. Should you provide Intel with comments, modifications, corrections, enhancements or other input (“Feedback”) related to the Software Intel will be free to use, disclose, reproduce, license or otherwise distribute or exploit the Feedback in its sole discretion without any obligations or restrictions of any kind, including without limitation, intellectual property rights or licensing obligations.
Compliance with laws. You agree to comply with all applicable laws and regulations governing your use, transfer, import or export (or prohibition thereof) of the Software.
Governing law. All disputes will be governed by the laws of the United States of America and the State of Delaware without reference to conflict of law principles and subject to the exclusive jurisdiction of the state or federal courts sitting in the State of Delaware, and each party agrees that it submits to the personal jurisdiction and venue of those courts and waives any objections. The United Nations Convention on Contracts for the International Sale of Goods (1980) is specifically excluded and will not apply to the Software.
Severability. The parties intend that if a court holds that any provision of this agreement is invalid or unenforceable under applicable law, the court will modify the provision to the minimum extent necessary to make it valid and enforceable or sever and delete the provision from this agreement. Any change to or deletion of a provision of this agreement under this Section will not affect the validity or enforceability of the remainder of this agreement, which will continue in full force and effect.
-7906
View File
File diff suppressed because it is too large Load Diff
-6
View File
@@ -1,6 +0,0 @@
{
"home": "https://github.com/intel/drivers.gpu.control-library",
"license": "./LICENSE",
"version": "v184",
"author": "Intel Corporation"
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"home": "https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c",
"license": "Embed in source",
"license": "MIT compatible (embed in source)",
"version": "2007-05-26 (Unicode 5.0)",
"author": "Markus Kuhn",
"modified": "CarterLi"
+15 -2
View File
@@ -2,6 +2,7 @@
#include "common/parsing.h"
#include "common/thread.h"
#include "detection/displayserver/displayserver.h"
#include "detection/terminaltheme/terminaltheme.h"
#include "util/textModifier.h"
#include "logo/logo.h"
@@ -22,10 +23,18 @@ static void initState(FFstate* state)
state->logoWidth = 0;
state->logoHeight = 0;
state->keysHeight = 0;
state->terminalLightTheme = false;
ffPlatformInit(&state->platform);
state->configDoc = NULL;
state->resultDoc = NULL;
{
// don't enable bright color if the terminal is in light mode
FFTerminalThemeResult result;
if (ffDetectTerminalTheme(&result, true /* forceEnv for performance */) && !result.bg.dark)
state->terminalLightTheme = true;
}
}
static void defaultConfig(void)
@@ -43,8 +52,12 @@ void ffInitInstance(void)
//https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?source=recommendations&view=msvc-170#utf-8-support
setlocale(LC_ALL, ".UTF8");
#else
// used for mbsrtowcs in Module `separator`
setlocale(LC_ALL, "");
// Never use `setlocale(LC_ALL, "")`
setlocale(LC_TIME, "");
setlocale(LC_NUMERIC, "");
#ifdef LC_MESSAGES
setlocale(LC_MESSAGES, "");
#endif
#endif
initState(&instance.state);
+1
View File
@@ -21,6 +21,7 @@ static FFModuleBaseInfo* C[] = {
(void*) &instance.config.modules.command,
(void*) &instance.config.modules.colors,
(void*) &instance.config.modules.cpu,
(void*) &instance.config.modules.cpuCache,
(void*) &instance.config.modules.cpuUsage,
(void*) &instance.config.modules.cursor,
(void*) &instance.config.modules.custom,
+8
View File
@@ -1,3 +1,4 @@
#include "fastfetch.h"
#include "common/option.h"
#include "common/color.h"
#include "util/stringUtils.h"
@@ -153,6 +154,8 @@ void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer)
{
#define FF_APPEND_COLOR_CODE_COND(prefix, code) \
if(ffStrStartsWithIgnCase(value, #prefix)) { ffStrbufAppendS(buffer, code); value += strlen(#prefix); continue; }
#define FF_APPEND_COLOR_PROP_COND(prefix, prop) \
if(ffStrStartsWithIgnCase(value, #prefix)) { if (instance.config.display.prop.length) ffStrbufAppend(buffer, &instance.config.display.prop); else ffStrbufAppendS(buffer, FF_COLOR_FG_DEFAULT); value += strlen(#prefix); continue; }
if (ffCharIsEnglishAlphabet(value[0]))
{
@@ -182,11 +185,16 @@ void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer)
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 FF_APPEND_COLOR_PROP_COND(keys, colorKeys)
else FF_APPEND_COLOR_PROP_COND(title, colorTitle)
else FF_APPEND_COLOR_PROP_COND(output, colorOutput)
else FF_APPEND_COLOR_PROP_COND(separator, colorSeparator)
}
ffStrbufAppendC(buffer, *value);
++value;
#undef FF_APPEND_COLOR_CODE_COND
#undef FF_APPEND_COLOR_PROP_COND
}
}
+6 -8
View File
@@ -24,12 +24,11 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig con
uint32_t blocksPercent = (uint32_t) (percent / 100.0 * options->barWidth + 0.5);
assert(blocksPercent <= options->barWidth);
if(options->barBorder)
if(options->barBorderLeft.length)
{
if(!options->pipe)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m[ ");
else
ffStrbufAppendS(buffer, "[ ");
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m");
ffStrbufAppend(buffer, &options->barBorderLeft);
}
if (percent != percent)
@@ -91,12 +90,11 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig con
}
}
if(options->barBorder)
if(options->barBorderRight.length)
{
if(!options->pipe)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m ]");\
else
ffStrbufAppendS(buffer, " ]");
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m");
ffStrbufAppend(buffer, &options->barBorderRight);
}
if(!options->pipe)
+37 -9
View File
@@ -51,6 +51,18 @@
{
"long": "print-structure",
"desc": "Print the default structure"
},
{
"long": "format",
"desc": "Set output format",
"arg": {
"type": "enum",
"enum": {
"default": "Default format",
"json": "JSON format"
},
"default": "default"
}
}
],
"Config": [
@@ -604,6 +616,22 @@
"default": "-"
}
},
{
"long": "bar-border-left",
"desc": "Set the string to use at left border of percentage bars",
"arg": {
"type": "string",
"default": "[ "
}
},
{
"long": "bar-border-right",
"desc": "Set the string to use at right border of percentage bars",
"arg": {
"type": "string",
"default": " ]"
}
},
{
"long": "bar-width",
"desc": "Set the width of percentage bars, in number of characters",
@@ -612,15 +640,6 @@
"default": 10
}
},
{
"long": "bar-border",
"desc": "Whether to show a border around percentage bars",
"arg": {
"type": "bool",
"optional": true,
"default": true
}
},
{
"long": "no-buffer",
"desc": "Set if the stdout application buffer should be disabled",
@@ -1170,6 +1189,15 @@
"default": false
}
},
{
"long": "cpucache-compact",
"desc": "Show all CPU caches in one line",
"arg": {
"type": "bool",
"optional": true,
"default": false
}
},
{
"long": "cpuusage-separate",
"desc": "Display CPU usage per CPU logical core, instead of an average result",
+19 -5
View File
@@ -1,10 +1,24 @@
Usage: fastfetch --color <color>
Shortcut of `fastfetch --color-keys <color> --color-title <color>`.
If no color is set, the main color of the logo will be used.
Following information applies to all settings
<color> must be a color encoding as ANSI escape sequences. It is inserted between "ESC[" and "m".
Infos about them can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters.
Examples:
--color 35: sets the color to magenta. `--color magenta` is also supported
--color 38;5;38: sets the color to 38th color of ANSI 256 colors
--color 4;92: sets the color to bright Green with underline. `--color underline_green` is also supported
--color 5;104: blinking text on a blue background
If no color is set, the main color of the logo will be used.
35: sets the color to magenta
38;5;38: sets the color to 38th color of ANSI 256 colors
4;92: sets the color to bright green with underline
5;104: blinking text on a blue background
ANSI named colors are also supported:
magenta: equivalent to `35`
underline_bright_green: equivalent to `4;92`
After v2.15.0, some special keys can be used:
keys: use the color set by `--color-keys`
title: use the color set by `--color-title`
output: use the color set by `--color-output`
separator: use the color set by `--color-separator`
+2 -2
View File
@@ -115,13 +115,13 @@ static uint8_t getNumCores(FFstrbuf* basePath, FFstrbuf* buffer)
bool ok = ffReadFileBuffer(basePath->chars, buffer);
ffStrbufSubstrBefore(basePath, baseLen);
if (ok)
return (uint8_t) ffStrbufCountC(buffer, ' ') + 1;
return (uint8_t) (ffStrbufCountC(buffer, ' ') + 1);
ffStrbufAppendS(basePath, "/related_cpus");
ok = ffReadFileBuffer(basePath->chars, buffer);
ffStrbufSubstrBefore(basePath, baseLen);
if (ok)
return (uint8_t) ffStrbufCountC(buffer, ' ') + 1;
return (uint8_t) (ffStrbufCountC(buffer, ' ') + 1);
return 0;
}
+2 -2
View File
@@ -126,9 +126,9 @@ static const char* detectNCores(FFCPUResult* cpu)
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((uint8_t*)ptr) + ptr->Size)
)
{
if(ptr->Relationship == RelationProcessorCore)
if (ptr->Relationship == RelationProcessorCore)
++cpu->coresPhysical;
else if(ptr->Relationship == RelationGroup)
else if (ptr->Relationship == RelationGroup)
{
for (uint32_t index = 0; index < ptr->Group.ActiveGroupCount; ++index)
{
+49
View File
@@ -0,0 +1,49 @@
#pragma once
#include "fastfetch.h"
typedef enum FFCPUCacheType
{
FF_CPU_CACHE_TYPE_UNIFIED = 0,
FF_CPU_CACHE_TYPE_INSTRUCTION = 1,
FF_CPU_CACHE_TYPE_DATA = 2,
FF_CPU_CACHE_TYPE_TRACE = 3,
} FFCPUCacheType;
typedef struct FFCPUCache
{
uint32_t size;
uint32_t num;
uint32_t lineSize;
FFCPUCacheType type;
} FFCPUCache;
typedef struct FFCPUCacheResult
{
FFlist caches[4]; // L1, L2, L3, L4(?)
} FFCPUCacheResult;
const char* ffDetectCPUCache(FFCPUCacheResult* result);
static inline FFCPUCache* ffCPUCacheAddItem(FFCPUCacheResult* result, uint32_t level, uint32_t size, uint32_t lineSize, FFCPUCacheType type)
{
FFlist* cacheLevel = &result->caches[level - 1];
FF_LIST_FOR_EACH(FFCPUCache, item, *cacheLevel)
{
if (item->type == type && item->size == size && item->lineSize == lineSize)
{
item->num++;
return item;
}
}
FFCPUCache* item = (FFCPUCache*)ffListAdd(cacheLevel);
*item = (FFCPUCache) {
.size = size,
.num = 1,
.lineSize = lineSize,
.type = type,
};
return item;
}
+58
View File
@@ -0,0 +1,58 @@
#include "cpucache.h"
#include "common/sysctl.h"
const char* ffDetectCPUCache(FFCPUCacheResult* result)
{
// https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_system_capabilities#3901385
uint32_t nPerfLevels = (uint32_t) ffSysctlGetInt("hw.nperflevels", 0);
if (nPerfLevels <= 0) return "sysctl(hw.nperflevels) failed";
// macOS provides the global system cache line size
uint32_t lineSize = (uint32_t) ffSysctlGetInt("hw.cachelinesize", 0);
char sysctlKey[256] = "hw.perflevelN.";
char* pNum = sysctlKey + strlen("hw.perflevel");
char* pSubkey = sysctlKey + strlen("hw.perflevelN.");
const size_t lenLeft = sizeof(sysctlKey) - strlen("hw.perflevelN.");
for (uint32_t i = 0; i < nPerfLevels; ++i)
{
*pNum = (char) ('0' + i);
strncpy(pSubkey, "physicalcpu", lenLeft);
uint32_t ncpu = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (ncpu <= 0) continue;
strncpy(pSubkey, "l1icachesize", lenLeft);
uint32_t size = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (size)
ffCPUCacheAddItem(result, 1, size, lineSize, FF_CPU_CACHE_TYPE_INSTRUCTION)->num = ncpu;
strncpy(pSubkey, "l1dcachesize", lenLeft);
size = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (size)
ffCPUCacheAddItem(result, 1, size, lineSize, FF_CPU_CACHE_TYPE_DATA)->num = ncpu;
strncpy(pSubkey, "l2cachesize", lenLeft);
size = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (size)
{
strncpy(pSubkey, "cpusperl2", lenLeft);
uint32_t cpuSper = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (cpuSper)
ffCPUCacheAddItem(result, 2, size, lineSize, FF_CPU_CACHE_TYPE_UNIFIED)->num = ncpu / cpuSper;
}
strncpy(pSubkey, "l3cachesize", lenLeft);
size = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (size)
{
strncpy(pSubkey, "cpusperl3", lenLeft);
uint32_t cpuSper = (uint32_t) ffSysctlGetInt(sysctlKey, 0);
if (cpuSper)
ffCPUCacheAddItem(result, 3, size, lineSize, FF_CPU_CACHE_TYPE_UNIFIED)->num = ncpu / cpuSper;
}
}
return NULL;
}
+104
View File
@@ -0,0 +1,104 @@
#include "cpucache.h"
#include "common/io/io.h"
#include "util/stringUtils.h"
static const char* parseCpuCacheIndex(FFstrbuf* path, FFCPUCacheResult* result, FFstrbuf* buffer, FFstrbuf* added)
{
uint32_t baseLen = path->length;
ffStrbufAppendS(path, "/level");
if (!ffReadFileBuffer(path->chars, buffer))
return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/level\") == NULL";
uint32_t level = (uint32_t) ffStrbufToUInt(buffer, 0);
if (level < 1 || level > 4) return "level < 1 || level > 4";
ffStrbufSubstrBefore(path, baseLen);
ffStrbufAppendS(path, "/size");
if (!ffReadFileBuffer(path->chars, buffer))
return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/size\") == NULL";
uint32_t sizeKb = (uint32_t) ffStrbufToUInt(buffer, 0);
if (sizeKb == 0) return "size == 0";
ffStrbufSubstrBefore(path, baseLen);
ffStrbufAppendS(path, "/type");
if (!ffReadFileBuffer(path->chars, buffer))
return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/type\") == NULL";
ffStrbufTrimRightSpace(buffer);
FFCPUCacheType cacheType = 0;
switch (buffer->chars[0])
{
case 'I': cacheType = FF_CPU_CACHE_TYPE_INSTRUCTION; break;
case 'D': cacheType = FF_CPU_CACHE_TYPE_DATA; break;
case 'U': cacheType = FF_CPU_CACHE_TYPE_UNIFIED; break;
case 'T': cacheType = FF_CPU_CACHE_TYPE_TRACE; break;
default: return "unknown cache type";
}
uint32_t lineSize = 0;
ffStrbufSubstrBefore(path, baseLen);
ffStrbufAppendS(path, "/coherency_line_size");
if (ffReadFileBuffer(path->chars, buffer))
lineSize = (uint32_t) ffStrbufToUInt(buffer, 0);
ffStrbufSubstrBefore(path, baseLen);
ffStrbufAppendS(path, "/shared_cpu_list");
if (!ffReadFileBuffer(path->chars, buffer))
return "ffReadFileBuffer(\"/sys/devices/system/cpu/cpuX/cache/indexX/shared_cpu_list\") == NULL";
ffStrbufTrimRightSpace(buffer);
// deduplicate shared caches
ffStrbufAppendF(buffer, "_%u_%u_%u_%u\n", level, sizeKb, lineSize, cacheType);
if (ffStrbufContain(added, buffer)) return "cache already added";
ffStrbufAppend(added, buffer);
ffCPUCacheAddItem(result, level, sizeKb * 1024, lineSize, cacheType);
return NULL;
}
static const char* parseCpuCache(FFstrbuf* path, FFCPUCacheResult* result, FFstrbuf* buffer, FFstrbuf* added)
{
ffStrbufAppendS(path, "/cache/");
uint32_t baseLen = path->length;
FF_AUTO_CLOSE_DIR DIR* pathCacheDir = opendir(path->chars);
if (!pathCacheDir)
return "opendir(\"/sys/devices/system/cpu/cpuX/cache/\") == NULL";
struct dirent* pathCacheEntry;
while ((pathCacheEntry = readdir(pathCacheDir)) != NULL)
{
if (!ffStrStartsWith(pathCacheEntry->d_name, "index")
|| !ffCharIsDigit(pathCacheEntry->d_name[strlen("index")])) continue;
ffStrbufAppendS(path, pathCacheEntry->d_name);
parseCpuCacheIndex(path, result, buffer, added);
ffStrbufSubstrBefore(path, baseLen);
}
return NULL;
}
const char* ffDetectCPUCache(FFCPUCacheResult* result)
{
// https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/devices/system/cpu/");
uint32_t baseLen = path.length;
FF_AUTO_CLOSE_DIR DIR* pathCpuDir = opendir(path.chars);
if (!pathCpuDir)
return "opendir(\"/sys/devices/system/cpu/\") == NULL";
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
FF_STRBUF_AUTO_DESTROY added = ffStrbufCreate();
struct dirent* pathCpuEntry;
while ((pathCpuEntry = readdir(pathCpuDir)) != NULL)
{
if (!ffStrStartsWith(pathCpuEntry->d_name, "cpu") ||
!ffCharIsDigit(pathCpuEntry->d_name[strlen("cpu")])) continue;
ffStrbufAppendS(&path, pathCpuEntry->d_name);
parseCpuCache(&path, result, &buffer, &added);
ffStrbufSubstrBefore(&path, baseLen);
}
return NULL;
}
@@ -0,0 +1,7 @@
#include "cpucache.h"
#include "common/sysctl.h"
const char* ffDetectCPUCache(FF_MAYBE_UNUSED FFCPUCacheResult* result)
{
return "Not supported on this platform";
}
+41
View File
@@ -0,0 +1,41 @@
#include "cpucache.h"
#include "util/mallocHelper.h"
#include <windows.h>
const char* ffDetectCPUCache(FFCPUCacheResult* result)
{
DWORD length = 0;
GetLogicalProcessorInformationEx(RelationCache, NULL, &length);
if (length == 0)
return "GetLogicalProcessorInformationEx(RelationCache, NULL, &length) failed";
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);
if (!pProcessorInfo || !GetLogicalProcessorInformationEx(RelationCache, pProcessorInfo, &length))
return "GetLogicalProcessorInformationEx(RelationCache, pProcessorInfo, &length) failed";
for(
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pProcessorInfo;
(uint8_t*)ptr < ((uint8_t*)pProcessorInfo) + length;
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((uint8_t*)ptr) + ptr->Size)
)
{
if(__builtin_expect(ptr->Relationship == RelationCache && ptr->Cache.Level > 0 && ptr->Cache.Level <= 4, true))
{
FFCPUCacheType cacheType = 0;
switch (ptr->Cache.Type)
{
case CacheUnified: cacheType = FF_CPU_CACHE_TYPE_UNIFIED; break;
case CacheInstruction: cacheType = FF_CPU_CACHE_TYPE_INSTRUCTION; break;
case CacheData: cacheType = FF_CPU_CACHE_TYPE_DATA; break;
case CacheTrace: cacheType = FF_CPU_CACHE_TYPE_TRACE; break;
default: __builtin_unreachable(); break;
}
ffCPUCacheAddItem(result, ptr->Cache.Level, ptr->Cache.CacheSize, ptr->Cache.LineSize, cacheType);
}
}
return NULL;
}
+2 -2
View File
@@ -3,8 +3,8 @@
#include "fastfetch.h"
#define FF_DE_PRETTY_PLASMA "KDE Plasma"
#define FF_DE_PRETTY_GNOME "Gnome"
#define FF_DE_PRETTY_GNOME_CLASSIC "Gnome Classic"
#define FF_DE_PRETTY_GNOME "GNOME"
#define FF_DE_PRETTY_GNOME_CLASSIC "GNOME Classic"
#define FF_DE_PRETTY_XFCE4 "Xfce4"
#define FF_DE_PRETTY_CINNAMON "Cinnamon"
#define FF_DE_PRETTY_MATE "Mate"
+2 -2
View File
@@ -43,7 +43,7 @@ static const char* parseEnv(void)
return "KDE";
if(getenv("GNOME_DESKTOP_SESSION_ID") != NULL)
return "Gnome";
return "GNOME";
if(getenv("MATE_DESKTOP_SESSION_ID") != NULL)
return "Mate";
@@ -163,7 +163,7 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name)
}
else if(
ffStrEqualsIgnCase(name, "Gnome") ||
ffStrEqualsIgnCase(name, "GNOME") ||
ffStrEqualsIgnCase(name, "ubuntu:GNOME") ||
ffStrEqualsIgnCase(name, "ubuntu") ||
ffStrEqualsIgnCase(name, "gnome-shell")
+2 -2
View File
@@ -1,8 +1,8 @@
#include "gpu_driver_specific.h"
#include "3rdparty/igcl/igcl_api.h"
#include "common/library.h"
#include "util/mallocHelper.h"
#include "igcl.h"
struct FFIgclData {
FF_LIBRARY_SYMBOL(ctlClose)
@@ -47,7 +47,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlFrequencyGetProperties)
if (ffctlInit(&(ctl_init_args_t) {
.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION),
.AppVersion = CTL_IMPL_VERSION,
.flags = CTL_INIT_FLAG_USE_LEVEL_ZERO,
.Size = sizeof(ctl_init_args_t),
.Version = 0,
+169
View File
@@ -0,0 +1,169 @@
#pragma once
// DISCLAIMER:
// THIS FILE IS CREATED FROM SCRATCH, BY READING THE OFFICIAL IGCL API
// DOCUMENTATION REFERENCED BELOW, IN ORDER TO MAKE FASTFETCH MIT COMPLIANT.
#include <stdint.h>
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv412ctl_result_t
typedef enum ctl_result_t
{
CTL_RESULT_SUCCESS = 0,
} ctl_result_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv420ctl_application_id_t
typedef struct ctl_application_id_t
{
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[8];
} ctl_application_id_t;
#define CTL_IMPL_VERSION (( 1 /*major*/ << 16 )|( 1 /*minor*/ & 0x0000ffff))
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv415ctl_init_flag_t
typedef enum ctl_init_flag_t
{
CTL_INIT_FLAG_USE_LEVEL_ZERO = 1,
CTL_INIT_FLAG_MAX
} ctl_init_flag_t;
typedef uint32_t ctl_version_info_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv415ctl_init_args_t
typedef struct ctl_init_args_t
{
uint32_t Size;
uint8_t Version;
ctl_version_info_t AppVersion;
ctl_init_flag_t flags;
ctl_version_info_t SupportedVersion;
ctl_application_id_t ApplicationUID;
} ctl_init_args_t;
typedef struct ctl_api_handle_t* ctl_api_handle_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv47ctlInitP15ctl_init_args_tP16ctl_api_handle_t
extern ctl_result_t ctlInit(ctl_init_args_t *pInitDesc, ctl_api_handle_t *phAPIHandle);
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#ctlclose
extern ctl_result_t ctlClose(ctl_api_handle_t hAPIHandle);
typedef struct ctl_device_adapter_handle_t* ctl_device_adapter_handle_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv419ctlEnumerateDevices16ctl_api_handle_tP8uint32_tP27ctl_device_adapter_handle_t
extern ctl_result_t ctlEnumerateDevices(ctl_api_handle_t hAPIHandle, uint32_t *pCount, ctl_device_adapter_handle_t* phDevices);
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv417ctl_device_type_t
typedef enum ctl_device_type_t
{
CTL_DEVICE_TYPE_GRAPHICS = 1,
CTL_DEVICE_TYPE_SYSTEM = 2,
CTL_DEVICE_TYPE_MAX
} ctl_device_type_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv422ctl_firmware_version_t
typedef struct ctl_firmware_version_t
{
uint64_t major_version;
uint64_t minor_version;
uint64_t build_number;
} ctl_firmware_version_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv417ctl_adapter_bdf_t
typedef struct ctl_adapter_bdf_t
{
uint8_t bus;
uint8_t device;
uint8_t function;
} ctl_adapter_bdf_t;
#define IGCL_CTL_MAX_DEVICE_NAME_LEN 100
#define IGCL_CTL_MAX_RESERVED_SIZE 112
typedef enum ctl_adapter_properties_flag_t
{
CTL_ADAPTER_PROPERTIES_FLAG_INTEGRATED = 1,
} ctl_adapter_properties_flag_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv431ctl_device_adapter_properties_t
typedef struct ctl_device_adapter_properties_t
{
uint32_t Size;
uint8_t Version;
void* pDeviceID;
uint32_t device_id_size;
ctl_device_type_t device_type;
uint32_t /*ctl_supported_functions_flags_t*/ supported_subfunction_flags;
uint64_t driver_version;
ctl_firmware_version_t firmware_version;
uint32_t pci_vendor_id;
uint32_t pci_device_id;
uint32_t rev_id;
uint32_t num_eus_per_sub_slice;
uint32_t num_sub_slices_per_slice;
uint32_t num_slices;
char name[IGCL_CTL_MAX_DEVICE_NAME_LEN];
ctl_adapter_properties_flag_t graphics_adapter_properties;
uint32_t Frequency;
uint16_t pci_subsys_id;
uint16_t pci_subsys_vendor_id;
ctl_adapter_bdf_t adapter_bdf;
char reserved[IGCL_CTL_MAX_RESERVED_SIZE];
} ctl_device_adapter_properties_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv422ctlGetDeviceProperties27ctl_device_adapter_handle_tP31ctl_device_adapter_properties_t
extern ctl_result_t ctlGetDeviceProperties(ctl_device_adapter_handle_t hDAhandle, ctl_device_adapter_properties_t* pProperties);
typedef struct ctl_temp_handle_t* ctl_temp_handle_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#ctlenumtemperaturesensors
extern ctl_result_t ctlEnumTemperatureSensors(ctl_device_adapter_handle_t hDAhandle, uint32_t* pCount, ctl_temp_handle_t* phTemperature);
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#ctltemperaturegetstate
extern ctl_result_t ctlTemperatureGetState(ctl_temp_handle_t hTemperature, double* pTemperature);
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv420ctlEnumMemoryModules27ctl_device_adapter_handle_tP8uint32_tP16ctl_mem_handle_t
typedef struct ctl_mem_handle_t* ctl_mem_handle_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv420ctlEnumMemoryModules27ctl_device_adapter_handle_tP8uint32_tP16ctl_mem_handle_t
extern ctl_result_t ctlEnumMemoryModules(ctl_device_adapter_handle_t hDAhandle, uint32_t *pCount, ctl_mem_handle_t* phMemory);
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv415ctl_mem_state_t
typedef struct ctl_mem_state_t
{
uint32_t Size;
uint8_t Version;
uint64_t free;
uint64_t size;
} ctl_mem_state_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv417ctlMemoryGetState16ctl_mem_handle_tP15ctl_mem_state_t
extern ctl_result_t ctlMemoryGetState(ctl_mem_handle_t hMemory, ctl_mem_state_t *pState);
typedef struct ctl_freq_handle_t* ctl_freq_handle_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#ctlenumfrequencydomains
extern ctl_result_t ctlEnumFrequencyDomains(ctl_device_adapter_handle_t hDAhandle, uint32_t* pCount, ctl_freq_handle_t* phFrequency);
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv417ctl_freq_domain_t
typedef enum ctl_freq_domain_t
{
CTL_FREQ_DOMAIN_GPU = 0,
CTL_FREQ_DOMAIN_MEMORY = 1,
CTL_FREQ_DOMAIN_MAX
} ctl_freq_domain_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv421ctl_freq_properties_t
typedef struct ctl_freq_properties_t
{
uint32_t Size;
uint8_t Version;
ctl_freq_domain_t type;
bool canControl;
double min;
double max;
} ctl_freq_properties_t;
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv425ctlFrequencyGetProperties17ctl_freq_handle_tP21ctl_freq_properties_t
extern ctl_result_t ctlFrequencyGetProperties(ctl_freq_handle_t hFrequency, ctl_freq_properties_t* pProperties);
+1 -1
View File
@@ -153,7 +153,7 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
static void detectGTK(const char* version, FFGTKResult* result)
{
//Mate, Cinnamon, Gnome, Unity, Budgie use dconf to save theme config
//Mate, Cinnamon, GNOME, Unity, Budgie use dconf to save theme config
//On other DEs, this will do nothing
detectGTKFromSettings(result);
if(allPropertiesSet(result))
+4 -3
View File
@@ -3,6 +3,7 @@
#include "common/thread.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "detection/displayserver/displayserver.h"
#include "util/stringUtils.h"
#include <stdlib.h>
#include <string.h>
@@ -43,11 +44,11 @@ static bool detectPlasmaFromFile(const char* filename, FFQtResult* result)
char categoryName[32];
sscanf(line, "[%31[^]]", categoryName);
if(strcasecmp(categoryName, "General") == 0)
if(ffStrEqualsIgnCase(categoryName, "General"))
category = PLASMA_CATEGORY_GENERAL;
else if(strcasecmp(categoryName, "KDE") == 0)
else if(ffStrEqualsIgnCase(categoryName, "KDE"))
category = PLASMA_CATEGORY_KDE;
else if(strcasecmp(categoryName, "Icons") == 0)
else if(ffStrEqualsIgnCase(categoryName, "Icons"))
category = PLASMA_CATEGORY_ICONS;
else
category = PLASMA_CATEGORY_OTHER;
+8 -1
View File
@@ -2,4 +2,11 @@
#include "fastfetch.h"
const char* ffDetectIcons(FFstrbuf* result);
typedef struct FFIconsResult
{
FFstrbuf icons1;
FFstrbuf icons2;
} FFIconsResult;
const char* ffDetectIcons(FFIconsResult* result);
+4 -9
View File
@@ -3,7 +3,7 @@
#include "detection/gtk_qt/gtk_qt.h"
#include "detection/displayserver/displayserver.h"
const char* ffDetectIcons(FFstrbuf* result)
const char* ffDetectIcons(FFIconsResult* result)
{
const FFDisplayServerResult* wmde = ffConnectDisplayServer();
@@ -18,18 +18,13 @@ const char* ffDetectIcons(FFstrbuf* result)
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
return "No icons could be found";
FF_STRBUF_AUTO_DESTROY gtkPretty = ffStrbufCreate();
ffParseGTK(&gtkPretty, gtk2, gtk3, gtk4);
ffParseGTK(&result->icons2, gtk2, gtk3, gtk4);
if(plasma->length > 0)
{
ffStrbufAppend(result, plasma);
ffStrbufAppendS(result, " [QT]");
if(gtkPretty.length > 0)
ffStrbufAppendS(result, ", ");
ffStrbufAppend(&result->icons1, plasma);
ffStrbufAppendS(&result->icons1, " [QT]");
}
ffStrbufAppend(result, &gtkPretty);
return NULL;
}
+1 -1
View File
@@ -1,6 +1,6 @@
#include "icons.h"
const char* ffDetectIcons(FF_MAYBE_UNUSED FFstrbuf* result)
const char* ffDetectIcons(FF_MAYBE_UNUSED FFIconsResult* result)
{
return "Not supported on this platform";
}
+13 -11
View File
@@ -1,7 +1,7 @@
#include "icons.h"
#include "util/windows/registry.h"
const char* ffDetectIcons(FFstrbuf* result)
const char* ffDetectIcons(FFIconsResult* result)
{
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel", &hKey, NULL) &&
@@ -17,18 +17,20 @@ const char* ffDetectIcons(FFstrbuf* result)
ffRegReadUint(hKey, L"{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", &ControlPanel, NULL);
if (!ThisPC)
ffStrbufAppendS(result, "This PC, ");
ffStrbufAppendS(&result->icons1, "This PC, ");
if (!UsersFiles)
ffStrbufAppendS(result, "User's Files, ");
if (!RemoteNetwork)
ffStrbufAppendS(result, "Remote Network, ");
if (!RecycleBin)
ffStrbufAppendS(result, "Recycle Bin, ");
if (!ControlPanel)
ffStrbufAppendS(result, "Control Panel");
ffStrbufAppendS(&result->icons1, "User's Files");
ffStrbufTrimRight(&result->icons1, ' ');
ffStrbufTrimRight(&result->icons1, ',');
ffStrbufTrimRight(result, ' ');
ffStrbufTrimRight(result, ',');
if (!RemoteNetwork)
ffStrbufAppendS(&result->icons2, "Remote Network, ");
if (!RecycleBin)
ffStrbufAppendS(&result->icons2, "Recycle Bin, ");
if (!ControlPanel)
ffStrbufAppendS(&result->icons2, "Control Panel");
ffStrbufTrimRight(&result->icons2, ' ');
ffStrbufTrimRight(&result->icons2, ',');
return NULL;
}
+1 -1
View File
@@ -45,7 +45,7 @@ const char* ffDetectInitSystem(FFInitSystemResult* result)
uint32_t iStart = ffStrbufFirstIndexS(&result->version, "Version ");
if (iStart < result->version.length)
{
iStart += strlen("Version");
iStart += (uint32_t) strlen("Version");
uint32_t iEnd = ffStrbufNextIndexC(&result->version, iStart + 1, ':');
ffStrbufSubstrBefore(&result->version, iEnd);
ffStrbufSubstrAfter(&result->version, iStart);
+1 -2
View File
@@ -14,10 +14,9 @@ void ffDetectLocale(FFstrbuf* result)
#ifdef LC_MESSAGES
ffStrbufAppendS(result, setlocale(LC_MESSAGES, NULL));
if(result->length > 0)
return;
#endif
ffStrbufAppendS(result, setlocale(LC_ALL, NULL));
ffStrbufAppendS(result, setlocale(LC_TIME, NULL));
}
+9 -9
View File
@@ -52,7 +52,7 @@ static void getUbuntuFlavour(FFOSResult* result)
if(!ffStrSet(xdgConfigDirs))
return;
if(strstr(xdgConfigDirs, "kde") != NULL || strstr(xdgConfigDirs, "plasma") != NULL)
if(ffStrContains(xdgConfigDirs, "kde") || ffStrContains(xdgConfigDirs, "plasma") || ffStrContains(xdgConfigDirs, "kubuntu"))
{
ffStrbufSetS(&result->name, "Kubuntu");
ffStrbufSetS(&result->prettyName, "Kubuntu");
@@ -61,7 +61,7 @@ static void getUbuntuFlavour(FFOSResult* result)
return;
}
if(strstr(xdgConfigDirs, "xfce") != NULL || strstr(xdgConfigDirs, "xubuntu") != NULL)
if(ffStrContains(xdgConfigDirs, "xfce") || ffStrContains(xdgConfigDirs, "xubuntu"))
{
ffStrbufSetS(&result->name, "Xubuntu");
ffStrbufSetS(&result->prettyName, "Xubuntu");
@@ -70,7 +70,7 @@ static void getUbuntuFlavour(FFOSResult* result)
return;
}
if(strstr(xdgConfigDirs, "lxde") != NULL || strstr(xdgConfigDirs, "lubuntu") != NULL)
if(ffStrContains(xdgConfigDirs, "lxde") || ffStrContains(xdgConfigDirs, "lubuntu"))
{
ffStrbufSetS(&result->name, "Lubuntu");
ffStrbufSetS(&result->prettyName, "Lubuntu");
@@ -79,7 +79,7 @@ static void getUbuntuFlavour(FFOSResult* result)
return;
}
if(strstr(xdgConfigDirs, "budgie") != NULL)
if(ffStrContains(xdgConfigDirs, "budgie"))
{
ffStrbufSetS(&result->name, "Ubuntu Budgie");
ffStrbufSetS(&result->prettyName, "Ubuntu Budgie");
@@ -88,7 +88,7 @@ static void getUbuntuFlavour(FFOSResult* result)
return;
}
if(strstr(xdgConfigDirs, "cinnamon") != NULL)
if(ffStrContains(xdgConfigDirs, "cinnamon"))
{
ffStrbufSetS(&result->name, "Ubuntu Cinnamon");
ffStrbufSetS(&result->prettyName, "Ubuntu Cinnamon");
@@ -97,7 +97,7 @@ static void getUbuntuFlavour(FFOSResult* result)
return;
}
if(strstr(xdgConfigDirs, "mate") != NULL)
if(ffStrContains(xdgConfigDirs, "mate"))
{
ffStrbufSetS(&result->name, "Ubuntu MATE");
ffStrbufSetS(&result->prettyName, "Ubuntu MATE");
@@ -106,7 +106,7 @@ static void getUbuntuFlavour(FFOSResult* result)
return;
}
if(strstr(xdgConfigDirs, "studio") != NULL)
if(ffStrContains(xdgConfigDirs, "studio"))
{
ffStrbufSetS(&result->name, "Ubuntu Studio");
ffStrbufSetS(&result->prettyName, "Ubuntu Studio");
@@ -115,7 +115,7 @@ static void getUbuntuFlavour(FFOSResult* result)
return;
}
if(strstr(xdgConfigDirs, "sway") != NULL)
if(ffStrContains(xdgConfigDirs, "sway"))
{
ffStrbufSetS(&result->name, "Ubuntu Sway");
ffStrbufSetS(&result->prettyName, "Ubuntu Sway");
@@ -124,7 +124,7 @@ static void getUbuntuFlavour(FFOSResult* result)
return;
}
if(strstr(xdgConfigDirs, "touch") != NULL)
if(ffStrContains(xdgConfigDirs, "touch"))
{
ffStrbufSetS(&result->name, "Ubuntu Touch");
ffStrbufSetS(&result->prettyName, "Ubuntu Touch");
+27 -16
View File
@@ -408,26 +408,36 @@ static uint32_t getAM(FFstrbuf* baseDir)
return result;
}
static uint32_t getGuixPackagesImpl(char* path)
static int compareHash(const void* a, const void* b)
{
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(1024);
return memcmp(a, b, 32);
}
ffProcessAppendStdOut(&output, (char* const[]) {
"guix",
"package",
"-p",
path,
"-I",
NULL
});
static uint32_t getGuixPackagesImpl(char* filename)
{
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
if (!ffAppendFileBuffer(filename, &content))
return 0;
// Count number of unique /gnu/store/ paths in PROFILE/manifest based on their hash value.
// Contains packages explicitly installed and their propagated inputs.
char* pend = content.chars;
//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++;
for (const char* pattern = content.chars; (pattern = strstr(pattern, "/gnu/store/")); pattern += 32)
{
pattern += strlen("/gnu/store/");
memmove(pend, pattern, 32);
pend += 32;
}
if (pend == content.chars)
return 0;
qsort(content.chars, (size_t) (pend - content.chars) / 32, 32, compareHash);
uint32_t count = 1;
for (const char* p = content.chars + 32; p < pend; p += 32)
count += compareHash(p - 32, p) != 0;
return count;
}
@@ -436,6 +446,7 @@ static uint32_t getGuixPackages(FFstrbuf* baseDir, const char* dirname)
{
uint32_t baseDirLength = baseDir->length;
ffStrbufAppendS(baseDir, dirname);
ffStrbufAppendS(baseDir, "/manifest");
uint32_t num_elements = getGuixPackagesImpl(baseDir->chars);
ffStrbufSubstrBefore(baseDir, baseDirLength);
return num_elements;
+1 -1
View File
@@ -17,7 +17,7 @@ static uint32_t getNumElements(const char* searchPath /* including `\*` suffix *
do // Managed to locate and create an handle to that folder.
{
if(!(wfd.dwFileAttributes & type)) continue;
if(!flag && strcasecmp(ignore, wfd.cFileName) == 0)
if(!flag && ffStrEqualsIgnCase(ignore, wfd.cFileName))
{
flag = true;
continue;
@@ -320,7 +320,7 @@ static void detectSt(FFTerminalFontResult* terminalFont, const FFTerminalResult*
uint32_t sIndex = ffStrbufNextIndexS(&font, index + 1, "size=");
if (sIndex != font.length)
{
sIndex += strlen("size=");
sIndex += (uint32_t) strlen("size=");
uint32_t sIndexEnd = ffStrbufNextIndexC(&font, sIndex, ':');
ffStrbufSetNS(&size, sIndexEnd - sIndex, font.chars + sIndex);
}
+13 -13
View File
@@ -231,33 +231,33 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
if(ffStrEqualsIgnCase(exeName, "sh")) // #849
return false;
if(strcasecmp(exeName, "bash") == 0)
if(ffStrEqualsIgnCase(exeName, "bash"))
return getShellVersionBash(exe, version);
if(strcasecmp(exeName, "zsh") == 0)
if(ffStrEqualsIgnCase(exeName, "zsh"))
return getExeVersionGeneral(exe, version); //zsh 5.9 (arm-apple-darwin21.3.0)
if(strcasecmp(exeName, "fish") == 0)
if(ffStrEqualsIgnCase(exeName, "fish"))
return getShellVersionFish(exe, version);
if(strcasecmp(exeName, "pwsh") == 0)
if(ffStrEqualsIgnCase(exeName, "pwsh"))
return getShellVersionPwsh(exe, version);
if(strcasecmp(exeName, "csh") == 0 || strcasecmp(exeName, "tcsh") == 0)
if(ffStrEqualsIgnCase(exeName, "csh") || ffStrEqualsIgnCase(exeName, "tcsh"))
return getExeVersionGeneral(exe, version); //tcsh 6.24.07 (Astron) 2022-12-21 (aarch64-apple-darwin) options wide,nls,dl,al,kan,sm,rh,color,filec
if(strcasecmp(exeName, "nu") == 0)
if(ffStrEqualsIgnCase(exeName, "nu"))
return getShellVersionNushell(exe, version);
if(strcasecmp(exeName, "ksh") == 0)
if(ffStrEqualsIgnCase(exeName, "ksh"))
return getShellVersionKsh(exe, version);
if(strcasecmp(exeName, "oksh") == 0)
if(ffStrEqualsIgnCase(exeName, "oksh"))
return getShellVersionOksh(exe, version);
if(strcasecmp(exeName, "oil.ovm") == 0)
if(ffStrEqualsIgnCase(exeName, "oil.ovm"))
return getShellVersionOils(exe, version);
if(strcasecmp(exeName, "elvish") == 0)
if(ffStrEqualsIgnCase(exeName, "elvish"))
return getExeVersionRaw(exe, version);
if(strcasecmp(exeName, "ash") == 0)
if(ffStrEqualsIgnCase(exeName, "ash"))
return getShellVersionAsh(exe, version);
if(strcasecmp(exeName, "xonsh") == 0)
if(ffStrEqualsIgnCase(exeName, "xonsh"))
return getShellVersionXonsh(exe, version);
#ifdef _WIN32
if(strcasecmp(exeName, "powershell") == 0 || strcasecmp(exeName, "powershell_ise") == 0)
if(ffStrEqualsIgnCase(exeName, "powershell") || ffStrEqualsIgnCase(exeName, "powershell_ise"))
return getShellVersionWinPowerShell(exe, version);
return getFileVersion(exe->chars, version);
@@ -54,6 +54,8 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
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") ||
ffStrbufEqualS(&result->processName, "fastfetch") || //994
ffStrbufEqualS(&result->processName, "flashfetch") ||
ffStrbufContainS(&result->processName, "debug") ||
ffStrbufContainS(&result->processName, "not-found") ||
ffStrbufEndsWithS(&result->processName, ".sh")
+4 -4
View File
@@ -74,17 +74,17 @@ static bool detectByEnv(FFTerminalThemeResult* result)
return true;
}
static inline bool detectColor(FFTerminalThemeResult* result)
static inline bool detectColor(FFTerminalThemeResult* result, bool forceEnv)
{
if (detectByEscapeCode(result))
if (!forceEnv && detectByEscapeCode(result))
return true;
return detectByEnv(result);
}
bool ffDetectTerminalTheme(FFTerminalThemeResult* result)
bool ffDetectTerminalTheme(FFTerminalThemeResult* result, bool forceEnv)
{
if (!detectColor(result)) return false;
if (!detectColor(result, forceEnv)) return false;
result->fg.dark = result->fg.r * 299 + result->fg.g * 587 + result->fg.b * 114 < 128000;
result->bg.dark = result->bg.r * 299 + result->bg.g * 587 + result->bg.b * 114 < 128000;
return true;
+1 -1
View File
@@ -16,4 +16,4 @@ typedef struct FFTerminalThemeResult
FFTerminalThemeColor bg;
} FFTerminalThemeResult;
bool ffDetectTerminalTheme(FFTerminalThemeResult* result);
bool ffDetectTerminalTheme(FFTerminalThemeResult* result, bool forceEnv);
+7 -1
View File
@@ -2,4 +2,10 @@
#include "fastfetch.h"
const char* ffDetectTheme(FFstrbuf* result);
typedef struct FFThemeResult
{
FFstrbuf theme1;
FFstrbuf theme2;
} FFThemeResult;
const char* ffDetectTheme(FFThemeResult* result);
+11 -19
View File
@@ -3,7 +3,7 @@
#include "detection/gtk_qt/gtk_qt.h"
#include "detection/displayserver/displayserver.h"
const char* ffDetectTheme(FFstrbuf* result)
const char* ffDetectTheme(FFThemeResult* result)
{
const FFDisplayServerResult* wmde = ffConnectDisplayServer();
@@ -18,6 +18,8 @@ const char* ffDetectTheme(FFstrbuf* result)
if(plasma->widgetStyle.length == 0 && plasma->colorScheme.length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
return "No themes found";
ffParseGTK(&result->theme2, gtk2, gtk3, gtk4);
FF_STRBUF_AUTO_DESTROY plasmaColorPretty = ffStrbufCreate();
if(ffStrbufStartsWithIgnCase(&plasma->colorScheme, &plasma->widgetStyle))
ffStrbufAppendNS(&plasmaColorPretty, plasma->colorScheme.length - plasma->widgetStyle.length, &plasma->colorScheme.chars[plasma->widgetStyle.length]);
@@ -26,42 +28,32 @@ const char* ffDetectTheme(FFstrbuf* result)
ffStrbufTrim(&plasmaColorPretty, ' ');
FF_STRBUF_AUTO_DESTROY gtkPretty = ffStrbufCreate();
ffParseGTK(&gtkPretty, gtk2, gtk3, gtk4);
if(plasma->widgetStyle.length > 0)
{
ffStrbufAppend(result, &plasma->widgetStyle);
ffStrbufAppend(&result->theme1, &plasma->widgetStyle);
if(plasma->colorScheme.length > 0)
{
ffStrbufAppendS(result, " (");
ffStrbufAppendS(&result->theme1, " (");
if(plasmaColorPretty.length > 0)
ffStrbufAppend(result, &plasmaColorPretty);
ffStrbufAppend(&result->theme1, &plasmaColorPretty);
else
ffStrbufAppend(result, &plasma->colorScheme);
ffStrbufAppend(&result->theme1, &plasma->colorScheme);
ffStrbufAppendC(result, ')');
ffStrbufAppendC(&result->theme1, ')');
}
}
else if(plasma->colorScheme.length > 0)
{
if(plasmaColorPretty.length > 0)
ffStrbufAppend(result, &plasmaColorPretty);
ffStrbufAppend(&result->theme1, &plasmaColorPretty);
else
ffStrbufAppend(result, &plasma->colorScheme);
ffStrbufAppend(&result->theme1, &plasma->colorScheme);
}
if(plasma->widgetStyle.length > 0 || plasma->colorScheme.length > 0)
{
ffStrbufAppendS(result, " [QT]");
if(gtkPretty.length > 0)
ffStrbufAppendS(result, ", ");
}
ffStrbufAppend(result, &gtkPretty);
ffStrbufAppendS(&result->theme1, " [QT]");
return NULL;
}
+1 -1
View File
@@ -1,6 +1,6 @@
#include "theme.h"
const char* ffDetectTheme(FF_MAYBE_UNUSED FFstrbuf* result)
const char* ffDetectTheme(FF_MAYBE_UNUSED FFThemeResult* result)
{
return "Not supported on this platform";
}
+1 -1
View File
@@ -334,7 +334,7 @@ static const char* detectWifiWithIoctls(FFlist* result)
#endif
const char* ffDetectWifi(FFlist* result)
const char* ffDetectWifi(FF_MAYBE_UNUSED FFlist* result)
{
#ifdef FF_HAVE_LIBNM
detectWifiWithLibnm(result);
+9 -6
View File
@@ -2,6 +2,7 @@
#include "common/sysctl.h"
#include "util/mallocHelper.h"
#include "util/stringUtils.h"
#include <ctype.h>
@@ -17,15 +18,17 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName)
for(size_t i = 0; i < length / sizeof(struct kinfo_proc); i++)
{
if (processes[i].kp_eproc.e_ppid != 1) continue;
const char* comm = processes[i].kp_proc.p_comm;
if(
strcasecmp(comm, "spectacle") != 0 &&
strcasecmp(comm, "amethyst") != 0 &&
strcasecmp(comm, "kwm") != 0 &&
strcasecmp(comm, "chunkwm") != 0 &&
strcasecmp(comm, "yabai") != 0 &&
strcasecmp(comm, "rectangle") != 0
!ffStrEqualsIgnCase(comm, "spectacle") &&
!ffStrEqualsIgnCase(comm, "amethyst") &&
!ffStrEqualsIgnCase(comm, "kwm") &&
!ffStrEqualsIgnCase(comm, "chunkwm") &&
!ffStrEqualsIgnCase(comm, "yabai") &&
!ffStrEqualsIgnCase(comm, "rectangle")
) continue;
ffStrbufAppendS(pluginName, comm);
+1 -1
View File
@@ -679,7 +679,7 @@ static void parseArguments(FFdata* data, int argc, char** argv, void (*parser)(F
if(i == argc - 1 || (
argv[i + 1][0] == '-' &&
argv[i + 1][1] != '\0' && // `-` is used as an alias for `/dev/stdin`
strcasecmp(argv[i], "--separator-string") != 0 // Separator string can start with a -
!ffStrEqualsIgnCase(argv[i], "--separator-string") // Separator string can start with a -
)) {
parser(data, argv[i], NULL);
}
+1
View File
@@ -43,6 +43,7 @@ typedef struct FFstate
uint32_t logoWidth;
uint32_t logoHeight;
uint32_t keysHeight;
bool terminalLightTheme;
FFPlatform platform;
yyjson_doc* configDoc;
+3 -3
View File
@@ -1802,9 +1802,9 @@ static const FFlogo G[] = {
.colorKeys = FF_COLOR_FG_BLUE,
.colorTitle = FF_COLOR_FG_BLUE,
},
// Gnome
// GNOME
{
.names = {"Gnome"},
.names = {"GNOME"},
.lines = FASTFETCH_DATATEXT_LOGO_GNOME,
.colors = {
FF_COLOR_FG_BLUE,
@@ -4158,7 +4158,7 @@ static const FFlogo U[] = {
FF_COLOR_FG_WHITE,
},
},
// UbuntuGnome
// UbuntuGNOME
{
.names = {"ubuntu gnome", "ubuntu-gnome"},
.lines = FASTFETCH_DATATEXT_LOGO_UBUNTU_GNOME,
+2 -2
View File
@@ -335,7 +335,7 @@ static bool logoPrintBuiltinIfExists(const FFstrbuf* name, FFLogoSize size)
return true;
}
const FFlogo* logo = logoGetBuiltin(name, size);
const FFlogo* logo = ffStrbufEqualS(name, "?") ? &ffLogoUnknown : logoGetBuiltin(name, size);
if(logo == NULL)
return false;
@@ -429,7 +429,7 @@ static bool logoTryKnownType(void)
if(options->type == FF_LOGO_TYPE_NONE)
{
logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL), false);
logoPrintNone();
return true;
}
+1 -1
View File
@@ -49,7 +49,7 @@ void ffPrintColors(FFColorsOptions* options)
for(uint8_t i = max(options->block.range[0], 8); i <= options->block.range[1]; i++)
{
if(!instance.config.display.pipe)
ffStrbufAppendF(&result, "\e[1;9%dm", i - 8);
ffStrbufAppendF(&result, "\e[9%dm", i - 8);
for (uint8_t j = 0; j < options->block.width; j++)
ffStrbufAppendS(&result, "");
}
+2 -2
View File
@@ -22,7 +22,7 @@ void ffPrintCPU(FFCPUOptions* options)
.frequencyBase = 0.0/0.0,
.frequencyBiosLimit = 0.0/0.0,
.name = ffStrbufCreate(),
.vendor = ffStrbufCreate()
.vendor = ffStrbufCreate(),
};
const char* error = ffDetectCPU(options, &cpu);
@@ -207,7 +207,7 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
.frequencyBase = 0.0/0.0,
.frequencyBiosLimit = 0.0/0.0,
.name = ffStrbufCreate(),
.vendor = ffStrbufCreate()
.vendor = ffStrbufCreate(),
};
const char* error = ffDetectCPU(options, &cpu);
+255
View File
@@ -0,0 +1,255 @@
#include "common/printing.h"
#include "common/jsonconfig.h"
#include "detection/cpucache/cpucache.h"
#include "modules/cpucache/cpucache.h"
#include "util/stringUtils.h"
#define FF_CPUCACHE_DISPLAY_NAME "CPU Cache"
#define FF_CPUCACHE_NUM_FORMAT_ARGS 2
static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOptions* options)
{
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
for (uint32_t i = 0; i < sizeof (result->caches) / sizeof (result->caches[0]) && result->caches[i].length > 0; i++)
{
ffStrbufClear(&key);
if (options->moduleArgs.key.length == 0)
ffStrbufAppendF(&key, "%s (L%u)", FF_CPUCACHE_DISPLAY_NAME, i + 1);
else
{
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 1, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &i, "index"},
}));
}
ffStrbufClear(&buffer);
uint64_t sum = 0;
FF_LIST_FOR_EACH(FFCPUCache, src, result->caches[i])
{
char typeStr = '?';
switch (src->type)
{
case FF_CPU_CACHE_TYPE_DATA: typeStr = 'D'; break;
case FF_CPU_CACHE_TYPE_INSTRUCTION: typeStr = 'I'; break;
case FF_CPU_CACHE_TYPE_UNIFIED: typeStr = 'U'; break;
case FF_CPU_CACHE_TYPE_TRACE: typeStr = 'T'; break;
}
if (buffer.length)
ffStrbufAppendS(&buffer, ", ");
if (src->num > 1)
ffStrbufAppendF(&buffer, "%ux", src->num);
ffParseSize(src->size, &buffer);
ffStrbufAppendF(&buffer, " (%c)", typeStr);
sum += (uint64_t) src->size * src->num;
}
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufPutTo(&buffer, stdout);
}
else
{
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
ffParseSize(sum, &buffer2);
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "result"},
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer2, "sum"},
}));
}
}
}
static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptions* options)
{
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
uint64_t sum = 0;
for (uint32_t i = 0; i < sizeof (result->caches) / sizeof (result->caches[0]) && result->caches[i].length > 0; i++)
{
if (buffer.length)
ffStrbufAppendS(&buffer, ", ");
uint32_t value = 0;
FF_LIST_FOR_EACH(FFCPUCache, src, result->caches[i])
value += (uint64_t) src->size * src->num;
ffParseSize(value, &buffer);
ffStrbufAppendF(&buffer, " (L%u)", i + 1);
sum += value;
}
if (options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufPutTo(&buffer, stdout);
}
else
{
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
ffParseSize(sum, &buffer2);
FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "result"},
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer2, "sum"},
}));
}
}
void ffPrintCPUCache(FFCPUCacheOptions* options)
{
FFCPUCacheResult result = {
.caches = {
ffListCreate(sizeof(FFCPUCache)),
ffListCreate(sizeof(FFCPUCache)),
ffListCreate(sizeof(FFCPUCache)),
ffListCreate(sizeof(FFCPUCache)),
},
};
const char* error = ffDetectCPUCache(&result);
if(error)
{
ffPrintError(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
goto exit;
}
if (!options->compact)
printCPUCacheNormal(&result, options);
else
printCPUCacheCompact(&result, options);
exit:
ffListDestroy(&result.caches[0]);
ffListDestroy(&result.caches[1]);
ffListDestroy(&result.caches[2]);
ffListDestroy(&result.caches[3]);
}
bool ffParseCPUCacheCommandOptions(FFCPUCacheOptions* options, const char* key, const char* value)
{
const char* subKey = ffOptionTestPrefix(key, FF_CPUCACHE_MODULE_NAME);
if (!subKey) return false;
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
return true;
if (ffStrEqualsIgnCase(subKey, "compact"))
{
options->compact = ffOptionParseBoolean(value);
return true;
}
return false;
}
void ffParseCPUCacheJsonObject(FFCPUCacheOptions* 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;
if (ffStrEqualsIgnCase(key, "compact"))
{
options->compact = yyjson_get_bool(val);
continue;
}
ffPrintError(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
}
}
void ffGenerateCPUCacheJsonConfig(FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
__attribute__((__cleanup__(ffDestroyCPUCacheOptions))) FFCPUCacheOptions defaultOptions;
ffInitCPUCacheOptions(&defaultOptions);
ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs);
}
void ffGenerateCPUCacheJsonResult(FF_MAYBE_UNUSED FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
FFCPUCacheResult result = {
.caches = {
ffListCreate(sizeof(FFCPUCache)),
ffListCreate(sizeof(FFCPUCache)),
ffListCreate(sizeof(FFCPUCache)),
ffListCreate(sizeof(FFCPUCache)),
},
};
const char* error = ffDetectCPUCache(&result);
if (error)
{
yyjson_mut_obj_add_str(doc, module, "error", error);
goto exit;
}
yyjson_mut_val* caches = yyjson_mut_obj_add_obj(doc, module, "result");
for (uint32_t i = 0; i < sizeof (result.caches) / sizeof (result.caches[0]) && result.caches[i].length > 0; i++)
{
yyjson_mut_val* level = yyjson_mut_obj_add_arr(doc, caches, &"l1\0l2\0l3\0l4\0"[i * 3]);
FF_LIST_FOR_EACH(FFCPUCache, src, result.caches[i])
{
yyjson_mut_val* item = yyjson_mut_arr_add_obj(doc, level);
yyjson_mut_obj_add_uint(doc, item, "size", src->size);
yyjson_mut_obj_add_uint(doc, item, "num", src->num);
const char* typeStr = "unknown";
switch (src->type)
{
case FF_CPU_CACHE_TYPE_DATA: typeStr = "data"; break;
case FF_CPU_CACHE_TYPE_INSTRUCTION: typeStr = "instruction"; break;
case FF_CPU_CACHE_TYPE_UNIFIED: typeStr = "unified"; break;
case FF_CPU_CACHE_TYPE_TRACE: typeStr = "trace"; break;
}
yyjson_mut_obj_add_uint(doc, item, "lineSize", src->lineSize);
yyjson_mut_obj_add_str(doc, item, "type", typeStr);
}
}
exit:
ffListDestroy(&result.caches[0]);
ffListDestroy(&result.caches[1]);
ffListDestroy(&result.caches[2]);
ffListDestroy(&result.caches[3]);
}
void ffPrintCPUCacheHelpFormat(void)
{
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUCACHE_DISPLAY_NAME, "{1}", FF_CPUCACHE_NUM_FORMAT_ARGS, ((const char* []) {
"Separate result - result",
"Sum result - sum",
}));
}
void ffInitCPUCacheOptions(FFCPUCacheOptions* options)
{
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_CPUCACHE_MODULE_NAME,
"Print CPU cache sizes",
ffParseCPUCacheCommandOptions,
ffParseCPUCacheJsonObject,
ffPrintCPUCache,
ffGenerateCPUCacheJsonResult,
ffPrintCPUCacheHelpFormat,
ffGenerateCPUCacheJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
options->compact = false;
}
void ffDestroyCPUCacheOptions(FFCPUCacheOptions* options)
{
ffOptionDestroyModuleArg(&options->moduleArgs);
}
+9
View File
@@ -0,0 +1,9 @@
#pragma once
#include "fastfetch.h"
#define FF_CPUCACHE_MODULE_NAME "CPUCache"
void ffPrintCPUCache(FFCPUCacheOptions* options);
void ffInitCPUCacheOptions(FFCPUCacheOptions* options);
void ffDestroyCPUCacheOptions(FFCPUCacheOptions* options);
+13
View File
@@ -0,0 +1,13 @@
#pragma once
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
#include "common/option.h"
typedef struct FFCPUCacheOptions
{
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
bool compact;
} FFCPUCacheOptions;
+29 -11
View File
@@ -4,12 +4,15 @@
#include "modules/icons/icons.h"
#include "util/stringUtils.h"
#define FF_ICONS_NUM_FORMAT_ARGS 1
#define FF_ICONS_NUM_FORMAT_ARGS 2
void ffPrintIcons(FFIconsOptions* options)
{
FF_STRBUF_AUTO_DESTROY icons = ffStrbufCreate();
const char* error = ffDetectIcons(&icons);
FFIconsResult result = {
.icons1 = ffStrbufCreate(),
.icons2 = ffStrbufCreate(),
};
const char* error = ffDetectIcons(&result);
if(error)
{
@@ -20,12 +23,21 @@ void ffPrintIcons(FFIconsOptions* options)
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufPutTo(&icons, stdout);
if (result.icons1.length)
ffStrbufWriteTo(&result.icons1, stdout);
if (result.icons2.length)
{
if (result.icons1.length)
fputs(", ", stdout);
ffStrbufWriteTo(&result.icons2, stdout);
}
putchar('\n');
}
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, "combined"}
{FF_FORMAT_ARG_TYPE_STRBUF, &result.icons1, "icons1"},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.icons2, "icons2"},
}));
}
}
@@ -67,22 +79,28 @@ void ffGenerateIconsJsonConfig(FFIconsOptions* options, yyjson_mut_doc* doc, yyj
void ffGenerateIconsJsonResult(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
FF_STRBUF_AUTO_DESTROY icons = ffStrbufCreate();
const char* error = ffDetectIcons(&icons);
FFIconsResult result = {
.icons1 = ffStrbufCreate(),
.icons2 = ffStrbufCreate()
};
const char* error = ffDetectIcons(&result);
if (error)
if(error)
{
yyjson_mut_obj_add_str(doc, module, "error", error);
return;
}
yyjson_mut_obj_add_strbuf(doc, module, "result", &icons);
yyjson_mut_val* icons = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, icons, "icons1", &result.icons1);
yyjson_mut_obj_add_strbuf(doc, icons, "icons2", &result.icons2);
}
void ffPrintIconsHelpFormat(void)
{
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ICONS_MODULE_NAME, "{1}", FF_ICONS_NUM_FORMAT_ARGS, ((const char* []) {
"Combined icons - combined"
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ICONS_MODULE_NAME, "{1}, {2}", FF_ICONS_NUM_FORMAT_ARGS, ((const char* []) {
"Icons part 1 - icons1",
"Icons part 2 - icons2",
}));
}
+2
View File
@@ -46,6 +46,7 @@ void ffPrintInitSystem(FFInitSystemOptions* options)
exit:
ffStrbufDestroy(&result.name);
ffStrbufDestroy(&result.exe);
ffStrbufDestroy(&result.version);
}
bool ffParseInitSystemCommandOptions(FFInitSystemOptions* options, const char* key, const char* value)
@@ -109,6 +110,7 @@ void ffGenerateInitSystemJsonResult(FF_MAYBE_UNUSED FFInitSystemOptions* options
exit:
ffStrbufDestroy(&result.name);
ffStrbufDestroy(&result.exe);
ffStrbufDestroy(&result.version);
}
void ffPrintInitSystemHelpFormat(void)
+1
View File
@@ -12,6 +12,7 @@
#include "modules/camera/camera.h"
#include "modules/chassis/chassis.h"
#include "modules/cpu/cpu.h"
#include "modules/cpucache/cpucache.h"
#include "modules/cpuusage/cpuusage.h"
#include "modules/command/command.h"
#include "modules/colors/colors.h"
+1
View File
@@ -12,6 +12,7 @@
#include "modules/camera/option.h"
#include "modules/chassis/option.h"
#include "modules/cpu/option.h"
#include "modules/cpucache/option.h"
#include "modules/cpuusage/option.h"
#include "modules/colors/option.h"
#include "modules/cursor/option.h"
+7 -6
View File
@@ -11,6 +11,7 @@
static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
{
// asm ("int3");
//Create the basic output
if(os->name.length > 0)
ffStrbufAppend(result, &os->name);
@@ -22,32 +23,32 @@ static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
ffStrbufAppend(result, &instance.state.platform.systemName);
//Append code name if it is missing
if(os->codename.length > 0 && !ffStrbufContain(result, &os->codename))
if(os->codename.length > 0 && !ffStrbufContainIgnCase(result, &os->codename))
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->codename);
}
//Append version if it is missing
if(os->versionID.length > 0 && !ffStrbufContain(result, &os->versionID))
if(os->versionID.length > 0 && !ffStrbufContainIgnCase(result, &os->versionID))
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->versionID);
}
else if(os->versionID.length == 0 && os->version.length > 0 && !ffStrbufContain(result, &os->version))
else if(os->versionID.length == 0 && os->version.length > 0 && !ffStrbufContainIgnCase(result, &os->version))
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->version);
}
//Append variant if it is missing
if(os->variant.length > 0 && ffStrbufFirstIndex(result, &os->variant) == result->length)
if(os->variant.length > 0 && !ffStrbufContainIgnCase(result, &os->variant))
{
ffStrbufAppendS(result, " (");
ffStrbufAppend(result, &os->variant);
ffStrbufAppendC(result, ')');
}
else if(os->variant.length == 0 && os->variantID.length > 0 && ffStrbufFirstIndex(result, &os->variantID) == result->length)
else if(os->variant.length == 0 && os->variantID.length > 0 && !ffStrbufContainIgnCase(result, &os->variantID))
{
ffStrbufAppendS(result, " (");
ffStrbufAppend(result, &os->variantID);
@@ -55,7 +56,7 @@ static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
}
//Append architecture if it is missing
if(ffStrbufFirstIndex(result, &instance.state.platform.systemArchitecture) == result->length)
if(!ffStrbufContainIgnCase(result, &instance.state.platform.systemArchitecture))
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &instance.state.platform.systemArchitecture);
+4
View File
@@ -5,6 +5,8 @@
#include "util/mallocHelper.h"
#include "util/wcwidth.h"
#include <locale.h>
static inline uint32_t max(uint32_t a, uint32_t b)
{
return a > b ? a : b;
@@ -31,6 +33,7 @@ static inline uint32_t getWcsWidth(const FFstrbuf* mbstr, wchar_t* wstr, mbstate
void ffPrintSeparator(FFSeparatorOptions* options)
{
setlocale(LC_CTYPE, "");
mbstate_t state = {};
bool fqdn = instance.config.modules.title.fqdn;
const FFPlatform* platform = &instance.state.platform;
@@ -86,6 +89,7 @@ void ffPrintSeparator(FFSeparatorOptions* options)
}
}
putchar('\n');
setlocale(LC_CTYPE, "C");
}
bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value)
+2 -2
View File
@@ -13,7 +13,7 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options)
{
FFTerminalThemeResult result = {};
if(!ffDetectTerminalTheme(&result))
if(!ffDetectTerminalTheme(&result, false))
{
ffPrintError(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Failed to detect terminal theme");
}
@@ -81,7 +81,7 @@ void ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* option
{
FFTerminalThemeResult result = {};
if(!ffDetectTerminalTheme(&result))
if(!ffDetectTerminalTheme(&result, false))
{
yyjson_mut_obj_add_str(doc, module, "error", "Failed to detect terminal theme");
return;
+28 -10
View File
@@ -4,12 +4,15 @@
#include "modules/theme/theme.h"
#include "util/stringUtils.h"
#define FF_THEME_NUM_FORMAT_ARGS 1
#define FF_THEME_NUM_FORMAT_ARGS 2
void ffPrintTheme(FFThemeOptions* options)
{
FF_STRBUF_AUTO_DESTROY theme = ffStrbufCreate();
const char* error = ffDetectTheme(&theme);
FFThemeResult result = {
.theme1 = ffStrbufCreate(),
.theme2 = ffStrbufCreate()
};
const char* error = ffDetectTheme(&result);
if(error)
{
@@ -20,12 +23,21 @@ void ffPrintTheme(FFThemeOptions* options)
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufPutTo(&theme, stdout);
if (result.theme1.length)
ffStrbufWriteTo(&result.theme1, stdout);
if (result.theme2.length)
{
if (result.theme1.length)
fputs(", ", stdout);
ffStrbufWriteTo(&result.theme2, stdout);
}
putchar('\n');
}
else
{
FF_PRINT_FORMAT_CHECKED(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_THEME_NUM_FORMAT_ARGS, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &theme, "combined"},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.theme1, "theme1"},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.theme2, "theme2"},
}));
}
}
@@ -67,8 +79,11 @@ void ffGenerateThemeJsonConfig(FFThemeOptions* options, yyjson_mut_doc* doc, yyj
void ffGenerateThemeJsonResult(FF_MAYBE_UNUSED FFThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
FF_STRBUF_AUTO_DESTROY theme = ffStrbufCreate();
const char* error = ffDetectTheme(&theme);
FFThemeResult result = {
.theme1 = ffStrbufCreate(),
.theme2 = ffStrbufCreate()
};
const char* error = ffDetectTheme(&result);
if(error)
{
@@ -76,13 +91,16 @@ void ffGenerateThemeJsonResult(FF_MAYBE_UNUSED FFThemeOptions* options, yyjson_m
return;
}
yyjson_mut_obj_add_strbuf(doc, module, "result", &theme);
yyjson_mut_val* theme = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, theme, "theme1", &result.theme1);
yyjson_mut_obj_add_strbuf(doc, theme, "theme2", &result.theme2);
}
void ffPrintThemeHelpFormat(void)
{
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_THEME_MODULE_NAME, "{1}", FF_THEME_NUM_FORMAT_ARGS, ((const char* []) {
"Combined themes - combined",
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_THEME_MODULE_NAME, "{1}, {2}", FF_THEME_NUM_FORMAT_ARGS, ((const char* []) {
"Theme part 1 - theme1",
"Theme part 2 - theme2",
}));
}
+22 -13
View File
@@ -180,9 +180,13 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
if (charTotal)
ffStrbufSetS(&options->barCharTotal, charTotal);
yyjson_val* border = yyjson_obj_get(val, "border");
if (border)
options->barBorder = yyjson_get_bool(border);
yyjson_val* borderLeft = yyjson_obj_get(val, "border-left");
if (borderLeft)
ffStrbufSetS(&options->barBorderLeft, yyjson_get_str(borderLeft));
yyjson_val* borderRight = yyjson_obj_get(val, "border-right");
if (borderRight)
ffStrbufSetS(&options->barBorderRight, yyjson_get_str(borderRight));
yyjson_val* width = yyjson_obj_get(val, "width");
if (width)
@@ -346,8 +350,10 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
ffOptionParseString(key, value, &options->barCharTotal);
else if(ffStrEqualsIgnCase(subkey, "width"))
options->barWidth = (uint8_t) ffOptionParseUInt32(key, value);
else if(ffStrEqualsIgnCase(subkey, "border"))
options->barBorder = ffOptionParseBoolean(value);
else if(ffStrEqualsIgnCase(subkey, "border-left"))
ffOptionParseString(key, value, &options->barBorderLeft);
else if(ffStrEqualsIgnCase(subkey, "border-right"))
ffOptionParseString(key, value, &options->barBorderRight);
else
return false;
}
@@ -364,7 +370,7 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
ffStrbufInit(&options->colorTitle);
ffStrbufInit(&options->colorOutput);
ffStrbufInit(&options->colorSeparator);
options->brightColor = true;
options->brightColor = !instance.state.terminalLightTheme;
ffStrbufInitStatic(&options->keyValueSeparator, ": ");
options->showErrors = false;
@@ -387,18 +393,19 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
options->tempUnit = FF_TEMPERATURE_UNIT_CELSIUS;
options->tempNdigits = 1;
ffStrbufInitStatic(&options->tempColorGreen, FF_COLOR_FG_GREEN);
ffStrbufInitStatic(&options->tempColorYellow, FF_COLOR_FG_LIGHT_YELLOW);
ffStrbufInitStatic(&options->tempColorRed, FF_COLOR_FG_LIGHT_RED);
ffStrbufInitStatic(&options->tempColorYellow, instance.state.terminalLightTheme ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_LIGHT_YELLOW);
ffStrbufInitStatic(&options->tempColorRed, instance.state.terminalLightTheme ? FF_COLOR_FG_RED : FF_COLOR_FG_LIGHT_RED);
ffStrbufInitStatic(&options->barCharElapsed, "");
ffStrbufInitStatic(&options->barCharTotal, "-");
ffStrbufInitStatic(&options->barBorderLeft, "[ ");
ffStrbufInitStatic(&options->barBorderRight, " ]");
options->barWidth = 10;
options->barBorder = true;
options->percentType = 9;
options->percentNdigits = 0;
ffStrbufInitStatic(&options->percentColorGreen, FF_COLOR_FG_GREEN);
ffStrbufInitStatic(&options->percentColorYellow, FF_COLOR_FG_LIGHT_YELLOW);
ffStrbufInitStatic(&options->percentColorRed, FF_COLOR_FG_LIGHT_RED);
ffStrbufInitStatic(&options->percentColorYellow, instance.state.terminalLightTheme ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_LIGHT_YELLOW);
ffStrbufInitStatic(&options->percentColorRed, instance.state.terminalLightTheme ? FF_COLOR_FG_RED : FF_COLOR_FG_LIGHT_RED);
options->tsVersion = true;
}
@@ -561,8 +568,10 @@ void ffOptionsGenerateDisplayJsonConfig(FFOptionsDisplay* options, yyjson_mut_do
yyjson_mut_obj_add_strbuf(doc, bar, "charElapsed", &options->barCharElapsed);
if (!ffStrbufEqual(&options->barCharTotal, &defaultOptions.barCharTotal))
yyjson_mut_obj_add_strbuf(doc, bar, "charTotal", &options->barCharTotal);
if (options->barBorder != defaultOptions.barBorder)
yyjson_mut_obj_add_bool(doc, bar, "border", options->barBorder);
if (!ffStrbufEqual(&options->barBorderLeft, &defaultOptions.barBorderLeft))
yyjson_mut_obj_add_strbuf(doc, bar, "borderLeft", &options->barBorderLeft);
if (!ffStrbufEqual(&options->barBorderRight, &defaultOptions.barBorderRight))
yyjson_mut_obj_add_strbuf(doc, bar, "borderRight", &options->barBorderRight);
if (options->barWidth != defaultOptions.barWidth)
yyjson_mut_obj_add_uint(doc, bar, "width", options->barWidth);
+2 -1
View File
@@ -43,8 +43,9 @@ typedef struct FFOptionsDisplay
FFstrbuf tempColorRed;
FFstrbuf barCharElapsed;
FFstrbuf barCharTotal;
FFstrbuf barBorderLeft;
FFstrbuf barBorderRight;
uint8_t barWidth;
bool barBorder;
uint8_t percentType;
uint8_t percentNdigits;
FFstrbuf percentColorGreen;
+37 -44
View File
@@ -28,7 +28,7 @@ void ffOptionsInitLogo(FFOptionsLogo* options)
bool ffOptionsParseLogoCommandLine(FFOptionsLogo* options, const char* key, const char* value)
{
if (strcasecmp(key, "-l") == 0)
if (ffStrEqualsIgnCase(key, "-l"))
goto logoType;
const char* subKey = ffOptionTestPrefix(key, "logo");
@@ -43,21 +43,14 @@ logoType:
exit(477);
}
//this is usually wanted when disabling logo
if(strcasecmp(value, "none") == 0)
{
options->paddingTop = 0;
options->paddingRight = 0;
options->paddingLeft = 0;
if(ffStrEqualsIgnCase(value, "none"))
options->type = FF_LOGO_TYPE_NONE;
}
else if(strcasecmp(value, "small") == 0)
{
else if(ffStrEqualsIgnCase(value, "small"))
options->type = FF_LOGO_TYPE_SMALL;
}
else
ffOptionParseString(key, value, &options->source);
}
else if(strcasecmp(subKey, "type") == 0)
else if(ffStrEqualsIgnCase(subKey, "type"))
{
options->type = (FFLogoType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "auto", FF_LOGO_TYPE_AUTO },
@@ -95,29 +88,29 @@ logoType:
}
ffOptionParseColor(value, &options->colors[index]);
}
else if(strcasecmp(subKey, "width") == 0)
else if(ffStrEqualsIgnCase(subKey, "width"))
options->width = ffOptionParseUInt32(key, value);
else if(strcasecmp(subKey, "height") == 0)
else if(ffStrEqualsIgnCase(subKey, "height"))
options->height = ffOptionParseUInt32(key, value);
else if(strcasecmp(subKey, "padding") == 0)
else if(ffStrEqualsIgnCase(subKey, "padding"))
{
uint32_t padding = ffOptionParseUInt32(key, value);
options->paddingLeft = padding;
options->paddingRight = padding;
}
else if(strcasecmp(subKey, "padding-top") == 0)
else if(ffStrEqualsIgnCase(subKey, "padding-top"))
options->paddingTop = ffOptionParseUInt32(key, value);
else if(strcasecmp(subKey, "padding-left") == 0)
else if(ffStrEqualsIgnCase(subKey, "padding-left"))
options->paddingLeft = ffOptionParseUInt32(key, value);
else if(strcasecmp(subKey, "padding-right") == 0)
else if(ffStrEqualsIgnCase(subKey, "padding-right"))
options->paddingRight = ffOptionParseUInt32(key, value);
else if(strcasecmp(subKey, "print-remaining") == 0)
else if(ffStrEqualsIgnCase(subKey, "print-remaining"))
options->printRemaining = ffOptionParseBoolean(value);
else if(strcasecmp(subKey, "preserve-aspect-ratio") == 0)
else if(ffStrEqualsIgnCase(subKey, "preserve-aspect-ratio"))
options->preserveAspectRatio = ffOptionParseBoolean(value);
else if(strcasecmp(subKey, "recache") == 0)
else if(ffStrEqualsIgnCase(subKey, "recache"))
options->recache = ffOptionParseBoolean(value);
else if(strcasecmp(subKey, "separate") == 0)
else if(ffStrEqualsIgnCase(subKey, "separate"))
options->separate = ffOptionParseBoolean(value);
else
return false;
@@ -129,7 +122,7 @@ logoType:
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_FILE;
}
else if(strcasecmp(subKey, "raw") == 0)
else if(ffStrEqualsIgnCase(subKey, "raw"))
{
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_FILE_RAW;
@@ -144,7 +137,7 @@ logoType:
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_DATA;
}
else if(strcasecmp(subKey, "raw") == 0)
else if(ffStrEqualsIgnCase(subKey, "raw"))
{
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_DATA_RAW;
@@ -152,27 +145,27 @@ logoType:
else
return false;
}
else if(strcasecmp(key, "--sixel") == 0)
else if(ffStrEqualsIgnCase(key, "--sixel"))
{
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_IMAGE_SIXEL;
}
else if(strcasecmp(key, "--kitty") == 0)
else if(ffStrEqualsIgnCase(key, "--kitty"))
{
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_IMAGE_KITTY;
}
else if(strcasecmp(key, "--kitty-direct") == 0)
else if(ffStrEqualsIgnCase(key, "--kitty-direct"))
{
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_IMAGE_KITTY_DIRECT;
}
else if(strcasecmp(key, "--iterm") == 0)
else if(ffStrEqualsIgnCase(key, "--iterm"))
{
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_IMAGE_ITERM;
}
else if(strcasecmp(key, "--raw") == 0)
else if(ffStrEqualsIgnCase(key, "--raw"))
{
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_IMAGE_RAW;
@@ -184,11 +177,11 @@ logoType:
ffOptionParseString(key, value, &options->source);
options->type = FF_LOGO_TYPE_IMAGE_CHAFA;
}
else if(strcasecmp(subKey, "fg-only") == 0)
else if(ffStrEqualsIgnCase(subKey, "fg-only"))
options->chafaFgOnly = ffOptionParseBoolean(value);
else if(strcasecmp(subKey, "symbols") == 0)
else if(ffStrEqualsIgnCase(subKey, "symbols"))
ffOptionParseString(key, value, &options->chafaSymbols);
else if(strcasecmp(subKey, "canvas-mode") == 0)
else if(ffStrEqualsIgnCase(subKey, "canvas-mode"))
{
options->chafaCanvasMode = (uint32_t) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "TRUECOLOR", 0 },
@@ -202,7 +195,7 @@ logoType:
{},
});
}
else if(strcasecmp(subKey, "color-space") == 0)
else if(ffStrEqualsIgnCase(subKey, "color-space"))
{
options->chafaColorSpace = (uint32_t) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "RGB", 0 },
@@ -210,7 +203,7 @@ logoType:
{},
});
}
else if(strcasecmp(subKey, "dither-mode") == 0)
else if(ffStrEqualsIgnCase(subKey, "dither-mode"))
{
options->chafaDitherMode = (uint32_t) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "NONE", 0 },
@@ -264,7 +257,7 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo
{
const char* key = yyjson_get_str(key_);
if (strcasecmp(key, "type") == 0)
if (ffStrEqualsIgnCase(key, "type"))
{
int value;
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
@@ -289,12 +282,12 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo
options->type = (FFLogoType) value;
continue;
}
else if (strcasecmp(key, "source") == 0)
else if (ffStrEqualsIgnCase(key, "source"))
{
ffStrbufSetS(&options->source, yyjson_get_str(val));
continue;
}
else if (strcasecmp(key, "color") == 0)
else if (ffStrEqualsIgnCase(key, "color"))
{
if (!yyjson_is_obj(val))
return "Property 'color' must be an object";
@@ -312,7 +305,7 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo
}
continue;
}
else if (strcasecmp(key, "width") == 0)
else if (ffStrEqualsIgnCase(key, "width"))
{
uint32_t value = (uint32_t) yyjson_get_uint(val);
if (value == 0)
@@ -320,7 +313,7 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo
options->width = value;
continue;
}
else if (strcasecmp(key, "height") == 0)
else if (ffStrEqualsIgnCase(key, "height"))
{
uint32_t value = (uint32_t) yyjson_get_uint(val);
if (value == 0)
@@ -328,7 +321,7 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo
options->height = value;
continue;
}
else if (strcasecmp(key, "padding") == 0)
else if (ffStrEqualsIgnCase(key, "padding"))
{
if (!yyjson_is_obj(val))
return "Logo padding must be an object";
@@ -347,27 +340,27 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo
#undef FF_PARSE_PADDING_POSITON
continue;
}
else if (strcasecmp(key, "printRemaining") == 0)
else if (ffStrEqualsIgnCase(key, "printRemaining"))
{
options->printRemaining = yyjson_get_bool(val);
continue;
}
else if (strcasecmp(key, "preserveAspectRatio") == 0)
else if (ffStrEqualsIgnCase(key, "preserveAspectRatio"))
{
options->preserveAspectRatio = yyjson_get_bool(val);
continue;
}
else if (strcasecmp(key, "recache") == 0)
else if (ffStrEqualsIgnCase(key, "recache"))
{
options->recache = yyjson_get_bool(val);
continue;
}
else if (strcasecmp(key, "separate") == 0)
else if (ffStrEqualsIgnCase(key, "separate"))
{
options->separate = yyjson_get_bool(val);
continue;
}
else if (strcasecmp(key, "chafa") == 0)
else if (ffStrEqualsIgnCase(key, "chafa"))
{
if (!yyjson_is_obj(val))
return "Chafa config must be an object";
+2
View File
@@ -13,6 +13,7 @@ void ffOptionsInitModules(FFOptionsModules* options)
ffInitCameraOptions(&options->camera);
ffInitCPUOptions(&options->cpu);
ffInitCPUUsageOptions(&options->cpuUsage);
ffInitCPUCacheOptions(&options->cpuCache);
ffInitChassisOptions(&options->chassis);
ffInitColorsOptions(&options->colors);
ffInitCommandOptions(&options->command);
@@ -81,6 +82,7 @@ void ffOptionsDestroyModules(FFOptionsModules* options)
ffDestroyBrightnessOptions(&options->brightness);
ffDestroyCameraOptions(&options->camera);
ffDestroyCPUOptions(&options->cpu);
ffDestroyCPUCacheOptions(&options->cpuCache);
ffDestroyCPUUsageOptions(&options->cpuUsage);
ffDestroyChassisOptions(&options->chassis);
ffDestroyColorsOptions(&options->colors);
+1
View File
@@ -12,6 +12,7 @@ typedef struct FFOptionsModules
FFBreakOptions break_;
FFBrightnessOptions brightness;
FFCPUOptions cpu;
FFCPUCacheOptions cpuCache;
FFCPUUsageOptions cpuUsage;
FFCameraOptions camera;
FFChassisOptions chassis;
+1
View File
@@ -24,6 +24,7 @@ bool ffIsSmbiosValueSet(FFstrbuf* value)
!ffStrbufIgnCaseEqualS(value, "Not Available") &&
!ffStrbufIgnCaseEqualS(value, "INVALID") &&
!ffStrbufIgnCaseEqualS(value, "Type1ProductConfigId") &&
!ffStrbufIgnCaseEqualS(value, "TBD by OEM") &&
!ffStrbufIgnCaseEqualS(value, "No Enclosure") &&
!ffStrbufIgnCaseEqualS(value, "Chassis Version") &&
!ffStrbufIgnCaseEqualS(value, "All Series") &&