fix: prioritize plugged status over default when battery is full

This commit is contained in:
Prakhar Chhalotre
2026-02-10 01:52:59 +05:30
parent 306f970684
commit e67b230dbe
+8 -1
View File
@@ -685,13 +685,20 @@ auto waybar::modules::Battery::update() -> void {
if (status == "Unknown") {
status = getAdapterStatus(capacity);
}
auto state = getState(capacity, true);
bool adapter_online = false;
if (!adapter_.empty()) {
std::ifstream(adapter_ / "online") >> adapter_online;
}
if (status == "Full" && adapter_online) {
status = "Plugged";
}
auto status_pretty = status;
puts(status.c_str());
// Transform to lowercase and replace space with dash
std::ranges::transform(status.begin(), status.end(), status.begin(),
[](char ch) { return ch == ' ' ? '-' : std::tolower(ch); });
auto format = format_;
auto state = getState(capacity, true);
processEvents(state, status, capacity);
setBarClass(state);
auto time_remaining_formatted = formatTimeRemaining(time_remaining);