USB autosuspend

How to disable autosuspend of specific USB devices




Find bus via vendor id

lsusb

Bus 001 Device 002: ID 1b1c:1b65 Corsair Harpoon Wireless Dongle
Bus 001 Device 005: ID 1038:0617 SteelSeries ApS SteelSeries Apex M750 TKL

grep 1b1c /sys/bus/usb/devices/*/idVendor

/sys/bus/usb/devices/1-2/idVendor:1b1c

grep 1038 /sys/bus/usb/devices/*/idVendor

/sys/bus/usb/devices/1-4.1/idVendor:1038


Manual toggle

cat /sys/bus/usb/devices/usb1/1-2/power/control
echo 'on' | sudo tee cat /sys/bus/usb/devices/usb1/1-2/power/control
cat /sys/bus/usb/devices/usb1/1-4/1-4.1/power/control
echo 'on' | sudo tee cat /sys/bus/usb/devices/usb1/1-4/1-4.1/power/control

Script to disable USB autosuspend for mouse and keyboard

~/bin/usbautosuspend
#!/bin/sh
# Disable USB autosuspend for mouse and keyboard
sleep 5;
# Corsair Harpoon Wireless Dongle
MOUSE="/sys/bus/usb/devices/usb1/1-2/power/control";
# SteelSeries ApS SteelSeries Apex M750 TKL
KEYBOARD="/sys/bus/usb/devices/usb1/1-4/1-4.1/power/control";
if [ -f "$MOUSE" ]; then
        echo 'on' | sudo tee cat $MOUSE;
fi
if [ -f "$KEYBOARD" ]; then
        echo 'on' | sudo tee cat $KEYBOARD;
fi
chmod 700 ~/bin/usbautosuspend

Service to automate the process on startup

/etc/systemd/system/usbautosuspend.service
[Unit]
Description=Disable USB autosuspend for mouse and keyboard

[Service]
ExecStart=/home/USER/bin/usbautosuspend

[Install]
WantedBy=multi-user.target
systemctl enable usbautosuspend.service