7374756666

Fixing immediate wake from sleep on a Mac Book Pro 2015

I have a late 2015 Mac Book Pro running KUbuntu (19.10 at time of writing).

When closing the lid or choosing sleep from the KDE menu it will wake up within a few seconds.

To fix this I added the following script to /lib/systemd/system-sleep/wakeup_disable

#!/bin/sh

# /lib/systemd/system-sleep/wakeup_disable
#
# Avoids that system wakes up immediately after suspend or hibernate
#
# Tested on MacBookPro 2015

case $1 in
  pre)
    if cat /proc/acpi/wakeup | grep -qE '^XHC1.*enabled'; then
        echo XHC1 > /proc/acpi/wakeup
    fi
    if cat /proc/acpi/wakeup | grep -qE '^LID0.*enabled'; then
        echo LID0 > /proc/acpi/wakeup
    fi
    ;;
esac

This disables waking from the lid being open and from USB devices (note this also disables keyboard and mouse waking) you have to push the power button to wake.

References:

  1. Arch Wiki
  2. Debian Wiki
  3. Ask Ubuntu