| Mobile | RSS

Breaking News Alert On Your Linux Machine

December 5th, 2008 | 4 Comments | Posted in Featured Post, Information, Script, Tutorials

For the past few days, I’ve been disconnected from T.V. and I couldn’t keep up with the buzz around. Visiting web portals frequently for updates didn’t seem feasible either. The tickers provided by many web portals could’ve been used, but, unfortunately almost all of them are incompatible with Linux, the beautiful OS.This was the very reason behind me venturing out to code a Breaking News Alert for Linux Machines. And, proudly, I was successful in that. According to the theory that states, “anything good and useful is to be shared”, here, I share the source code and instructions to create a custom Breaking News Alert for your Linux Machine/Linux News Ticker


Source Code

In the sample code below, I’ve used  DNAIndia Latest News Feed
Here is the code for GNOME Desktop Environment
Download it From Here in a textt File

#!/bin/bash
mkdir -p /tmp/dnadata
cd /tmp/dnadata
rm -rf news-latest*
wget http://www.dnaindia.com/services/rss/news-latest.xml
if [[ "$(echo  $(md5sum news-latest.xml | sed -e 's:news-latest.xml::g'))" == "$(echo  $(md5sum check.xml | sed -e 's:check.xml::g'))" ]]
then
echo “same news”

else

cat news-latest.xml | grep “pubDate” | sed -e ’s:<pubDate>::g’ | sed -e ’s:</pubDate>::g’ | head -n 3 | tail -n 1 > 1
cat news-latest.xml | grep “title” | sed -e ’s:<title>::g’ | sed -e ’s:</title>::g’ | head -n 3 | tail -n 1 > 2
cat news-latest.xml | grep “description” | sed -e ’s:<description>::g’ | sed -e ’s:</description>::g’ | head -n 3 | tail -n 1 > 3
zenity –display :0 –title=”$(echo $(cat 2))” –info –text=”$(echo $(cat 3)) n n n n News as on $(echo $(cat 1))”
fi
cat news-latest.xml > check.xml

Here Is Coding For KDE

Download it From Here in a text File

#!/bin/bash
mkdir -p /tmp/dnadata
cd /tmp/dnadata
rm -rf news-latest*
wget http://www.dnaindia.com/services/rss/news-latest.xml
if [[ "$(echo  $(md5sum news-latest.xml | sed -e 's:news-latest.xml::g'))" == "$(echo  $(md5sum check.xml | sed -e 's:check.xml::g'))" ]]
then
echo “same news”

else
cat news-latest.xml | grep “pubDate” | sed -e ’s:<pubDate>::g’ | sed -e ’s:</pubDate>::g’ | head -n 3 | tail -n 1 > 1
cat news-latest.xml | grep “title” | sed -e ’s:<title>::g’ | sed -e ’s:</title>::g’ | head -n 3 | tail -n 1 > 2
cat news-latest.xml | grep “description” | sed -e ’s:<description>::g’ | sed -e ’s:</description>::g’ | head -n 3 | tail -n 1 > 3
kdialog –display :0 –title=”$(echo $(cat 2))” –msgbox=”$(echo $(cat 3)) n n n n News as on $(echo $(cat 1))”
fi
cat news-latest.xml > check.xml

___
Please Note : As My Linux Box Is out of Disk Space . I’m Unable to check the KDE Script . But I hope it will run Fine . If any one can Confirm please Drop a Comment
___

  • Save the Above Script in a File and add it to cron job

To add a cron job use following command
[You need to know VI or VIM for this]

crontab -eu username

replace username with your desired username
and add following entry [ which will check every one minute ]

*/1 * * * * /bin/bash   /path/to/the/file/script &> /dev/null

The above command is set to execute every minute.

Here is Screen Shot of The Script

breaking_news

Breaking News Aleart ScreenShot

Short Description about the Script

This script downloads the specified RSS feed and checks against any old versions of the same. If a change is observed , the script extracts the relevant information from the feed and sends the output to different files. These are then displayed using the ALERT command.
PS. This script needs an active Internet connection for its successful execution. (Duh!!)

You can use any other news feed for your Breaking News Alert Box/Live News Ticker on your Linux Machine. If you’re stuck with that or need help/guidance with regard to the code, kindly drop a comment with your original email, so that I could personally respond to you.

Special Thanks To Aravind Jose T. for helping me to pep-up this post !!

Leave a Reply 2480 views, 1 so far today |
Follow Discussion

4 Responses to “Breaking News Alert On Your Linux Machine”

  1. Binny V A Says:

    Nice script. One recommendation - use the notify-send command instead of zenity or kdialog.

    And provide the script as a downloadable text file - wordpress have formatted the code - creating a lot of syntax errors(– is changed to -, etc.)

  2. Kunal Gautam Says:

    @Binny Here is Modified script with notify-send command and thanks for suggestion :)

    Download From here :)

  3. Kunal Gautam Says:

    Source Code will be Unavailable for few days as I’m played with some config badly . Sorry for inconvenience

Trackbacks

  1. Get Breaking News Alert Ticker on your Desktop  

Leave a Reply