diff --git a/include/query.hpp b/include/query.hpp index 1af9823..3e00306 100644 --- a/include/query.hpp +++ b/include/query.hpp @@ -210,7 +210,7 @@ class Disk std::string mountdir; }; - Disk(const std::string_view path, std::vector& paths); + Disk(const std::string_view path, std::vector& paths); float& total_amount() noexcept; float& free_amount() noexcept; diff --git a/src/main.cpp b/src/main.cpp index 97d6740..06fe8a5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include "config.hpp" #include "display.hpp" -#include "fmt/compile.h" #include "gui.hpp" #include "switch_fnv1a.hpp" #include "util.hpp" @@ -19,14 +18,10 @@ : (optarg != NULL)) using namespace std::string_view_literals; -using namespace fmt::literals; static void version() { - // {fmt} lib doesn't like fmt::println() - // why? I know that "just put the newline \n and shut up" (nobody said it) - // but would be nice :) - fmt::print("customfetch {} branch {}\n"_cf, VERSION, BRANCH); + fmt::println("customfetch {} branch {}", VERSION, BRANCH); #ifdef GUI_MODE fmt::println("GUI mode enabled"); @@ -134,6 +129,8 @@ user terminal_name : Terminal name [alacritty] terminal_version: Terminal version [0.13.2] +# with `symb` I mean a symbol to be used for the +# view of the color palette builtin title : user and hostname colored with ${{auto2}} [toni@arch2] title_sep : separator between the title and the system infos (with the title lenght) [--------] @@ -146,12 +143,13 @@ builtin # such as indeed cursor # because it is not GTK-Qt specific theme + cursor : cursor name with its size (auto add the size if queried) [Bibata-Modern-Ice (16px)] cursor_name : cursor name [Bibata-Modern-Ice] cursor_size : cursor size [16] # the N stands for the gtk version number to query -# so for example if you want to query the gtk3 theme version -# write it like "theme.gtk3" +# so for example if you want to query the gtk3 theme name +# write it like "theme-gtk3.name" # note: they may be inaccurate if didn't find anything in the config files # thus because of using as last resort the `gsettings` exacutable theme-gtkN diff --git a/src/parse.cpp b/src/parse.cpp index c250ece..ac3ce0c 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -862,11 +862,11 @@ void addValueFromModule(const std::string& moduleName, const std::string& module const Config& config = parse_args.config; systemInfo_t& sysInfo = parse_args.systemInfo; - const auto& moduleMember_hash = fnv1a16::hash(moduleMemberName); - static std::vector queried_gpus; - static std::vector queried_disks; - static std::vector queried_themes_names; - static systemInfo_t queried_themes; + const auto& moduleMember_hash = fnv1a16::hash(moduleMemberName); + static std::vector queried_gpus; + static std::vector queried_disks; + static std::vector queried_themes_names; + static systemInfo_t queried_themes; if (moduleName == "os") { @@ -1092,6 +1092,12 @@ void addValueFromModule(const std::string& moduleName, const std::string& module { switch (moduleMember_hash) { + case "cursor"_fnv1a16: + if (query_theme.cursor_size() == UNKNOWN) + SYSINFO_INSERT(query_theme.cursor()); + else + SYSINFO_INSERT(fmt::format("{} ({}px)", query_theme.cursor(), query_theme.cursor_size())); + break; case "cursor_name"_fnv1a16: SYSINFO_INSERT(query_theme.cursor()); break; case "cursor_size"_fnv1a16: SYSINFO_INSERT(query_theme.cursor_size()); break; } diff --git a/src/query/unix/disk.cpp b/src/query/unix/disk.cpp index aa82885..6cb1f5a 100644 --- a/src/query/unix/disk.cpp +++ b/src/query/unix/disk.cpp @@ -8,10 +8,10 @@ using namespace Query; -Disk::Disk(const std::string_view path, std::vector& paths) +Disk::Disk(const std::string_view path, std::vector& paths) { if (std::find(paths.begin(), paths.end(), path) == paths.end()) - paths.push_back(path); + paths.push_back(path.data()); else return; diff --git a/src/query/unix/gpu.cpp b/src/query/unix/gpu.cpp index 09c7b34..415bb0e 100644 --- a/src/query/unix/gpu.cpp +++ b/src/query/unix/gpu.cpp @@ -8,12 +8,12 @@ using namespace Query; -static std::string _get_name(const std::string_view m_vendor_id_s, const std::string_view m_device_id_s) +static std::string get_name(const std::string_view m_vendor_id_s, const std::string_view m_device_id_s) { std::string name = binarySearchPCIArray(m_vendor_id_s, m_device_id_s); debug("GPU binarySearchPCIArray name = {}", name); - size_t first_bracket = name.find('['); - size_t last_bracket = name.rfind(']'); + const size_t first_bracket = name.find('['); + const size_t last_bracket = name.rfind(']'); // remove the chips name "TU106 [GeForce GTX 1650]" // This should work for AMD and Intel too. @@ -29,7 +29,7 @@ static std::string _get_name(const std::string_view m_vendor_id_s, const std::st return name; } -static std::string _get_vendor(const std::string_view m_vendor_id_s) +static std::string get_vendor(const std::string_view m_vendor_id_s) { return binarySearchPCIArray(m_vendor_id_s); } static GPU::GPU_t get_gpu_infos(const std::string_view m_vendor_id_s, const std::string_view m_device_id_s) @@ -41,8 +41,8 @@ static GPU::GPU_t get_gpu_infos(const std::string_view m_vendor_id_s, const std: if (m_device_id_s == UNKNOWN || m_vendor_id_s == UNKNOWN) return ret; - ret.name = _get_name(m_vendor_id_s, m_device_id_s); - ret.vendor = _get_vendor(m_vendor_id_s); + ret.name = get_name(m_vendor_id_s, m_device_id_s); + ret.vendor = get_vendor(m_vendor_id_s); return ret; } @@ -54,8 +54,8 @@ GPU::GPU(const std::uint16_t id, std::vector& queried_gpus) else return; - const u_short max_iter = 10; - u_short id_iter = id; + const std::uint16_t max_iter = 10; + std::uint16_t id_iter = id; std::string sys_path; int i = 0; for (; i <= max_iter; i++) diff --git a/src/query/unix/ram.cpp b/src/query/unix/ram.cpp index 5e535d3..691a2b0 100644 --- a/src/query/unix/ram.cpp +++ b/src/query/unix/ram.cpp @@ -13,9 +13,9 @@ using namespace Query; SRECLAIMABLE };*/ -static size_t get_from_text(std::string& line, u_short& iter_index) +static size_t get_from_text(std::string& line, u_short& iter_index, const std::uint16_t len) { - std::string amount = line.substr(line.find(':') + 1); + std::string amount = line.substr(len + 1); strip(amount); ++iter_index; return std::stoi(amount); @@ -40,16 +40,16 @@ static RAM::RAM_t get_amount() noexcept while (std::getline(file, line) && iter_index < 4) { if (hasStart(line, "MemAvailable:")) - memory_infos.free_amount = get_from_text(line, iter_index); + memory_infos.free_amount = get_from_text(line, iter_index, "MemAvailable:"_len); - if (hasStart(line, "MemTotal:")) - memory_infos.total_amount = get_from_text(line, iter_index); + else if (hasStart(line, "MemTotal:")) + memory_infos.total_amount = get_from_text(line, iter_index, "MemTotal:"_len); - if (hasStart(line, "SwapFree:")) - memory_infos.swap_free_amount = get_from_text(line, iter_index); + else if (hasStart(line, "SwapFree:")) + memory_infos.swap_free_amount = get_from_text(line, iter_index, "SwapFree:"_len); - if (hasStart(line, "SwapTotal:")) - memory_infos.swap_total_amount = get_from_text(line, iter_index); + else if (hasStart(line, "SwapTotal:")) + memory_infos.swap_total_amount = get_from_text(line, iter_index, "SwapTotal:"_len); /*if (line.find("Shmem:") != std::string::npos) extra_mem_info.at(SHMEM) = get_from_text(line); diff --git a/src/query/unix/system.cpp b/src/query/unix/system.cpp index 30d49a7..2489fd5 100644 --- a/src/query/unix/system.cpp +++ b/src/query/unix/system.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -36,12 +37,13 @@ static void get_host_paths(System::System_t& paths) { // everyone does it like "KVM/QEMU Standard PC (...) (host_version)" so why not paths.host_vendor = "KVM/QEMU"; - paths.host_version = fmt::format("({})", read_by_syspath(syspath + "/product_version")); + paths.host_version = std::string_view('(' + read_by_syspath(syspath + "/product_version") + ')').data(); } else paths.host_version = read_by_syspath(syspath + "/product_version"); } + // idfk why it has a newline if (paths.host_version.back() == '\n') paths.host_version.pop_back(); } @@ -70,8 +72,8 @@ static System::System_t get_system_infos_lsb_releases() } // get OS /etc/lsb-release infos - u_short iter_index = 0; - std::string line; + std::uint16_t iter_index = 0; + std::string line; while (std::getline(os_release_file, line) && iter_index < 3) { if (hasStart(line, "DISTRIB_DESCRIPTION="))