Skip to content

Instantly share code, notes, and snippets.

@PatelUtkarsh
Last active January 3, 2019 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatelUtkarsh/058056f3c19fea91ebfab2172ddcd315 to your computer and use it in GitHub Desktop.
Save PatelUtkarsh/058056f3c19fea91ebfab2172ddcd315 to your computer and use it in GitHub Desktop.
Get notification when internet is up, This uses pushbullet api.
function notifynet(){
isdown=0
echo "Pres CTRL+C to stop..."
while :
do
sleep 5
if [ $(ping -q -c 1 -W 1 8.8.4.4 >/dev/null) ]; then
echo -n "1"
if [ $isdown -eq 1 ]; then
isdown=0
wget -qO- "push.example.com?msg=webpush&title=Awesome&secret=SecretForAuthReplaceME" &> /dev/null
fi
else
echo -n "0"
isdown=1
fi
done
}
@PatelUtkarsh
Copy link
Author

PatelUtkarsh commented Nov 18, 2018

Add this to .bashrc or .zshrc and run notifynet in tmux/screen session once. then onwards whenever internet is off and back on it will notify.

For notification, you can use another script as mentioned here: https://gist.github.com/PatelUtkarsh/56500891d659a1cdefbfa2c42721e377

This assumes you have an active mobile internet to get the notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment