Skip to content

Fix omarchy-battery-status clobbering UPower rate on unreadable power_now - #12840

Closed
AyanMulla09 wants to merge 1 commit into
omacom:quattrofrom
AyanMulla09:fix/battery-status-power-now-enodev
Closed

AyanMulla09 wants to merge 1 commit into
omacom:quattrofrom
AyanMulla09:fix/battery-status-power-now-enodev

Conversation

@AyanMulla09

Copy link
Copy Markdown

Summary

  • omarchy-battery-status checks [[ -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.
  • The fix reads the value first and only overrides power_rate_raw when the read succeeds and the content is numeric. Same guard applied to the current_now/voltage_now fallback, which had the identical hazard.

Fixes #12735

Test plan

  • Added a regression case to test/shell.d/battery-status-test.sh covering an existing-but-unreadable power_now node, and confirmed it fails against the unpatched script and passes against the fix.
  • Ran test/shell.d/battery-status-test.sh directly — both cases pass.
  • Ran the full test/shell suite; the same 5 files fail on a clean quattro checkout with no changes, so they're unrelated to this fix.

…_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>
@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Thanks. PR for this already opened: #12649

@bjarneo bjarneo closed this Sep 21, 2026
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.

omarchy-battery-status shows 0W when power_now exists but returns ENODEV, clobbering good UPower rate

2 participants