Repository navigation
Conversation
omarchy-battery-status read everything from the first battery UPower enumerates and the first BAT*/cycle_count glob match. On a dual-battery machine (Power Bridge ThinkPads and the like) whose first pack is dead, the panel pins at 0% / 0Wh with a bogus cycle count while the working battery charges fine. Headline figures now come from UPower's aggregate DisplayDevice, which is what the bar icon already reads, so panel and bar agree. Live wattage and cycle counts are summed over the packs that actually hold a charge, so a dead or disconnected pack no longer masks a working one. Charge threshold reporting is unchanged: it still comes from the first battery's own UPower info, since the aggregate carries no threshold lines. Single-battery machines see identical output (verified byte-for-byte on a one-battery ThinkPad, both output modes). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates battery reporting to handle multi-battery systems with dead packs correctly.
Changes:
- Uses UPower’s aggregate
DisplayDevice. - Aggregates live sysfs wattage and cycle counts.
- Adds dual-battery regression coverage.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/omarchy-battery-status |
Aggregates battery status and per-pack telemetry. |
test/shell.d/battery-status-test.sh |
Adds the required battery type fixture. |
test/shell.d/battery-status-dual-battery-test.sh |
Tests a dead-first dual-battery configuration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Asserts the combined sysfs wattage and the joined per-pack cycle format, which the dead-pack scenario alone never exercised. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… dead A dead pack contributes zero wattage and its -1 cycle count already fails the digit check, so the live/present split and its fallback bought nothing. Excluding scope=Device supplies keeps wireless peripherals out of the machine's numbers, which the old BAT* glob did by accident. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summing only the packs that report would understate the machine's draw; UPower's laggier aggregate beats a wrong instantaneous number. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Pushed two commits on top:
Both scenarios are locked in the dual-battery test; full shell suite green. — 🤖 Claude, posting on behalf of @dhh |
|
Ah, much simpler 😄 Thanks! |
|
This PR also fixes a related single-battery bug I just filed as #6895: on HP/ACPI laptops the Could you add a regression test for the ENODEV-on-read case (attribute present, read returns empty/invalid)? The existing fixture only covers the success path. Repro and root cause are in #6895. |
Some ACPI firmware exposes sysfs attributes whose read() fails with ENODEV, so a readable power_now or current_now can yield an empty string. The metering loop already discards an empty power_now, but awk coerced an empty current_now to 0, which passed the digit check and reported 0W as a metered value. Validate the raw reads before the math and lock both empty-read fallbacks in the dual-battery test (omacom#6895).
|
Added the test. while writing it I found the current_now/voltage_now fallback had the same hole: awk coerces the empty read to 0, which passes the digit check and gets counted as a metered 0W. fixed that too and locked both empty-read cases in the dual-battery test. |
UPower's composite DisplayDevice sums every present battery's energy-full, so a dead pack that still advertises the capacity it once had drags the percentage toward half and stretches time-to-full toward ten hours while the live pack sits near full (omacom#7916). Split packs by electrical liveness — voltage, stored energy, or current flow, since a dead pack keeps advertising energy_full — and rebuild percentage, capacity, and remaining time from the live packs' own energy readings whenever a dead pack was excluded. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9xdoAKqs6u53PAahM88u
|
Status: no conflicts against quattro, shell suite green. Two additions since the simplification pass:
One known gap, out of scope here: the panel icon fill reads |
|
Verified 3c40745 against the firmware it's meant to handle — nobody had run this branch on a machine that actually fails the read, so here's a data point from one. HP Spectre x360 14-ea0, single pack, $ cat /sys/class/power_supply/BAT0/power_now
cat: /sys/class/power_supply/BAT0/power_now: No such device
$ ls /sys/class/power_supply/BAT0/current_now
ls: cannot access '/sys/class/power_supply/BAT0/current_now': No such file or directorySame moment, packaged script vs this branch at cbe0705:
The single-pack path works out as intended: Two other affected machines reported the identical failure on #7182 and #6895 — an HP Spectre x360 14-ef2xxx ( I'd opened #7182 for the single-battery case before this commit existed; since this covers it, I'm closing that in favour of this PR so there's only one to review. |
|
@hegge25 Thank you for running the branch on the firmware it was actually written for, |
|
Summary for review, since the thread has grown long:
|
|
Tested this on a ThinkPad T480 with BAT0 + BAT1, running Omarchy 4.0.2-1. Before this PR, BAT0 was at 77% and holding while BAT1 was at 13% and charging. UPower’s DisplayDevice correctly showed the combined state as 42.77%, 20.39/47.67 Wh, charging at 16.774 W. The battery popup was only showing BAT0: 77%, holding, 0 W, and 22 Wh. After applying the PR, I tested again with BAT0 at 77% and BAT1 at 28%. DisplayDevice showed 50.79%, 24.21/47.67 Wh, charging at 17.084 W. The popup showed 50%, 47 Wh, charging at 17.1 W, 1h 23m to full, and both cycle counts (50 / 122). So this fixes the multi-battery aggregation issue on my T480. The focused battery tests also passed before and after the live test. I tested while charging, but didn’t get a discharging sample. PASS. |
|
Tested cbe0705 on a ThinkPad T480 (20L6S0CE41) with both packs, internal BAT0 (22 Wh) + external BAT1 (57 Wh), running Omarchy 4.0.3-1 on kernel 7.2.3-arch1-3. Works as expected. Before, the power panel showed only BAT0: 100%, fully-charged, 0W, 22Wh, cycles 42, while BAT1 was charging at 90%.
|
…cked from omacom/omarchy#6845 until it ships
|
Automated duplication check: this pull request looks similar to #10392, which covers the same battery-status multi-battery aggregation. I keep that one open and close this one to consolidate review. If you feel this is the wrong decision, please open the PR again with a note on the difference. |
|
@bjarneo — fair call that #6845 had scope creep by the end, it started as one dual-battery fix (dead-first T480 pinning at 0%) and picked up two more failure modes along the way, so I understand why the duplication check flagged it against #10392. That said, #10392 isn't a full duplicate, it's a subset — it only switches percentage/state to
Happy to help un-mess this: I can open a dedicated minimal PR just for the #6895 ENODEV guard (single-battery, tiny diff, easy to review) and leave the multi-battery aggregation to #10392 / a rebased follow-up — or go whatever way you prefer. Just let me know which split you'd like. |
|
Hey. Yes. That would be nice. Trying to untangle all the PRs, so some might be not 100% correctly closed! |
…cked from omacom/omarchy#6845 until it ships
…e, bar plugins, power panel (#128) * devops(arch): keep the display at scale 1 in monitors.lua, Omarchy now reads Lua and ignores monitors.conf Omarchy moved its Hyprland config to Lua, and hyprland.lua only requires the .lua files, so monitors.conf here is no longer loaded. Auto-scaling put the T480's 14" 1080p panel at 1.5; scale 1 fits more on screen. * docs(t480): name the Omarchy install T480-omarchy, so the booted OS shows in a prompt * docs(t480): give each OS its own hostname, one machine should not look like one install * devops: set each install's hostname with make hostname, so a new install does not depend on reading the docs * devops(arch): count both T480 batteries in the power panel, cherry-picked from omacom/omarchy#6845 until it ships * devops(arch): keep the System Pulse bar patch in the repo, separators and GB survive a reinstall Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * devops(arch): install the shell plugins with make plugins, so the list is a script and not README steps Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

On a dual-battery machine (Power Bridge ThinkPads and the like) whose first pack is dead, the power panel pins at 0% / 0Wh with a bogus cycle count while the working battery charges fine.
omarchy-battery-statusreads everything from the first battery UPower enumerates (upower -e | grep BAT | head -n 1) and the firstBAT*/cycle_countglob match, so whichever pack sorts first wins regardless of whether it holds a charge.Found on a ThinkPad T480 (dead internal BAT0, working removable BAT1): the panel showed
0%,0Wh, cycles-1while the bar icon — which reads UPower's aggregateDisplayDevice— was correct the whole time.The fix:
DisplayDevice, the same source the bar icon uses, so panel and bar now always agree — with one battery, several, or a dead pack in the mix.Notes for review:
cyclesvalue becomes e.g.5 / 7(one count per live pack). The panel's key/value parser renders it as-is; single-battery machines still get a plain number.--shelland plain modes.test/shell.d/battery-status-dual-battery-test.shreproduces the T480 scenario (dead pack enumerated first). The existing test's fixture gained atypefile, since batteries are now identified by sysfstyperather than aBAT*name glob.Verified on hardware:
energy-full— verified by @hilather (Power panel reports dead BAT0 (0% / 0W / Holding) on dual-battery ThinkPads #7916); their numbers are the cbe0705 regression test.power_nowpresent but failing with ENODEV, an HP/ACPI firmware class also reported on two other HP machines — verified by @hegge25 (Keep UPower's rate when a sysfs power attribute cannot be read #7182), rate matchingupowerto within 0.03W.Fixes #6895. Fixes #7916.
🤖 Generated with Claude Code