Cron Alarm Clock

Unhappily, I’m sorry to say the there are a lack of alarm clocks in Linux. I’ve tried a few but really was impressed with none. So I decided to go with what the Linux uses for some of it’s timed events: Cron. Cron can be a good alarm and its easy to use.

The application “crontab” is used to create and edit cron jobs and the cron daemon checks for cronjobs a the top of every minute. A command line mp3 player can be used here but I like use Audacious. Cron will need to be told what X display to play Audacious on to discover the current display:

env | grep DISPLAY

Then as regular user edit crontab.

crontab -e

Here’s a simple comment to represent the cronjob layout:

#   minute (0-59),
#   |   hour (0-23),
#   |   |   day of the month (1-31),
#   |   |   |   month of the year (1-12),
#   |   |   |   |   day of the week (0-6 with 0=Sunday).
#   |   |   |   |   |   commands

Enter the time (multiple times, days need to be separated with commas) and script to execute for the alarm. The asterik can be used (*) to satisfy all variables. Here’s mine for audacious:

07  21  *   *   1,2,3,4,5   env DISPLAY=:0.0 audacious /home/user/My\ Music/Other/Alarms/301gq.mp3

I found some good alarm tracks at this site the were perfect for the task.

I like vim as my system editor but any can be used. In Gentoo edit the /etc/rc.conf to change it. To list the crontab.

crontab -l 

Additional Information:

Other Options

Wmtimer

Wmtimer works well for Gnome users (KDE has kalarm) it leaves a small window on the screen which can’t be hidden but it is able use the system beep or execute a command on an alarm/timer event. Starting it from the command line is pretty easy:

wmtimer -a -t 18:39:00 -e "mpg321 ~/Music/Other/Alarms/301gq.wav"

timer-applet

Timer-applet is a python application that adds a the ability to put a timer on the Gnome panel. Bugzilla has an ebuild for it, but I couldn’t get it to add to the gnome panel.

USE="libnotify sounds" emerge timer-applet

Audacious

Audacious also has alarm ability but it’s buried DeeeEEep in it’s preferences ( Preferences > Plugins > General ).

Alarm Clock

Thats actually its name. Despite the grey name, Alarm Clock is a very nice addition. Its a python script for the Gnome desktop that has the ability to run an application, display a message and to use as a tray icon. Its a good application and easy to install.

Alarm Clock requires python, pygtk, pynotif (notify-python in portage)
pygst (gst-python in portage).

alarm-clock.png

Zenity Alert

Zenity is Gnome’s notification program. This won’t get a person out of bed but it can be good for reminders. In crontab enter:

Note: I wasn’t able to get this to work. If anyone can figure it out please let me know.

    23  15  *   *   * env DISPLAY=:0:0 notify-send -i gtk-info "libnotify          example" "An example of libnotify notification thingy."
  • Thanks 2 keyboard cowboy.

About Gen2ly

<3's linux

8 thoughts on “Cron Alarm Clock

  1. Gift says:

    Я круче нигде не видел.

  2. moumni says:

    thanks dude, came in handy for work :)

  3. Thanks for doing the research for us. This was helpful today, and as with the previous comment, this was for work for me too.

  4. [...] http://linuxtidbits.wordpress.com/2008/01/19/cron-alarm-clock/ Author: WladyX on 21 January, 2008 Category: General, Scripts Newer: Nautilus preview sounds Ubuntu Older: Firefox extensions [...]

  5. Elena says:

    I’m sorry, but the Cron alarm clock system seemed way over my head. However, when I pressed “this site” on your Cron display, I found my self amused with all of the
    alarm sounds. I was truly enjoying myself.

  6. Oreolek says:

    It’s notify-send “text”

  7. Jack says:

    Haha, you use a general quarters alarm? Didn’t know anyone else did. It’s *the* sound that gets me going. :P

  8. vevhlos says:

    I was using cron with clementine and it worked fine. When i switched to audacious (clementine became a feature-bloat as expected) my alarm would never ring! The env DISPLAY=:0.0 did it for me, thanks!
    ps. I use audacious -p so the already open audacious can just start playing. Cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s