Using Is there a "variable" to see if computer is in sleep mode?
Here is the code that should output to a file when system goes into SUSPEND or AWAKES:
(this code is in /etc/pm/sleep.d)
(also had to make the file executable: sudo chmod +x sleep_mode)
(when running from the command line, the "suspend script" is written to the file.
(but when I suspend the computer or awaken the computer... nothing is written to file.)
#!/bin/bash
# general entry
echo "suspend script"
echo "%suspend script" >> /tmp/suspend_time.txt
date +%s >> /tmp/suspend_time.txt
case "$1" in
suspend)
# executed on suspend
echo "%system_suspend" >> /tmp/suspend_time.txt
date +%s >> /tmp/suspend_time.txt
;;
resume)
# executed on resume
echo "%system_resume" >> /tmp/suspend_time.txt
date +%s >> /tmp/suspend_time.txt
;;
*)
;;
esac