OK, I can’t seem to get the escaping to work right with crontab no matter how I fiddle, so I’ve replaced the one-liner with a regular script and meaningful variables names and all:
1,14,32,26 * * * * ~/bin/bin/memento-mori
The script itself being (with the 32-bit hack mentioned below):
#!/bin/sh
set -e
if grep open /proc/acpi/button/lid/LID?/state > /dev/null
then
CURRENT=`date +%s`;
if [ $(( $CURRENT % 8 )) = 1 ]
then
# DEATH_DATE=`date --date='9 August 2074' +%s`
DEATH_DATE="3300998400"
REMAINING=$(( $DEATH_DATE - $CURRENT ))
REMAINING_MINUTES=$(( $REMAINING / 60 ))
REMAINING_MINUTES_FMT=`env printf "%'d" $REMAINING_MINUTES`
(sleep 10m && killall xmessage &)
xmessage "$REMAINING_MINUTES_FMT minutes left to live. Is what you are doing important?"
fi
fi
OK, I can’t seem to get the escaping to work right with crontab no matter how I fiddle, so I’ve replaced the one-liner with a regular script and meaningful variables names and all:
The script itself being (with the 32-bit hack mentioned below):