Skip to content

Take the low battery warning down once the battery is no longer low - #15902

Closed
defer wants to merge 3 commits into
omacom:quattrofrom
defer:quattro-battery-low-notification-fixes
Closed

defer wants to merge 3 commits into
omacom:quattrofrom
defer:quattro-battery-low-notification-fixes

Conversation

@defer

@defer defer commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

The warning is sent as a critical toast, and critical toasts never expire and are restored
from disk on every shell restart. A warning sent before shutdown therefore came back on the
next boot with the laptop on the charger, and once shown it stayed on screen after plugging in
until dismissed by hand.

shouldWarnLowBattery now also reports when the battery is no longer low: present but not
discharging at or below the threshold. The battery service keeps that decision and, while it
holds, dismisses any toast from omarchy-action with the battery-caution icon
omarchy-battery-low sends. Matching on the app and icon rather than the title keeps it working
across a language change, and both are in the saved toast files, so warnings already on disk
match too. The service acts on every battery check, on power source and battery device
changes, and whenever the toast stack changes, so a stale warning brought back by the restore
is taken down as soon as UPower reports the battery, not on the next 30 second check. Without
a battery nothing is dismissed.

The summary match the notifications IPC dismiss used moves into a dismissWhere function on the
service, shared by dismissBySummary, which the IPC now calls, and a new dismissByAppIcon, so
other services can dismiss toasts in process without spawning omarchy-notification-dismiss.

The battery model tests cover warning on battery, staying quiet and clearing a stale warning
while charging, clearing on plugging in, and leaving notifications alone when there is no
battery.

Fixes #14639

Fixes #8813

The warning is sent as a critical toast, and critical toasts never expire
and are restored from disk on every shell restart. A warning sent before
shutdown therefore came back on the next boot with the laptop on the charger,
and once shown it stayed on screen after plugging in until dismissed by hand.

shouldWarnLowBattery now also reports when the battery is no longer low:
present but not discharging at or below the threshold. On each battery check
and power source change, the battery service then dismisses any toast titled
with the low battery warning through the notifications service. It also
watches the toast stack, so a stale warning brought back by the restore,
which reads its files after the first battery check, is taken down as soon as
it appears. The title is read once at startup with omarchy-i18n from the CLI
catalog omarchy-battery-low sends it from, so the match holds in every language.

The summary match the notifications IPC dismiss used moves into a
dismissBySummary function on the service, which the IPC now calls,
so other services can dismiss toasts in process without spawning
omarchy-notification-dismiss.

The battery model tests cover warning on battery, staying quiet and clearing a
stale warning while charging, clearing on plugging in, and leaving notifications
alone when there is no battery.
@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

The battery service now removes low-battery warnings after the battery recovers or starts charging.

  • Low-battery warnings disappear when a present battery is no longer low.

Both earlier unnumbered findings are addressed: matching no longer depends on translated titles, and popup callbacks use the model’s dismissal decision.

Reviews (3) · Last reviewed commit: "Do not notify if there is a notification..." · Reviewed by Greptile

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 19, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at bb26e59 and run on a disposable Omarchy VM linked to this branch, with the kernel's test_power fake battery standing in for a real one. Nothing found that needs changing.

What ran, on the base (60f5b49) and on this head:

  • Warned at 8% on battery, then plugged in: on the base the warning stays; here it is gone within six seconds.
  • Warning on screen, shell killed, charger plugged in while it was down, shell started on AC: on the base the warning is restored from disk and stays; here it is restored and taken straight down.
  • Recovered to 40% while still discharging: stays on the base, gone here.
  • Restarted the shell while still at 8%: the restored warning stays here, as it should. A second, identical warning is also sent after the restart; the base does the same at its next 30 second check, so that is not from this change.

./test/cli and the battery, notifications, plugin and QML format shell tests pass on the head, and battery-test.sh fails with the shell changes reverted. CI is green.

Second opinion: Codex Medium reviewed it in two rounds. It raised one possible startup case: if UPower reported the battery present before its level and state, a check could read it as recovered and dismiss a warning that is still valid. That did not happen in the restart-while-low run above, and if it did, the same check clears the notified flag, so the warning is sent again on the next real reading. Codex withdrew it as a blocker, and its last round found nothing. It agreed with the rest of my reading, and its independence is not guaranteed.

There are five other open pull requests for this bug: #11415, #11959, #14218, #14825 and #15911. This one handles cases the older ones miss. #11415, #11959 and #14825 match the English title "Time to recharge!", so on a translated desktop the warning never comes down, and none of the three clears a warning restored after a restart. #14218 clears restored warnings only during its first three checks, and it looks the title up in the current language, so a warning saved before a language change is never matched and keeps coming back. Matching on the sender and the battery-caution icon, and checking again whenever the toast stack changes, covers both. #15911 is newer and matches a new sender name, which warnings already saved on disk do not carry. Which one lands is the maintainer's call.

This fixes #14639 and #8813, now linked. It is waiting on the maintainer.

@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge and removed verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 19, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed again at c24ddfd, the commit that stops a second warning being sent while one is already up, and ran it on a disposable Omarchy VM linked to this branch with the kernel's test_power fake battery. Nothing found that needs changing.

The second warning after a restart that I noted last time is gone: restarting the shell while still at 8% now leaves exactly one warning on screen. The rest still holds against the base (60f5b49): plugged in at 8%, the warning stays on the base and comes down here; plugged in while the shell was down and restarted on AC, the base restores it and keeps it while this takes it straight down; recovered to 40% while still discharging, the base keeps it and this removes it.

./test/cli passes, and so do the battery, battery status, notifications, notification send, plugins, no-battery power and QML format shell tests. battery-test.sh fails with the shell changes reverted. CI is green.

Second opinion: Codex Medium reviewed the new commit in two rounds. In the first it pointed out that the new check looks for a warning in the toast stack rather than on screen, so after a restart while low, an old warning pushed below a tall stack of newer toasts would keep a fresh one from being sent. In the second it agreed this is no worse than the base, where a warning buried by later toasts in one session is never sent again until the battery recovers either, and that the check also keeps the battery-low hook from running twice; it withdrew the finding and found nothing else. Its independence is not guaranteed.

The competing pull requests for this bug (#11415, #11959, #14218, #14825 and #15911) have not changed since they were compared, and the reasons this one covers more still stand. Which one lands is the maintainer's call, and this is waiting on them.

@aholbreich

Copy link
Copy Markdown
Contributor

Heads-up on the new notification engine (#15932, merged Oct 20, after this branch): the notification service no longer has popupModel or dismissPopup(). On current quattro, notificationService.popupModel is undefined, so popupRows() returns [] and the warning is never dismissed. battery-test.sh still passes because it only covers BatteryModel.js. The cards now live in a private ListModel (toasts) and close through closeToast(key, reason). So a port needs a small public method on the notifications service, for example one that closes the cards matching an app and icon. The rows still carry app and appIcon, so your matching works as is. The branch also conflicts in battery/Service.qml after #15289.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 24, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Checked again against current quattro (bd97868), after the new notification engine (#15932). I've taken the verified and ready labels off: they were earned on the old engine, and this branch no longer works or merges.

  • The notifications service no longer has popupModel or dismissPopup(). On quattro, notificationService.popupModel is undefined, so popupRows() returns nothing. The warning is never dismissed, and the guard in c24ddfd against sending a second warning never fires either. battery-test.sh still passes, because it covers only BatteryModel.js.
  • It conflicts with quattro in battery/Service.qml after Show a video wallpaper's still frame on the lock screen instead of playing it #15289.

The design is still the best of the open fixes. Matching on app and icon works in any language, and reacting to the toast stack needs no spawned process. On quattro, the competing #14218 fails shell-idle-spawn-test for exactly that reason. A port needs a small public method on the notifications service, since the toast list is now a private ListModel that closes through closeToast(key, reason). That method should also cover a toast held while the deck is open: the new engine keeps it out of the list for up to 30 s, and a dismiss that only looks at the list misses it.

Reviewed by reading the branch against quattro. Codex Medium and Muse Spark 1.3 High each confirmed independently that the old API is gone. Whether to port this or finish #14218 is with the maintainer.

@omarchybot

Copy link
Copy Markdown
Collaborator

Closing in favour of #16562, which ports this design to the new notification engine (#15932). Thank you, Diogo: matching the warning on its sender and icon, and reacting to the toast stack rather than the clock, is the approach #16562 takes, and you're credited as a co-author on its commit.

This branch can't land as it is, because #15932 removed the popupModel and dismissPopup() it relies on. #16562 adds a small public dismissWhere(app, appIcon) and a shown signal to the notifications service in their place. It also covers two cases the new engine introduced: a warning held behind an open deck, and one restored after a restart.

@omarchybot omarchybot closed this Oct 25, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

A correction to the note above: #16562 has since taken the simpler route #14639 proposed. It sends the warning as a normal toast that expires after 30 seconds instead of dismissing it from the battery service. It still credits this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

3 participants