_ _ (_) ___ | |_ ____ | |/ _ \| __|_ / | | (_) | |_ / / _/ |\___/ \__/___| |__/
When my desktop computer resumes from suspend in Debian Linux, the scroll on my wireless Microsoft All-in-One Media keyboard does not function correctly. This can be fixed by unplugging the USB transceiver dongle and plugging it back in again. An alternative solution is to run the following command as root to reload the driver for keyboard and mouse.
sudo
modprobe -r usbhid && modprobe usbhid
exit
Alternatively...
sudo sh -c 'modprobe -r usbhid && modprobe usbhid'
To automatically reload the usbhid module when the system resumes from suspend, create the file "/lib/systemd/system-sleep/post-suspend.sh":
sudo nano /lib/systemd/system-sleep/post-suspend.sh
Paste the following into the file, save it (Ctrl-O) and exit from nano (Ctrl-X):
#!/bin/bash
if [ "${1}" == "post" ]; then
modprobe -r usbhid && modprobe usbhid
fi
To make that file executable, set its permissions as follows:
sudo chmod +x /lib/systemd/system-sleep/post-suspend.sh
The following is another way to write the file "/lib/systemd/system-sleep/post-suspend.sh" using a heredoc and then set its permissions:
sudo sh -c 'cat > /lib/systemd/system-sleep/post-suspend.sh' << 'EOF'
#!/bin/bash
if [ "${1}" == "post" ]; then
modprobe -r usbhid && modprobe usbhid
fi
EOF
sudo chmod +x /lib/systemd/system-sleep/post-suspend.sh
Notes: