Repository navigation
Conversation
omarchy-battery-status always took the first BAT* device, so a dual-battery ThinkPad with a present-but-dead internal pack reported 0% / 0W / Holding. UPower's DisplayDevice is not a substitute: it still counts the dead cell's energy-full, so the bar showed ~49% with a 10-hour ETA while the live pack was at 99%. Aggregate only packs that still show voltage, energy, or current. A healthy empty cell keeps voltage, so a real 0% pack is not dropped. The power panel uses the same live set for the icon and fill instead of DisplayDevice.
There was a problem hiding this comment.
Pull request overview
Filters electrically dead battery packs so CLI and power panel readings reflect live batteries.
Changes:
- Aggregates live battery status while excluding dead packs.
- Aligns panel percentage, icon, and charge-threshold logic.
- 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 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy-battery-status |
Selects and aggregates live battery packs. |
shell/plugins/panels/power/Model.js |
Adds live-pack and combined-state helpers. |
shell/plugins/panels/power/Panel.qml |
Uses live-pack data in the panel and bar. |
test/shell.d/battery-status-test.sh |
Tests dead-first dual-battery status. |
test/shell.d/power-test.sh |
Tests panel filtering and hold detection. |
Suppressed comments (1)
shell/plugins/panels/power/Panel.qml:86
- Once the panel has been opened,
batteryInfo.percentageremains populated, while its refresh timer stops when the panel closes. This branch therefore freezes the bar percentage/fill at the last panel reading indefinitely; meanwhileviewDevice()continues following UPower, so the icon can diverge again. Use the CLI value only while it is being refreshed, or run the refresh while closed.
var fromStatus = Model.combinedFractionFromStatus(root.batteryInfo)
if (fromStatus >= 0) return fromStatus
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
isLivePack only looked at energy, rate, and percentage, so a 0% cell with voltage was dropped while omarchy-battery-status kept it. Use the same voltage floor as the CLI, and emit pack.N.path so the panel can follow the CLI-selected set when Quickshell's UPowerDevice has no voltage.
UPower's percentage and time-to-full still count a dead pack's energy-full, so a T460 with a 0 V internal cell showed ~50% and a 10 hour ETA while the working slice was nearly full. Always derive % and remaining time from the live energy and instantaneous watts, prefer kernel charge limits, and stop falling the bar fill back to DisplayDevice. Signed sysfs power_now is taken as magnitude so charging time is not blank. A 0-100 kernel window is treated as no charge limit.
omarchy-battery-status emits BAT1; Quickshell may expose the sysfs path. Basename match keeps CLI-selected packs when voltage is missing.
|
You're right about the composite denominator, and it's confirmed against #6845: with a dead pack advertising 20.65Wh next to a 20.94Wh live pack near full, DisplayDevice reports 49% with a ~9.6h time-to-full. The mechanism is in UPower's I've pushed a fix to #6845 that takes the same approach as yours on the script side: packs split by electrical liveness (voltage, stored energy, or current flow — deliberately not What #6845 deliberately doesn't touch is the QML side: the panel icon fill and battery service still read |
|
I'll close mine in favor of yours then. The icon isn't a big deal and I'm just going to replace the internal battery. I ran into a later problem where the hibernate/sleep function kicked in when the battery was still half full due to the misleading indicators. Not sure if yours handles that (or doesn't need to). Just thought I'd mention it. |
|
Thanks for closing in favor. The T460s numbers, they're the regression test now. The early hibernate isn't omarchy, it's upowerd: the daemon triggers hibernate on its own, from the same broken composite reading, so #6845 can't fix it. Until you swap the pack, set UsePercentageForPolicy=false in /etc/UPower/UPower.conf. Then upowerd decides based on time-to-empty instead of percentage, and the dead pack doesn't affect that number. The real fix belongs upstream in UPower. |
Fixes #7916.
On dual-battery ThinkPads
omarchy-battery-statustakesupower -e | grep BAT | head -n 1— always BAT0. When the internal pack is present but electrically dead (0 V / 0 Wh /pending-charge), the power panel shows 0% / 0W / Holding while the slice is charging.UPower's composite
DisplayDeviceis not a drop-in fix: it still counts the dead cell'senergy-full, so the bar icon reports ~49% with a ~10 hour ETA while the live pack is at 99% / 2.2W / 3 minutes to full. Related PRs that sum every presentBAT*or switch to DisplayDevice (#7138, #6845, #7186) keep that composite-denominator bug.This keeps one bar icon and makes the numbers match the pack that actually holds a charge.
omarchy-battery-statuswalks everyBAT*and skips packs with no voltage, energy, or current. A healthy empty cell still shows voltage, so a real 0% pack is not dropped. If every pack looks dead, the previous present set is used rather than printing nothing.UPower.displayDevice. A long charge (timeToFull >= 8h) no longer counts as a hold.omarchy-battery-statusget the same live-pack line.Verified on a ThinkPad T460s (dead BAT0, live BAT1 charging): 99% / 20Wh / 2.2W / 3m to full.
Tests
test/shell.d/battery-status-test.sh— existing single-pack fixture still passes; added a T460s-shaped dead-first fixture (98% / charging / 2.2W / 20Wh / 14m, not 0% holding and not 49%).test/shell.d/power-test.sh— live-pack filtering, combined fraction, and an 20-hour charge not counting as holding.bash test/shell.d/battery-status-test.shandbash test/shell.d/power-test.share green.Screenshots
After, on this T460s (open power panel): 99%, pumping power, 2.2W, 3m to full, 20Wh.
Filed by Grok 4.6 via Grok Build.