-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix suspend/sleep on T2 MacBooks #5129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jzimdars
wants to merge
2
commits into
basecamp:master
Choose a base branch
from
jzimdars:fix-t2-suspend
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| echo "Fix suspend/sleep on T2 MacBooks" | ||
|
|
||
| # Only run on T2 Macs | ||
| if ! lspci -nn | grep -q "106b:180[12]"; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Force s2idle (freeze) suspend mode — T2 Macs cannot use S3 (deep) sleep | ||
| sudo mkdir -p /etc/systemd/sleep.conf.d | ||
| cat <<EOF | sudo tee /etc/systemd/sleep.conf.d/t2-suspend.conf >/dev/null | ||
| [Sleep] | ||
| SuspendState=freeze | ||
| EOF | ||
|
|
||
| # Add mem_sleep_default=s2idle to kernel cmdline if not present | ||
| T2_CONF="/etc/limine-entry-tool.d/t2-mac.conf" | ||
| if [[ -f "$T2_CONF" ]] && ! grep -q "mem_sleep_default=s2idle" "$T2_CONF"; then | ||
| sudo sed -i 's/pcie_ports=compat"/pcie_ports=compat mem_sleep_default=s2idle"/' "$T2_CONF" | ||
| fi | ||
|
|
||
| # Regenerate boot config so kernel cmdline change takes effect | ||
| if command -v limine-mkinitcpio >/dev/null 2>&1; then | ||
| sudo limine-mkinitcpio | ||
| fi | ||
|
|
||
| # Create and enable suspend service if not already present | ||
| if [[ ! -f /etc/systemd/system/omarchy-suspend-t2.service ]]; then | ||
| cat <<'EOF' | sudo tee /etc/systemd/system/omarchy-suspend-t2.service >/dev/null | ||
| [Unit] | ||
| Description=Manage T2 modules around suspend | ||
| Before=sleep.target | ||
| StopWhenUnneeded=yes | ||
|
|
||
| [Service] | ||
| User=root | ||
| Type=oneshot | ||
| RemainAfterExit=yes | ||
| ExecStart=/bin/bash -c 'for dev in /sys/bus/pci/devices/*/; do vendor=$(cat "$dev/vendor" 2>/dev/null); device=$(cat "$dev/device" 2>/dev/null); if [[ "$vendor" == "0x106b" ]] && [[ "$device" == "0x2005" || "$device" == "0x1801" || "$device" == "0x1802" ]]; then echo 0 > "$dev/d3cold_allowed" 2>/dev/null; fi; done; rmmod brcmfmac_wcc 2>/dev/null; rmmod brcmfmac 2>/dev/null; rmmod -f apple-bce 2>/dev/null' | ||
| ExecStop=/bin/bash -c 'modprobe apple-bce; sleep 2; modprobe brcmfmac' | ||
|
|
||
| [Install] | ||
| WantedBy=sleep.target | ||
| EOF | ||
|
|
||
| sudo systemctl daemon-reload | ||
| sudo systemctl enable omarchy-suspend-t2.service | ||
| fi | ||
|
|
||
| # Clean up old user-created suspend-t2.service (pre-omarchy naming) | ||
| if [[ -f /etc/systemd/system/suspend-t2.service ]]; then | ||
| sudo systemctl disable suspend-t2.service 2>/dev/null | ||
| sudo rm -f /etc/systemd/system/suspend-t2.service | ||
| sudo systemctl daemon-reload | ||
| fi | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only edits
/etc/limine-entry-tool.d/t2-mac.confand only via a fragile string replacement ofpcie_ports=compat". On many installs the effective kernel cmdline comes from/etc/default/limine(which can override drop-ins), so this migration may not actually applymem_sleep_default=s2idle. Update the effective Limine config (e.g.,/etc/default/liminewhen present) and runlimine-update(as other migrations do) so the new cmdline takes effect, and append the param more robustly if the expected substring isn’t present.