Wake up from suspend using wireless USB keyboard or mouse (for any Linux Distro)

In terminal:

grep . /sys/bus/usb/devices/*/power/wakeup

The result, for me, was to find out that all usb were disabled.

  1. So now, type:

     sudo su
    

    we have now root privillages.

  2. I have 8 usb ports (you do that for as many usb ports you have) ,so:

     echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
     echo enabled > /sys/bus/usb/devices/usb2/power/wakeup
     echo enabled > /sys/bus/usb/devices/usb3/power/wakeup
     echo enabled > /sys/bus/usb/devices/usb4/power/wakeup
     echo enabled > /sys/bus/usb/devices/usb5/power/wakeup
     echo enabled > /sys/bus/usb/devices/usb6/power/wakeup
     echo enabled > /sys/bus/usb/devices/usb7/power/wakeup
     echo enabled > /sys/bus/usb/devices/usb8/power/wakeup
    

    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.

  3. Run

     sudo nano /etc/rc.local
    

    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.


In addition to my guide above i want to add this information, because i recently discovered that some wireless usb devices after waking up from sleep, they revert back to disable. I repeat, only some usb devices do that, not all. That's why i didn't add this small guide up on my guide.

So you did as i instructed above and your pc successfully wakes up, but later in the day suddenly it doesn't wake up again.

Solution:

Open a terminal and do :

lsusb

At your keyboard device id information the 4 first digits are the vendor id and the 4 next digits are the product id (see screenshot) enter image description here

Next do:

sudo nano /etc/udev/rules.d/10-wakeup.rules

Where "wakeup" enter your desired name of the script. Number 10 is the priority in case you have many other udev rules, the lower the number the 'rule' will be executed before the others.

Copy paste this and replace the vendor id and product id with your own wireless keyboard vendor id and product id.

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="062a", ATTRS{idProduct}=="4101" RUN+="/bin/sh -c 'echo enabled > /sys/bus/usb/devices/usb8/power/wakeup'"

*usb8 for me is my wireless keyboard (you can also see that in the screenshot (Bus 008)), replace it with your own.

Ctrl + O to save , Ctrl + X to exit and reboot.