RSS Alarm Clock

I finally managed to get a sound card for an old computer. Now, I can make my Ubuntu Alarm Clock! What better way to wake up each morning, than to have your friendly linux box read the news to you? The techniques that I am using are nothing new (Hak5 did it and some people at the Ubuntu Forums have talked about it). It is pretty simple, just download and install the file and the necessary perl libaries, then create a bash script and add it to the crontab.

Get the programs

You will need festival and perl. You will also need mplayer if you want to play music. You can do the standard "sudo apt-get install ..." to get these (they were all installed in my basic`edgy <>`_ installation).

I am going to use cpan to install the perl modules. cpan is like apt for perl. You might have to set up cpan if this is your first time using it. If you are asked to set it up, I recommend typing "no" on the first question, and cpan will autoconfigure.

At the terminal:

sudo cpan

This is the cpan terminal, autoconfigure if necessary. It may take a while to install each package. If it says it requires other modules, install them as well.

install XML::RSS
install XML::Parser
install DateTime::Format::Mail
install DateTime::Format::W3CDTF

Create a file called "" in ~/alarm and put this in it:

#!/usr/bin/perl -w
# rss2html - converts an RSS file to HTML
# It take one argument, either a file on the local system,
# or an HTTP URL like
# by Jonathan Eisenzopf. v1.0 19990901
# Copyright (c) 1999 Jupitermedia Corp. All Rights Reserved.
# See for more information
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

#  ~~~P1mped 0ut l33t hax0r s7yle by d1gital~~~

use strict;
use XML::RSS;
use LWP::Simple;

# Declare variables
my $content;
my $file;

# check for command-line argument
die "Usage: <lines> (<RSS file> | <URL>)\n" unless @ARGV == 2;

# get the command-line argument
my $arg = shift;

my $lines = $arg;
$arg = shift;
# create new instance of XML::RSS
my $rss = new XML::RSS;

# argument is a URL
if ($arg=~ /http:/i) {
    $content = get($arg);
    die "Could not retrieve $arg" unless $content;
    # parse the RSS content

# argument is a file
} else {
    $file = $arg;
    die "File \"$file\" does't exist.\n" unless -e $file;
    # parse the RSS file

# print the HTML channel

sub print_html {
    my $rss = shift;
    print <<HTML;

    # print the channel items
    my $i = 0;
    foreach my $item (@{$rss->{'items'}})
      next unless defined($item->{'title'});
      print "$item->{'title'}... ... ... ... ...\n";
      if($i==$lines - 1){
       $i = $i + 1;

    print <<HTML;

Play a Random Song

You don't have to do this, but I want to hear a song after the news, so make a file, in ~/alarm From the Ubuntu Forum

#made by rusl modifying file

# File locations

# Create a temporary logfile of all matches
find $WritingsPath -iregex ".*.mp3" > $TempLog
find $WritingsPath -iregex ".*.ogg" >> $TempLog
find $WritingsPath -iregex ".*.wav" >> $TempLog

# Choose a random line number (any number from 1 to the length of the file)
UpperBound=$(cat $TempLog | wc -l)
RandomLine=$(( $LowerBound + ($UpperBound * $RANDOM) / ($RandomMax + 1) ))

# Use sed to grab the random line
Command=$(sed -n "$RandomLine{p;q;}" "$TempLog")

# open the random line in TextEdit
mplayer "$Command"

Make Your Alarm File

Make a file in ~/alarm

rm -rf alarm.txt
echo "good morning , today is" >> alarm.txt
date >> alarm.txt
echo "From Digg" >> alarm.txt
~/alarm/ 6 >> alarm.txt

echo "From Slashdot" >> alarm.txt
~/alarm/ 6 >> alarm.txt

festival --tts alarm.txt
rm -rf alarm.txt


You can add any number of news sources.

Set Permissions

cd ~/alarm
chmod +x
chmod +x

Set Your Alarm

Use the crontab to set your alarm. From the terminal:

crontab -e

And paste this into the file:

0 7 * * * /home/USERNAME/alarm/

Further Additions

Hak5 has a script to get the weather.