Repository navigation
Fix omarchy-battery-status clobbering UPower rate on unreadable power_now - #12840
Closed
AyanMulla09 wants to merge 1 commit into
Closed
AyanMulla09 wants to merge 1 commit into
AyanMulla09 wants to merge 1 commit into
Conversation
…_now The sysfs power_now/current_now/voltage_now nodes can exist and pass a [[ -r ]] check while the actual read fails (e.g. ENODEV on some laptops). That produced an empty value, which awk silently coerced to 0, overwriting a perfectly good UPower energy-rate with 0W. Only override power_rate_raw once the read actually succeeds and yields a numeric value. Same guard applied to the current_now/ voltage_now fallback, which had the same hazard. Fixes omacom#12735 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
|
Thanks. PR for this already opened: #12649 |
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.
Summary
omarchy-battery-statuschecks[[ -r $battery_path/power_now ]]before reading the sysfs node, but on some laptops the node passes that check and still fails to read (ENODEV). The empty result gets coerced to 0 by awk, overwriting a correct UPower energy-rate with 0W.power_rate_rawwhen the read succeeds and the content is numeric. Same guard applied to thecurrent_now/voltage_nowfallback, which had the identical hazard.Fixes #12735
Test plan
test/shell.d/battery-status-test.shcovering an existing-but-unreadablepower_nownode, and confirmed it fails against the unpatched script and passes against the fix.test/shell.d/battery-status-test.shdirectly — both cases pass.test/shellsuite; the same 5 files fail on a cleanquattrocheckout with no changes, so they're unrelated to this fix.