Alarms in Ubuntu

I've been looking for a while for a good, easy to use, easy to install, no fuss alarm clock. Just something I can set to go off in 10 minutes. Or at 2 o'clock. Or tomorrow. I haven't found any apps that did that in a nice and easy fashion. I have found several that would do lots of things, but none of them were easy to use and handle - almost all of them were bloated, with bad UI. So, once more, I googled, but this time I came across another solution. 'Look ye to the command line!' I read. 'Use the at command, Luke!' And so I issued a 'man at' and quickly came upon good stuff.

From the man page of at:

DESCRIPTION
at and batch read commands from standard input or a specified
file which are to be executed at a later time, using /bin/sh.

Which, in my ears, sound awesome! You see, what you get here is close to the power of crontab, but single-use, i.e. you setup a command to run once, at a given time, and that's it. In other words, a command that will let you set up alarms easily.

The next step was turning at into an actual alarm. I prefer the sound method: play something that sounds like an actual alarm, and you'll be sure you don't overlook the thing. You can combine with something visual too, of course, like a dialog box. For the sound, I found AUTHENTIC NAVY ALARM SOUNDS PAGE which hosts a few different wave files. In particular, the general alarm (old style) works well for me. To play it, all you need to do is

aplay -q sound.file

Combined with at, this then becomes

echo "aplay -q sound.file" | at [time]

One of the beauties of at is that it will accept lots of different time inputs. So, you can do 'at 7:40', 'at 3pm', 'at now + 5 minutes', 'at today + 5 days', etc.

With things put together into a script, it might look like

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
if [ "$1" = '' ]
then
    echo "No argument for for alarm! Supply with time
example:
    alarm 7:45
    alarm 19:59
    alarm 3pm + 3 day
    alarm 2010-09-18
    "
    exit 1
else
    if `echo aplay -q /home/fake51/Downloads/gqold.wav | at $1 2>\&1 > /dev/null`
    then
        exit 0
    else
        echo "Setting alarm failed"
        exit 1
    fi
fi

Save the above script as alarm in \~/bin/, chmod to 0755 and you can then set alarms like

alarm 11:40
alarm "2010-01-06 12:00"

alarm "now + 5 minutes"

Should you want to remove the alarms before they run, you can see commands set to run with atq and remove them with atrm [number]

social