Skip to content

Add the Apple Silicon battery charge limit to omarchy-mac - #525

Merged
maralcbr merged 4 commits into
quattro-upstreamfrom
mac/62-battery-charge-limit
Sep 25, 2026
Merged

maralcbr merged 4 commits into
quattro-upstreamfrom
mac/62-battery-charge-limit

Conversation

@maralcbr

Copy link
Copy Markdown
Member

Ticket 62 of the Apple Silicon convergence plan. Stacked on #514 (omarchy-hw-platform).

What changed

  • Ports omarchy battery charge limit [80|100] from Add an Apple Silicon battery charge limit command #497 into the omarchy-mac add-on package, with the same driver semantics: it writes only the end threshold (80 restarts charging at 75, 100 restores full charging) and checks the SMC's readback. Full charging stays the default.
  • The command refuses unless omarchy-hw-platform reports apple-silicon.
  • Persistence: a successful change is saved as CHARGE_CONTROL_END_THRESHOLD= in /etc/udev/macsmc-battery.conf, and a package udev rule runs a small restore helper when macsmc-battery appears at boot. The helper reapplies only a saved 80 or 100, only on Apple Silicon, and never fails the udev event. Nothing needs enabling.
  • Why that file: on the M2 Max (mx-mac image), asahi-scripts 20260127.1 already ships 93-macsmc-battery-charge-control.rules plus a path unit that save the threshold to that same file and restore it at boot. Sharing it keeps one saved value instead of two stores that could disagree; our rule keeps persistence working if asahi-scripts is ever dropped from the image, and it also restores an explicit 100, which the Asahi rule skips.
  • Package README and ORIGINS updated. manual/ is untouched: Mac-only user docs belong in mac-manual/ (Move the Mac user manual into mac-manual/ #520), so a line for the Mac hardware page can follow there. The package version stays 0.1.0; the recipe pin (Add omarchy-mac for aarch64 edge omarchy-pkgs#626) needs a pkgrel bump or version bump when it picks this up.

Testing

  • New packages/omarchy-mac/test/battery-test.sh: status, set/clear with saved value, failed write, ignored write, failed save, invalid input, the root branch (no sudo), missing thresholds, and qualcomm / generic-aarch64 / generic / contradictory-detector fixtures, which leave the battery and saved value untouched. The restore helper covers a simulated reboot, values saved by asahi-scripts, last value wins, unsupported values, missing battery and non-Apple fixtures. udevadm verify checks the rule when available.
  • Package ./test/all passes in an aarch64 Arch container as non-root and as root (systemd 261). Mutants removing the platform gates, the save, the value check and the no-trailing-newline read are each caught.
  • Router check: with the package command staged beside the runtime's bin/, omarchy battery lists it and omarchy battery charge limit --help works. ./test/cli, architecture-gates-test.sh, apple-settings-test.sh and battery-status-test.sh pass.
  • M2 Max, read-only: kernel 7.1.12 exposes writable charge_control_start_threshold and charge_control_end_threshold (both 100), charge_behaviour [auto] inhibit-charge, no charge_types; macsmc_power is built in. Nothing was written. The driver (Asahi and mainline) gives 75/80 and 100/100 on both the CHWA and CHLS firmware paths.

Not yet done on hardware (converged image, tickets 25/26/51): omarchy battery charge limit 80, reboot and a cold boot, confirm Charge limit: 80% (restart charging at 75%), then 100 and reboot for 100/100. To check our rule alone, mask the Asahi one first with sudo ln -s /dev/null /etc/udev/rules.d/93-macsmc-battery-charge-control.rules.

Second review: two rounds; two minor verified findings (conditional style, untested root branch) fixed, final round clean.

@maralcbr
maralcbr changed the base branch from mac/13-hw-platform to quattro-upstream September 25, 2026 09:43
@maralcbr
maralcbr merged commit 2301f37 into quattro-upstream Sep 25, 2026
5 checks passed

@malik-na malik-na left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I found no blocking issues in the six-file change against the PR description and repository conventions.

Validated on an M1 MacBook Air: setting 80 produced 75/80 and saved 80; setting 100 restored 100/100 and saved 100. The restore helper applied a saved 80 on live hardware. With the PR checkout dev-linked and its battery files staged, a warm reboot came back at 75/80 with saved 80; the one-time check then restored 100/100. The final PR head's command, helper, udev rule, and battery test blobs match the tested checkout.

Limits: I did not test a cold boot or install the complete omarchy-mac add-on package transaction.

maralcbr added a commit that referenced this pull request Sep 25, 2026
Brings in the password sync (#532), audio (#535), display (#533), Wi-Fi
resume (#529) and battery charge limit (#525) work.

omarchy-drive-password takes #532's version. It already carries what #503
added (no tracing, the new password over stdin), and it has no Apple branch.
#503's drive-password-apple-test.sh asserted that the disk password never
changes the login or root password, which ticket 19 replaced with a
journaled LUKS-first sync for the system disk; drive-password-test.sh covers
the shared behaviour, so the Apple copy goes.
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