mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Always mark battery as full at 100%
Since we're now clamping at 100% and rounding, mark as full at that point. Some batteries will stay in charging state for a long time while stuck at the same charge level. Just mark them as full to not be confusing.
This commit is contained in:
parent
eb3f4216d4
commit
f45d582957
@ -134,11 +134,17 @@ const std::tuple<uint8_t, float, std::string> waybar::modules::Battery::getInfos
|
|||||||
}
|
}
|
||||||
if (capacity > 100.f) {
|
if (capacity > 100.f) {
|
||||||
// This can happen when the battery is calibrating and goes above 100%
|
// This can happen when the battery is calibrating and goes above 100%
|
||||||
// Handle it gracefully by clamping at 100% and presenting it as full
|
// Handle it gracefully by clamping at 100%
|
||||||
capacity = 100.f;
|
capacity = 100.f;
|
||||||
|
}
|
||||||
|
uint8_t cap = round(capacity);
|
||||||
|
if (cap == 100) {
|
||||||
|
// If we've reached 100% just mark as full as some batteries can stay
|
||||||
|
// stuck reporting they're still charging but not yet done
|
||||||
status = "Full";
|
status = "Full";
|
||||||
}
|
}
|
||||||
return {round(capacity), time_remaining, status};
|
|
||||||
|
return {cap, time_remaining, status};
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
spdlog::error("Battery: {}", e.what());
|
spdlog::error("Battery: {}", e.what());
|
||||||
return {0, 0, "Unknown"};
|
return {0, 0, "Unknown"};
|
||||||
|
Loading…
Reference in New Issue
Block a user