Skip to content

Commit

Permalink
config: new option, ascii-logo-type + change nitch_like_config
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntRanch committed Aug 24, 2024
1 parent 4de3742 commit f488e9d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
16 changes: 12 additions & 4 deletions assets/config-examples/nitch_like_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ layout = [
"│${blue} 󰥔 ${0}uptime │ ${blue} $<os.uptime>",
"│${red}  ${0}shell │ ${red} $<user.shell>",
"│${!#FF5F1F} 󰏖 ${0}pkgs │ ${!#FF5F1F} $<os.pkgs>",
"│${yellow}  ${0} CPU │ ${yellow} $<cpu.name>",
"│${green}  ${0} GPU │ ${green} $<gpu.name>",
"│${magenta} 󰍛 ${0} memory │ ${magenta} $<ram.ram>",
"├───────────┤",
"│ 󰏘 colors │ ${\e[30m}  ${\e[31m}  ${\e[32m}  ${\e[33m}  ${\e[34m}  ${\e[35m}  ${\e[36m}  ${\e[37m}  ",
"│ 󰏘 colors │ ${\e[30m}  ${\e[31m}  ${\e[32m}  ${\e[33m}  ${\e[34m}  ${\e[35m}  ${\e[36m}  ${\e[37m}  ",
"╰───────────╯"
]

Expand All @@ -55,19 +57,25 @@ source-path = "os"
# note: it MUST contain an "ascii" subdirectory
data-dir = "/usr/share/customfetch"

# The type of ASCII art to apply, ("small", "old").
# Not guaranteed to exist, WILL crash if it doesn't exist.
# Leave empty for regular.
# This does not apply to custom distros (-d)
ascii-logo-type = "small"

# A separetor (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 = 5
offset = 3

# Offset between the start and the ascii art
pre-logo-offset = 5
pre-logo-offset = 3

# Padding of the logo from the top
logo-padding-top = 0
logo-padding-top = 3

# Colors can be with: hexcodes (#55ff88) and for bold put '!' (!#55ff88)
# OR ANSI escape code colors like "\e[1;34m"
Expand Down
7 changes: 7 additions & 0 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Config
std::string data_dir;
std::string sep_reset;
std::string gui_bg_image;
std::string ascii_logo_type;
std::uint16_t offset = 0;
std::uint16_t pre_logo_offset = 0;
std::uint16_t logo_padding_top = 0;
Expand Down Expand Up @@ -144,6 +145,12 @@ source-path = "os"
# note: it MUST contain an "ascii" subdirectory
data-dir = "/usr/share/customfetch"
# The type of ASCII art to apply, ("small", "old").
# Not guaranteed to exist, it will return the regular linux ascii art if it doesn't exist.
# Leave empty for regular.
# This does not apply to custom distros (-d)
ascii-logo-type = ""
# A separetor (string) that when ecountered, will automatically
# reset color, aka. automatically add ${0} (only in layout)
# Make it empty for disabling
Expand Down
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ void Config::loadConfigFile(const std::string_view filename, colors_t& colors)

// clang-format off
this->gui = this->getConfigValue<bool>("gui.enable", false);
this->ascii_logo_type = this->getConfigValue<std::string>("config.ascii-logo-type", "");

this->source_path = this->getConfigValue<std::string>("config.source-path", "os");
this->data_dir = this->getConfigValue<std::string>("config.data-dir", "/usr/share/customfetch");
this->sep_reset = this->getConfigValue<std::string>("config.sep-reset", ":");
Expand Down
4 changes: 2 additions & 2 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ std::string Display::detect_distro(const Config& config)
Query::System system;
std::string format;

format = fmt::format("{}/ascii/{}.txt", config.data_dir, str_tolower(system.os_id()));
format = fmt::format("{}/ascii/{}.txt", config.data_dir, str_tolower(system.os_id()) + (config.ascii_logo_type.empty() ? "" : "_" + config.ascii_logo_type));
if (std::filesystem::exists(format))
return format;

format = fmt::format("{}/ascii/{}.txt", config.data_dir, str_tolower(system.os_name()));
format = fmt::format("{}/ascii/{}.txt", config.data_dir, str_tolower(system.os_name()) + (config.ascii_logo_type.empty() ? "" : "_" + config.ascii_logo_type));
if (std::filesystem::exists(format))
return format;

Expand Down

0 comments on commit f488e9d

Please sign in to comment.