Skip to content

Instantly share code, notes, and snippets.

@wheeskers
Last active March 13, 2024 11:43
Show Gist options
  • Select an option

  • Save wheeskers/dbd091cc995c7f830889 to your computer and use it in GitHub Desktop.

Select an option

Save wheeskers/dbd091cc995c7f830889 to your computer and use it in GitHub Desktop.
Disable wakeup for device using systemd

Check devices

# cat /proc/acpi/wakeup

Find specific devices

Examples:

EHC1	  S3	*enabled  pci:0000:00:1d.0
EHC2	  S3	*enabled  pci:0000:00:1a.0

Temporary disable waking up for selected device

# echo "EHC1" > /proc/acpi/wakeup
# echo "EHC2" > /proc/acpi/wakeup

Persistent changes via systemd

Create file like this one:

# nano /etc/tmpfiles.d/ehc1-disable-wake.conf

With lines:

w+ /proc/acpi/wakeup - - - - EHC1
w+ /proc/acpi/wakeup - - - - EHC2

Then reboot and check again -- specified devices will not wake up a machine until you let them again.

@brandsimon
Copy link

brandsimon commented May 6, 2020

Thank you for all the hints here.
I decided to disable my devices via /sys/devices/*/*/power/wakeup, since /proc/acpi/wakeup is only a toggle, and I want it to be disabled for sure, also I can then easily specify multiple devices:
e.g. forXHC S3 *disabled pci:0000:00:14.0 the tmpfiles looks like this:

w /sys/devices/pci0000:00/0000:00:14.0/power/wakeup - - - - disabled

Hopefully this is helpful for someone.

Edit: Also be careful with sysfs and tmpfiles, because some devices will be available after tmpfiles is processed
source: https://wiki.archlinux.org/index.php/Systemd#Temporary_files

@HaleTom
Copy link

HaleTom commented Mar 13, 2024

It is possible to write multiple lines to the same file, either with \n in the argument or using the w+ type on multiple lines (including the first one) for appending
-- https://wiki.archlinux.org/title/Systemd#Temporary_files:~:text=It%20is%20possible,for%20appending%3A

@HaleTom
Copy link

HaleTom commented Mar 13, 2024

Here's how to do it via sytstemd:
https://unix.stackexchange.com/a/772229/143394

@wheeskers
Copy link
Author

@HaleTom, thanks for the tip! Updated.

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