Skip to content

Commit

Permalink
misc: update configs + some code renames
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Aug 30, 2024
1 parent 34639b8 commit fd9fa70
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 58 deletions.
33 changes: 29 additions & 4 deletions assets/config-examples/config_cool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,32 @@ source-path = "os"
# note: it MUST contain an "ascii" subdirectory
data-dir = "/usr/share/customfetch"

# A separetor (string) that when ecountered, will automatically
# The type of ASCII art to apply ("small", "old").
# Basically will add "_<type>" to the logo filename.
# It will return the regular linux ascii art if it doesn't exist.
# Leave empty it for regular.
ascii-logo-type = ""

# A char (or string) to use in $<user.title_sep>
sep-title = "-"

# A separetor (or string) that when ecountered, will automatically
# reset color, aka. automatically add ${0} (only in layout)
# Make it empty for disabling
sep-reset = ":"

# Offset between the ascii art and the system infos
# Offset between the ascii art and the layout
offset = 5

# Padding of the logo from the top
# Padding between the start and the ascii art
logo-padding-left = 0

# Padding of the ascii art from the top
logo-padding-top = 0

# Padding of the layout from the top
layout-padding-top = 0

# Colors can be with: hexcodes (#55ff88) and for bold put '!' (!#55ff88)
# OR ANSI escape code colors like "\e[1;34m"
# remember to add ${0} where you want to reset color
Expand All @@ -110,13 +125,23 @@ secs = " seconds"
[os.pkgs]
# Ordered list of which packages installed count should be displayed in $<os.pkgs>
# remember to not enter the same name twice, else the world will finish
# Choices: pacman, flatpak, dpkg
# Choices: pacman, flatpak, dpkg, apk
#
# Pro-tip: if your package manager isnt listed here, yet,
# use the bash command component in the layout
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

# Distros and package manager specific
# package manager paths for getting the packages count from path.
# They are arrayies so you can add multiple paths.
#
# If you don't know what these ares, leave them by default settings
pacman-dirs = ["/var/lib/pacman/local/"]
dpkg-files = ["/var/lib/dpkg/status"]
flatpak-dirs = ["/var/lib/flatpak/app/", "~/.local/share/flatpak/app/"]
apk-files = ["/var/lib/apk/db/installed"]

# GUI options
# note: customfetch needs to be compiled with GUI_MODE=1 (check with "cufetch --version")
[gui]
Expand Down
51 changes: 38 additions & 13 deletions assets/config-examples/config_modified.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,52 @@ source-path = "os"
# note: it MUST contain an "ascii" subdirectory
data-dir = "/usr/share/customfetch"

# A separetor (string) that when ecountered, will automatically
# The type of ASCII art to apply ("small", "old").
# Basically will add "_<type>" to the logo filename.
# It will return the regular linux ascii art if it doesn't exist.
# Leave empty it for regular.
ascii-logo-type = ""

# A char (or string) to use in $<user.title_sep>
sep-title = "-"

# A separetor (or string) that when ecountered, will automatically
# reset color, aka. automatically add ${0} (only in layout)
# Make it empty for disabling
sep-reset = ":"

# Offset between the ascii art and the system infos
# Offset between the ascii art and the layout
offset = 5

# Padding of the logo from the top
# Padding between the start and the ascii art
logo-padding-left = 0

# Padding of the ascii art from the top
logo-padding-top = 0

# Padding of the layout from the top
layout-padding-top = 0

# Colors can be with: hexcodes (#55ff88) and for bold put '!' (!#55ff88)
# OR ANSI escape code colors like "\e[1;34m"
# remember to add ${0} where you want to reset color
black = "\e[1;30m"
red = "\e[1;31m"
green = "\e[1;32m"
yellow = "\e[1;33m"
blue = "\e[1;34m"
black = "\e[1;30m"
red = "\e[1;31m"
green = "\e[1;32m"
yellow = "\e[1;33m"
blue = "\e[1;34m"
magenta = "\e[1;35m"
cyan = "\e[1;36m"
white = "\e[1;37m"
cyan = "\e[1;36m"
white = "\e[1;37m"

# $<os.uptime> config
[os.uptime]
# how to display the name of the uptime
# e.g: hours = "hrs" -> "Uptime: 3hrs"
days = " days"
days = " days"
hours = " hours"
mins = " mins"
secs = " seconds"
mins = " mins"
secs = " seconds"

# $<os.pkgs> config
[os.pkgs]
Expand All @@ -104,6 +119,16 @@ secs = " seconds"
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

# Distros and package manager specific
# package manager paths for getting the packages count from path.
# They are arrayies so you can add multiple paths.
#
# If you don't know what these ares, leave them by default settings
pacman-dirs = ["/var/lib/pacman/local/"]
dpkg-files = ["/var/lib/dpkg/status"]
flatpak-dirs = ["/var/lib/flatpak/app/", "~/.local/share/flatpak/app/"]
apk-files = ["/var/lib/apk/db/installed"]

# GUI options
# note: customfetch needs to be compiled with GUI_MODE=1 (which is enabled by default)
[gui]
Expand Down
31 changes: 28 additions & 3 deletions assets/config-examples/config_simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,32 @@ source-path = "os"
# note: it MUST contain an "ascii" subdirectory
data-dir = "/usr/share/customfetch"

# A separetor (string) that when ecountered, will automatically
# The type of ASCII art to apply ("small", "old").
# Basically will add "_<type>" to the logo filename.
# It will return the regular linux ascii art if it doesn't exist.
# Leave empty it for regular.
ascii-logo-type = ""

# A char (or string) to use in $<user.title_sep>
sep-title = "-"

# A separetor (or string) that when ecountered, will automatically
# reset color, aka. automatically add ${0} (only in layout)
# Make it empty for disabling
sep-reset = ":"

# Offset between the ascii art and the system infos
# Offset between the ascii art and the layout
offset = 5

# Padding of the logo from the top
# Padding between the start and the ascii art
logo-padding-left = 0

# Padding of the ascii art from the top
logo-padding-top = 0

# Padding of the layout from the top
layout-padding-top = 0

# Colors can be with: hexcodes (#55ff88) and for bold put '!' (!#55ff88)
# OR ANSI escape code colors like "\e[1;34m"
# remember to add ${0} where you want to reset color
Expand Down Expand Up @@ -95,6 +110,16 @@ secs = " seconds"
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

# Distros and package manager specific
# package manager paths for getting the packages count from path.
# They are arrayies so you can add multiple paths.
#
# If you don't know what these ares, leave them by default settings
pacman-dirs = ["/var/lib/pacman/local/"]
dpkg-files = ["/var/lib/dpkg/status"]
flatpak-dirs = ["/var/lib/flatpak/app/", "~/.local/share/flatpak/app/"]
apk-files = ["/var/lib/apk/db/installed"]

# GUI options
# note: customfetch needs to be compiled with GUI_MODE=1 (which is enabled by default)
[gui]
Expand Down
19 changes: 16 additions & 3 deletions assets/config-examples/nitch_like_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ sep-reset = ":"
# Offset between the ascii art and the system infos
offset = 3

# Offset between the start and the ascii art
pre-logo-offset = 3
# Padding between the start and the ascii art
logo-padding-left = 3

# Padding of the logo from the top
# Padding of the ascii art from the top
logo-padding-top = 3

# Padding of the layout from the top
layout-padding-top = 0

# Colors can be with: hexcodes (#55ff88) and for bold put '!' (!#55ff88)
# OR ANSI escape code colors like "\e[1;34m"
# remember to add ${0} where you want to reset color
Expand Down Expand Up @@ -109,6 +112,16 @@ secs = " seconds"
# e.g "Packages: $(pacman -Q | wc -l) (pacman)"
pkg-managers = ["pacman", "dpkg", "flatpak"]

# Distros and package manager specific
# package manager paths for getting the packages count from path.
# They are arrayies so you can add multiple paths.
#
# If you don't know what these ares, leave them by default settings
pacman-dirs = ["/var/lib/pacman/local/"]
dpkg-files = ["/var/lib/dpkg/status"]
flatpak-dirs = ["/var/lib/flatpak/app/", "~/.local/share/flatpak/app/"]
apk-files = ["/var/lib/apk/db/installed"]

# GUI options
# note: customfetch needs to be compiled with GUI_MODE=1 (check with "cufetch --version")
[gui]
Expand Down
24 changes: 12 additions & 12 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Config
Config(const std::string_view configFile, const std::string_view configDir, colors_t& colors);

// config file
std::vector<std::string> layouts;
std::vector<std::string> layout;
std::string source_path;
std::string font;
std::string data_dir;
Expand Down Expand Up @@ -182,23 +182,23 @@ layout-padding-top = 0
# Colors can be with: hexcodes (#55ff88) and for bold put '!' (!#55ff88)
# OR ANSI escape code colors like "\e[1;34m"
# remember to add ${0} where you want to reset color
black = "\e[1;30m"
red = "\e[1;31m"
green = "\e[1;32m"
yellow = "\e[1;33m"
blue = "\e[1;34m"
black = "\e[1;30m"
red = "\e[1;31m"
green = "\e[1;32m"
yellow = "\e[1;33m"
blue = "\e[1;34m"
magenta = "\e[1;35m"
cyan = "\e[1;36m"
white = "\e[1;37m"
cyan = "\e[1;36m"
white = "\e[1;37m"
# $<os.uptime> config
[os.uptime]
# how to display the name of the uptime
# e.g: hours = "hrs" -> "Uptime: 3hrs"
days = " days"
days = " days"
hours = " hours"
mins = " mins"
secs = " seconds"
mins = " mins"
secs = " seconds"
# $<os.pkgs> config
[os.pkgs]
Expand All @@ -214,7 +214,7 @@ pkg-managers = ["pacman", "dpkg", "flatpak"]
# Distros and package manager specific
# package manager paths for getting the packages count from path.
# They are arrayies so you can add multiple paths.
#
#
# If you don't know what these ares, leave them by default settings
pacman-dirs = ["/var/lib/pacman/local/"]
dpkg-files = ["/var/lib/dpkg/status"]
Expand Down
2 changes: 1 addition & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Config::loadConfigFile(const std::string_view filename, colors_t& colors)

// clang-format off
// Idk but with `this->` looks more readable
this->layouts = this->getValueArrayStr("config.layout", {});
this->layout = this->getValueArrayStr("config.layout", {});
this->gui = this->getValue<bool>("gui.enable", false);
this->ascii_logo_type = this->getValue<std::string>("config.ascii-logo-type", "");
this->source_path = this->getValue<std::string>("config.source-path", "os");
Expand Down
24 changes: 12 additions & 12 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
const std::string_view path)
{
systemInfo_t systemInfo{};
std::vector<std::string> asciiArt{}, layouts{ config.layouts };
std::vector<std::string> asciiArt{}, layout{ config.layout };

if (!config.m_display_distro && !config.m_disable_source && !config.source_path.empty())
{
Expand Down Expand Up @@ -89,7 +89,7 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c

for (int i = 0; i < config.layout_padding_top; i++)
{
layouts.insert(layouts.begin(), "");
layout.insert(layout.begin(), "");
}

while (std::getline(file, line))
Expand Down Expand Up @@ -140,26 +140,26 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
return asciiArt;

std::string _;
for (std::string& layout : layouts)
for (std::string& layout : layout)
layout = parse(layout, systemInfo, _, config, colors, true);

// erase each element for each instance of MAGIC_LINE
layouts.erase(std::remove_if(layouts.begin(), layouts.end(),
layout.erase(std::remove_if(layout.begin(), layout.end(),
[](const std::string_view str) { return str.find(MAGIC_LINE) != std::string::npos; }),
layouts.end());
layout.end());

size_t i;
for (i = 0; i < layouts.size(); i++)
for (i = 0; i < layout.size(); i++)
{
size_t origin = config.logo_padding_left;

// The user-specified offset to be put before the logo
for (size_t j = 0; j < config.logo_padding_left; j++)
layouts.at(i).insert(0, " ");
layout.at(i).insert(0, " ");

if (i < asciiArt.size())
{
layouts.at(i).insert(origin, asciiArt.at(i));
layout.at(i).insert(origin, asciiArt.at(i));
origin += asciiArt.at(i).length();
}

Expand All @@ -169,9 +169,9 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
debug("spaces: {}", spaces);

for (size_t j = 0; j < spaces; j++)
layouts.at(i).insert(origin, " ");
layout.at(i).insert(origin, " ");

layouts.at(i) += config.gui ? "" : NOCOLOR;
layout.at(i) += config.gui ? "" : NOCOLOR;
}

for (; i < asciiArt.size(); i++)
Expand All @@ -183,10 +183,10 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c

line += asciiArt[i];

layouts.push_back(line);
layout.push_back(line);
}

return layouts;
return layout;
}

void Display::display(const std::vector<std::string>& renderResult)
Expand Down
Loading

0 comments on commit fd9fa70

Please sign in to comment.