Commit ef454e9d authored by Nate Graham's avatar Nate Graham
Browse files

applets/battery: adjust show/hide conditions for charge limits

When we are using a charge threshold, the kernel may stop charging
within a percentage point of the actual threshold and this is
considered correct behavior, so we have to handle that. See
https://bugzilla.kernel.org/show_bug.cgi?id=215531.

Also, Upower may give us a status of "Not charging" rather than
"Fully charged", so we need to account for that as well. See
https://gitlab.freedesktop.org/upower/upower/-/issues/142.

BUG: 435931


(cherry picked from commit 49013bf4)
parent b53fec37
Pipeline #137364 passed with stage
in 11 minutes and 54 seconds
......@@ -33,7 +33,20 @@ Item {
}
if (pmSource.data.Battery["Has Cumulative"]
&& !(pmSource.data["Battery"]["State"] === "FullyCharged" && pmSource.data["AC Adapter"]["Plugged in"])) {
&& !((pmSource.data["AC Adapter"]["Plugged in"] && pmSource.data["Battery"]["State"] === "FullyCharged") ||
// When we are using a charge threshold, the kernel
// may stop charging within a percentage point of the actual threshold
// and this is considered correct behavior, so we have to handle
// that. See https://bugzilla.kernel.org/show_bug.cgi?id=215531.
(pmSource.data["AC Adapter"]["Plugged in"]
&& typeof pmSource.data["Battery"]["Charge Stop Threshold"] === "number"
&& (pmSource.data.Battery.Percent >= pmSource.data["Battery"]["Charge Stop Threshold"] - 1
&& pmSource.data.Battery.Percent <= pmSource.data["Battery"]["Charge Stop Threshold"] + 1)
// Also, Upower may give us a status of "Not charging" rather than
// "Fully charged", so we need to account for that as well. See
// https://gitlab.freedesktop.org/upower/upower/-/issues/142.
&& (pmSource.data["Battery"]["State"] === "NoCharge" || pmSource.data["Battery"]["State"] === "FullyCharged"))
)){
return PlasmaCore.Types.ActiveStatus;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment