Don't show battery estimate at 0

If we think we're done might as well not show 0h 0min as the estimate
and just not show anything.
pull/923/head
Pedro Côrte-Real 2020-11-27 14:23:37 +00:00
parent 89ca155c43
commit 31a4aff1f8
1 changed files with 5 additions and 1 deletions

View File

@ -204,6 +204,10 @@ const std::string waybar::modules::Battery::formatTimeRemaining(float hoursRemai
uint16_t full_hours = static_cast<uint16_t>(hoursRemaining); uint16_t full_hours = static_cast<uint16_t>(hoursRemaining);
uint16_t minutes = static_cast<uint16_t>(60 * (hoursRemaining - full_hours)); uint16_t minutes = static_cast<uint16_t>(60 * (hoursRemaining - full_hours));
auto format = std::string("{H} h {M} min"); auto format = std::string("{H} h {M} min");
if (full_hours == 0 && minutes == 0) {
// Migh as well not show "0h 0min"
return "";
}
if (config_["format-time"].isString()) { if (config_["format-time"].isString()) {
format = config_["format-time"].asString(); format = config_["format-time"].asString();
} }