mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-16 09:24:45 +12:00
Only redraw battery indicator on power change if power change option is set to true
This commit is contained in:
parent
578b01e06b
commit
2934138a66
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue