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:

#!/bin/sh

# Execute fancontrol

case "$1" in
        post)
          /usr/sbin/service fancontrol restart 
                ;;
esac

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".

Comments

I had the exactly same problem with my fans!

Thanks!

Add new comment

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.