2

A previous post used info that is outdated for Ubuntu Mate 18.04.

According to this article, Running scripts before and after suspend with systemd, I have this script in /lib/systemd/system-sleep/:

#!/bin/bash 
#
# located in /lib/systemd/system-sleep/
# Created 4/2/19
exec 2> /tmp/systemd_suspend_test_err.txt
if [ "${1}" = "pre" ]; then
  # Do the thing you want before suspend here
  echo "we are suspending." > /tmp/systemd_suspend_test.txt
elif [ "${1}" = "post" ]; then
  # Do the thing you want after resume here
  echo "and we are back from being suspended" >> /tmp/systemd_suspend_test.txt
fi

However, none of the echo statements work.

BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
fixit7
  • 2,776
  • 3
  • 30
  • 70

1 Answers1

4

I feel kind of stupid, but I forgot to set the execute bit. Now the script works after I used:

chmod +x
BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
fixit7
  • 2,776
  • 3
  • 30
  • 70