Repository navigation
Dismiss the low battery warning when the charger is plugged in - #14739
mikkelkonyher wants to merge 2 commits into
Conversation
|
|
Thanks for the thorough testing on the MBP. Heads-up that a few PRs are open for the same fix to #14639: #14218, #14825, #11959 and #11415 (plus the auto-expire part of #12666). It'd help maintainers if you could say what this one covers that the others don't. The case of a warning restored after a shell restart seems like the distinguishing point. Two small things. GitHub shows conflicts with |
23b7d32 to
a9d6d34
Compare
|
Thanks, both points are done. I rebased on What this covers that the others don't, from reading their diffs:
This one keeps the warning critical while the battery is low, dismisses a restored warning whenever it shows up, and spawns no process. The branch rofrol linked on #14639 (comment) handles the restart case more thoroughly: the notification service remembers a dismissal that arrives before its restore, so a restored warning never shows. This one is simpler, but a restored warning can stay up for up to 30 seconds after a restart. One thing to note: like the others, it dismisses as soon as the battery stops discharging. If #9883 lands, an AC flap at critical charge would take the warning down while the latch keeps it from coming back, so whichever lands second needs to dismiss on recovery instead. |
|
Tested on One edge case: if (notifications && typeof notifications.dismissBySummary === "function")
notifications.dismissBySummary("Time to recharge") |
|
Thanks for testing it, and for the clone case. I have a notifications clone myself, and in a copy of the 4.0.4 shell the battery check threw a |
|
Since #15326, |
|
Thanks, you're right. Since #15326 this only matches the English title, so the warning stays up in every other language. #14218 now looks up the translated |
Fixes #14639 and #8813.
The low battery warning is sent as a critical notification, so it never expires on its own and comes back after every shell restart. That is right while the battery is low, but the warning also stays after the charger is plugged in, and nothing takes it off screen.
The change
On every battery check where the battery is not low, the battery service dismisses the "Time to recharge" toast. Checks run every 30 seconds and whenever the charger is plugged in or unplugged.
The battery service and the notification service run in the same shell, so the battery service calls the notification service directly through
firstPartyServiceFor("omarchy.notifications"), the way the lock service reaches the battery service. No process is spawned. The notification service's existing dismiss-by-summary loop moves from its IPC target intodismissBySummary(), which the IPCdismissnow calls, soomarchy notification dismissbehaves as before. A notifications clone made before this change has nodismissBySummary, so the battery service checks for it and skips the dismissal instead of throwing on every check.It dismisses on every such check rather than only when the battery recovers, because a warning restored after a shell restart can appear after the first check, and the battery service has no record of sending it.
Critical notifications still never expire on their own. Only the battery service decides when its warning is no longer true.
Tested
test/shell.d/battery-test.shcovers dismissing when the charger is plugged in, dismissing a warning restored after a restart, and leaving the warning alone while the battery is low or not reported.notifications-test.shandnotification-send-test.shstill pass. The other failures in./test/shellon my machine fail the same way on a cleanquattro.omarchy restart shell, and after plugging in the charger.firstPartyServiceForreturns null, so a clone can't exercise this path):dismissBySummary, the battery check threw aTypeErrorwithout the guard, and threw nothing with it.Service.qmlandBatteryModel.jsare unchanged between v4.0.4 and currentquattro. I have not run the shell from currentquattroitself.