5

I'd like to wakeup my system via keyboard or mouse. This can be done via /proc/acpi/wakeup and a simple

echo DEVNAME > /proc/acpi/wakeup

my wakeup file looks like this

       Device   S-state   Status   Sysfs node
  ---------------------------------------
  1. P0P2     S4    *disabled  pci:0000:00:01.0
  2. P0P3     S4    *disabled  
  3. P0P1     S4    *disabled  pci:0000:00:1e.0
  4. UAR1     S4    *disabled  pnp:00:0c
  5. EUSB     S4    *disabled  pci:0000:00:1d.7
  6. USBE     S4    *disabled  pci:0000:00:1a.7
  7. P0P5     S4    *disabled  
  8. P0P6     S4    *disabled  
  9. P0P7     S4    *disabled  
  10. P0P8    S4    *disabled  pci:0000:00:1c.4
  11. P0P9    S4    *disabled  pci:0000:00:1c.5
  12. GBEC    S4    *disabled  
  13. USB0    S4    *disabled  pci:0000:00:1d.0
  14. USB1    S4    *disabled  pci:0000:00:1d.1
  15. USB2    S4    *disabled  pci:0000:00:1d.2
  16. USB3    S4    *disabled  
  17. USB4    S4    *disabled  pci:0000:00:1a.0
  18. USB5    S4    *disabled  pci:0000:00:1a.1
  19. USB6    S4    *disabled  pci:0000:00:1a.2
  20. P0P4    S4    *disabled  pci:0000:00:1c.0

My question is: How can I find out which (USB) device belongs to my mouse/keyboard? I failed with lsusb so far, but maybe I just missed the right switches.

1
  • You can't go too far wrong by just enabling all of your usb ports. Or you can enable one at a time until you find the one that makes it work.
    – psusi
    Jul 29, 2011 at 19:18

2 Answers 2

7
grep `ls /dev/input/by-path/*-mouse |\
    head -1 |\
    cut -d- -f 3` /proc/acpi/wakeup |\
    gawk '{print $1}'

This finds the input device for your mouse, then looks up the PCI ID in /proc/acpi/wakeup to give you the name. In fact, you could just redirect the output of that command back to /proc/acpi/wakeup in order to enable wakeups from that device.

3

Ok, I've found a way, though it does not look very clean ;)

I'll start from the end - running this one-liner will tell you the truth:

grep "USB.*pci" /proc/acpi/wakeup |\
    cut -d ':' -f 2- |\
    while read aaa; do \
        find /dev/.udev \
            -name "*$aaa*" \
            -print \
            -exec grep "$aaa" /proc/acpi/wakeup \; -exec echo \; ;\
    done

Nice, isn't it? And here is, how it works:

  • The beginning should be obvious: grep "USB.*" /proc/acpi/wakeup extracts from the list only USB devices that have a known sysfs node.
  • cut -d ':' -f 2- leaves just the ending (numbers) after 'pci:' on each line.
  • Then, for each ending (aaa=0000:00:1d.2 and so on), try to find an udev device symlink that contains the string.
  • For each device symlink found, the find command :
    • prints the name of udev symlink, <-- this is the most useful part
    • executes grep to display the line from /proc/acpi/wakeup that corresponds to the found device,
    • appends a blank line for output clarity.

So, thanks to the meaningful naming of device symlinks by udev, you can tell which USB device is the keyboard, mouse etc.

1
  • This method seems to return nothing in my case Nov 28, 2020 at 18:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .