fix: prioritize plugged status over default when battery is full
This commit is contained in:
@@ -685,13 +685,20 @@ auto waybar::modules::Battery::update() -> void {
|
|||||||
if (status == "Unknown") {
|
if (status == "Unknown") {
|
||||||
status = getAdapterStatus(capacity);
|
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;
|
auto status_pretty = status;
|
||||||
puts(status.c_str());
|
puts(status.c_str());
|
||||||
// Transform to lowercase and replace space with dash
|
// Transform to lowercase and replace space with dash
|
||||||
std::ranges::transform(status.begin(), status.end(), status.begin(),
|
std::ranges::transform(status.begin(), status.end(), status.begin(),
|
||||||
[](char ch) { return ch == ' ' ? '-' : std::tolower(ch); });
|
[](char ch) { return ch == ' ' ? '-' : std::tolower(ch); });
|
||||||
auto format = format_;
|
auto format = format_;
|
||||||
auto state = getState(capacity, true);
|
|
||||||
processEvents(state, status, capacity);
|
processEvents(state, status, capacity);
|
||||||
setBarClass(state);
|
setBarClass(state);
|
||||||
auto time_remaining_formatted = formatTimeRemaining(time_remaining);
|
auto time_remaining_formatted = formatTimeRemaining(time_remaining);
|
||||||
|
|||||||
Reference in New Issue
Block a user