0

I am facing strange behavior. I have noticed that when my notebook is asleep and I unplug my two external displays causes keyboard and mouse to not work on next awaking. Solution for me so far has been making the notebook sleep and wake a few times and it fixes itself.

If external displays are unplugged while awake than this problem is not faced.

EDIT: This issue is the same for internal touch pad and keyboard.

1 Answers1

1

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

  • I should have mention that this issue is the same for internal touch pad and keyboard so I don't think this is solution. – Oliver Tušla Aug 29 '18 at 12:07
  • Yes if the internal keyboard is off-line you can't type the script. You would have to use /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:20
  • @WinEunuuchs2Unix wouldn't sudo udevadm trigger have the same effect? – danzel Aug 29 '18 at 13:33