Skip to content

Instantly share code, notes, and snippets.

@FlafyDev
Last active August 2, 2022 18:07
Show Gist options
  • Save FlafyDev/925cb58aaa3e16dad8483e8702e257af to your computer and use it in GitHub Desktop.
Save FlafyDev/925cb58aaa3e16dad8483e8702e257af to your computer and use it in GitHub Desktop.
shell script to make a usb device be able to wake up from suspend.
input=$1
dmesg | grep "\[.*\] usb [^:]*: .*$input" | grep -o -P "usb .*?:" | grep -o "[0-9][^:]*" | uniq | while read device; do echo enabled >/sys/bus/usb/devices/$device/power/wakeup; done
@FlafyDev
Copy link
Author

FlafyDev commented Aug 2, 2022

Here is how it gets the ids of the device:
input="HyperX"

  • dmesg | grep "\[.*\] usb [^:]*: .*$input"
[    2.117325] usb 1-2.1.3: Product: HyperX Alloy Elite
[    2.117326] usb 1-2.1.3: Manufacturer: HyperX Alloy Elite
  • dmesg | grep "\[.*\] usb [^:]*: .*HyperX" | grep -o -P "usb .*?:"
usb 1-2.1.3:
usb 1-2.1.3:
  • dmesg | grep "\[.*\] usb [^:]*: .*HyperX" | grep -o -P "usb .*?:" | grep -o "[0-9][^:]*" | uniq
1-2.1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment