How to wake from suspend with USB keyboard (16.04 LTS)
9,488
Below is a pure udev way of doing what is suggested https://askubuntu.com/a/848699/1048516.
- Become root
- Get a rough idea of where mice and keyboards are connected:
# udevadm info /dev/input/by-path/*-kbd
P: /devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.1/2-3.1:1.0/0003:045E:001D.0002/input/inp
ut4/event4
[...]
# udevadm info /dev/input/by-path/*-mouse | grep P:
P: /devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4:1.0/0003:046D:C03D.0001/input/input3/event3
P: /devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4:1.0/0003:046D:C03D.0001/input/input3/mouse0
- from the path, keyboard is at usb2/2-3/2-3.1 and mouse is at usb2/2-4
- Check current state of wakeup:
# grep . /sys/bus/usb/devices/*/power/wakeup
/sys/bus/usb/devices/1-1/power/wakeup:disabled
/sys/bus/usb/devices/2-10/power/wakeup:disabled
/sys/bus/usb/devices/2-3.1/power/wakeup:disabled
/sys/bus/usb/devices/2-3/power/wakeup:disabled
/sys/bus/usb/devices/2-4/power/wakeup:disabled
/sys/bus/usb/devices/2-8/power/wakeup:disabled
/sys/bus/usb/devices/4-1/power/wakeup:disabled
/sys/bus/usb/devices/usb1/power/wakeup:disabled
/sys/bus/usb/devices/usb2/power/wakeup:disabled
/sys/bus/usb/devices/usb3/power/wakeup:disabled
/sys/bus/usb/devices/usb4/power/wakeup:disabled
- Add the below to the file /etc/udev/rules.d/10-wake-computer-with-keyboard-or-mouse.rules
# /etc/udev/rules.d/10-wake-computer-with-keyboard-or-mouse.rules
# - enable wakeup on ALL USB hubs (0-99)
# e.g. ls /sys/bus/usb/devices/usb*
# - rumor is that this step may not be necessary
# on all computers
# (I couldn't figure out how to enable wake on
# only parent hub of the keyboard and mouse.)
KERNEL=="usb[0-9]|usb[0-9][0-9]", SUBSYSTEM=="usb", DRIVER=="usb", ATTR{power/wakeup}="enabled"
# enable wakeup for all keyboards
# Keyboards are HID class 3 protocol 1 devices.
SUBSYSTEM=="usb", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceProtocol}=="01", ATTR{../power/wakeup}="enabled"
# enable wakeup for all mice (button click, not movement)
# Mice are HID class 3 protocol 2 devices.
SUBSYSTEM=="usb", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceProtocol}=="02", ATTR{../power/wakeup}="enabled"
- reload and trigger udev:
# systemctl restart udev.service
# udevadm trigger
- check allowed wakeup status again:
# grep . /sys/bus/usb/devices/*/power/wakeup
/sys/bus/usb/devices/1-1/power/wakeup:disabled
/sys/bus/usb/devices/2-10/power/wakeup:disabled
/sys/bus/usb/devices/2-3.1/power/wakeup:enabled
/sys/bus/usb/devices/2-3/power/wakeup:disabled
/sys/bus/usb/devices/2-4/power/wakeup:enabled
/sys/bus/usb/devices/2-8/power/wakeup:disabled
/sys/bus/usb/devices/4-1/power/wakeup:disabled
/sys/bus/usb/devices/usb1/power/wakeup:enabled
/sys/bus/usb/devices/usb2/power/wakeup:enabled
/sys/bus/usb/devices/usb3/power/wakeup:enabled
/sys/bus/usb/devices/usb4/power/wakeup:enabled
- test (one of various methods)
# systemctl unmask suspend.target
# systemctl suspend
Related videos on Youtube
Author by
Mike Oberdick
Updated on September 18, 2022Comments
-
Mike Oberdick over 1 year
I have been banging my head against a wall for a couple days on this...I have read through several forums...etc. and nothing has worked. My machine is a Dell Optiplex 330 which originally ran Windows 10 and the wake from USB keyboard/mouse worked fine. Now, I can't seem to get my computer to wakeup from suspend with my keyboard and/or mouse no matter what I do. Any thoughts?
-
Admin about 7 yearsSomehow after days of searching and trying...I found this site after posting my question and it worked like a charm! [link]bernaerts.dyndns.org/linux/74-ubuntu/220-ubuntu-resume-usb-hid
-
Admin about 7 yearsFor me, there's a setting in the BIOS to enable/disable allowing USB devices to wake the computer. Granted, my computer isn't even Dell, but still, check the BIOS
-
Admin about 7 yearsYep...my bios only offered wake on nic but not usb.
-
Admin about 6 years
-
-
Mike Oberdick about 7 yearsThank you for your answer...my next step was to try a ps/2 connection but where the heck would I find one of those at this point lol. Thankfully the solution I posted below ended up working out.
-
cdosborn almost 4 yearsAppreciate the effort you made here. Didn't have to change anything.
-
jarno over 2 yearsThis enabled also wake up by mouse movement for one of my mouses in Ubuntu 20.04, but it is actually a PS/2 mouse connected via USB to PS/2 adapter.