Skip to content

Restore the saved battery charge limit when installing its rule - #72

Open
mmdisbrow wants to merge 3 commits into
omacom:mainfrom
mmdisbrow:submission/mac-battery-restore
Open

mmdisbrow wants to merge 3 commits into
omacom:mainfrom
mmdisbrow:submission/mac-battery-restore

Conversation

@mmdisbrow

@mmdisbrow mmdisbrow commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Installing or upgrading the battery-limit udev rule does not produce an add event for an already-present battery. Run the existing restore helper after that transaction so the owner's saved limit applies during the current boot.

The hook skips chroots and unbooted roots and never fails the package transaction. The restore helper retains its existing platform and saved-value checks.

Validation:

  • bash omarchy-mac/test/all passes in an isolated environment with the real home and running services hidden.
  • The battery fixture checks the staged hook's Path trigger, Install and Upgrade operations, exact target rule and PostTransaction timing, then executes its real restore command against a fixture battery.
  • Negative controls changing the target or removing either Install or Upgrade fail the new trigger assertion.

Merge order: this candidate bumps omarchy-mac from 0.2.3 to 0.2.4. #69 and #76 also propose 0.2.4, so whichever lands later must rebase and use the next version. If release-policy #30 lands first, remove this version bump and the README version line instead. No package release is made by this PR.

AI-assisted implementation and preparation with OpenAI Codex.

AI-assisted implementation and tests prepared with OpenAI Codex. Hardware and build qualification are recorded separately; no DCO sign-off is supplied.
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues remain.

Summary

Restores the saved battery charge limit after installing or upgrading its udev rule.

  • Installing the battery rule reapplies a saved limit to a battery already present.

Since the previous review, only the test assertions changed. No new actionable issues were found. The earlier README version mismatch is fixed.

Reviews (3) · Last reviewed commit: "test: verify battery restoration hook tr..." · Reviewed by Greptile

Comment thread omarchy-mac/version Resolved
Show 0.2.4 in the package overview to match the version file.

AI-assisted follow-up with OpenAI Codex.

@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 for this. The hook is the right fix: an already-present battery never gets a new add event, so without it a saved limit waits for the next boot. It copies the Touch ID hook's guard exactly (skip in a chroot or an unbooted root, never fail the transaction), and the restore helper already exits quietly with no saved limit, an unsupported value or a non-Apple platform. Running it on every omarchy-mac upgrade is fine too, since it only rewrites the value the owner saved.

Two things:

  1. Heads-up on omarchy-mac/version: #69 and your #76 also bump to 0.2.4, so whichever lands second needs a re-bump. If #30 lands first, which moves the bump into the release PR, please drop the bump and the README version line then.

  2. The new test runs the hook's Exec line but never checks its [Trigger]. We broke Target (omarchy-mac/share/libalpm/hooks/90-omarchy-mac-battery-charge-limit.hook:6) to a path nothing ships, and separately deleted Operation = Upgrade (line 5). battery-test.sh passed both times, so a hook that never fires would ship green. touchid-activate-test.sh:148-169 already does this for the Touch ID hook: assert the trigger lines, then check that Target names the staged rule. Can we do the same around omarchy-mac/test/battery-test.sh:167?

Minor: the validation numbers in the PR description and the migration claim don't match this PR. Please trim that section to what this PR changes.

Copy link
Copy Markdown
Contributor Author

Thanks, Scott. I added a test that checks the hook's [Trigger] section and that Target names the staged rule, following the pattern in touchid-activate-test.sh. Breaking Target or removing Operation = Upgrade now fails the test. I also trimmed the description to what this PR changes. I kept the 0.2.4 version bump for now and will rebase or re-bump based on whichever of #69 or #76 lands first, or drop it if #30 lands first.

@mmdisbrow

Copy link
Copy Markdown
Contributor Author

To make the version collision concrete, I suggest #72 retain 0.2.4 if it lands first; after #64 and #72, #69 can take the resulting main and use 0.2.5; my draft #76 would use 0.2.6 only if accepted and landed after those. These numbers follow actual landing order, not reserved releases. The three identical 0.2.4 edits merge textually but should not ship different contents under the same package version.

If #30 lands first, I will drop my feature-PR version bumps and duplicate README version lines and follow release-only versioning instead. #76 remains draft pending the scope decision. Does that order work for the maintainers and @audreyt?

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