You can run this script to reboot you mouse, keyboard and everything else attached to the USB bus:
Add this script using sudo -H gedit /usr/local/bin/reset-usb
:
#!/bin/bash
# NAME: /usr/local/bin/reset-usb
# DATE: August 17, 2018.
# DESC: Written for Ask Ubuntu Question:
# https://askubuntu.com/questions/1061754
# Reboots / resets all USB devices including mouse & WiFi
if [[ $(id -u) != 0 ]]; then # root powers needed to call this script
echo $0 must be called with sudo powers
exit 1
fi
for i in /sys/bus/pci/drivers/[uoex]hci_hcd/*:*; do
[ -e "$i" ] || continue
echo "${i##*/}" > "${i%/*}/unbind"
echo "${i##*/}" > "${i%/*}/bind"
done
systemctl restart NetworkManager.service
exit 0
Copy and paste above script into gedit
. Then save the file and exit. Next mark the file as executable with:
sudo chmod +x /usr/local/bin/reset-usb
Use the script by calling it from the command line using:
sudo reset-usb
If this works you can call it automatically when Laptop is resumed by modifying this script: How to prevent wifi sleep after suspend
/etc/systemd/sysyem-sleep
to automatically call it when waking up. Not sure if internal keyboard gets rebooted by script or not. I'll try to remember to test that after. the – WinEunuuchs2Unix Aug 29 '18 at 12:20sudo udevadm trigger
have the same effect? – danzel Aug 29 '18 at 13:33