15

I am using GNOME 3.36.6 on Arch Linux. By default, GNOME's automatic suspend option is enabled and it works as expected. However, I have to press the power button to wake the computer from suspend. I want to use my USB keyboard, which works by default on Windows.

The Linux kernel documentation describes how /sys/devices/.../power/wakeup files control whether or not a device is supposed to signal system wakeup. According to the documentation:

The initial value in the power/wakeup file is “disabled” for the majority of devices; the major exceptions are power buttons, keyboards, and Ethernet adapters whose WoL (wake-on-LAN) feature has been set up with ethtool.

This is not the case on my system. When I run grep . /sys/bus/usb/devices/*/power/wakeup, I can see that wakeup is disabled for all USB devices. I found the question Wake up from suspend using wireless USB keyboard or mouse (for any Linux Distro) on the Ubuntu Stack Exchange, which explains how to identify the correct device in /sys/bus/usb/devices and use /etc/rc.local to apply the correct configuration on boot.

All of this seems pretty complicated, difficult to remember, and error-prone. Using /etc/rc.local is discouraged on systemd-based distributions like Debian, Ubuntu, Arch and Fedora. Researching this problem turns up lots of outdated advice (systemd became Debian's default init system in 2015), as well as questions about suspend itself being broken over the years. As of 2020, GNOME seems to lack user-friendly configuration for wake-on-USB; on Windows, this is accessible from the Power Management tab of the device's hardware properties.

What is the simplest and most reliable way to enable wakeup for a specific USB keyboard or mouse, on a modern systemd-based Linux distribution?

(The Arch Linux Wiki page on suspend and hibernate suggests that the answer is probably to automatically configure the appropriate /sys/devices/.../power/wakeup file using systemd-tmpfiles, but identifying a graphical or simple command line tool that makes it easy to select the correct USB device, and is packaged in popular distributions, would be even better.)

See also

sjy
  • 896

3 Answers3

2

Write the

 echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
 echo enabled > /sys/bus/usb/devices/usb2/power/wakeup
 .....................................................

part of Ask Ubuntu in a script and try it adding it in crontab for root.

2

In my opinion the best way is to setup the BIOS for that.

I did it several years ago and it works very well with the keyboard. I never succeeded with the mouse, but it may depend upon your BIOS.

However, for me, pressing any key on the keyboard wakes up the system. You can set on the OS whether you need or not your password to enter your session.

Greenonline
  • 1,851
  • 7
  • 17
  • 23
1

One solution is to use a udev rule to enable wakeup based on USB vendor and product ID, e.g. add a /etc/udev/rules.d/usb-wake.rules file containing something like:

ACTION=="add", ATTR{idProduct}=="c542", ATTR{idVendor}=="046d", \
    RUN="/bin/bash -c 'echo enabled > /sys%E{DEVPATH}/power/wakeup'"
mnk
  • 21