[GUIDE] Framework Laptop 16 Suspend Waking Up Early Or Failing To Suspend Fix

Cool, thank you!
Is there a way to disable all wakeup events by default, except for the power button, instead of listing specific devices?

Not that I am aware of, or I would have tried that.
To get a list of everything that could possibly wake up the laptop you can do:
find /sys -iname "wakeup" | grep "\/power\/wakeup"

As you can see, there are lots of different things that can wakeup.
If you have a number-pad in addition to the keyboard, you will probably need to add an extra line in for that.

I could find all devices with a wakeup option, excluding the power button, and disable them:

find /sys/devices/ -path \*/power/wakeup ! -path /sys/devices/.../power/wakeup -exec 

How can I tell what is the power button device?

This one is the power button, so you probably don’t want to disable this one:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/power/wakeup

You can check what PNP0C0C is with this:

cat /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1/name
Power Button

So, in general look for a “name” file in the file tree close the the “/power/wakeup” file and you should be able to find a name for it.

1 Like

Thank you for your help, James!
I ended up with the following script, that disables every wakeup device except for the power button, which is perfect for my use case.

#!/bin/sh
# This file should be placed in directory: /usr/lib/systemd/system-sleep

PATH=/sbin:/usr/sbin:/bin:/usr/bin

case "$1" in
  pre)
    # Disable all wakeup devices except for the power button
    find /sys/devices -path '*/power/wakeup' ! -path '*/LNXSYSTM:00/*' |
      while read wakeup; do echo disabled > $wakeup; done
    exit 0
    ;;
  post)
    exit 0
    ;;
  *)
    exit 1
    ;;
esac
1 Like

Sleep and wake use cases are complex.
One use case you might want to consider is the battery wake up. This should wakeup the laptop when the battery is low. Purpose then is to hibernate, (suspend-to-disk) so you don’t loose work.
At least on Linux the choice of what wakes is user selectable so each user can choose.

1 Like

Nice. Yes, for this use case this is a solid workaround.

Updated script (the match condition was wrong)

#!/bin/sh
# This file should be placed in directory: /usr/lib/systemd/system-sleep

PATH=/sbin:/usr/sbin:/bin:/usr/bin

case "$1" in
  pre)
    # Disable all wakeup devices except for the power button
    find /sys/devices -path '*/power/wakeup' \
                    ! -path '*/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/*' |
      while read wakeup; do echo disabled > $wakeup; done
    exit 0
    ;;
  post)
    exit 0
    ;;
  *)
    exit 1
    ;;
esac
2 Likes

Wrote a script based on @James3 and @tobiac 's conversation to find the paths which you want to disable, since I am nervous about disabling everything.

#!/bin/sh

to_disable_names=("Touchpad" "Mouse" "Keyboard")

wakeups=$(find /sys/devices -path '*/power/wakeup')
to_disable_devices=()
for wakeup in $wakeups; do
    device=$(echo "$wakeup" | xargs dirname | xargs dirname)
    names=$(echo "$device" | xargs -I{} find {} -path '*/name' | xargs cat)

    # # Uncomment to print all devices and names:
    # echo "$wakeup vvvvvvvvvvvvvvvvvvvvvvvvvvvv"
    # echo "$names"
    # echo ""
    # # ---end

    # Uncomment to find wakeup paths:
    for to_disable_name in "${to_disable_names[@]}"; do
        if echo "$names" | grep -q "$to_disable_name"; then
            printf '%-80s # %s\n' "$wakeup" "$to_disable_name"
        fi
    done
    # ---end
done

Output:

/sys/devices/platform/AMDI0010:03/i2c-1/i2c-PIXA3854:00/power/wakeup             # Touchpad
/sys/devices/platform/AMDI0010:03/i2c-1/i2c-PIXA3854:00/power/wakeup             # Mouse
/sys/devices/pci0000:00/0000:00:08.1/0000:c4:00.3/usb1/power/wakeup              # Keyboard
/sys/devices/pci0000:00/0000:00:08.1/0000:c4:00.3/usb1/1-3/1-3.2/power/wakeup    # Keyboard
/sys/devices/pci0000:00/0000:00:08.1/0000:c4:00.3/usb1/1-3/power/wakeup          # Keyboard
/sys/devices/pci0000:00/0000:00:08.1/0000:c4:00.3/usb1/1-4/power/wakeup          # Keyboard
/sys/devices/pci0000:00/0000:00:08.1/0000:c4:00.3/usb1/1-4/1-4.2/power/wakeup    # Keyboard
/sys/devices/pci0000:00/0000:00:08.1/0000:c4:00.3/power/wakeup                   # Keyboard
/sys/devices/pci0000:00/0000:00:08.1/power/wakeup                                # Keyboard