gwern comments on Open Thread, August 2010 - Less Wrong

4 Post author: NancyLebovitz 01 August 2010 01:27PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (676)

You are viewing a single comment's thread. Show more comments above.

Comment author: gwern 14 August 2010 04:17:49PM *  1 point [-]

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