Alarm
I couldn't find an alarm script one night so I wrote this. Basically it checks the time every minute, and uses mplayer to play a sound file when the alarm goes off. I found it was all too easy just to press escape and go back to sleep, so it asks you a (simple) maths question, which when you get the correct answer, disables the alarm.
This code depends on random, which basically just echoes random numbers to the terminal.
The following command activates the alarm.
$ alarm hour minute
This can be downloaded from here.
#!/bin/bash alarmFile="/home/harry/.alarm/alarm.mp3" maxRandom="20"; if [ $# -lt 2 ] then echo Usage: echo $0 [hour] [minute] exit; fi echo "Setting alarm for $1:$2"; done="no" while [ $done != "yes" ]; do if [ $1$2 == `date +%H%M` ] then echo "Wakey Wakey!" mplayer "$alarmFile" &> /dev/null & inta=1; intb=2; actual="0"; answer=-1; while [[ $answer != $actual ]] do inta=`random $maxRandom` intb=`random $maxRandom` let actual=$inta+$intb read -p "$inta + $intb = " answer done echo "Ok, kill it." killall mplayer; done="yes" fi if [ $done != "yes" ]; then sleep 1m; fi done