I'm using a wireless Logitech Keyboard with a Logitech Unifying Receiver plugged into a KVM switch. I created a systemd suspend shortcut to suspend the laptop, a Lenovo IdeaPad. The laptop's lid is always closed. I'm unable to wake the Lenovo from suspend unless I lift the laptop's lid. Once the lid is lifted, the laptop wakes. I want to be able to wake the laptop without having to lift the lid. I'm not sure how to do this.
I tried two things, neither worked. First, I enabled the wakeup file for the Logitech Unifying Receiver (proc/acpi/wakeup). It did indeed wake the laptop when I used the keyboard. The problem was that the laptop woke within about five minutes without any input from me. No activity from the keyboard or anything else. Second, I tried the fix described at How do I get a wireless USB keyboard to to wake Ubuntu 13.10 from suspend? Same problem as the first -- the laptop wakes at unpredictable times, seemingly on its own.
When I look at devices using lsinput, I can see the Logitech keyboard. It's given the physical address usb-0000:00:14.0-3.1.1:1. When I look at proc/acpi/wakeup, I see pci:0000:00:14.0. There is no 3.1.1 extension. If I look at /sys/bus/usb/devices/1-3.1.1, I see it's the Logitech Unifying Receiver.
Here is the result of cat syslog during a wake event:
How do I put all this together to wake with keyboard input, but to suppress other wake events?
It's several days later and I've discovered this -- "Interaction with the Embedded Controller This is where really difficult to diagnose issues occur. The Embedded Controller (EC) contains proprietary code to control peripherals." From https://wiki.ubuntu.com/Kernel/Reference/ACPITricksAndTips
Suffice it to say, this looks pretty difficult and is likely specific to my Lenovo.
From: USB IR remote wakup from Suspend
I had the same problem and was also stumped by my USBs not appearing in /proc/acpi/wakeup. In the end, however, despite many solutions suggesting this was required I did not need to enable USBs in ACPI.
Instead, enabling wakeup on the USB port my IR device was connected to was was enough.
Find your device ID:
In the above example my device ID is 5168.
Grep /sys/bus/usb to find the port your device is plugged into:
This indicates my device is plugged into bus3, port 13.
Confirm the port is correct:
Bus 3, port 13 matches the bus/port returned by grep (3-13)
Check if wakeup is enabled:
Enable wakeup on port:
Check if wakeup enabled:
Test your device, does it wake the system?
Make this change persistent across reboots:
Add the following lines after the comments and before 'exit 0'
Now happily wake your PC from your USB device.
Limitations
One problem with this approach is that if the USB port the IR device is plugged into changes, then enabling that port specifically does not help.
This post has a way of enabling any IR port based on the device that is plugged into it using a Udev rule.
References
Kodi, MCE Remote and Ubuntu
Wake from suspend with keyboard or mouse
Enabling IR devices with a Udev rule
Original Answer Below
This question has three answers that may work for you: Wake up from suspend using wireless USB keyboard or mouse (for any Linux Distro)
Answer 1 (15 upvotes)
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.
Answer 2 (7 upvotes)
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 :
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:
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.
*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.
Answer 3
Pavlos Theodorou's answer is very helpful. I would like to add that you can find the usb device that your mouse/keyboard is connected to at boot-up by piping dmesg through grep a couple of times, then egrep once, and finally using tail to make sure it was the most recent entry.
Using this method, you don't have to enable wake on ALL usb ports.
I put the following in my /etc/rc.local file and it finds my logitech receiver every time, even if moved from one usb port to another. Just substitute the name of your keyboard or mouse from dmesg in place of "Logitech K270"
This works on boot, but doesn't seem to run on wake from suspend, so I had to put a script file in /lib/systemd/system-sleep/. Create it, set it as globally executable and give it a name that starts with a double digit number between 00 and 99. My script is as follows, again substite your keyboard/mouse verbage from dmesg:
For some reason I can't explain, the 'post' sleep if statement only works every other wake-up... but the 'pre' sleep if statement seems to work every time.
As of Sep 10, 2021, making enabled state as permanent doesn't work for few devices on Ubuntu 18+.
The fantastic answer by @Pavlos Theodorou, also Answer 2 here, solved the issue. Link to the post here.