Posts Tagged ‘GTK’

Internet Connection monitoring script for the GNOME panel

Wednesday, January 14th, 2009

I was having issues with my Internet connection lately. My connection used to drop after using it for a while and the router used to lose the IP address. I decided to write a simple script that would sit on the GNOME panel and tell me the current state of my Internet connection.

I found a Java-GNOME library that would allow me to program for the GTK using Java. I wrote a simple Java program that would connect to www.google.com and check if it can get the content. It would do this periodically (every 10s) with a connection timeout of 5s. If the site is reachable, the program would show a green icon in the notification area. If not, it will show a red blinking icon.

To use it here is what you need to do:

  1. Extract this archive to a scripts sub-directory in your home folder.
  2. In your .profile, add the following lines at the end
  3. #Invoking Internet connection monitoring script
    $HOME/scripts/networkmonitor.sh

Internet Connection is upInternet Connection is up

Just log in again and you should see a green/red icon in your GNOME panel notification area. In case you face any problems try running $HOME/scripts/network_monitor.sh from a terminal and also check the sh file executable permission.