feat: Introduce cpu frequency display modes

This commit is contained in:
Emilio B. Pedrollo
2025-09-30 15:28:42 -03:00
committed by Jakob P. Liljenberg
parent 4f661d5404
commit 040171400a
6 changed files with 118 additions and 26 deletions

View File

@@ -812,9 +812,16 @@ namespace Cpu {
+ Theme::c("graph_text") + "up" + Mv::r(1) + upstr;
}
#ifdef __linux__
const bool freq_range = Config::getS("freq_mode") == "range";
#else
const bool freq_range = false;
#endif
//? Cpu clock and cpu meter
if (Config::getB("show_cpu_freq") and not cpuHz.empty())
out += Mv::to(b_y, b_x + b_width - 10) + Fx::ub + Theme::c("div_line") + Symbols::h_line * (7 - cpuHz.size())
out += Mv::to(b_y, b_x + b_width - (freq_range ? 20 : 10)) + Fx::ub + Theme::c("div_line")
+ Symbols::h_line * ((freq_range ? 17 : 7) - cpuHz.size())
+ Symbols::title_left + Fx::b + Theme::c("title") + cpuHz + Fx::ub + Theme::c("div_line") + Symbols::title_right;
out += Mv::to(b_y + 1, b_x + 1) + Theme::c("main_fg") + Fx::b + "CPU " + cpu_meter(safeVal(cpu.cpu_percent, "total"s).back())
@@ -2117,9 +2124,14 @@ namespace Draw {
auto& custom = Config::getS("custom_cpu_name");
static const bool hasCpuHz = not Cpu::get_cpuHz().empty();
#ifdef __linux__
static const bool freq_range = Config::getS("freq_mode") == "range";
#else
static const bool freq_range = false;
#endif
const string cpu_title = uresize(
(custom.empty() ? Cpu::cpuName : custom),
b_width - (Config::getB("show_cpu_freq") and hasCpuHz ? 14 : 4)
b_width - (Config::getB("show_cpu_freq") and hasCpuHz ? (freq_range ? 24 : 14) : 5)
);
box += createBox(b_x, b_y, b_width, b_height, "", false, cpu_title);
}