internet.sh
by
Harald Hoyer
—
last modified
Oct 09, 2009 09:50 AM
Simple shell script, which uses zenity to display a notification icon in the desktop notification area.
internet.sh
—
text/x-sh,
656 bytes
File contents
#!/bin/bash
exec 3> >(zenity --notification --listen)
set_red() {
echo "tooltip: Internet disconnected" >&3
echo "icon: /home/harald/soundkonverter-0.3.9/src/pics/ledred.png" >&3
}
set_green() {
echo "tooltip: Internet connected" >&3
echo "icon: /home/harald/soundkonverter-0.3.9/src/pics/ledgreen.png" >&3
}
get_state() {
wget -q -O - 'https://speedport.ip/cgi-bin/webcm?getpage=../html/top_newstatus.htm' | grep -q 'aktiv' && return 0
return 1
}
oldstate="off"
while true; do
get_state
state=$?
if [ $state != $oldstate ]; then
[ $state -eq 0 ] && set_green || set_red
fi
oldstate=$state
sleep 5
done
Harald Hoyer