Merge pull request #1101 from Max1Truc/master
fix: incorrect battery percentage on Pinebook Propull/1112/head
commit
cf3d6545c3
|
@ -164,13 +164,25 @@ const std::tuple<uint8_t, float, std::string, float> waybar::modules::Battery::g
|
|||
std::ifstream(bat / "status") >> _status;
|
||||
auto rate_path = fs::exists(bat / "current_now") ? "current_now" : "power_now";
|
||||
std::ifstream(bat / rate_path) >> power_now;
|
||||
auto now_path = fs::exists(bat / "charge_now") ? "charge_now" : "energy_now";
|
||||
|
||||
std::string now_path;
|
||||
if (fs::exists(bat / "charge_now")) {
|
||||
now_path = "charge_now";
|
||||
} else if (fs::exists(bat / "energy_now")) {
|
||||
now_path = "energy_now";
|
||||
} else {
|
||||
now_path = "capacity";
|
||||
}
|
||||
std::ifstream(bat / now_path) >> energy_now;
|
||||
auto full_path = fs::exists(bat / "charge_full") ? "charge_full" : "energy_full";
|
||||
std::ifstream(bat / full_path) >> energy_full;
|
||||
auto full_design_path = fs::exists(bat / "charge_full_design") ? "charge_full_design" : "energy_full_design";
|
||||
std::ifstream(bat / full_design_path) >> energy_full_design;
|
||||
|
||||
if (now_path == "capacity") {
|
||||
energy_now = energy_now * energy_full / 100;
|
||||
}
|
||||
|
||||
// Show the "smallest" status among all batteries
|
||||
if (status_gt(status, _status)) {
|
||||
status = _status;
|
||||
|
|
Loading…
Reference in New Issue