Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Adds per-cell battery sections while retaining machine-wide power summaries.
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.
Changes:
- Adds battery detail discovery with UPower/sysfs fallbacks.
- Renders multi-battery cards with cell-specific metrics.
- Adds shell scenarios for several battery configurations.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
bin/omarchy-battery-details |
Emits per-battery metadata. |
shell/plugins/panels/power/Model.js |
Adds filtering, parsing, and labels. |
shell/plugins/panels/power/Panel.qml |
Renders per-battery sections. |
test/shell.d/battery-details-test.sh |
Tests battery discovery scenarios. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (d.state === s.FullyCharged) return "Full" | ||
| if (d.state === s.PendingCharge) return "Holding" | ||
| if (d.state === s.PendingDischarge) return "Pending" | ||
| return "Idle" |
| function isPhysicalBattery(device, displayDevice, types) { | ||
| var d = device || {} | ||
| var t = types || {} | ||
| if (!d || d === displayDevice) return false | ||
| if (d.type !== t.Battery) return false | ||
| if (d.powerSupply === false) return false |
Charge cycles, design capacity and health are facts about a physical cell. They have no aggregate: a machine with a 965-cycle pack and a 156-cycle pack has no cycle count of its own. The panel reported the first cell's numbers under a machine-wide label, so a T480 showed 965 cycles and 57% health for a laptop whose other pack was at 156 and 42%. Render one section per battery below the machine-wide summary, each with its own charge level, cycles, capacity, health and flow. The hero and the stats row above keep describing the machine; the sections describe the cells. On a single-battery machine nothing changes — the sections only appear when there is more than one cell to tell apart. omarchy-battery-details supplies what UPower's QML API does not expose: charge cycles and charge thresholds, plus a vendor and model so a cell is identifiable. It falls back to /sys/class/power_supply where the firmware reports nothing to UPower, which is common on older machines. Cells are selected on UPower's power-supply flag rather than the battery_ D-Bus prefix. Peripherals enumerate under that same prefix, so the prefix alone is not a filter, and a paired mouse would otherwise take an ordinal and turn "Battery" into "Battery 1". Two-battery ThinkPads are named Internal and External from DMI, since Lenovo's Power Bridge always enumerates the built-in cell first. That is the only layout nameable with confidence; every other machine gets ordinals rather than a guess.
0b6afc7 to
4ed6067
Compare
|
Automated duplication check: this pull request looks similar to #8904, which covers the same per-battery power sections. 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. |
Charge cycles, design capacity and health are facts about a physical cell. They have no aggregate — a machine with a 965-cycle pack and a 156-cycle pack has no cycle count of its own.
The panel reports the first cell's numbers under a machine-wide label. On my T480 it shows 965 cycles and 57% health for a laptop whose other pack is at 156 and 42%. Swap which pack the kernel enumerates first and the same machine reports the other set. Neither is wrong about a battery; both are wrong about the laptop.
What this does
Renders one section per battery below the machine-wide summary, each with its own charge level, cycles, capacity, health and flow. The hero and the stats row keep describing the machine; the sections describe the cells.
On a single-battery machine nothing changes. The sections only appear when there is more than one cell to tell apart, and
omarchy-battery-detailsexits 0 with no output when there is nothing to say.bin/omarchy-battery-detailsUPower's QML API exposes neither charge cycles nor charge thresholds, so the panel cannot reach them through
UPowerDevice. This supplies those, plus a vendor and model so a cell is identifiable, and falls back to/sys/class/power_supplywhere the firmware reports nothing to UPower — common on older machines. Live values still come from UPower; this only covers the gaps.Cells are selected on UPower's power-supply flag rather than the
battery_D-Bus prefix. Peripherals enumerate under that same prefix, so the prefix alone is not a filter — without this, a paired Bluetooth mouse takes an ordinal and turns "Battery" into "Battery 1".Model.isPhysicalBatteryapplies the same test on the QML side, so the two agree on what counts.Two-battery ThinkPads are named Internal and External from DMI, since Power Bridge always enumerates the built-in cell first. That is the only layout nameable with confidence; every other machine gets ordinals.
Testing
test/shell.d/battery-details-test.shis new and covers four machines with a stubbedupower: a Power Bridge ThinkPad with a Bluetooth mouse attached, a three-battery non-ThinkPad, a single-battery laptop with a paired keyboard, and a desktop with only a mouse. Removing the power-supply filter fails it withnot ok - power bridge names the built-in cell, because the mouse inflates the count to three and the naming no longer applies.Verified on a ThinkPad T480 running the exact files in this PR — script resolved through
PATH, no QML errors in the journal:Same sections, captured from this code running as a local plugin so the machine-wide figures above them are already correct; in this PR alone the hero still comes from
omarchy-battery-statusuntil #8770 lands.Relationship to #8770
Independent — no overlapping files — but they are two halves of the same problem, and this one reads better on top of #8770. That PR fixes the machine-wide figures (the hero percentage and runtime, which today come from the first cell too); this one gives the per-cell facts somewhere honest to live. #8770 deliberately left
cyclesalone because there was nowhere to put it; this is that somewhere.