mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:52:08 +02:00
Store big strings in separate files
This commit is contained in:
@@ -9,3 +9,6 @@ trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.txt]
|
||||
insert_final_newline = false
|
||||
|
||||
@@ -37,6 +37,21 @@ if(BUILD_TESTS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mtune=native -pipe -fno-plt -Wconversion -Wpedantic")
|
||||
endif(BUILD_TESTS)
|
||||
|
||||
function(fastfetch_load_text FILENAME OUTVAR)
|
||||
file(READ "${FILENAME}" TEMP)
|
||||
string(REPLACE "\n" "\\n" TEMP "${TEMP}")
|
||||
string(REPLACE "\"" "\\\"" TEMP "${TEMP}")
|
||||
string(REPLACE "$\\" "" TEMP "${TEMP}")
|
||||
set("${OUTVAR}" "${TEMP}" PARENT_SCOPE)
|
||||
endfunction(fastfetch_load_text)
|
||||
|
||||
fastfetch_load_text(src/data/config.txt DATATEXT_CONFIG)
|
||||
fastfetch_load_text(src/data/modules.txt DATATEXT_MODULES)
|
||||
fastfetch_load_text(src/data/help.txt DATATEXT_HELP)
|
||||
fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR)
|
||||
fastfetch_load_text(src/data/help_format.txt DATATEXT_HELP_FORMAT)
|
||||
fastfetch_load_text(src/data/help_config.txt DATATEXT_HELP_CONFIG)
|
||||
|
||||
configure_file(src/fastfetch_config.h.in fastfetch_config.h)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Fastfetch configuration
|
||||
# Write every argument in different lines.
|
||||
# Direct arguments will overwrite the corresponding ones in this file.
|
||||
# Whitespaces are trimmed at the beginning and the end.
|
||||
# Empty lines or lines starting with # are ignored.
|
||||
# There are more arguments possible than the ones listed here, take a look at fastfetch --help
|
||||
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
|
||||
# Use fastfetch --print-default-config > ~/.config/fastfetch/config.conf to generate a new one with current default
|
||||
@@ -0,0 +1,108 @@
|
||||
Usage: fastfetch <options>
|
||||
|
||||
Informative options:
|
||||
-h, --help: shows this message and exits
|
||||
-h <command>, --help <command>: shows help for a specific command and exits
|
||||
-v --version: prints the version of fastfetch and exits
|
||||
--list-logos: list available logos and exits
|
||||
--print-logos: shows available logos and exits
|
||||
--print-default-config: prints the default config and exits
|
||||
--print-default-structure: prints the default stucture and exits
|
||||
--print-available-modules: prints a list of available modules and exits
|
||||
--print-available-presets: list presets fastfetch knows about. They can be loaded with --load-config. (+)
|
||||
--list-supported-features: list the supported features fastfetch was compiled with. Mainly for development.
|
||||
|
||||
General options:
|
||||
--structure <structure>: sets the structure of the fetch. Must be a colon separated list of keys. Use --print-available-modules to show th
|
||||
--set <key=value>: hard set the value of a key
|
||||
-c <color>, --color <color>: sets the color of the keys. Must be a linux console color code (+)
|
||||
--spacing <width>: sets the distance between logo and text
|
||||
-s <str>, --separator <str>: sets the separator between key and value. Default is a colon with a space
|
||||
-x <offset>, --offsetx <offset>: sets the x offset. Can be negative to cut the logo, but no more than logo width.
|
||||
--show-errors <?value>: print occuring errors
|
||||
-r <?value> --recache <?value>: generate new cached values
|
||||
--nocache <?value>: don't use cached values, but also don't overwrite existing ones
|
||||
--print-remaining-logo <?value>: print the remaining logo, if it is higher than the number of lines shown
|
||||
--multithreading <?value>: use multiple threads to detect values
|
||||
--load-config <file>: load a config file (+)
|
||||
--allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output
|
||||
--disable-linewrap <?value>: Disable linewrap during the run
|
||||
--hide-cursor <?value>: Hide the cursor during the run
|
||||
|
||||
Logo options:
|
||||
-l <name>, --logo <name>: sets the shown logo. Also changes the main color accordingly. This will also load file contents as logo if the given argument
|
||||
--color-logo <?value>: if set to false, the logo will be black / white
|
||||
|
||||
Format options: Provide the format string for custom output. Use fastfetch --help *-format for specific help.
|
||||
--os-format <format>
|
||||
--host-format <format>
|
||||
--kernel-format <format>
|
||||
--uptime-format <format>
|
||||
--processes-format <format>
|
||||
--packages-format <format>
|
||||
--shell-format <format>
|
||||
--resolution-format <format>
|
||||
--de-format <format>
|
||||
--wm-format <format>
|
||||
--wm-theme-format <format>
|
||||
--theme-format <format>
|
||||
--icons-format <format>
|
||||
--font-format <format>
|
||||
--cursor-format <format>
|
||||
--terminal-format <format>
|
||||
--terminal-font-format <format>
|
||||
--cpu-format <format>
|
||||
--gpu-format <format>
|
||||
--memory-format <format>
|
||||
--disk-format <format>
|
||||
--battery-format <format>
|
||||
--locale-format <format>
|
||||
--local-ip-format <format>
|
||||
|
||||
Key options: Provide a custom key for an output
|
||||
--os-key <key>
|
||||
--host-key <key>
|
||||
--kernel-key <key>
|
||||
--uptime-key <key>
|
||||
--processes-key <key>
|
||||
--packages-key <key>
|
||||
--shell-key <key>
|
||||
--resolution-key <key>: takes the resolution index as argument
|
||||
--de-key <key>
|
||||
--wm-key <key>
|
||||
--wm-theme-key <key>
|
||||
--theme-key <key>
|
||||
--icons-key <key>
|
||||
--font-key <key>
|
||||
--cursor-key <key>
|
||||
--terminal-key <key>
|
||||
--terminal-font-key <key>
|
||||
--cpu-key <key>
|
||||
--gpu-key <key>: takes the gpu index as format argument
|
||||
--memory-key <key>
|
||||
--disk-key <key>: takes the mount path as format argument
|
||||
--battery-key <key>: takes the battery index as format argument
|
||||
--locale-key <key>
|
||||
--local-ip-key <key>: takes the name of this network interface as format argument
|
||||
|
||||
Library optins: Set the path of a library to load
|
||||
--lib-PCI <path>
|
||||
--lib-X11 <path>
|
||||
--lib-Xrandr <path>
|
||||
--lib-gio <path>
|
||||
--lib-DConf <path>
|
||||
--lib-wayland <path>
|
||||
--lib-XFConf <path>
|
||||
--lib-SQLite <path>
|
||||
|
||||
Module specific options:
|
||||
--disk-folders <folders>: A colon separated list of folder paths for the disk output. Default is "/:/home"
|
||||
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
|
||||
--localip-show-ipv4 <?value>: Show ipv4 addresses in local ip module. Default is true
|
||||
--localip-show-ipv6 <?value>: Show ipv6 addresses in local ip module. Default is false
|
||||
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
|
||||
|
||||
Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci"
|
||||
If a value starts with a ?, it is optional. "true" will be used if not set.
|
||||
A (+) at the end indicates that more help can be printed with --help <option>
|
||||
All options can be made permanent in $XDG_CONFIG_HOME/fastfetch/config.conf
|
||||
@@ -0,0 +1,9 @@
|
||||
usage: fastfetch --color <color>
|
||||
|
||||
<color> must be a color encoding for linux terminals. 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 pink
|
||||
--color 4;92: sets the color to bright Green with underline
|
||||
--color 5;104: blinking text on a blue background
|
||||
If no color is set, the main color of the logo will be used.
|
||||
@@ -0,0 +1,9 @@
|
||||
usage: fastfetch --load-config <file>
|
||||
|
||||
Loads a config file. A config file contains one flag per line. Empty lines or lines starting with # are ignored.
|
||||
If the file is relative it looks in the following order:
|
||||
- relative to the current working directory
|
||||
- relative to ~/.local/share/fastfetch/presets/
|
||||
- relative to /usr/share/fastfetch/presets/
|
||||
Fastfetch provides some default presets. List them with --print-available-presets.
|
||||
Note that this will only print presets fastfetch knows about and not every possible one.
|
||||
@@ -0,0 +1,42 @@
|
||||
A format string is a string that contains placeholders for values.
|
||||
These placeholders begin with a '{', containing the index of the value, and end with a '}'.
|
||||
For example the format string "Values: {1} ({2})", with the values "First" and "My second val", will produce
|
||||
The format string can contain placeholders in any order and have multiple occurences.
|
||||
To include spaces when setting from the command line, surround the whole string with double quotes (").
|
||||
|
||||
If the value index is missing, meaning the placeholder is "{}", an internal counter sets the value index.
|
||||
This means that the format string "Values: {1} ({2})" is equivalent to "Values: {} ({})".
|
||||
Note that this counter only counts empty placeholders, so the format string "{2} {} {}" will contain the second v
|
||||
|
||||
To make formatting easier, a double open curly brace ("{{") will be printed as a single open curly brace and not
|
||||
If a value index is misformatted or wants a non-existing value, it will be printed as is, with the curly braces aro
|
||||
If the last placeholder isn't closed, it will be treated like it was at the end of the format string.
|
||||
|
||||
To only print something if a variable is set, use "{?<index>} ... {?}".
|
||||
For example, to only print a second value if it is set, use "{?2} Second value: {2}{?}".
|
||||
If a "{?}" is found without an opener, it is printed as is.
|
||||
|
||||
To only print something if a variable is not set, do the same as with if, just replace every '?' with a '!'.
|
||||
For example to print a fallback for a second value if it is not set, use "{?2}{2}{?}{/2}Second value fallback{/}"
|
||||
|
||||
There is a special variable set if an error occured during detection. You can access it with "{e}", "{error}" o
|
||||
You can use ifs and not ifs with it like with an index. For example use "{?e}some text{?}", to print a text if an
|
||||
|
||||
To stop formatting at any point in the format string, use "{-}".
|
||||
For example to print an error instead of the normal output if it occured, prefix the format string with "{?e}{e}{-
|
||||
|
||||
To print something with color, start a placeholder with a '#' and then the linux terminal color encoding.
|
||||
"\\033[" at the start, and an 'm' at the end is automatically added, so don't do that.
|
||||
A "{#}" is equivalent to a "{#0}" and resets everything to normal.
|
||||
For example to print something pink and underline, use "{#4;35}...{#}".
|
||||
If not in a format string, fastfetch wraps errors with "{#1;31}error{#}", so you might want to do that to if you
|
||||
Information about what the numbers mean can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Sele
|
||||
Which escape codes are supported and how they look is defined by your terminal.
|
||||
|
||||
If a format string evaluates to an empty value, the whole line in the output will be discarded.
|
||||
You can therefore use --host-format " " to disable host output.
|
||||
Note that --host-format "" would evaluate as not set, and therefore use the built-in host format
|
||||
This can be used to print nothing if an error occured: prefix the format string with "{?e}{-}{?}...".
|
||||
|
||||
Format string is also the way to go to set a fixed value - just use one without placeholders.
|
||||
For example when running in headless mode, you could use "--resolution-format "Preferred".
|
||||
@@ -0,0 +1,28 @@
|
||||
Battery
|
||||
Break
|
||||
Colors
|
||||
CPU
|
||||
Cursor
|
||||
DE
|
||||
Disk
|
||||
Font
|
||||
GPU
|
||||
Host
|
||||
Icons
|
||||
Kernel
|
||||
Locale
|
||||
LocalIp
|
||||
Memory
|
||||
OS
|
||||
Packages
|
||||
Processes
|
||||
Resolution
|
||||
Separator
|
||||
Shell
|
||||
Terminal
|
||||
TerminalFont
|
||||
Theme
|
||||
Title
|
||||
Uptime
|
||||
WM
|
||||
WMTheme
|
||||
+12
-252
@@ -10,16 +10,6 @@
|
||||
|
||||
#define FASTFETCH_DEFAULT_STRUCTURE "Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Disk:Battery:Locale:Break:Colors"
|
||||
|
||||
#define FASTFETCH_DEFAULT_CONFIG \
|
||||
"# Fastfetch configuration\n" \
|
||||
"# Write every argument in different lines.\n" \
|
||||
"# Direct arguments will overwrite the corresponding ones in this file.\n" \
|
||||
"# Whitespaces are trimmed at the beginning and the end.\n" \
|
||||
"# Empty lines or lines starting with # are ignored.\n" \
|
||||
"# There are more arguments possible than the ones listed here, take a look at fastfetch --help\n" \
|
||||
"# This file was shipped with "FASTFETCH_PROJECT_VERSION".\n" \
|
||||
"# Use fastfetch --print-default-config > ~/.config/fastfetch/config.conf to generate a new one with current defaults.\n"
|
||||
|
||||
// Things only needed by fastfetch
|
||||
typedef struct FFdata
|
||||
{
|
||||
@@ -29,198 +19,6 @@ typedef struct FFdata
|
||||
bool multithreading;
|
||||
} FFdata;
|
||||
|
||||
static inline void printHelp()
|
||||
{
|
||||
puts(
|
||||
"Usage: fastfetch <options>\n"
|
||||
"\n"
|
||||
"Informative options:\n"
|
||||
" -h, --help: shows this message and exits\n"
|
||||
" -h <command>, --help <command>: shows help for a specific command and exits\n"
|
||||
" -v --version: prints the version of fastfetch and exits\n"
|
||||
" --list-logos: list available logos and exits\n"
|
||||
" --print-logos: shows available logos and exits\n"
|
||||
" --print-default-config: prints the default config and exits\n"
|
||||
" --print-default-structure: prints the default stucture and exits\n"
|
||||
" --print-available-modules: prints a list of available modules and exits\n"
|
||||
" --print-available-presets: list presets fastfetch knows about. They can be loaded with --load-config. (+)\n"
|
||||
" --list-supported-features: list the supported features fastfetch was compiled with. Mainly for development.\n"
|
||||
"\n"
|
||||
"General options:\n"
|
||||
" --structure <structure>: sets the structure of the fetch. Must be a colon separated list of keys. Use --print-available-modules to show the default\n"
|
||||
" --set <key=value>: hard set the value of a key\n"
|
||||
" -c <color>, --color <color>: sets the color of the keys. Must be a linux console color code (+)\n"
|
||||
" --spacing <width>: sets the distance between logo and text\n"
|
||||
" -s <str>, --separator <str>: sets the separator between key and value. Default is a colon with a space\n"
|
||||
" -x <offset>, --offsetx <offset>: sets the x offset. Can be negative to cut the logo, but no more than logo width.\n"
|
||||
" --show-errors <?value>: print occuring errors\n"
|
||||
" -r <?value> --recache <?value>: generate new cached values\n"
|
||||
" --nocache <?value>: don't use cached values, but also don't overwrite existing ones\n"
|
||||
" --print-remaining-logo <?value>: print the remaining logo, if it is higher than the number of lines shown\n"
|
||||
" --multithreading <?value>: use multiple threads to detect values\n"
|
||||
" --load-config <file>: load a config file (+)\n"
|
||||
" --allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output\n"
|
||||
" --disable-linewrap <?value>: Disable linewrap during the run\n"
|
||||
" --hide-cursor <?value>: Hide the cursor during the run\n"
|
||||
"\n"
|
||||
"Logo options:\n"
|
||||
" -l <name>, --logo <name>: sets the shown logo. Also changes the main color accordingly. This will also load file contents as logo if the given argument is a path\n"
|
||||
" --color-logo <?value>: if set to false, the logo will be black / white\n"
|
||||
"\n"
|
||||
"Format options: Provide the format string for custom output. Use fastfetch --help *-format for specific help.\n"
|
||||
" --os-format <format>\n"
|
||||
" --host-format <format>\n"
|
||||
" --kernel-format <format>\n"
|
||||
" --uptime-format <format>\n"
|
||||
" --processes-format <format>\n"
|
||||
" --packages-format <format>\n"
|
||||
" --shell-format <format>\n"
|
||||
" --resolution-format <format>\n"
|
||||
" --de-format <format>\n"
|
||||
" --wm-format <format>\n"
|
||||
" --wm-theme-format <format>\n"
|
||||
" --theme-format <format>\n"
|
||||
" --icons-format <format>\n"
|
||||
" --font-format <format>\n"
|
||||
" --cursor-format <format>\n"
|
||||
" --terminal-format <format>\n"
|
||||
" --terminal-font-format <format>\n"
|
||||
" --cpu-format <format>\n"
|
||||
" --gpu-format <format>\n"
|
||||
" --memory-format <format>\n"
|
||||
" --disk-format <format>\n"
|
||||
" --battery-format <format>\n"
|
||||
" --locale-format <format>\n"
|
||||
" --local-ip-format <format>\n"
|
||||
"\n"
|
||||
"Key options: Provide a custom key for an output\n"
|
||||
" --os-key <key>\n"
|
||||
" --host-key <key>\n"
|
||||
" --kernel-key <key>\n"
|
||||
" --uptime-key <key>\n"
|
||||
" --processes-key <key>\n"
|
||||
" --packages-key <key>\n"
|
||||
" --shell-key <key>\n"
|
||||
" --resolution-key <key>: takes the resolution index as argument\n"
|
||||
" --de-key <key>\n"
|
||||
" --wm-key <key>\n"
|
||||
" --wm-theme-key <key>\n"
|
||||
" --theme-key <key>\n"
|
||||
" --icons-key <key>\n"
|
||||
" --font-key <key>\n"
|
||||
" --cursor-key <key>\n"
|
||||
" --terminal-key <key>\n"
|
||||
" --terminal-font-key <key>\n"
|
||||
" --cpu-key <key>\n"
|
||||
" --gpu-key <key>: takes the gpu index as format argument\n"
|
||||
" --memory-key <key>\n"
|
||||
" --disk-key <key>: takes the mount path as format argument\n"
|
||||
" --battery-key <key>: takes the battery index as format argument\n"
|
||||
" --locale-key <key>\n"
|
||||
" --local-ip-key <key>: takes the name of this network interface as format argument\n"
|
||||
"\n"
|
||||
"Library optins: Set the path of a library to load\n"
|
||||
" --lib-PCI <path>\n"
|
||||
" --lib-X11 <path>\n"
|
||||
" --lib-Xrandr <path>\n"
|
||||
" --lib-gio <path>\n"
|
||||
" --lib-DConf <path>\n"
|
||||
" --lib-wayland <path>\n"
|
||||
" --lib-XFConf <path>\n"
|
||||
" --lib-SQLite <path>\n"
|
||||
"\n"
|
||||
"Module specific options:\n"
|
||||
" --disk-folders <folders>: A colon separated list of folder paths for the disk output. Default is \"/:/home\"\n"
|
||||
" --battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/\n"
|
||||
" --localip-show-ipv4 <?value>: Show ipv4 addresses in local ip module. Default is true\n"
|
||||
" --localip-show-ipv6 <?value>: Show ipv6 addresses in local ip module. Default is false\n"
|
||||
" --localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false\n"
|
||||
"\n"
|
||||
"Parsing is not case sensitive. E.g. \"--lib-PCI\" is equal to \"--Lib-Pci\"\n"
|
||||
"If a value starts with a ?, it is optional. \"true\" will be used if not set.\n"
|
||||
"A (+) at the end indicates that more help can be printed with --help <option>\n"
|
||||
"All options can be made permanent in $XDG_CONFIG_HOME/fastfetch/config.conf"
|
||||
);
|
||||
}
|
||||
|
||||
static inline void printCommandHelpColor()
|
||||
{
|
||||
puts(
|
||||
"usage: fastfetch --color <color>\n"
|
||||
"\n"
|
||||
"<color> must be a color encoding for linux terminals. It is inserted between \"ESC[\" and \"m\".\n"
|
||||
"Infos about them can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters.\n"
|
||||
"Examples:\n"
|
||||
" \"--color 35\": sets the color to pink\n"
|
||||
" \"--color 4;92\": sets the color to bright Green with underline\n"
|
||||
" \"--color 5;104\": blinking text on a blue background\n"
|
||||
"If no color is set, the main color of the logo will be used.\n"
|
||||
);
|
||||
}
|
||||
|
||||
static inline void printCommandHelpFormat()
|
||||
{
|
||||
puts(
|
||||
"A format string is a string that contains placeholders for values.\n"
|
||||
"These placeholders begin with a '{', containing the index of the value, and end with a '}'.\n"
|
||||
"For example the format string \"Values: {1} ({2})\", with the values \"First\" and \"My second val\", will produce \"Values: First (My second val)\".\n"
|
||||
"The format string can contain placeholders in any order and have multiple occurences.\n"
|
||||
"To include spaces when setting from the command line, surround the whole string with double quotes (\").\n"
|
||||
"\n"
|
||||
"If the value index is missing, meaning the placeholder is \"{}\", an internal counter sets the value index.\n"
|
||||
"This means that the format string \"Values: {1} ({2})\" is equivalent to \"Values: {} ({})\".\n"
|
||||
"Note that this counter only counts empty placeholders, so the format string \"{2} {} {}\" will contain the second value, then the first, and then the second again.\n"
|
||||
"\n"
|
||||
"To make formatting easier, a double open curly brace (\"{{\") will be printed as a single open curly brace and not counted as the beginning of a placeholder.\n"
|
||||
"If a value index is misformatted or wants a non-existing value, it will be printed as is, with the curly braces around it.\n"
|
||||
"If the last placeholder isn't closed, it will be treated like it was at the end of the format string.\n"
|
||||
"\n"
|
||||
"To only print something if a variable is set, use \"{?<index>} ... {?}\".\n"
|
||||
"For example, to only print a second value if it is set, use \"{?2} Second value: {2}{?}\".\n"
|
||||
"If a \"{?}\" is found without an opener, it is printed as is.\n"
|
||||
"\n"
|
||||
"To only print something if a variable is not set, do the same as with if, just replace every '?' with a '!'.\n"
|
||||
"For example to print a fallback for a second value if it is not set, use \"{?2}{2}{?}{/2}Second value fallback{/}\".\n"
|
||||
"\n"
|
||||
"There is a special variable set if an error occured during detection. You can access it with \"{e}\", \"{error}\" or \"{0}\".\n"
|
||||
"You can use ifs and not ifs with it like with an index. For example use \"{?e}some text{?}\", to print a text if an error occurred.\n"
|
||||
"\n"
|
||||
"To stop formatting at any point in the format string, use \"{-}\".\n"
|
||||
"For example to print an error instead of the normal output if it occured, prefix the format string with \"{?e}{e}{-}{?}...\".\n"
|
||||
"\n"
|
||||
"To print something with color, start a placeholder with a '#' and then the linux terminal color encoding.\n"
|
||||
"\"\\033[\" at the start, and an 'm' at the end is automatically added, so don't do that.\n"
|
||||
"A \"{#}\" is equivalent to a \"{#0}\" and resets everything to normal.\n"
|
||||
"For example to print something pink and underline, use \"{#4;35}...{#}\".\n"
|
||||
"If not in a format string, fastfetch wraps errors with \"{#1;31}error{#}\", so you might want to do that to if you show errors.\n"
|
||||
"Information about what the numbers mean can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters.\n"
|
||||
"Which escape codes are supported and how they look is defined by your terminal.\n"
|
||||
"\n"
|
||||
"If a format string evaluates to an empty value, the whole line in the output will be discarded.\n"
|
||||
"You can therefore use --host-format \" \" to disable host output.\n"
|
||||
"Note that --host-format \"\" would evaluate as not set, and therefore use the built-in host format\n"
|
||||
"This can be used to print nothing if an error occured: prefix the format string with \"{?e}{-}{?}...\".\n"
|
||||
"\n"
|
||||
"Format string is also the way to go to set a fixed value - just use one without placeholders.\n"
|
||||
"For example when running in headless mode, you could use \"--resolution-format \"Preferred\"."
|
||||
);
|
||||
}
|
||||
|
||||
static inline void printCommandHelpLoadConfig()
|
||||
{
|
||||
puts(
|
||||
"usage: fastfetch --load-config <file>\n"
|
||||
"\n"
|
||||
"Loads a config file. A config file contains one flag per line. Empty lines or lines starting with # are ignored.\n"
|
||||
"If the file is relative it looks in the following order:\n"
|
||||
" - relative to the current working directory\n"
|
||||
" - relative to ~/.local/share/fastfetch/presets/\n"
|
||||
" - relative to /usr/share/fastfetch/presets/\n"
|
||||
"Fastfetch provides some default presets. List them with --print-available-presets.\n"
|
||||
"Note that this will only print presets fastfetch knows about and not every possible one."
|
||||
);
|
||||
}
|
||||
|
||||
static void constructAndPrintCommandHelpFormat(const char* name, const char* def, uint32_t numArgs, ...)
|
||||
{
|
||||
va_list argp;
|
||||
@@ -241,12 +39,14 @@ static void constructAndPrintCommandHelpFormat(const char* name, const char* def
|
||||
|
||||
static inline void printCommandHelp(const char* command)
|
||||
{
|
||||
if(strcasecmp(command, "c") == 0 || strcasecmp(command, "color") == 0)
|
||||
printCommandHelpColor();
|
||||
if(command == NULL)
|
||||
fputs(FASTFETCH_DATATEXT_HELP, stdout);
|
||||
else if(strcasecmp(command, "c") == 0 || strcasecmp(command, "color") == 0)
|
||||
fputs(FASTFETCH_DATATEXT_HELP_COLOR, stdout);
|
||||
else if(strcasecmp(command, "format") == 0)
|
||||
printCommandHelpFormat();
|
||||
else if(strcasecmp(command, "load-config") == 0)
|
||||
printCommandHelpLoadConfig();
|
||||
fputs(FASTFETCH_DATATEXT_HELP_FORMAT, stdout);
|
||||
else if(strcasecmp(command, "load-config") == 0 || strcasecmp(command, "loadconfig") == 0 || strcasecmp(command, "config") == 0)
|
||||
fputs(FASTFETCH_DATATEXT_HELP_CONFIG, stdout);
|
||||
else if(strcasecmp(command, "os-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("os", "{3} {12}", 12,
|
||||
@@ -490,42 +290,6 @@ static inline void printCommandHelp(const char* command)
|
||||
fprintf(stderr, "No specific help for command %s provided\n", command);
|
||||
}
|
||||
|
||||
static inline void printAvailableModules()
|
||||
{
|
||||
puts(
|
||||
"Battery\n"
|
||||
"Break\n"
|
||||
"Colors\n"
|
||||
"CPU\n"
|
||||
"Cursor\n"
|
||||
"DE\n"
|
||||
"Disk\n"
|
||||
"Font\n"
|
||||
"GPU\n"
|
||||
"Host\n"
|
||||
"Icons\n"
|
||||
"Kernel\n"
|
||||
"Locale\n"
|
||||
"LocalIp\n"
|
||||
"Memory\n"
|
||||
"OS\n"
|
||||
"Packages\n"
|
||||
"Processes\n"
|
||||
"Resolution\n"
|
||||
"Separator\n"
|
||||
"Shell\n"
|
||||
"Terminal\n"
|
||||
"TerminalFont\n"
|
||||
"Theme\n"
|
||||
"Title\n"
|
||||
"Uptime\n"
|
||||
"WM\n"
|
||||
"WMTheme\n"
|
||||
"\n"
|
||||
"+ Additional defined by --set"
|
||||
);
|
||||
}
|
||||
|
||||
static inline void listAvailablePresetsFromFolder(FFstrbuf* folder, uint8_t indentation, const char* folderName)
|
||||
{
|
||||
DIR* dir = opendir(folder->chars);
|
||||
@@ -740,11 +504,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
{
|
||||
if(strcasecmp(key, "-h") == 0 || strcasecmp(key, "--help") == 0)
|
||||
{
|
||||
if(value == NULL)
|
||||
printHelp();
|
||||
else
|
||||
printCommandHelp(value);
|
||||
|
||||
printCommandHelp(value);
|
||||
exit(0);
|
||||
}
|
||||
else if(strcasecmp(key, "-v") == 0 || strcasecmp(key, "--version") == 0)
|
||||
@@ -764,17 +524,17 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
}
|
||||
else if(strcasecmp(key, "--print-default-config") == 0)
|
||||
{
|
||||
puts(FASTFETCH_DEFAULT_CONFIG);
|
||||
fputs(FASTFETCH_DATATEXT_CONFIG, stdout);
|
||||
exit(0);
|
||||
}
|
||||
else if(strcasecmp(key, "--print-default-structure") == 0)
|
||||
{
|
||||
puts(FASTFETCH_DEFAULT_STRUCTURE);
|
||||
fputs(FASTFETCH_DEFAULT_STRUCTURE, stdout);
|
||||
exit(0);
|
||||
}
|
||||
else if(strcasecmp(key, "--print-available-modules") == 0)
|
||||
{
|
||||
printAvailableModules();
|
||||
fputs(FASTFETCH_DATATEXT_MODULES, stdout);
|
||||
exit(0);
|
||||
}
|
||||
else if(strcasecmp(key, "--print-available-presets") == 0)
|
||||
@@ -1023,7 +783,7 @@ static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
|
||||
FILE* file = fopen(filename->chars, "w");
|
||||
if(file != NULL)
|
||||
{
|
||||
fputs(FASTFETCH_DEFAULT_CONFIG, file);
|
||||
fputs(FASTFETCH_DATATEXT_CONFIG, file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,20 @@
|
||||
#define FASTFETCH_PROJECT_NAME "@PROJECT_NAME@"
|
||||
#define FASTFETCH_PROJECT_VERSION "@PROJECT_VERSION@"
|
||||
|
||||
#ifndef FASTFETCH_BUILD_FLASHFETCH
|
||||
|
||||
#define FASTFETCH_DATATEXT_CONFIG "@DATATEXT_CONFIG@"
|
||||
#define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@"
|
||||
#define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@"
|
||||
#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@"
|
||||
#define FASTFETCH_DATATEXT_HELP_FORMAT "@DATATEXT_HELP_FORMAT@"
|
||||
#define FASTFETCH_DATATEXT_HELP_CONFIG "@DATATEXT_HELP_CONFIG@"
|
||||
|
||||
#else
|
||||
|
||||
//Needed for flashfetch logo
|
||||
#define FASTFETCH_BUILD_DISTRIBUTION_ID "@BUILD_DISTRIBUTION_ID@"
|
||||
|
||||
#endif
|
||||
|
||||
#endif // FASTFETCH_INDLUDED_fastfetch_config_h_in
|
||||
|
||||
Reference in New Issue
Block a user