summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjkre <usokk@student.kit.edu>2023-12-14 22:56:31 +0100
committerjkre <usokk@student.kit.edu>2023-12-14 22:56:31 +0100
commit2934138a660ad0b80bde31e5c81f495d7b76dc13 (patch)
tree34f8d115437b85241102e99a83557e67b9a67a31 /src
parent578b01e06b6e9bc94d6b20ec361a518ab466ec96 (diff)
Only redraw battery indicator on power change if power change option is set to true
Diffstat (limited to 'src')
-rw-r--r--src/btop_draw.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp
index 9e49d1f..ae9ba69 100644
--- a/src/btop_draw.cpp
+++ b/src/btop_draw.cpp
@@ -717,14 +717,14 @@ namespace Cpu {
const auto& [percent, watts, seconds, status] = current_bat;
- if (redraw or percent != old_percent or watts != old_watts or seconds != old_seconds or status != old_status) {
+ if (redraw or percent != old_percent or (watts != old_watts and Config::getB("show_battery_watts")) or seconds != old_seconds or status != old_status) {
old_percent = percent;
old_watts = watts;
old_seconds = seconds;
old_status = status;
const string str_time = (seconds > 0 ? sec_to_dhms(seconds, true, true) : "");
const string str_percent = to_string(percent) + '%';
- const string str_watts = (watts != -1 ? fmt::format("{:.2f}", watts) + 'W' : "");
+ const string str_watts = (watts != -1 and Config::getB("show_battery_watts") ? fmt::format("{:.2f}", watts) + 'W' : "");
const auto& bat_symbol = bat_symbols.at((bat_symbols.contains(status) ? status : "unknown"));
const int current_len = (Term::width >= 100 ? 11 : 0) + str_time.size() + str_percent.size() + str_watts.size() + to_string(Config::getI("update_ms")).size();
const int current_pos = Term::width - current_len - 17;
@@ -736,7 +736,7 @@ namespace Cpu {
out += Mv::to(y, bat_pos) + title_left + Theme::c("title") + Fx::b + "BAT" + bat_symbol + ' ' + str_percent
+ (Term::width >= 100 ? Fx::ub + ' ' + bat_meter(percent) + Fx::b : "")
- + (not str_time.empty() ? ' ' + Theme::c("title") + str_time : "") + (not str_watts.empty() ? ' ' + Theme::c("title") + Fx::b + str_watts : " ") + Fx::ub + title_right;
+ + (not str_time.empty() ? ' ' + Theme::c("title") + str_time : "") + (not str_watts.empty() ? " " + Theme::c("title") + Fx::b + str_watts : "") + Fx::ub + title_right;
}
}
else if (bat_pos > 0) {