Skip to content

Keep UPower's battery rate when sysfs has no live reading - #17265

Merged
dhh merged 1 commit into
quattrofrom
battery-rate-unreadable-sysfs
Nov 1, 2026
Merged

dhh merged 1 commit into
quattrofrom
battery-rate-unreadable-sysfs

Conversation

@dhh

@dhh dhh commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

On the XPS 16 (N1x), the battery's firmware reports its present rate as unknown. The kernel still creates BAT0/current_now, but every read of it fails with ENODEV. omarchy-battery-status only checked -r, so it read an empty value, worked out a 0W draw, and threw away the rate UPower had already calculated from the falling charge (~11W). As a result the status line and power panel showed no drain rate at all.

The script now takes the power_now or current_now × voltage_now reading only when the read succeeds and returns a number; otherwise UPower's energy-rate stands. Machines that report a live reading are unchanged.

  • Status line on the XPS 16 before: Battery 90% · 9h 12m left · 98Wh
  • After: Battery 89% · 7h 58m left · 11W / 98Wh

The added case in test/shell.d/battery-status-test.sh (a current_now that reads back empty) fails on quattro and passes with this change.

The underlying gap is the firmware not reporting a present rate, which is worth raising with Dell/NVIDIA separately.

🤖 Generated with Claude Code

Firmware that doesn't know the present rate leaves current_now in place
but fails every read of it, so the readable-file check passed, the read
came back empty, and the draw showed as 0W. Only take the sysfs reading
when it is a number, and otherwise keep UPower's rate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps UPower’s battery rate when live readings are unavailable.

  • Battery status keeps UPower’s rate when sysfs has no number.

Reviews (1) · Last reviewed commit: "Keep UPower's battery rate when sysfs ha..." · Reviewed by Greptile

@dhh
dhh merged commit 4761d7b into quattro Nov 1, 2026
3 checks passed
omarchybot added a commit to calledtoconstruct/omarchy that referenced this pull request Nov 1, 2026
quattro's omacom#17265 rewrote the sysfs rate read to take a value only when it is a number. Keep that, and keep this branch's gate that skips it under DisplayDevice, whose rate already sums every pack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh
dhh deleted the battery-rate-unreadable-sysfs branch November 1, 2026 19:16
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
berenddeboer pushed a commit to berenddeboer/omarchy that referenced this pull request Nov 6, 2026
Firmware that doesn't know the present rate leaves current_now in place
but fails every read of it, so the readable-file check passed, the read
came back empty, and the draw showed as 0W. Only take the sysfs reading
when it is a number, and otherwise keep UPower's rate.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4761d7b)
omarchybot added a commit to mateuseap/omarchy that referenced this pull request Nov 17, 2026
quattro's omacom#17265 added a test for an unreadable current_now at the same spot this branch's cycle-count tests sit. Keep both, cycle-count tests first, since they still rely on CMB0's power_now, which quattro's test removes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants