Execute a script after suspend in Ubuntu 16.04
Sometimes you need to execute a script when your computer is recovering from suspend. Usually, as it is my case, this is necessary to fix some hardware that is not waking up properly.
Happily, this is a very easy task. You just have to add a script to the directory
/lib/systemd/system-sleep and it will be executed when going to or from suspend.
In my case, the script is as follows:
# Execute fancontrol
case "$1" in
/usr/sbin/service fancontrol restart
The "post" option in the case is for when the computer is waking up. If you need to execute something when going to sleep use "pre".