fix: incorrect battery percentage on Pinebook Pro
This commit is contained in:
parent
cdce3e03ea
commit
f3a6e2d494
|
@ -164,13 +164,25 @@ const std::tuple<uint8_t, float, std::string, float> waybar::modules::Battery::g
|
||||||
std::ifstream(bat / "status") >> _status;
|
std::ifstream(bat / "status") >> _status;
|
||||||
auto rate_path = fs::exists(bat / "current_now") ? "current_now" : "power_now";
|
auto rate_path = fs::exists(bat / "current_now") ? "current_now" : "power_now";
|
||||||
std::ifstream(bat / rate_path) >> 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;
|
std::ifstream(bat / now_path) >> energy_now;
|
||||||
auto full_path = fs::exists(bat / "charge_full") ? "charge_full" : "energy_full";
|
auto full_path = fs::exists(bat / "charge_full") ? "charge_full" : "energy_full";
|
||||||
std::ifstream(bat / full_path) >> 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";
|
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;
|
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
|
// Show the "smallest" status among all batteries
|
||||||
if (status_gt(status, _status)) {
|
if (status_gt(status, _status)) {
|
||||||
status = _status;
|
status = _status;
|
||||||
|
|
Loading…
Reference in New Issue