Wake up from suspend using wireless USB keyboard or mouse (for any Linux Distro)
hit in terminal:
grep . /sys/bus/usb/devices/*/power/wakeup
The result, for me, was to find out that all usb were disabled. So now, type:
1.
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.
Next step:
3.
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)
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.
None of the above mentioned answers helped me. That's why I post here
my own one.
Enabling / disabling wake up from suspend for USB devices
Tested in KDE neon 5.16.2, based on Ubuntu 18.04 but should work in any distribution.
1. Show the list of USB devices to identify the one you want to enable / disable:
grep . /sys/bus/usb/devices/*/product
you should obtain something like this:
/sys/bus/usb/devices/3-3/product:Cord Optical Mouse /sys/bus/usb/devices/3-4.3/product:802.11n WLAN Adapter /sys/bus/usb/devices/3-4.4/product:USB Receiver /sys/bus/usb/devices/3-4/product:USB2.0 Hub /sys/bus/usb/devices/4-4/product:USB3.0 Hub /sys/bus/usb/devices/usb1/product:EHCI Host Controller /sys/bus/usb/devices/usb2/product:EHCI Host Controller /sys/bus/usb/devices/usb3/product:xHCI Host Controller /sys/bus/usb/devices/usb4/product:xHCI Host Controller
2. Check wake up status of all USB devices:
grep . /sys/bus/usb/devices/*/power/wakeup
the result should be something like this:
/sys/bus/usb/devices/1-1/power/wakeup:disabled /sys/bus/usb/devices/2-1/power/wakeup:disabled /sys/bus/usb/devices/3-11/power/wakeup:disabled /sys/bus/usb/devices/3-3/power/wakeup:enabled /sys/bus/usb/devices/3-4.4/power/wakeup:disabled /sys/bus/usb/devices/3-4/power/wakeup:disabled /sys/bus/usb/devices/4-4/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
In my case wake up is only enabled for the USB device 3-3 that, according to the previous list, is "Cord Optical Mouse".
I want to enable wake up from suspend only for wireless keyboard and disable it for the rest. The keyboard USB receiver is connected to a HUB and corresponds to 3-4.4 on the previous list ("USB Receiver").
3. Create a script that does the work:
To have root permissions:
sudo su
Then we create the file for the script (the file can be called "usbwakeup" or whatever descriptive you want):
nano /etc/init.d/usbwakeup
Contents of the file. Just adapt it to your needs by changing the "SCRIPT ACTIONS" section (I like adding comments to scripts in order to know what they actually do if I open them again someday):
#!/bin/bash # ####################### # GENERAL INFORMATION # ####################### # # - This script enables / disables wake up from suspend# for USB devices. # # - The script needs execution permissions. # # - For this script to be executed when the system starts, there must be # a symbolic link to it in /etc/rc3.d/ with priority S01 # (for example: /etc/rc3.d/S01usbwakeup) # ########################### # RELATED USEFUL COMMANDS # ########################### # # - Identify USB devices: # grep . /sys/bus/usb/devices/*/product # # - Check the status of "wake up of the suspension" of USB devices: # grep . /sys/bus/usb/devices/*/power/wakeup # # ################## # SCRIPT ACTIONS # ################## # # Disables wake up from suspend for optical mouse echo disabled > /sys/bus/usb/devices/3-3/power/wakeup # # Enables wake up from suspend for the wireless keyboard that I have connected to a USB 3.0 HUB in the USB port nr.4 echo enabled > /sys/bus/usb/devices/3-4.4/power/wakeup
4. Give it execution permissions:
chmod +x /etc/init.d/usbwakeup
5. Create a symbolic link in /etc/rc3.d/ for it to start on boot up:
sudo ln -s /etc/init.d/usbwakeup /etc/rc3.d/S01usbwakeup
By restart the system everything should work as specified in the script. The changes will be persistent as they will be executed with each system boot.
Sources consulted (apart of this post):
https://ubuntuforums.org/showthread.php?t=2388336
https://www.thomasmonaco.com/prevent-usb-devices-waking-ubuntu-sleep/
https://unix.stackexchange.com/questions/83748/the-rc0-d-rc1-d-directories-in-etc