Skip to content

omarchy-mac: stop the charge-limit unit failing after a charger plug or resume - #109

Merged
scottjones merged 1 commit into
omacom:mainfrom
only21mil:charge-threshold-no-start-limit
Nov 9, 2026
Merged

scottjones merged 1 commit into
omacom:mainfrom
only21mil:charge-threshold-no-start-limit

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

After omarchy battery charge limit 80, plugging in the charger or resuming from sleep leaves a failed unit behind (#102):

● macsmc-battery-charge-control-end-threshold.service  loaded failed failed
     Active: failed (Result: start-limit-hit)

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 in systemctl --failed.

Change

  • A vendor drop-in, macsmc-battery-charge-control-end-threshold.service.d/50-omarchy-mac-no-start-limit.conf, sets StartLimitIntervalSec=0 under [Unit]. The service only rewrites one line of /etc/udev/macsmc-battery.conf, so a start limit protects nothing there.
  • install already stages everything under vendor/, so it needs no change. An owner's same-name drop-in in /etc still replaces this one.
  • The drop-in's comment and the README's "Battery charge limit" section both name macsmc-battery charge threshold: spurious start-limit-hit on SMC Elec notification bursts AsahiLinux/asahi-scripts#78. This is a stopgap, to be dropped once asahi-scripts fixes the unit upstream.
  • version moves 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/version in 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 the version and README version-line hunks.

Merge order: #72, a different battery fix, also edits the README, test/battery-test.sh and version. The hunks here are in other places: the new test sits after the first block of battery-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, in version and 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.sh stages 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 requires systemd-analyze verify --root to 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:

Base: the new test fails with StartLimitIntervalSec unset

This branch passes:

Candidate: every battery test passes, including the two new checks

  • omarchy-mac/test/all: exit 0, 122 ok, no failures.
  • .github/scripts/check-scope and check-architecture-gates: exit 0.
  • Mutations of the drop-in each fail the test: no drop-in, a value of 10s, a misspelled unit directory, the key under [Service], the old StartLimitInterval= name, and an extra unknown key.

Not checked

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

…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>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 scottjones left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@only21mil

Copy link
Copy Markdown
Contributor Author

Note

🤖 Opus 5.5 replying on behalf of Victor.

@scottjones, thank you for the review. Checking that the unit has no Restart= covers the one way lifting the start limit could turn into a loop, and thanks for comparing the fixture with asahi-scripts upstream too. On the version: if #72 lands first, I'll rebase this branch and move it to 0.2.7.

@scottjones
scottjones merged commit 3040a61 into omacom:main Nov 9, 2026
3 of 4 checks passed
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