Skip to content

Commit

Permalink
config: add layout-padding-top
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Aug 24, 2024
1 parent aa7ab83 commit abc8f93
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 24 deletions.
12 changes: 8 additions & 4 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ class Config
std::string sep_reset;
std::string gui_bg_image;
std::string ascii_logo_type;
std::uint16_t offset = 0;
std::uint16_t logo_padding_left = 0;
std::uint16_t logo_padding_top = 0;
std::uint16_t offset = 0;
std::uint16_t logo_padding_left = 0;
std::uint16_t logo_padding_top = 0;
std::uint16_t layout_padding_top = 0;

bool gui = false;
std::vector<std::string> layouts;
Expand Down Expand Up @@ -162,9 +163,12 @@ offset = 5
# Padding between the start and the ascii art
logo-padding-left = 0
# Padding of the logo from the top
# 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
30 changes: 15 additions & 15 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ 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", ":");
this->offset = this->getConfigValue<std::uint16_t>("config.offset", 5);
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", ":");
this->offset = this->getConfigValue<std::uint16_t>("config.offset", 5);
this->logo_padding_left = this->getConfigValue<std::uint16_t>("config.logo-padding-left", 0);
this->font = this->getConfigValue<std::string>("gui.font", "Liberation Mono Normal 12");
this->gui_bg_image = this->getConfigValue<std::string>("gui.bg-image", "disable");
this->logo_padding_top = this->getConfigValue<std::uint16_t>("config.logo-padding-top", 0);

this->uptime_d_fmt = this->getConfigValue<std::string>("os.uptime.days", " days");
this->uptime_h_fmt = this->getConfigValue<std::string>("os.uptime.hours", " hours");
this->uptime_m_fmt = this->getConfigValue<std::string>("os.uptime.mins", " mins");
this->uptime_s_fmt = this->getConfigValue<std::string>("os.uptime.secs", " secs");
this->layout_padding_top = this->getConfigValue<std::uint16_t>("config.layout-padding-top", 0);
this->font = this->getConfigValue<std::string>("gui.font", "Liberation Mono Normal 12");
this->gui_bg_image = this->getConfigValue<std::string>("gui.bg-image", "disable");
this->logo_padding_top = this->getConfigValue<std::uint16_t>("config.logo-padding-top", 0);

this->uptime_d_fmt = this->getConfigValue<std::string>("os.uptime.days", " days");
this->uptime_h_fmt = this->getConfigValue<std::string>("os.uptime.hours", " hours");
this->uptime_m_fmt = this->getConfigValue<std::string>("os.uptime.mins", " mins");
this->uptime_s_fmt = this->getConfigValue<std::string>("os.uptime.secs", " secs");

colors.black = this->getThemeValue("config.black", "\033[1;30m");
colors.red = this->getThemeValue("config.red", "\033[1;31m");
Expand Down
5 changes: 5 additions & 0 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
asciiArt.push_back("");
}

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

while (std::getline(file, line))
{
std::string pureOutput;
Expand Down
15 changes: 10 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ A command-line system information tool (or neofetch like program), which its foc
--bg-image <path> Path to image to be used in the background in GUI (put "disable" for disabling in the config)
--logo-padding-top <num> Padding of the logo from the top
--logo-padding-left <num> Padding of the logo from the left
--layout-padding-top <num> Padding of the layout from the top
--gen-config [<path>] Generate default config file to config folder (if path, it will generate to the path)
Will ask for confirmation if file exists already
Expand Down Expand Up @@ -253,11 +254,12 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_
{"distro", required_argument, 0, 'd'},
{"source-path", required_argument, 0, 's'},

{"logo-padding-top", required_argument, 0, "logo-padding-top"_fnv1a16},
{"logo-padding-left",required_argument, 0, "logo-padding-left"_fnv1a16},
{"bg-image", required_argument, 0, "bg-image"_fnv1a16},
{"color", required_argument, 0, "color"_fnv1a16},
{"gen-config", optional_argument, 0, "gen-config"_fnv1a16},
{"logo-padding-top", required_argument, 0, "logo-padding-top"_fnv1a16},
{"logo-padding-left", required_argument, 0, "logo-padding-left"_fnv1a16},
{"layout-padding-top", required_argument, 0, "layout-padding-top"_fnv1a16},
{"bg-image", required_argument, 0, "bg-image"_fnv1a16},
{"color", required_argument, 0, "color"_fnv1a16},
{"gen-config", optional_argument, 0, "gen-config"_fnv1a16},
{0,0,0,0}
};

Expand Down Expand Up @@ -309,6 +311,9 @@ static bool parseargs(int argc, char* argv[], Config& config, const std::string_
case "logo-padding-left"_fnv1a16:
config.logo_padding_left = std::atoi(optarg); break;

case "layout-padding-top"_fnv1a16:
config.layout_padding_top = std::atoi(optarg); break;

case "bg-image"_fnv1a16:
config.gui_bg_image = optarg; break;

Expand Down

0 comments on commit abc8f93

Please sign in to comment.