diff --git a/assets/ascii/fedora.txt b/assets/ascii/fedora.txt index b6aa546..44728c4 100644 --- a/assets/ascii/fedora.txt +++ b/assets/ascii/fedora.txt @@ -2,18 +2,18 @@ ${blue} .',;::::;,'. ${blue} .';:cccccccccccc:;,. ${blue} .;cccccccccccccccccccccc;. ${blue} .:cccccccccccccccccccccccccc:. -${blue} .;ccccccccccccc;${1}.:dddl:.${blue};ccccccc;. -${blue} .:ccccccccccccc;${1}OWMKOOXMWd${blue};ccccccc:. -${blue}.:ccccccccccccc;${1}KMMc${blue};cc;${1}xMMc${blue};ccccccc:. -${blue},cccccccccccccc;${1}MMM.${blue};cc;${1};WW:${blue};cccccccc, -${blue}:cccccccccccccc;${1}MMM.${blue};cccccccccccccccc: -${blue}:ccccccc;${1}oxOOOo${blue};${1}MMM0OOk.${blue};cccccccccccc: -${blue}cccccc;${1}0MMKxdd:${blue};${1}MMMkddc.${blue};cccccccccccc; -${blue}ccccc;${1}XM0'${blue};cccc;${1}MMM.${blue};cccccccccccccccc' -${blue}ccccc;${1}MMo${blue};ccccc;${1}MMW.${blue};ccccccccccccccc; -${blue}ccccc;${1}0MNc.${blue}ccc${1}.xMMd${blue};ccccccccccccccc; -${blue}cccccc;${1}dNMWXXXWM0:${blue};cccccccccccccc:, -${blue}cccccccc;${1}.:odl:.${blue};cccccccccccccc:,. +${blue} .;ccccccccccccc;${0}.:dddl:.${blue};ccccccc;. +${blue} .:ccccccccccccc;${0}OWMKOOXMWd${blue};ccccccc:. +${blue}.:ccccccccccccc;${0}KMMc${blue};cc;${0}xMMc${blue};ccccccc:. +${blue},cccccccccccccc;${0}MMM.${blue};cc;${0};WW:${blue};cccccccc, +${blue}:cccccccccccccc;${0}MMM.${blue};cccccccccccccccc: +${blue}:ccccccc;${0}oxOOOo${blue};${0}MMM0OOk.${blue};cccccccccccc: +${blue}cccccc;${0}0MMKxdd:${blue};${0}MMMkddc.${blue};cccccccccccc; +${blue}ccccc;${0}XM0'${blue};cccc;${0}MMM.${blue};cccccccccccccccc' +${blue}ccccc;${0}MMo${blue};ccccc;${0}MMW.${blue};ccccccccccccccc; +${blue}ccccc;${0}0MNc.${blue}ccc${0}.xMMd${blue};ccccccccccccccc; +${blue}cccccc;${0}dNMWXXXWM0:${blue};cccccccccccccc:, +${blue}cccccccc;${0}.:odl:.${blue};cccccccccccccc:,. ${blue}:cccccccccccccccccccccccccccc:'. ${blue}.:cccccccccccccccccccccc:;,.. ${blue} '::cccccccccccccc::;,. diff --git a/include/config.hpp b/include/config.hpp index d601e45..203258a 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -35,6 +35,7 @@ class Config Config(const std::string_view configFile, const std::string_view configDir, colors_t& colors); // config file + bool slow_query_warnings = true; std::vector layout; std::string source_path; std::string font; @@ -151,6 +152,12 @@ inline constexpr std::string_view AUTOCONFIG = R"#([config] # # Read the manual cufetch.1 for more infos with $() tag +# cufetch behavioural settings + +# Warn against tradeoffs between slower queries for availability +# e.g. falling back to gsettings when we can't find the config file for GTK +slow-query-warnings = true + layout = [ "$", "$", diff --git a/include/query.hpp b/include/query.hpp index b649d16..ede7568 100644 --- a/include/query.hpp +++ b/include/query.hpp @@ -124,9 +124,9 @@ class Theme }; Theme(const std::uint8_t ver, systemInfo_t& queried_themes, std::vector& queried_themes_names, - const std::string& theme_name_version); + const std::string& theme_name_version, const Config &config); - Theme(systemInfo_t& queried_themes); + Theme(systemInfo_t& queried_themes, const Config &config); std::string gtk_theme() noexcept; std::string gtk_icon_theme() noexcept; @@ -140,6 +140,7 @@ class Theme systemInfo_t& m_queried_themes; const std::string m_theme_name_version; std::string m_wmde_name; + const Config& m_Config; }; class CPU diff --git a/include/util.hpp b/include/util.hpp index f3e20dd..3eb9b0d 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -107,6 +107,13 @@ void warn(const std::string_view fmt, Args&&... args) noexcept fmt::format(fmt::runtime(fmt), std::forward(args)...)); } +template +void info(const std::string_view fmt, Args&&... args) noexcept +{ + fmt::println(BOLD_COLOR((fmt::rgb(fmt::color::cyan))), "INFO: {}", + fmt::format(fmt::runtime(fmt), std::forward(args)...)); +} + /** Ask the user a yes or no question. * @param def The default result * @param fmt The format string diff --git a/src/parse.cpp b/src/parse.cpp index a40e86e..4434e9e 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -877,7 +877,7 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co else if (moduleName == "theme") { - Query::Theme query_theme(queried_themes); + Query::Theme query_theme(queried_themes, config); if (sysInfo.find(moduleName) == sysInfo.end()) sysInfo.insert({ moduleName, {} }); @@ -894,9 +894,9 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co else if (moduleName == "theme-gtk-all") { - Query::Theme gtk2(2, queried_themes, queried_themes_names, "gtk2"); - Query::Theme gtk3(3, queried_themes, queried_themes_names, "gtk3"); - Query::Theme gtk4(4, queried_themes, queried_themes_names, "gtk4"); + Query::Theme gtk2(2, queried_themes, queried_themes_names, "gtk2", config); + Query::Theme gtk3(3, queried_themes, queried_themes_names, "gtk3", config); + Query::Theme gtk4(4, queried_themes, queried_themes_names, "gtk4", config); if (sysInfo.find(moduleName) == sysInfo.end()) sysInfo.insert({ moduleName, {} }); @@ -922,7 +922,7 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co "Syntax should be like 'theme_gtkN' which N stands for the version of gtk to query (single number)", moduleName); - Query::Theme query_theme(ver, queried_themes, queried_themes_names, fmt::format("gtk{}", ver)); + Query::Theme query_theme(ver, queried_themes, queried_themes_names, fmt::format("gtk{}", ver), config); if (sysInfo.find(moduleName) == sysInfo.end()) sysInfo.insert({ moduleName, {} }); diff --git a/src/query/unix/theme.cpp b/src/query/unix/theme.cpp index 215646a..e277f14 100644 --- a/src/query/unix/theme.cpp +++ b/src/query/unix/theme.cpp @@ -1,6 +1,7 @@ #include #include +#include "config.hpp" #include "parse.hpp" #include "query.hpp" #include "rapidxml-1.13/rapidxml.hpp" @@ -122,6 +123,12 @@ static bool get_cursor_from_gtk_configs(const std::uint8_t ver, Theme::Theme_t& if (get_gtk_cursor_config(fmt::format("{}/.gtkrc-{}.0", std::getenv("HOME"), ver), theme)) return true; + if (get_gtk_cursor_config(fmt::format("{}/.gtkrc-{}.0-kde", std::getenv("HOME"), ver), theme)) + return true; + + if (get_gtk_cursor_config(fmt::format("{}/.gtkrc-{}.0-kde4", std::getenv("HOME"), ver), theme)) + return true; + return false; } @@ -208,7 +215,7 @@ static bool get_gtk_theme_config(const std::string_view path, Theme::Theme_t& th return true; } -static void get_gtk_theme_settings(const std::string_view de_name, Theme::Theme_t& theme) +static void get_gtk_theme_settings(const std::string_view de_name, Theme::Theme_t& theme, const Config &config) { debug("calling {}", __PRETTY_FUNCTION__); @@ -220,6 +227,12 @@ static void get_gtk_theme_settings(const std::string_view de_name, Theme::Theme_ theme.gtk_theme_name = gtk_theme_env; } + if (config.slow_query_warnings) { + warn("cufetch could not detect a gtk configuration file. cufetch will use the much-slower gsettings."); + warn("If there's a file in a standard location that we aren't detecting, please file an issue on our GitHub."); + info("You can disable this warning by disabling slow-query-warnings in your config.toml file."); + } + const char* interface; switch(fnv1a16::hash(str_tolower(de_name.data()))) { @@ -256,7 +269,7 @@ static void get_gtk_theme_settings(const std::string_view de_name, Theme::Theme_ theme.gtk_font.erase(std::remove(theme.gtk_font.begin(), theme.gtk_font.end(), '\''), theme.gtk_font.end()); } -static void get_gtk_theme_from_configs(const std::uint8_t ver, const std::string_view de_name, Theme::Theme_t& theme) +static void get_gtk_theme_from_configs(const std::uint8_t ver, const std::string_view de_name, Theme::Theme_t& theme, const Config &config) { if (get_gtk_theme_config(fmt::format("{}/gtk-{}.0/settings.ini", configDir, ver), theme)) return; @@ -270,10 +283,16 @@ static void get_gtk_theme_from_configs(const std::uint8_t ver, const std::string if (get_gtk_theme_config(fmt::format("{}/.gtkrc-{}.0", std::getenv("HOME"), ver), theme)) return; - get_gtk_theme_settings(de_name, theme); + if (get_gtk_theme_config(fmt::format("{}/.gtkrc-{}.0-kde", std::getenv("HOME"), ver), theme)) + return; + + if (get_gtk_theme_config(fmt::format("{}/.gtkrc-{}.0-kde4", std::getenv("HOME"), ver), theme)) + return; + + get_gtk_theme_settings(de_name, theme, config); } -static void get_de_gtk_theme(const std::string_view de_name, const std::uint8_t ver, Theme::Theme_t& theme) +static void get_de_gtk_theme(const std::string_view de_name, const std::uint8_t ver, Theme::Theme_t& theme, const Config &config) { switch (fnv1a16::hash(str_tolower(de_name.data()))) { @@ -285,7 +304,7 @@ static void get_de_gtk_theme(const std::string_view de_name, const std::uint8_t std::ifstream f(path, std::ios::in); if (!f.is_open()) { - get_gtk_theme_from_configs(ver, de_name, theme); + get_gtk_theme_from_configs(ver, de_name, theme, config); return; } @@ -331,27 +350,28 @@ static void get_de_gtk_theme(const std::string_view de_name, const std::uint8_t } break; default: - get_gtk_theme_from_configs(ver, de_name, theme); + get_gtk_theme_from_configs(ver, de_name, theme, config); } } static void get_gtk_theme(const bool dont_query_dewm, const std::uint8_t ver, const std::string_view de_name, - Theme::Theme_t& theme) + Theme::Theme_t& theme, const Config &config) { if (dont_query_dewm) { - get_gtk_theme_from_configs(ver, de_name, theme); + get_gtk_theme_from_configs(ver, de_name, theme, config); return; } - get_de_gtk_theme(de_name, ver, theme); + get_de_gtk_theme(de_name, ver, theme, config); } // clang-format off Theme::Theme(const std::uint8_t ver, systemInfo_t& queried_themes, std::vector& queried_themes_names, - const std::string& theme_name_version) + const std::string& theme_name_version, const Config &config) : m_queried_themes(queried_themes), - m_theme_name_version(theme_name_version) + m_theme_name_version(theme_name_version), + m_Config(config) { if (std::find(queried_themes_names.begin(), queried_themes_names.end(), m_theme_name_version) == queried_themes_names.end()) @@ -368,7 +388,7 @@ Theme::Theme(const std::uint8_t ver, systemInfo_t& queried_themes, std::vector