#!/bin/bash

echo "Rebind USB input devices"

BUSIDS="$(ls -l /sys/class/input/ | grep event | grep xhci-hcd | cut -d "/" -f 10 | sort -u)"

for i in $BUSIDS; do
    echo "Re-bind /sys/bus/usb/drivers/usb/$i"
    sleep 1
    echo $i > /sys/bus/usb/drivers/usb/unbind
    sleep 1
    echo $i > /sys/bus/usb/drivers/usb/bind
done
