0

I'm trying to to execute a golang script every time my computer is going to sleep/resuming from sleep.

Here is the script inside the /lib/systemd/system-sleep folder:

#!/bin/bash
if [ "${1}" == "pre" ]; then
/usr/local/bin/smartdeck sleep
elif [ "${1}" == "post" ]; then
/usr/local/bin/smartdeck wakeup
fi

The script will send a simple POST message to my smart power switch to turn off power for my speakers.

Here are the permissions on the script:

jonathan@jonathan-desktop:/lib/systemd/system-sleep$ ls -l
total 8
-rwxr-xr-x 1 root root  92 Feb 22  2018 hdparm
-rwxr-xr-x 1 root root 139 Feb 16 21:18 pre-suspend.sh <- this is the script

If I run this command from the terminal it works as expected. But when I sleep/suspend/resume my elementary os, nothing happens. Does elementary os run these scripts on system sleep?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.