From 1b2f11b41234f7cdf83212c81cdbf086f491049d Mon Sep 17 00:00:00 2001 From: masiboss <32394683+masiboss@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:49:34 +0100 Subject: [PATCH] cut less of cpu name if frequency is not shown --- src/btop_draw.cpp | 6 +++++- src/btop_shared.hpp | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp index edb1eec6..5ae357eb 100644 --- a/src/btop_draw.cpp +++ b/src/btop_draw.cpp @@ -2063,7 +2063,11 @@ namespace Draw { box = createBox(x, y, width, height, Theme::c("cpu_box"), true, (cpu_bottom ? "" : "cpu"), (cpu_bottom ? "cpu" : ""), 1); auto& custom = Config::getS("custom_cpu_name"); - const string cpu_title = uresize((custom.empty() ? Cpu::cpuName : custom) , b_width - 14); + static const bool hasCpuHz = not Cpu::get_cpuHz().empty(); + const string cpu_title = uresize( + (custom.empty() ? Cpu::cpuName : custom), + b_width - (Config::getB("show_cpu_freq") and hasCpuHz ? 14 : 4) + ); box += createBox(b_x, b_y, b_width, b_height, "", false, cpu_title); } diff --git a/src/btop_shared.hpp b/src/btop_shared.hpp index 383e1898..017c7f83 100644 --- a/src/btop_shared.hpp +++ b/src/btop_shared.hpp @@ -210,6 +210,8 @@ namespace Cpu { auto get_core_mapping() -> unordered_flat_map; extern unordered_flat_map core_mapping; + auto get_cpuHz() -> string; + //* Get battery info from /sys auto get_battery() -> tuple; }