I was looking for hours, maybe more, for a solution and i just found it. I want to share it with everyone. This way it will be easier googling this problem to find the solution faster. So, just like the title says, below is the solution.
Ubuntu – Wake up from suspend using wireless USB keyboard or mouse (for any Linux Distro)
suspendusbwakeupwireless
Related Solutions
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
Best Answer
hit in terminal:
The result, for me, was to find out that all usb were disabled. So now, type:
1.
we have now root privillages.
2.I have 8 usb ports (you do that for as many usb ports you have) ,so:
Go ahead and test it. Now you can wake up from any wireless or wired usb keyboard and mouse.
So then, the reason we must enable all of them, is because in the next step, we will write this in rc.local to execute the command after every reboot, and after reboot some linux distros (maybe all) change the usb ports. We don't have to worry for anything going wrong by enabling all of them, since linux is in suspend or hibernation, it can't use the wifi to download anything, so it won't wake up without we wake it up on purpose.
Next step:
3.
and we paste everything from step 2. in there (before the exit 0 of course).
That's it. From now on we can use our wireless usb and mouse to wake up from suspend.
I hope it works for all of you. This guide was made after testing all other possible solutions around the internet.