Skip to content

Dismiss low battery notification when charger is connected - #14825

Closed
kajhaccou wants to merge 1 commit into
omacom:quattrofrom
kajhaccou:dismiss-low-battery-on-charge
Closed

kajhaccou wants to merge 1 commit into
omacom:quattrofrom
kajhaccou:dismiss-low-battery-on-charge

Conversation

@kajhaccou

@kajhaccou kajhaccou commented Oct 10, 2026 •

Copy link
Copy Markdown

Summary

Plugging in the charger now clears the "Time to recharge!" toast. The toast is sent as critical, and critical notifications never time out (durationFor in shell/plugins/notifications/Service.qml), so until now it stayed on screen until clicked away, even while charging.

+function dismissLowBatteryWarningOnAc()
+  execDetached bash -c
+    omarchy-power-present && omarchy-notification-dismiss "Time to recharge"

 Process warningProcess   # runs omarchy-battery-low
+  onExited
+    dismissLowBatteryWarningOnAc

 Connections { target: UPower }
   onOnBatteryChanged
     checkBattery
+    dismissLowBatteryWarningOnAc
     applyPowerProfile
     refreshPowerProfile
  • On plug-in: the toast is dismissed immediately.
  • On warningProcess exit: catches a warning that was still being sent when the charger connected, which the plug-in dismiss would have missed.
  • execDetached: every dismiss starts its own process, so a dismiss is never queued behind the warning or dropped while another is running.
  • omarchy-power-present: the power source is checked when the toast is removed, so a dismiss that lands after a quick unplug leaves the new warning alone.

Evidence

Tested on a Framework laptop with the patched shell, sending the same toast as omarchy-battery-low. The screenshots were taken with an earlier version of this branch that had the same plug-in dismiss:

  • Before: charger unplugged, "Time to recharge!" toast on screen

    before

    After: charger plugged back in, toast gone 2s later

    after

test/shell.d/battery-test.sh, battery-status-test.sh and power-test.sh pass. The race fallback is not covered by a test.

Merge Danger

Door: two-way

One method and two calls to it in shell/plugins/services/battery/Service.qml. Reverting the commit fully undoes it, and there is no migration or config change.

Blast Radius: tiny

  • Only on-screen toasts are dismissed; the notification history still has the warning.
  • The match is on summary text, so a toast from another app whose title contains "Time to recharge" would also be dismissed on plug-in. If the wording in bin/omarchy-battery-low changes, this string has to change with it.
  • omarchy-battery-low runs the battery-low hook after sending the toast, so in the race case a slow hook delays the fallback dismiss until the hook finishes.
  • Desktops without a battery never switch from battery to AC, so this code never runs there.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CkcTtVEmH9xSdHdmkXfkdM

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

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

Summary

Clears the low-battery toast when the charger connects.

  • The low-battery toast disappears when external power is connected.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Power source changes] --> C[Start detached power check]
  B[Battery warning process exits] --> C
  C --> D{External power present?}
  D -->|Yes| E[Dismiss matching visible toasts]
  D -->|No| F[Leave toasts alone]
Loading

Reviews (6) · Last reviewed commit: "Dismiss low battery notification when ch..." · Reviewed by Greptile

@kajhaccou
kajhaccou force-pushed the dismiss-low-battery-on-charge branch 4 times, most recently from 11c697f to c157e7e Compare October 11, 2026 09:06
@jandrusk

Copy link
Copy Markdown

Heads up: there are already two open PRs for the same fix, #14739 and #14218 (issue #14639 tracks the never-expiring critical toast). It's probably worth comparing approaches there so maintainers only have to review one. Yours adds a nice touch by re-checking omarchy-power-present before dismissing.

@omarchybot

Copy link
Copy Markdown
Collaborator

Read the diff at 33b4be3 against quattro. Nothing has been run or verified yet. This pull request gets no label for now, because it takes two models agreeing on what kind of change it is before anything else happens. Claude Opus 5.5 classified it as a bug fix. The second model, Codex Medium, did not review it: it is reachable, but omabot had used up its daily limit on reviewer calls.

It will not be reviewed or tested until a second model has classified it. Nothing is needed from you in the meantime.

@omarchybot

Copy link
Copy Markdown
Collaborator

Closing in favour of #16562, which fixes the low battery warning staying up on the new notification engine (#15932). Thank you for working on this. Your change pointed at the right moment to take the warning down, and #16562 credits it.

#16562 matches the warning on its sender and icon rather than the English title, so it also works in other languages. It also covers the warning restored after a restart and one held behind an open notification deck.

@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants