Repository navigation
Add sleep drain visibility, battery health, and charge limit to power panel - #20379
Merged
Merged
Conversation
Contributor
[Medium impact] The PR appears safe to merge; the previous stale-icon issue is fixed and no new actionable issues were found. SummaryAdds sleep-drain readings, battery health, and hardware charge-limit controls to the power panel and CLI.
|
Contributor
Author
cursor Bot
pushed a commit
to mark-groves/omarchy
that referenced
this pull request
Nov 27, 2026
… panel (omacom#20379) * Add sleep drain, battery health, and charge limit to power panel * Fix ToggleSwitch knob centering at compact header heights * Refine power panel with compact charge limit toggle, bar tick, and 3x3 stats * Address Greptile review: RTL marker, Style.easeOut, semantic colors, and re-arm check * Turn one-time top-up into a switch row and refresh charge limit when closed
This was referenced Dec 1, 2026
BrahimiMehdi
added a commit
to BrahimiMehdi/omarchy
that referenced
this pull request
Dec 2, 2026
Resolves the conflicts with omacom#19046 (stale charge rate) and omacom#20379 (charge limit state): the settled charge-limit verdict is now a trailing argument after rateFresh and limitState, and the detail refresh uses the queued battery read quattro added instead of a separate process wrapper. Review fixes: - Picking a power profile while an unplug is held back saved it as the AC preference. setProfile now reads the power source UPower reports, not the one the panel shows. - A widget created on AC treated its own creation as the plug-in, so a real charge limit read as charging for a minute. The battery service now records when power last arrived, and a widget settles from that; one created long after a plug-in shows the limit at once. - The 90 s charge-rate guard follows the reported power source, so a held dropout still restarts it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Brings three laptop battery essentials to
omarchy.powerand theomarchy batteryCLI with zero idle polling:1. Sleep drain visibility (
Last sleep)default/systemd/system-sleep/omarchy-sleep-statshook (packaged into/usr/lib/systemd/system-sleep/alongsideunmount-fuse) that records pre/post battery energy and S0ix residency across suspend/hibernate into/run/omarchy/last-sleepand a capped 50-entry/var/lib/omarchy/sleep-history.tsv.energy_now) and charge-based (charge_now * voltage_min_design) batteries, usesCLOCK_BOOTTIME(/proc/uptime) to avoid NTP jumps, clamps 32-bit PMC S0ix counter wraps (hw_us <= wall_us * 1.05), ignores AC-plugged sleeps, and suppresses noisy rates on sleeps under 5 minutes.Last sleep(0.4%/h) in row 3 of the right stats column (balancing the 3×3 grid) with the full breakdown (8h 12m · −3.3% · 0.4%/h · 0.3W · S0ix 97%) in aPanelToolTipon hover, and shows a dedicated warning line (Last sleep stayed shallow (S0ix XX%)) only whens2idleS0ix residency drops below 80%. Also includes recent sleep history inomarchy-debug.2. Battery health & UPower disabled-threshold bugfix
health(energy_full / energy_full_design, clamped to 100%) inomarchy-battery-status --shelland displaysBattery healthin the power panel stats grid.omarchy-battery-statustreating UPower 1.91+'s hwdbcharge-start/end-thresholddefaults (75%/80%) as an active charge limit whenChargeThresholdEnabledisfalseand sysfscharge_control_end_thresholdis100.3. Compact hardware charge limit (
CHARGE LIMIT · 80%+ one-time top-up)bin/omarchy-battery-limit(status [--shell]|on|off|once|toggle) backed by UPower'sorg.freedesktop.UPower.Device.EnableChargeThresholdD-Bus method (already passwordless for active local desktop sessions via upstreamorg.freedesktop.upower.policy, covering Framework, ThinkPad, ASUS, Lenovo firmware conservation mode, Dell, and Apple Silicon).ToggleSwitchrow (CHARGE LIMIT · 80%) matching the Wi-Fi band Automatic toggle, plus a 2px threshold tick mark directly on the battery progress bar when active (RTL-mirrored, fades out while topping up to 100% once).Style.easeOut) a second switch row directly underneath (Top up to 100% oncewhen idle → boldNext charge goes to 100%on battery /Charging to 100% onceon AC when toggled on), keepingCHARGE LIMIT · 80%ON and aligned on both edges with zero layout shift.100% oncere-arming inshell/plugins/services/battery/Service.qml(WatchedFile+ existingUPower.displayDevice/UPower.onBatterysignals, zero polling): automatically re-enables the charge limit once the battery reaches 100% (including if already full when armed) or after unplugging (2s debounce against USB-C PD renegotiation), and refreshesactiveChargeLimitinPanel.qmleven when closed so the bar icon stays in sync with CLI changes.4. Compact
ToggleSwitchcentering fixshell/Ui/ToggleSwitch.qmlsoknobSizeis derived fromtrackHeight - knobInset * 2withy: root.knobInset, preventing odd-parityanchors.verticalCenterflooring from letting the knob touch the top track border at compact 12–14px header heights (fixes both the Power panel Charge Limit switch and the Wi-Fi panel Automatic switch).Screenshots
Before
After (charge limit off / on / one-time 100% override)
Tests
test/shell.d/battery-status-test.sh— passtest/shell.d/power-test.sh— passtest/shell.d/battery-test.sh— passtest/shell.d/i18n-test.sh— passtest/shell.d/motion-test.sh— passtest/shell.d/unowned-system-paths-test.sh— pass./test/cli— pass