Fix round to 0 or 1 in capacity computation with given full-at

This commit is contained in:
Alexander Kobel 2020-04-21 00:53:36 +02:00
parent b18262f6d0
commit df0d34dbd4

View File

@ -119,7 +119,7 @@ const std::tuple<uint8_t, float, std::string> waybar::modules::Battery::getInfos
if (config_["full-at"].isUInt()) {
auto full_at = config_["full-at"].asUInt();
if (full_at < 100) {
capacity = static_cast<float>(capacity / full_at) * 100;
capacity = 100.f * capacity / full_at;
if (capacity > full_at) {
capacity = full_at;
}