From fa029c54fbe3d8b9ed20069e90b8c734c358ca71 Mon Sep 17 00:00:00 2001 From: Wey Gu Date: Mon, 13 Oct 2025 08:19:10 +0800 Subject: [PATCH] macbook 12' fixes on login keyboard & suspend wake up (#1959) * macbook 12' fixes on login keyboard & suspend wake up - apple spi keyboard production_name pattern fixed: Macbook 12' are MacBook8,1 9,1 and 10,1 for 2015, 2016 and 2017 models The MacBookPro12,1 is not a thing. ref: https://everymac.com/ultimate-mac-lookup/?identify=MacBook10%2C1 - add fix-apple-suspend-nvme.sh to fix MacBooks with NVMe cannot wake up ref: https://github.com/Dunedan/mbp-2016-linux?tab=readme-ov-file#suspend--hibernation * fix escapes in file path * add invocation in all.sh and migration script * Fix paths --------- Co-authored-by: David Heinemeier Hansson --- install/config/all.sh | 1 + .../config/hardware/fix-apple-suspend-nvme.sh | 38 +++++++++++++++++++ migrations/1759913695.sh | 3 ++ 3 files changed, 42 insertions(+) create mode 100644 install/config/hardware/fix-apple-suspend-nvme.sh create mode 100644 migrations/1759913695.sh diff --git a/install/config/all.sh b/install/config/all.sh index f7a8de91..52516f19 100644 --- a/install/config/all.sh +++ b/install/config/all.sh @@ -28,4 +28,5 @@ run_logged $OMARCHY_INSTALL/config/hardware/nvidia.sh run_logged $OMARCHY_INSTALL/config/hardware/fix-f13-amd-audio-input.sh run_logged $OMARCHY_INSTALL/config/hardware/fix-apple-bcm43xx.sh run_logged $OMARCHY_INSTALL/config/hardware/fix-apple-spi-keyboard.sh +run_logged $OMARCHY_INSTALL/config/hardware/fix-apple-suspend-nvme.sh run_logged $OMARCHY_INSTALL/config/hardware/fix-apple-t2.sh diff --git a/install/config/hardware/fix-apple-suspend-nvme.sh b/install/config/hardware/fix-apple-suspend-nvme.sh new file mode 100644 index 00000000..9ae11739 --- /dev/null +++ b/install/config/hardware/fix-apple-suspend-nvme.sh @@ -0,0 +1,38 @@ +# Fix NVMe suspend issues on MacBook models +# This prevents NVMe drives from failing to wake from sleep properly +MACBOOK_MODEL=$(cat /sys/class/dmi/id/product_name 2>/dev/null || true) + +if [[ "$MACBOOK_MODEL" =~ MacBook(8,1|9,1|10,1)|MacBookPro13,[123]|MacBookPro14,[123] ]]; then + echo "Detected MacBook model: $MACBOOK_MODEL" + echo "Applying NVMe suspend fix..." + + # Check if the NVMe device exists at the expected PCI address + NVME_DEVICE="/sys/bus/pci/devices/0000:01:00.0/d3cold_allowed" + + if [[ -f "$NVME_DEVICE" ]]; then + # Apply the fix immediately to prevent d3cold power state issues + echo 0 | sudo tee "$NVME_DEVICE" >/dev/null || true + + # Create systemd service to ensure fix persists across reboots + # The service runs after multi-user.target to ensure the device is available + cat </dev/null +[Unit] +Description=Omarchy NVMe Suspend Fix for MacBook + +[Service] +ExecStart=/bin/bash -c 'echo 0 > /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed' + +[Install] +WantedBy=multi-user.target +EOF + + # Enable the service to run on boot + sudo systemctl enable omarchy-nvme-suspend-fix.service + sudo systemctl daemon-reload + + echo "NVMe suspend fix applied and systemd service enabled" + else + echo "Warning: NVMe device not found at expected PCI address (0000:01:00.0)" + echo "This fix may not be needed for this MacBook model" + fi +fi diff --git a/migrations/1759913695.sh b/migrations/1759913695.sh new file mode 100644 index 00000000..8ce4ad13 --- /dev/null +++ b/migrations/1759913695.sh @@ -0,0 +1,3 @@ +echo "Fix NVMe suspend issues on MacBook models" + +bash $OMARCHY_PATH/install/config/hardware/fix-apple-suspend-nvme.sh