Reseting USB devices after resuming from sleep/suspend #
After resuming my devices were not usable #
My devices were becoming unresponsive after resuming from suspend. I did not troubleshoot/replaced the KVM switch, but it could be a hardware issue as this started out of nowehere.
Make sure you have usbutils installed #
sudo apt-get install usbutils
List your devices #
$ lsusb
Bus 004 Device 002: ID 05e3:0620 Genesys Logic, Inc. GL3523 Hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 0bda:b832 Realtek Semiconductor Corp. 802.11ac WLAN Adapter
Bus 003 Device 008: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 003 Device 006: ID 05ac:024f Apple, Inc. Aluminium Keyboard (ANSI)
Bus 003 Device 005: ID 05ac:0265 Apple, Inc. Magic Trackpad
Bus 003 Device 012: ID 046d:0807 Logitech, Inc. Webcam B500
Bus 003 Device 011: ID 1235:8210 Focusrite-Novation Scarlett 2i2 3rd Gen
Bus 003 Device 010: ID 046d:085e Logitech, Inc. BRIO Ultra HD Webcam
Bus 003 Device 009: ID 0fd9:0080 Elgato Systems GmbH Stream Deck MK.2
Bus 003 Device 007: ID 2109:2817 VIA Labs, Inc. USB2.0 Hub
Bus 003 Device 004: ID 2109:2817 VIA Labs, Inc. USB2.0 Hub
Bus 003 Device 002: ID 05e3:0610 Genesys Logic, Inc. Hub
Create the unit file #
sudo vim /lib/systemd/system-sleep/reset-usb
Populate the file #
#!/bin/sh
case "$1" in
pre)
;;
post)
# Add the devices you want to reset
/usr/bin/usbreset 0bda:b832 # wifi adapter
/usr/bin/usbreset 05ac:0265 # trackpad
/usr/bin/usbreset 05ac:024f # keyboard
/usr/bin/usbreset 1235:8210 # sound bridge
;;
esac
Change permissions #
sudo chmod +x /lib/systemd/system-sleep/reset-usb
Reload the unit files #
sudo systemctl daemon-reload