Saturday, July 18, 2009

Quick popup

Today I was downloading a file using bittorrent. I was using my laptop. I kept it on my lap and started working on a document when download was going on. After a while I noticed that the download has stopped. When I checked, I found that the network cable had come out. This repeated for a while and I found that how much ever I try, the cable will come out slowly as it was not really fitting in the socket. By the time I notice this, 10-15 minutes would have elapsed without network.

How do I know just when it gets disconnected? I was running XFCE. I knew that XFCE allowed to create widgets that can do this for me. But, reading and understanding them and again writing one will take time. Also, I cannot use any built in one as I want a real popup. (My panel auto hides. Can't waste height on a wide screen monitor).

This is what I did.

while sleep 1 ;
do
ping -c 3 www.google.com ;
[ $? == "1" ] && xterm -e "wall trouble && sleep 10";
done

Thats all! When my network went down, xterm just screamed on my face that there is trouble. Then I will push the cable a bit and press ctrl-c to dismiss the message. I love xterm... :)

No comments: