Fix stale charge-limit threshold in battery status panel - #356
Open
jastincheis wants to merge 3 commits into
Open
Fix stale charge-limit threshold in battery status panel#356jastincheis wants to merge 3 commits into
jastincheis wants to merge 3 commits into
Conversation
omarchy-battery-status preferred UPower's charge-*-threshold over the device's own sysfs value. The macsmc-battery driver never calls power_supply_changed() for a threshold-only write, so UPower's copy goes stale the moment battery-charge-limit changes it and never catches up — the panel kept showing the old limit (e.g. 80%) even after the slider set a new one (e.g. 87%), even though the real hardware threshold was applied correctly. Panel.qml already worked around this same staleness for the slider's own display by reading the CLI instead of UPower; apply the same fix here by reading sysfs first and falling back to UPower only when sysfs isn't readable. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nyix3VJYzz9JEXHPwHPYTK
Member
|
Please add a focused regression proving sysfs wins when UPower returns a different, non-empty threshold. That stale-cache case is the bug, and this PR currently changes production code without changing its test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
omarchy-battery-statuspreferred UPower'scharge-*-thresholdfields over the device's own sysfs value. Themacsmc-batterydriver never callspower_supply_changed()for a threshold-only write, so UPower's cached copy goes stale the momentbattery-charge-limitchanges it and never catches up.Symptom: after raising the charge limit via the power panel's slider (e.g. 80% → 87%), the panel kept reporting/holding at the old limit (80%) — even though the real hardware threshold in sysfs was applied correctly and the battery would in fact charge past 80%.
Panel.qmlalready worked around this exact staleness for the slider's own display, by readingbattery-charge-limit status(which reads sysfs) instead of UPower:omarchy-battery-statusnever got the equivalent fix — it still checked UPower's value first and only fell back to sysfs when UPower returned nothing, which almost never happens (UPower always returns some — just possibly stale — value).Fix
Swap the read order in
omarchy-battery-status: read the device's owncharge_control_{end,start}_thresholdfrom sysfs first, falling back to UPower's cached fields only when sysfs isn't readable, matching the approach already used inPanel.qml.Verification
bash test/shell.d/battery-status-test.sh— passes./test/shell— same 233 files, same 5 pre-existing failures as onquattrobefore this change (confirmed viagit stash); none touch battery statusthreshold 75-80%(stale UPower value)threshold 82-87%(live sysfs value)🤖 Generated with Claude Code