3

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: syslog of laptop waking up

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.

1

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:

$ lsusb

Bus 002 Device 002: ID 8087:8001 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8009 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 13ba:0018 PCPlay Barcode PCP-BCG4209
Bus 003 Device 002: ID 1934:5168 Feature Integration Technology Inc. (Fintek) F71610A or F71612A Consumer Infrared Receiver/Transceiver
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In the above example my device ID is 5168.

Grep /sys/bus/usb to find the port your device is plugged into:

$ grep 5168 /sys/bus/usb/devices/*/idProduct  

/sys/bus/usb/devices/3-13/idProduct:5168

This indicates my device is plugged into bus3, port 13.

Confirm the port is correct:

$lsusb -t

/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
|__ Port 13: Dev 2, If 0, Class=Vendor Specific Class, Driver=mceusb, 12M

|__ Port 14: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 14: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M

Bus 3, port 13 matches the bus/port returned by grep (3-13)

Check if wakeup is enabled:

$ cat /sys/bus/usb/devices/3-13/power/wakeup  

disabled

Enable wakeup on port:

$ sudo sh -c 'echo "enabled" > /sys/bus/usb/devices/3-13/power/wakeup'

Check if wakeup enabled:

$ cat /sys/bus/usb/devices/3-13/power/wakeup  

enabled

Test your device, does it wake the system?

Make this change persistent across reboots:

$ sudo nano /etc/rc.local

Add the following lines after the comments and before 'exit 0'

# Enable Wake on IR for USB bus 3 port 13.  
echo enabled > /sys/bus/usb/devices/3-13/power/wakeup

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:

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.


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 :

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.


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"

KB="$(dmesg | grep "Logitech K270 as" | grep -o -P "usb.{0,5}" | egrep -o ".{0,3}$" | tail -1)"
echo enabled > /sys/bus/usb/devices/${KB}/power/wakeup

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:

#!/bin/sh

# Action script to enable wake after suspend by keyboard or mouse

if [ $1 = post ]
    then
    KB="$(dmesg | grep "Logitech K270 as" | grep -o -P "usb.{0,5}" | egrep -o ".{0,3}$" | tail -1)"
    echo enabled > /sys/bus/usb/devices/${KB}/power/wakeup
fi

if [ $1 = pre ]
    then
    KB="$(dmesg | grep "Logitech K270 as" | grep -o -P "usb.{0,5}" | egrep -o ".{0,3}$" | tail -1)"
    echo enabled > /sys/bus/usb/devices/${KB}/power/wakeup
fi

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.

  • Unfortunately, I had already tried this (it's the link given above). It resulted in the problem referred to in my original description. That is, the system wakes spontaneously. – KCinAZ Nov 4 '18 at 15:02
  • I've added a new detailed answer showing how to discover USB device – WinEunuuchs2Unix Nov 4 '18 at 15:42
  • I think the KVM is causing the USB port to become difficult to identify. When I use "echo enabled > /sys/bus/usb/devices/$${KB}/power/wakeup" I get bash: /sys/bus/usb/devices/000/wakeup: No such file or directory. – KCinAZ Nov 4 '18 at 21:38
  • $KB resolves to 000. The Logitech receiver is 1-3.1.1, but under that directory, there is no 000. If I enable wakeup in the 1-3.1.1 power directory, the system goes back to waking itself about every five minutes, without input. It's as if the KVM switch is sending the laptop signals. In order to stop the Lenovo from waking all the time, I have to set 1-3.1.1.power/wakeup to disabled. – KCinAZ Nov 4 '18 at 21:48
  • To summarize: the 1-3.1.1 is the Unifying Receiver. The Keyboard came back as "0.0.0" - no such directory. If I enable wakeup of 1-3.1.1, the system wakes up "on its own." – KCinAZ Nov 4 '18 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.