Skip to content

Commit

Permalink
display and gui: fix ascii-logo-type path
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Sep 10, 2024
1 parent 42d8734 commit 71b65e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,20 @@ std::string Display::detect_distro(const Config& config)
{
debug("/etc/os-release = \n{}", shell_exec("cat /etc/os-release"));

const std::string& ascii_logo_type = (config.ascii_logo_type.empty() ? "" : "_" + config.ascii_logo_type);

if (!config.m_custom_distro.empty())
{
return fmt::format("{}/ascii/{}{}.txt", config.data_dir, config.m_custom_distro, ascii_logo_type);
return fmt::format("{}/ascii/{}.txt", config.data_dir, config.m_custom_distro);
}
else
{
Query::System system;
std::string format;

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

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

Expand Down
12 changes: 11 additions & 1 deletion src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace GUI;
// Display::render but only for images on GUI
static std::vector<std::string> render_with_image(const Config& config, const colors_t& colors)
{
const std::string& path = Display::detect_distro(config);
std::string path{Display::detect_distro(config)};
systemInfo_t systemInfo{};
std::vector<std::string> layout{ config.layout };

Expand All @@ -48,6 +48,16 @@ static std::vector<std::string> render_with_image(const Config& config, const co
else
die("Unable to load image '{}'", config.source_path);

if (!config.ascii_logo_type.empty())
{
const size_t& pos = path.rfind('.');

if (pos != std::string::npos)
path.insert(pos, "_" + config.ascii_logo_type);
else
path += "_" + config.ascii_logo_type;
}

// this is just for parse() to auto add the distro colors
std::ifstream file(path, std::ios::binary);
std::string line, _;
Expand Down
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ int main (int argc, char *argv[])

std::string path = config.m_display_distro ? Display::detect_distro(config) : config.source_path;

if (!config.ascii_logo_type.empty() && !config.gui)
if (!config.ascii_logo_type.empty())
{
const size_t& pos = path.rfind('.');

Expand All @@ -440,6 +440,8 @@ int main (int argc, char *argv[])
!std::filesystem::exists((path = config.data_dir + "/ascii/linux.txt")))
die("'{}' doesn't exist. Can't load image/text file", path);

debug("{} path = {}", __PRETTY_FUNCTION__, path);

#ifdef GUI_MODE
if (config.gui)
{
Expand Down

0 comments on commit 71b65e5

Please sign in to comment.