Repository navigation
omarchy-mac: stop the charge-limit unit failing after a charger plug or resume - #109
Conversation
…unit asahi-scripts' macsmc-battery-charge-control-end-threshold.path uses PathChanged= on the SMC battery's charge_control_end_threshold, which the macsmc driver notifies on every SMC Elec event. A charger plug or a resume sends a burst of them, so the service starts more than five times in ten seconds and systemd marks it failed with start-limit-hit, along with its path unit (omacom#102). Every start exits 0 and the saved limit stays right, so what the owner sees is a failed unit in systemctl --failed. The service only rewrites one line of /etc/udev/macsmc-battery.conf, so a vendor drop-in sets StartLimitIntervalSec=0 under [Unit]. The package's install already stages everything under vendor/. The drop-in goes once AsahiLinux/asahi-scripts#78 fixes the unit upstream; an owner's same-name drop-in in /etc still replaces it. battery-test stages asahi-scripts' unit as it ships beside the package and reads the [Unit] value systemd merges from the drop-ins, since systemd ignores the key under [Service]. It also requires systemd-analyze verify to print nothing, since verify warns about an ignored setting but still exits 0, and skips only that check where a trivial unit cannot verify cleanly either. The README's battery section says why the drop-in is there, and the version moves to 0.2.6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Greptile has paused reviews on this repository — it used its 100 free open-source review credits for this billing period. Reviews resume automatically on November 21. To continue before then, an organization admin can keep reviews running past the free credits — those bill as normal usage.
scottjones
left a comment
There was a problem hiding this comment.
Thanks, this is a clean fix. StartLimitIntervalSec=0 is in the right section, the unit has no Restart= so it can't loop, and it does nothing on Macs that don't have the unit. The test fixture matches asahi-scripts upstream too. As you noted in the PR body, the bump to 0.2.6 will collide with #72, so one of them will need a rebump.
|
Note 🤖 Opus 5.5 replying on behalf of Victor. @scottjones, thank you for the review. Checking that the unit has no |
Problem
After
omarchy battery charge limit 80, plugging in the charger or resuming from sleep leaves a failed unit behind (#102):The unit comes from asahi-scripts. Its path unit watches
charge_control_end_threshold, and the macsmc driver signals that file on every SMC "Elec" event. A charger plug or a resume sends a burst of them, so the service starts more than five times in ten seconds and hits systemd's default start limit. Its path unit then fails too. Every start succeeds and the saved limit stays right, so what the owner sees is a stale entry insystemctl --failed.Change
macsmc-battery-charge-control-end-threshold.service.d/50-omarchy-mac-no-start-limit.conf, setsStartLimitIntervalSec=0under[Unit]. The service only rewrites one line of/etc/udev/macsmc-battery.conf, so a start limit protects nothing there.installalready stages everything undervendor/, so it needs no change. An owner's same-name drop-in in/etcstill replaces this one.versionmoves to 0.2.6.Scope and approval
This is a one-line package default. Only Macs with asahi-scripts' charge-threshold unit are affected. No issue or maintainer approval is needed beyond #102, whose reporter suggested this drop-in.
Version: CONTRIBUTING on main says to bump
omarchy-mac/versionin the PR that changes behaviour, and #104 did that on 7 November, so this PR bumps it. If #30 merges first and moves bumps into release PRs, drop theversionand README version-line hunks.Merge order: #72, a different battery fix, also edits the README,
test/battery-test.shandversion. The hunks here are in other places: the new test sits after the first block ofbattery-test.sh, and the README text goes in the Battery section, while #72 adds at the end of both files. A trial merge with #72's head conflicts only on the version number, inversionand on README line 3, where #72 already conflicts with main. Either PR can land first; the other then needs only the version number picked.Verification
test/battery-test.shstages asahi-scripts' unit as it ships, next to the staged package. It reads the[Unit]value systemd merges from the drop-ins, since systemd ignores this key under[Service]. It then requiressystemd-analyze verify --rootto print nothing, because verify warns about an ignored setting but still exits 0. Where even a trivial unit can't be verified, such as in an emulated container, it skips only that check.Base 24430b4 with only the new test added fails:
This branch passes:
omarchy-mac/test/all: exit 0, 122 ok, no failures..github/scripts/check-scopeandcheck-architecture-gates: exit 0.10s, a misspelled unit directory, the key under[Service], the oldStartLimitInterval=name, and an extra unknown key.Not checked
failedstate after a charger plug or resume, before and after. The reporter of Charge limit leaves macsmc-battery charge threshold unit failed after charger events (start-limit-hit) #102 cleared it on their Mac with the same drop-in in/etc.Prior PRs
None make this change. Thanks to jotenakis2, who diagnosed it in #102 and suggested this drop-in.
Merge Danger
Door: two-way
Blast Radius: one asahi-scripts unit's start limit
Generated with Claude Opus 5.5 and GPT-6.1 Sol in T3 Code Nightly