Views:
198β
Votes: 4β
β
Solution
Tags:
16.04
bash
suspend
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1301658
Title:
Creating script to report system suspend or awake is not running?
ID:
/2020/12/20/Creating-script-to-report-system-suspend-or-awake-is-not-running_
Created:
December 20, 2020
Edited: December 20, 2020
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
Copy your script to:
/lib/systemd/system-sleep/sleep_mode
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:
echo "%s
to:
echo "s
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
The 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