Time Since Last Resume
It's handy to know when to take a break.
Log the time when the system resumes from standby / sleep / hibernation
Reference: System-D Suspend Service
$ nano /usr/lib/systemd/system-sleep/sinceresume
#!/bin/sh
case $1 in
post)
logger "sinceresume resumed"
;;
esac
Grep the time out of the syslog
$ grep "sinceresume resumed" /var/log/syslog | tail -n 1
Time since last resume
$ cat sinceresume.sh
#!/bin/bash
# Get the syslog entry from the command line argument
syslog_entry="$(grep sinceresume /var/log/syslog | tail -n 1)"
# Extract the timestamp from the syslog entry using awk
timestamp=$(echo "$syslog_entry" | awk '{print $1, $2, $3}')
# Convert the extracted timestamp to a Unix timestamp
syslog_unix_timestamp=$(date -d "$timestamp" "+%s")
# Get the current Unix timestamp
current_unix_timestamp=$(date "+%s")
# Calculate the number of seconds since the syslog timestamp
seconds_since_syslog=$((current_unix_timestamp - syslog_unix_timestamp))
minutes_since_syslog=$((seconds_since_syslog / 60))
echo "$minutes_since_syslog minutes since your last break ($timestamp)"
I've added this to my shell startup.