Repository navigation
Conversation
The warning was guarded only by a latch that clears as soon as the battery stops discharging. A charger too weak to climb past the threshold flips the battery in and out of discharging every few seconds, clearing the latch each time, so every poll fired a fresh toast. Gate the warning on a one-minute cooldown as well as the latch, persisted alongside it so it survives a shell reload. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ThTCkRCbS5EHykvTgfUSW
|
Closing this in favour of #10081, which reported the same bug a day earlier and fixes it better. We landed on the same root cause independently — One data point from here that may be useful when reviewing #10081, since it's the same code path. I reproduced the fault in an isolated Quickshell harness loading the real service with only
Hysteresis should drive that to a single toast for the whole episode. Worth confirming the latch also survives a |
Problem
The low battery warning is guarded only by a
notifiedLowBatterylatch inshell/plugins/services/battery/Service.qml, and that latch clears the moment the battery stops discharging.With a charger too weak to climb past the 10% threshold, the battery flips between charging and discharging every few seconds. Each flip clears the latch, so the next 30-second poll fires a fresh toast — the warning repeats indefinitely while the battery hovers on the threshold. Reported on a laptop whose charger cannot outpace draw at 10%.
Fix
Gate the warning on a one-minute cooldown in addition to the latch.
shouldWarnLowBatterynow takeslastNotifiedAt,now, andcooldown, and returns the updated timestamp; the service persists it inPersistentPropertiesalongside the existing latch, so it survives a shell reload.The latch is kept, so a normal steady drain still warns exactly once — the cooldown only matters when the latch keeps getting reset.
Tests
test/shell.d/battery-test.sh— three new cases: the warning is held inside the cooldown, fires again once it expires, and the timestamp is preserved when no battery is present. All pass; the new cases fail against the unfixed model../test/shell: only pre-existing environmental failures (missingomarchy-pkgscheckout forconfig-test.shandunowned-system-paths-test.sh;snapper-test.shnot executable).Behaviour was also checked in an isolated Quickshell harness loading the real service with only
UPowerstubbed, reproducing the reported scenario — 8% battery flipping in and out of discharging once a second:🤖 Generated with Claude Code
https://claude.ai/code/session_012ThTCkRCbS5EHykvTgfUSW