Sunday, January 10, 2010

Cricket updates in Ubuntu terminal as a pop-up message

I'm a cricket fan. I like to watch cricket matches. But I don't have a TV in my boding place and exam is coming very closer. Therefore I'm satisfying just getting updates of the match. But to do that I have to go to a relevant website (I recommend http://www.cricinfo.com/) and get the update. But when I'm working with terminal I have waste extra time to go to web browser and watch it. How if the relevant details appear side of my window as a pop-up message. Cool isn't it? Let's try then.
  • First you have to check whether you have the package "libnotify-bin". You can check it by executing following command in your terminal

dpkg --list | grep -i notify

  • If you don't have that, then you have to install it by using our common "apt-get install" command.
  • After that give the following command to see the content of a web page in the terminal. The command format is;
        lynx --dump "web url"

lynx --dump "http://www.cricinfo.com/rsadomestic-09/engine/current/match/423149.html"






  • After looking at the screen shot you can see there is not much information. The reason is most of them are comming under hidden links which you can see under "References"

  • I just want to get the total marks and current batsman score and who are the current bowlers. Those details comes under last URL in this case. Finding it is a different scenario which is not relate to the topic, so I'm not going to explain it further.

lynx --dump "http://www.cricinfo.com/rsadomestic-09/engine/current/match/423149.html?view=live;wrappertype=live"



  • As you can see in the image I got relevant information as well as some additional stuff. From next command I filter out what I exactly need.

lynx --dump "http://www.cricinfo.com/rsadomestic-09/engine/current/match/423149.html?view=live;wrappertype=live" | grep -A 20 -e "KwaZulu-Natal Inland 259 & 352/5d"



  • Then by using following command I will be able to get the above detail as a pop up message side of my terminal window.

notify-send "`lynx --dump "http://www.cricinfo.com/rsadomestic-09/engine/current/match/423149.html?view=live;wrappertype=live" | grep -A 20 -e "KwaZulu-Natal Inland 259 & 352/5d"`"



  • As you can see that message will fadeout after some seconds. From the below command I get the updated information in every 5 minutes (5m)

while [ 1 ]; do notify-send "`lynx --dump "http://www.cricinfo.com/rsadomestic-09/engine/current/match/423149.html?view=live;wrappertype=live" | grep -A 20 -e "KwaZulu-Natal Inland 259 & 352/5d"`"; sleep 5m; done

Have fun.

1 comment: