Skip to content

Commit

Permalink
misc: rename "vocabulary" + some grammar fixes
Browse files Browse the repository at this point in the history
renamed components to tags and module submodule to module member
  • Loading branch information
Toni500github committed Sep 5, 2024
1 parent 508a3f0 commit 8259f7c
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 47 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ secs = " seconds"
# Choices: pacman, flatpak, dpkg, apk
#
# Pro-tip: if your package manager isnt listed here, yet,
# use the bash command component in the layout
# use the bash command tag in the layout
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

Expand Down Expand Up @@ -252,24 +252,24 @@ bg-image = "/tmp/idk.png"
```

We got the config.toml file, in there we got an array variable called "layout". That's the variable where you customize how the infos should be displayed.\
You have 4 components: `$<module.submod>`, `${color}`, `$(bash command)`, `$[something,equalToSomethingElse,iftrue,ifalse]`. They can be used in the ascii art text file and layout, but how to use them?
You have 4 tags: `$<module.member>`, `${color}`, `$(bash command)`, `$[something,equalToSomethingElse,iftrue,ifalse]`. They can be used in the ascii art text file and layout, but how to use them?

* **The info component (`$<>`)** will print a member of a module\
* **The info tag (`$<>`)** will print a value of a module\
e.g `$<user.name>` will print the username, `$<os.kernel_version>` will print the kernel version and so on.\
run "cufetch -l" for a list of builti-in modules

* **The bash command component (`$()`)** let's you execute bash commands\
* **The bash command tag (`$()`)** let's you execute bash commands\
e.g `$(echo \"hello world\")` will indeed echo out Hello world.\
you can even use pipes\
e.g `$(echo \"hello world\" | cut -d' ' -f2)` will only print world

* **The conditional component (`$[]`)** is used for equal conditional check.\
* **The conditional tag (`$[]`)** is used for equal conditional check.\
Syntax MUST be `$[something,equalToSomethingElse,iftrue,ifalse]` with no spaces between commas ','\
Each part can have a component or anything else.\
Each part can have a tag or anything else.\
e.g `$[$<user.name>,$(echo $USER),the name is correct,the name is NOT correct]`\
This is useful when on some terminal or WM the detection can be different than others\

* **The color component (`${}`)** is used for which color to use for colorizing the text\
* **The color tag (`${}`)** is used for which color to use for colorizing the text\
e.g `${red}hello world` will indeed print "hello world" in red (or the color you set in the variable).\
The colors can be: <ins>black</ins>, <ins>red</ins>, <ins>green</ins>, <ins>blue</ins>, <ins>cyan</ins>, <ins>yellow</ins>, <ins>magenta</ins>, <ins>white</ins> and they can be configured in the config file.\
You can put a custom hex color e.g: `${#ff6622}`.\
Expand Down
6 changes: 3 additions & 3 deletions assets/config-examples/config_cool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# here is how it works:
# the variable "layout" is used for showing the infos
# as like as the user want, no limitation.
# inside here there are 4 "components": $<> $() ${} $[]
# inside here there are 4 "tags": $<> $() ${} $[]

# $<> lets you access a member of a module
# e.g $<user.name> will print the username, $<os.kernel_version> will print the kernel version and so on.
Expand All @@ -16,7 +16,7 @@

# $[] is used for equal conditional check
# syntax MUST be $[something,equalToSomethingElse,iftrue,ifalse] with no spaces between commas ','
# Each part can have a component or anything else.
# Each part can have a tag or anything else.
# e.g $[$<user.name>,$(echo $USER),the name is correct,the name is NOT correct]
# This is useful when on some terminal or WM the detection can be different than others

Expand Down Expand Up @@ -149,7 +149,7 @@ secs = " seconds"
# Choices: pacman, flatpak, dpkg, apk
#
# Pro-tip: if your package manager isnt listed here, yet,
# use the bash command component in the layout
# use the bash command tag in the layout
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

Expand Down
6 changes: 3 additions & 3 deletions assets/config-examples/config_modified.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# here is how it works:
# the variable "layout" is used for showing the infos
# as like as the user want, no limitation.
# inside here there are 4 "components": $<> $() ${} $[]
# inside here there are 4 "tags": $<> $() ${} $[]

# $<> lets you access a member of a module
# e.g $<user.name> will print the username, $<os.kernel_version> will print the kernel version and so on.
Expand All @@ -16,7 +16,7 @@

# $[] is used for equal conditional check
# syntax MUST be $[something,equalToSomethingElse,iftrue,ifalse] with no spaces between commas ','
# Each part can have a component or anything else.
# Each part can have a tag or anything else.
# e.g $[$<user.name>,$(echo $USER),the name is correct,the name is NOT correct]
# This is useful when on some terminal or WM the detection can be different than others

Expand Down Expand Up @@ -136,7 +136,7 @@ secs = " seconds"
# Choices: pacman, flatpak, dpkg, apk
#
# Pro-tip: if your package manager isnt listed here, yet,
# use the bash command component in the layout
# use the bash command tag in the layout
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

Expand Down
6 changes: 3 additions & 3 deletions assets/config-examples/config_simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# here is how it works:
# the variable "layout" is used for showing the infos
# as like as the user want, no limitation.
# inside here there are 4 "components": $<> $() ${} $[]
# inside here there are 4 "tags": $<> $() ${} $[]

# $<> lets you access a member of a module
# e.g $<user.name> will print the username, $<os.kernel_version> will print the kernel version and so on.
Expand All @@ -16,7 +16,7 @@

# $[] is used for equal conditional check
# syntax MUST be $[something,equalToSomethingElse,iftrue,ifalse] with no spaces between commas ','
# Each part can have a component or anything else.
# Each part can have a tag or anything else.
# e.g $[$<user.name>,$(echo $USER),the name is correct,the name is NOT correct]
# This is useful when on some terminal or WM the detection can be different than others

Expand Down Expand Up @@ -127,7 +127,7 @@ secs = " seconds"
# Choices: pacman, flatpak, dpkg, apk
#
# Pro-tip: if your package manager isnt listed here, yet,
# use the bash command component in the layout
# use the bash command tag in the layout
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

Expand Down
6 changes: 3 additions & 3 deletions assets/config-examples/nitch_like_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# here is how it works:
# the variable "layout" is used for showing the infos
# as like as the user want, no limitation.
# inside here there are 4 "components": $<> $() ${} $[]
# inside here there are 4 "tags": $<> $() ${} $[]

# $<> lets you access a member of a module
# e.g $<user.name> will print the username, $<os.kernel_version> will print the kernel version and so on.
Expand All @@ -16,7 +16,7 @@

# $[] is used for equal conditional check
# syntax MUST be $[something,equalToSomethingElse,iftrue,ifalse] with no spaces between commas ','
# Each part can have a component or anything else.
# Each part can have a tag or anything else.
# e.g $[$<user.name>,$(echo $USER),the name is correct,the name is NOT correct]
# This is useful when on some terminal or WM the detection can be different than others

Expand Down Expand Up @@ -131,7 +131,7 @@ secs = " seconds"
# Choices: pacman, flatpak, dpkg, apk
#
# Pro-tip: if your package manager isnt listed here, yet,
# use the bash command component in the layout
# use the bash command tag in the layout
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

Expand Down
16 changes: 8 additions & 8 deletions cufetch.1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ How does it work?
.PP
We got the config.toml file, in there we got an array variable called "layout". That's the variable where you customize how the infos should be displayed.
.br
You have 4 components: $<module.submod>, ${color}, $(bash command), $[something,equalToSomething,ifTrue,ifFalse]. They can be used in the ascii art text file and layout, but how to use them?
You have 4 tags: $<module.member>, ${color}, $(bash command), $[something,equalToSomething,ifTrue,ifFalse]. They can be used in the ascii art text file and layout, but how to use them?
.PP
Here's a simple bare-minimal example:
.br
Expand All @@ -26,9 +26,9 @@ layout = [
.br
]
.PP
The \fBInfo component $<>\fR let's you print a part of a module. All the modules and their parts are listed in the `--list-modules` argument
The \fBInfo tag $<>\fR let's you print a part of a module. All the modules and their parts are listed in the `--list-modules` argument
.PP
The \fBColor component ${}\fR is used for printing the text of a certain color.
The \fBColor tag ${}\fR is used for printing the text of a certain color.
.br
The colors can be: \fIblack\fR, \fIred\fR, \fIgreen\fR, \fIblue\fR, \fIcyan\fR, \fIyellow\fR, \fImagenta\fR, \fIwhite\fR and they can be configured in the config file.
.br
Expand All @@ -46,23 +46,23 @@ It's possible to enable multiple options, put these symbols before '#':

OR They can have ANSI escape codes, e.g "\\e[1;31m" and "\\e[38;5;160m" (\fBNOTE\fR: 256 colors ANSI escape codes, those that have \\e[38 or \\e[48, can't be used in GUI)
.br
You can also use them inside the component, like ${!#343345} or ${\\e[1;31m}.
You can also use them inside the tag, like ${!#343345} or ${\\e[1;31m}.
.br
To reset colors use ${0} or ${1} for reset and bold text.
.br
To instead use the colors that the ascii art logo uses, use ${auto} for getting the 1st color, ${auto4} for the 4th one and so on.
.PP
The \fBConditional component $[]\fR is used for equal conditional check.
The \fBConditional tag $[]\fR is used for equal conditional check.
.br
syntax \fBMUST\fR be $[something,equalToSomethingElse,ifTrue,ifFalse] with no spaces between commas ','
.br
Each part can have a component or anything else.
Each part can have a tag or anything else.
.br
e.g $[$<user.name>,$(echo $USER),the name is correct,the name is NOT correct]
.br
This is useful when on some terminal or WM the detection can be different than others
.PP
The \fBBash command component $()\fR speaks for itself. It can execute normal bash commands.
The \fBBash command tag $()\fR speaks for itself. It can execute normal bash commands.
.PP
To escape any $ or bracket, just use \\
.SH OPTIONS
Expand Down Expand Up @@ -103,7 +103,7 @@ Use GUI mode instead of priting in the terminal (use \fB\-V\fR to check if it's
Offset between the ascii art and the system infos
.TP
\fB\-l\fR. \fB\-\-list\-modules\fR
Print the list of the components and its members
Print the list of the tags and its members
.TP
\fB\-h\fR, \fB\-\-help\fR
Print this help menu
Expand Down
12 changes: 6 additions & 6 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ inline constexpr std::string_view AUTOCONFIG = R"#([config]
# here is how it works:
# the variable "layout" is used for showing the infos
# as like as the user want, no limitation.
# inside here there are 4 "components": $<> $() ${} $[]
# inside here there are 4 "tags": $<> $() ${} $[]
# $<> lets you access a member of a module
# $<> lets you print the value of a member of a module
# e.g $<user.name> will print the username, $<os.kernel_version> will print the kernel version and so on.
# run "cufetch -l" for a list of builti-in modules
Expand All @@ -107,7 +107,7 @@ inline constexpr std::string_view AUTOCONFIG = R"#([config]
# $[] is used for equal conditional check
# syntax MUST be $[something,equalToSomethingElse,iftrue,ifalse] with no spaces between commas ','
# Each part can have a component or anything else.
# Each part can have a tag or anything else.
# e.g $[$<user.name>,$(echo $USER),the name is correct,the name is NOT correct]
# This is useful when on some terminal or WM the detection can be different than others
Expand Down Expand Up @@ -156,8 +156,8 @@ layout = [
"${auto}GPU: $<gpu.name>",
"${auto}RAM: $<ram.ram>",
"",
"${\e[40m} ${\e[41m} ${\e[42m} ${\e[43m} ${\e[44m} ${\e[45m} ${\e[46m} ${\e[47m} ", # normal colors
"${\e[100m} ${\e[101m} ${\e[102m} ${\e[103m} ${\e[104m} ${\e[105m} ${\e[106m} ${\e[107m} " # light colors
"$<builtin.colors_bg>", # normal colors
"$<builtin.colors_light_bg>" # light colors
]
# display ascii-art or image/gif (GUI only) near layout
Expand Down Expand Up @@ -229,7 +229,7 @@ secs = " seconds"
# Choices: pacman, flatpak, dpkg, apk
#
# Pro-tip: if your package manager isnt listed here, yet,
# use the bash command component in the layout
# use the bash command tag in the layout
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]
Expand Down
18 changes: 17 additions & 1 deletion include/display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,26 @@
namespace Display
{

/*
* Render the layout along side the ASCII art and return the vector
* @param config The config class
* @param colors The colors
* @param already_analyzed_path If already checked that the source path is not a binary file
* @param path Path to source file
*/
std::vector<std::string> render(const Config& config, const colors_t& colors, const bool already_analyzed_path,
const std::string_view path);

void display(const std::vector<std::string>& renderResult);
/*
* Display the ascii art and layout
* @param renderResult The rendered vector usually by Display::render()
*/
void display(const std::vector<std::string>& renderResult);

/*
* Detect the distro you are using and return the path to the ASCII art
* @param config The config class
*/
std::string detect_distro(const Config& config);

} // namespace Display
Expand Down
1 change: 1 addition & 0 deletions include/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Window : public Gtk::Window
{
Glib::RefPtr<Gdk::Pixbuf> scaled_pixbuf =
m_original_pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);

m_bg_image.set(scaled_pixbuf);
}
}
Expand Down
28 changes: 22 additions & 6 deletions include/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,34 @@
#include "config.hpp"
#include "query.hpp"

// Parse input, in-place, with data from systemInfo.
// Documentation on formatting is in the default config.toml file.
// pureOutput is set to the string, but without the brackets.
/* Parse input, in-place, with data from systemInfo.
* Documentation on formatting is in the default config.toml file or the cufetch.1 manual.
* @param input The string to parse
* @param systemInfo The system infos
* @param pureOutput The output of the string but without tags
* @param config The config
* @param colors The colors
* @param parsingLayout If we are parsing layout or not
* @param is_image If the source path is an image (used for GUI mode only)
*/
std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::string& pureOutput, const Config& config,
const colors_t& colors, const bool parsingLayout, const bool is_image = false);

// Set module values to a systemInfo_t map.
// If the name of said module matches any module name, it will be added
// else, error out.
/* Set module members values to a systemInfo_t map.
* If the name of said module matches any module name, it will be added
* else, error out.
* @param sysInfo The systemInfo_t map
* @param moduleName The module name
* @param moduleValueName The module member value name
* @param config The config
* @param colors The colors
*/
void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, const std::string& moduleValueName,
const Config& config, const colors_t& colors);

/*
* Return a module member value
*/
std::string getInfoFromName(const systemInfo_t& systemInfo, const std::string_view moduleName,
const std::string_view moduleValueName);

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ ram
used : used amount of RAM (auto) [2.81 GiB]
free : available amount of RAM (auto) [10.46 GiB]
total : total amount of RAM (auto) [15.88 GiB]
ram : swapfile used and total amount of RAM (auto) [477.68 MiB / 512.00 MiB]
swap : swapfile used and total amount of RAM (auto) [477.68 MiB / 512.00 MiB]
swap_free : swapfile available amount of RAM (auto) [34.32 MiB]
swap_total : swapfile total amount of RAM (auto) [512.00 MiB]
swap_used : swapfile used amount of RAM (auto) [477.68 MiB]
Expand Down
12 changes: 6 additions & 6 deletions src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::s
{
const size_t& dot_pos = command.find('.');
if (dot_pos == std::string::npos)
die("module name '{}' doesn't have a dot '.' for separiting module name and submodule", command);
die("module name '{}' doesn't have a dot '.' for separiting module name and value", command);

const std::string& moduleName = command.substr(0, dot_pos);
const std::string& moduleValueName = command.substr(dot_pos + 1);
Expand All @@ -248,15 +248,15 @@ std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::s
{
const size_t& condition_comma = command.find(',');
if (condition_comma == command.npos)
die("condition component {} doesn't have a comma for separiting the condition", command);
die("condition tag {} doesn't have a comma for separiting the condition", command);

const size_t& equalto_comma = command.find(',', condition_comma + 1);
if (equalto_comma == command.npos)
die("condition component {} doesn't have a comma for separiting the equalto", command);
die("condition tag {} doesn't have a comma for separiting the equalto", command);

const size_t& true_comma = command.find(',', equalto_comma + 1);
if (true_comma == command.npos)
die("condition component {} doesn't have a comma for separiting the true statment", command);
die("condition tag {} doesn't have a comma for separiting the true statment", command);

const std::string& condition = command.substr(0, condition_comma);
const std::string& equalto = command.substr(condition_comma + 1, equalto_comma - condition_comma - 1);
Expand Down Expand Up @@ -739,7 +739,7 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co
{
debug("moduleValueName.lenght() = {} && 'colors_symbol'_len = {}", moduleValueName.length(), "colors_symbol()"_len);
if (moduleValueName.length() <= "colors_symbol()"_len)
die("color palette submodule '{}' in invalid.\n"
die("color palette module member '{}' in invalid.\n"
"Must be like 'colors_symbol(`symbol for printing the color palette`)'.\n"
"e.g 'colors_symbol(@)' or 'colors_symbol(string)'", moduleValueName);

Expand All @@ -755,7 +755,7 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co
else if (hasStart(moduleValueName, "colors_light_symbol"))
{
if (moduleValueName.length() <= "colors_light_symbol()"_len)
die("color palette submodule '{}' in invalid.\n"
die("color palette module member '{}' in invalid.\n"
"Must be like 'colors_light_symbol(`symbol for printing the color palette`)'.\n"
"e.g 'colors_light_symbol(@)' or 'colors_light_symbol(string)'", moduleValueName);

Expand Down

0 comments on commit 8259f7c

Please sign in to comment.