Ubuntu – How to run sudo .sh file after wakeup : Touchpad disabled after upgrading to Ubuntu 17.10

17.10suspendtouchpadwakeup

I faced a small issue after an upgrade to Ubuntu 17.10. My touchpad started to disable after my system wakes up from suspend mode. I tried this temporary method and works for me:

  1. Create touchpad_wakeup.sh file in your home directory.

Its content is:

sudo rmmod i2c_hid
sudo modprobe i2c_hid
  1. So next time when my system wakesup: I login my username and password, then open terminal window using the shortcut key Ctrl+Alt+T

Write the following:

sudo bash ./touchpad_wakeup.sh
  1. Press enter

My touchpad starts working. I want to add this to wakeup sequence (/usr/lib/pm-utils/sleep.d), but didn't have much success to automate this.

Best Answer

To automate the call to your script on wakeup, you can add it under /lib/systemd/system-sleep instead of /usr/lib/pm-utils/sleep.d

Here is what I've done:

  • sudo touch /lib/systemd/system-sleep/touchpadwakeup
  • Put the following content:
#!/bin/sh

case $1 in
  post)
    rmmod i2c_hid
    modprobe i2c_hid
    ;;
esac
  • sudo chmod +x /lib/systemd/system-sleep/touchpadwakeup

It works fine but I hope we'll have a cleaner solution (e.g, a patch) in the near future.