🔍 See Original Answer on Ask Ubuntu 🔗
Creating script to report system suspend or awake is not running?
December 20, 2020
Edited: December 20, 2020
November 24, 2022
Copy to clipboard: false
Copy your script to:
You will need to use
sudo powers. After copying flag it as executable:
sudo chmod +x /lib/systemd/system-sleep/sleep_mode
Additionally change all occurrences of:
The percent sign is unnecessary.
The existing date command is OK:
date +%s >> /tmp/suspend_time.txt
However it is formatted as number of seconds since January 1, 1970 which isn’t the most readable date format.
case statement can be changed:
case $1/$2 in pre/*) echo "$0: Going to $2..." # Place your pre suspend commands here, or `exit 0` if no pre suspend action required ;; post/*) echo "$0: Waking up from $2..." # Place your post suspend (resume) commands here, or `exit 0` if no pre suspend action required ;; esac