Skip to content

Disable MacBook10,1 BCM4350 wakeup through S3 - #14020

Open
omarchybot wants to merge 5 commits into
quattrofrom
omabot/pr-10314
Open

omarchybot wants to merge 5 commits into
quattrofrom
omabot/pr-10314

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

On the 2017 12-inch MacBook (MacBook10,1), ACPI leaves the Broadcom BCM4350 Wi-Fi card (ARPT, PCI 14e4:43a3) armed as a wake source through S3, which the author measured as roughly a third of a watt of drain while asleep. This disables that wakeup on MacBook10,1 only: a udev rule sets the PCI device's power/wakeup to disabled, and a boot oneshot plus a system-sleep hook run omarchy-hw-macbook10-sleep-drain, which does the same and toggles ARPT in /proc/acpi/wakeup if it is still enabled. A migration brings existing MacBook10,1 installs along. Lid-close stays suspend: hibernate on this chassis did not reach S4 and left applespi delivering no keyboard or trackpad input.

The unit and the sleep hook run as root on every boot and suspend, so they name /usr/bin/omarchy-hw-macbook10-sleep-drain through quoted heredocs rather than $OMARCHY_PATH/bin. Under omarchy dev link that variable points at a checkout the user owns, and a path baked into a root-owned file would let that user's copy run as root, and keep doing so after omarchy dev unlink. privileged-heredoc-test enforces this. The setup touches no lid or sleep configuration: it writes its three files, enables the oneshot, and leaves /etc/systemd/logind.conf.d and sleep.conf.d as it found them.

Nothing here has run on a MacBook10,1 at this commit, and the tests stub sysfs, so whether it saves the power it describes rests on someone with the hardware. It is related to #9060, the same model draining overnight, but does not fix it: that report's main causes are the card timing out on entering D3 and a spurious LID0 wake, and this addresses only the Wi-Fi wake source among them.

Supersedes #10314 by @Skeptomenos, whose commits this carries unchanged, with the fixes above on top.

Skeptomenos and others added 3 commits September 5, 2026 13:36
Airport stays armed as ARPT, which holds the radio up for the whole suspend. Do not follow S3 with hibernate on this chassis: that path hung with a dead SPI keyboard.

Co-authored-by: Cursor <[email protected]>
The unit and system-sleep hook baked ${OMARCHY_PATH}/bin into files root executes on every boot and suspend. Under omarchy dev link that is a checkout the user owns, so replacing the script there runs it as root, and the baked path outlives omarchy dev unlink. privileged-heredoc-test fails on it. Quote both heredocs and name /usr/bin, where the package installs every bin/ command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The leaf deleted /etc/systemd/logind.conf.d/30-macbook10-suspend-then-hibernate.conf and sleep.conf.d/30-macbook10-hibernate-delay.conf and reloaded logind. Omarchy has never written either file, so on any machine but the one they were tried on, the only file they can match is one an administrator wrote, and an update would silently change their lid or hibernate policy. The lid action was never this change's to set; it stays as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Codex Medium <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 3/5

[High impact] Adds hardware power-management code that runs at boot and sleep.

The PR does not appear safe to merge until service startup and migration retry behavior are addressed.

Findings

  1. P1 Failed start skips migration retry ▶
  2. P1 Service can start without helper ▶
  3. P2 ACPI toggle result goes untested ▶

Summary

The PR adds a MacBook10,1-specific helper, udev rule, boot service, sleep hook, and migration to disable BCM4350 wakeup during S3.

  • The new migration guard avoids repeating machine-wide setup for another user, but can mistake an enabled service for a successfully started one.
  • The previously reported missing-helper startup path and ACPI-toggle test limitation remain outstanding.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Run per-user migration] --> B{Service enabled?}
  B -- No --> C[Write rule, unit, and hook]
  C --> D[Enable and start service]
  D -- Start fails after enable --> E[Migration fails; no marker]
  E --> A
  B -- Yes --> F[Skip setup; mark migration complete]
Loading

Reviews (2) · Last reviewed commit: "Skip the MacBook10,1 sleep-drain migrati..." · Reviewed by Greptile

sudo chmod 755 "$sleep_hook"

sudo systemctl daemon-reload
sudo systemctl enable --now omarchy-macbook10-sleep-drain.service

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Service can start without helper If a MacBook10,1 uses omarchy dev link and the new helper has not been installed at /usr/bin, this migration still writes and immediately starts a service that requires it. The service fails, the update stops, and the sleep hook also points to the missing helper. Keep the packaged path for root execution, but wait to activate the service until that helper is installed.

OMARCHY_SYSFS_ROOT="$sys" OMARCHY_ACPI_WAKEUP="$acpi" bash "$apply"
[[ $(cat "$sys/sys/bus/pci/devices/0000:02:00.0/power/wakeup") == disabled ]] ||
fail "apply disables BCM4350 PCI wakeup"
[[ $(cat "$acpi") == ARPT ]] || fail "apply toggles ACPI ARPT when it was enabled" "$(cat "$acpi")"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 ACPI toggle result goes untested The fixture is an ordinary file, so asserting that it now contains ARPT only proves the helper attempted a write. It cannot verify that /proc/acpi/wakeup changed ARPT from enabled to disabled. The test could pass while the wake source remains enabled; model the toggle or validate the resulting state on hardware.

@jandrusk

jandrusk commented Oct 6, 2026

Copy link
Copy Markdown

Looks careful, and the quoted heredocs pass privileged-heredoc-test on current quattro (unlike #14018). Two small notes:

  • migrations/1788600200.sh carries the September timestamp from Disable MacBook10,1 BCM4350 wakeup through S3 #10314. It doesn't collide with anything today, but a fresh date +%s keeps ordering honest next to the newer migrations.
  • sudo systemctl enable --now in install/hardware/apple/fix-macbook10-sleep-drain.sh runs inside arch-chroot on fresh installs. The other hardware leaves use plain enable and let boot apply it. The migration could call sudo /usr/bin/omarchy-hw-macbook10-sleep-drain directly to apply immediately on existing installs.

As the description says, this still needs someone with a MacBook10,1 to confirm the drain actually drops (cc #9060).

omarchybot and others added 2 commits October 15, 2026 06:04
The setup stopped touching any resume or sleep configuration, but the test still passed OMARCHY_MACBOOK10_RESUME_CONF to it, which reads as if the leaf had a resume file to write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Migration markers are per-user, so a second user on the same MacBook re-ran the privileged setup and needed sudo for a repair the machine already had; one who could not elevate would leave it pending and stop every later migration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Codex Medium <[email protected]>
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Reviewed at 7b9f449 against quattro, with a second opinion from Codex Medium. This is a hardware fix, so it now waits on someone with a MacBook10,1 to confirm it.

Pushed to this branch:

  • 7b9f449c3 makes the migration skip setup once omarchy-macbook10-sleep-drain.service is enabled. Migration markers are per-user, so a second user on the same MacBook would have run the privileged setup again and been asked for sudo for a fix the machine already had. If they could not elevate, the migration would stay pending and block every later one. A new test case covers it: it passes with the change and fails with the change reverted. Codex found this one.
  • 3069a7d28 drops an OMARCHY_MACBOOK10_RESUME_CONF variable the test still passed, although the setup no longer touches any resume or sleep configuration.

What ran: ./test/cli, macbook10-sleep-drain-test.sh and privileged-heredoc-test.sh ran on an Omarchy worker VM, both at this head and merged onto current quattro, and all passed. The neighbouring Apple and provisioning hardware tests also passed on the merge. The full shell suite was not run. Every test stubs sysfs and /proc/acpi/wakeup, so none of them shows the power saving.

Points raised on this PR, checked against the source:

  • Dev link and the /usr/bin path: this is by design. The unit and hook name the packaged command so that root never runs a user-writable checkout, and bin/omarchy-dev-link already says fixed system paths need the package. On a dev-linked install without that package, the migration fails and stays pending until the package arrives.
  • enable --now inside arch-chroot: systemd enables the unit and skips the start there, so fresh installs are unaffected. On existing installs, --now is what applies the fix straight away.
  • The September migration timestamp: omarchy-migrate keeps a marker per filename rather than a timestamp watermark, so an older number is still run.
  • Enabled after a failed start: Codex's second round pointed out that a first run whose start failed leaves the unit enabled, so the next run skips setup. That case is fine: the udev rule, unit and sleep hook are all written before enable --now, so the configuration is complete, and the sleep hook applies the fix at the next suspend.

Waiting on: confirmation from a MacBook10,1. @Skeptomenos, you measured the original drain, and @4ever911, you reported it in #9060. If either of you can test this head, the command can run straight from a checkout without installing anything, and it lasts until the next reboot:

git clone https://github.com/basecamp/omarchy.git && cd omarchy
git checkout 7b9f449c3f13af6cbe4222edb911f43d1449e3ef
sudo bash bin/omarchy-hw-macbook10-sleep-drain
bash bin/omarchy-hw-macbook10-sleep-drain status   # expect acpi_arpt=disabled and wakeup=disabled

Then suspend for a known length of time, ideally overnight, and reply here with:

  • the full SHA above
  • your product_name
  • the battery percentage or energy_now before and after
  • the same figures for a comparable sleep without the command

This addresses only the Wi-Fi wake source. The D3 timeout and the LID0 wake described in #9060 are not covered here.

Comment thread migrations/1788600200.sh
echo "Cut MacBook10,1 S3 drain by disabling Wi-Fi wakeup"

# The fix is machine-wide, so a second user finds the service enabled and has nothing to escalate for.
if ! systemctl is-enabled --quiet omarchy-macbook10-sleep-drain.service 2>/dev/null; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Failed start skips migration retry If systemctl enable --now enables the unit but its initial start fails, the migration stops without a completion marker. On the next run, this is-enabled check skips setup and lets the migration be marked complete even though the service has never started successfully. Check successful activation, not just enablement, before treating the fix as applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants