From f5d56602df70950de6b7d40966b00c9939c81763 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Sun, 26 Jan 2020 17:16:07 +0100 Subject: Intial commit of v2 See https://drewdevault.com/2019/12/30/dotfiles.html --- bin/usb2sys | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 bin/usb2sys (limited to 'bin/usb2sys') diff --git a/bin/usb2sys b/bin/usb2sys new file mode 100755 index 0000000..d810431 --- /dev/null +++ b/bin/usb2sys @@ -0,0 +1,36 @@ +#!/bin/bash +# +# usb2sys - find lsusb device in /sys file system +# +# https://superuser.com/a/1253083 +# + +die() +{ + echo "$@" + exit 1 +} + +[[ $# -lt 1 ]] && die "need vendor and product ids (from lsusb) as dddd:dddd" + +vendor=${1%:*} +product=${1##*:} + +sys=/sys/bus/usb/devices/ +cd $sys + +for d in *; do + path=$sys/$d + if [ -f $path/idProduct ]; then + prod=$( cat $path/idProduct ) + vend=$( cat $path/idVendor ) + + if [ $prod = $product -a $vend = $vendor ]; then + echo prod = $prod + echo vend = $vend + echo /sys device is $path + cat $path/power/wakeup + echo "" + fi + fi +done -- cgit 1.4.1