Last active
January 3, 2019 01:54
-
-
Save PatelUtkarsh/058056f3c19fea91ebfab2172ddcd315 to your computer and use it in GitHub Desktop.
Get notification when internet is up, This uses pushbullet api.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this to
.bashrc
or.zshrc
and runnotifynet
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.