Skip to content

Instantly share code, notes, and snippets.

@wzpan
Last active December 19, 2015 07:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wzpan/5916134 to your computer and use it in GitHub Desktop.
Shell - an applet to notify the network status.
#!/bin/bash
net_stat=1
while true
do
PINGRET=$( ping 8.8.8.8 -c 4 | grep "ttl=" )
[ -z "$PINGRET" ] &&
{
if [ $net_stat -eq 1 ]; then
notify-send -i /usr/share/icons/oxygen/48x48/actions/dialog-cancel.png "Warning" "Bad connection"
net_stat=0
fi
echo Bad connection
}||
{
if [ $net_stat -eq 0 ]; then
notify-send -i /usr/share/icons/oxygen/48x48/actions/dialog-ok-apply.png "Congrats" "Network connected"
net_stat=1
fi
echo Network connected
}
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment