Continuing the discussion from Blank Screen after suspend, brightness key not working, bluetooth auto start at boot:
From the above discussion one thing didn’t solved and that was my USB WiFi mouse was not working from sleep. I have to manually unplug and plugin it to work.
I was searching for a solution. I found some info and did solved the problem some how. I am sharing with the forum for others.
Put the following script somewhere sensible. I put it at /usr/local/bin/reset-input-device.sh
.
#! /bin/sh
# Reset the keyboard driver and USB mouse
modprobe -r usbhid
modprobe usbhid
Since it has to be run as root, you should be careful with permissions, i.e.:
$ sudo chown root:root reset-input-device.sh
$ sudo chmod 744 reset-input-device.sh
Now we need to create a service file in the /etc/systemd/system/ directory – let’s call it /etc/systemd/system/reset-input-devices-after-sleep.service. It should look like this:
# This service is used to work around an apparent bug that freezes
# keyboard and mouse inputs after waking from sleep.
[Unit]
Description=Reset the keyboard and mouse after waking from sleep
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
[Service]
ExecStart=/usr/local/bin/reset-input-device.sh
CPUWeight=500
[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
Then enable the service so that it is ready to respond to a return-from-suspend event both now and after every new boot:
$ systemctl enable --now reset-input-devices-after-sleep.service
Correct me If I did some wrong here. I am not expert on bash script.
Thanks
Shahi