Skip to content

Commit

Permalink
misc: update README.md and some definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Sep 5, 2024
1 parent 8259f7c commit f6040b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,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 palette
"$<builtin.colors_light_bg>" # light colors palette
]

# display ascii-art or image/gif (GUI only) near layout
Expand Down Expand Up @@ -251,12 +251,12 @@ 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.\
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 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 tag (`$<>`)** will print a value of a module\
* **The info tag (`$<>`)** will print a 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
run `cufetch -l` for a list of builti-in modules

* **The bash command tag (`$()`)** let's you execute bash commands\
e.g `$(echo \"hello world\")` will indeed echo out Hello world.\
Expand Down
8 changes: 4 additions & 4 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,22 @@ inline constexpr std::string_view AUTOCONFIG = R"#([config]
# as like as the user want, no limitation.
# inside here there are 4 "tags": $<> $() ${} $[]
# $<> lets you print the value of a member of a module
# The Info tag $<> 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
# $() 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
# $[] 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 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
# ${} 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)
# you can even put a custom hex color e.g: ${#ff6622}
#
Expand Down
20 changes: 10 additions & 10 deletions src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,28 +246,28 @@ std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::s

case ']':
{
const size_t& condition_comma = command.find(',');
if (condition_comma == command.npos)
die("condition tag {} doesn't have a comma for separiting the condition", command);
const size_t& conditional_comma = command.find(',');
if (conditional_comma == command.npos)
die("conditional tag {} doesn't have a comma for separiting the conditional", command);

const size_t& equalto_comma = command.find(',', condition_comma + 1);
const size_t& equalto_comma = command.find(',', conditional_comma + 1);
if (equalto_comma == command.npos)
die("condition tag {} doesn't have a comma for separiting the equalto", command);
die("conditional 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 tag {} doesn't have a comma for separiting the true statment", command);
die("conditional 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);
const std::string& conditional = command.substr(0, conditional_comma);
const std::string& equalto = command.substr(conditional_comma + 1, equalto_comma - conditional_comma - 1);
const std::string& true_statment = command.substr(equalto_comma + 1, true_comma - equalto_comma - 1);
const std::string& false_statment = command.substr(true_comma + 1);

std::string _;
const std::string& parsed_condition = parse(condition, systemInfo, _, config, colors, true);
const std::string& parsed_conditional = parse(conditional, systemInfo, _, config, colors, true);
const std::string& parsed_equalto = parse(equalto, systemInfo, _, config, colors, true);

if (parsed_condition == parsed_equalto)
if (parsed_conditional == parsed_equalto)
{
const std::string& parsed_true_stam = parse(true_statment, systemInfo, _, config, colors, true);
output = output.replace(dollarSignIndex, (endBracketIndex + 1) - dollarSignIndex,
Expand Down

0 comments on commit f6040b7

Please sign in to comment.