mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix(Battery): plugged state
This commit is contained in:
parent
9a091d7740
commit
17291dffdf
@ -93,10 +93,14 @@ const std::tuple<uint8_t, uint32_t, std::string> waybar::modules::Battery::getIn
|
|||||||
total += capacity;
|
total += capacity;
|
||||||
total_current += current_now;
|
total_current += current_now;
|
||||||
}
|
}
|
||||||
uint16_t capacity = total / batteries_.size();
|
if (!adapter_.empty() && status == "Discharging") {
|
||||||
if (status == "Charging" && total_current != 0) {
|
bool online;
|
||||||
status = "Plugged";
|
std::ifstream(adapter_ / "online") >> online;
|
||||||
|
if (online) {
|
||||||
|
status = "Plugged";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
uint16_t capacity = total / batteries_.size();
|
||||||
return {capacity, total_current, status};
|
return {capacity, total_current, status};
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
@ -113,7 +117,7 @@ const std::string waybar::modules::Battery::getAdapterStatus(uint8_t capacity,
|
|||||||
return "Full";
|
return "Full";
|
||||||
}
|
}
|
||||||
if (online) {
|
if (online) {
|
||||||
return current_now == 0 ? "Charging" : "Plugged";
|
return "Charging";
|
||||||
}
|
}
|
||||||
return "Discharging";
|
return "Discharging";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user