Skip to main content

web/imdown

1#!/usr/bin/env bash
2# Bash functions for notifying when your internet connection comes back up
3# From https://brettterpstra.com/2018/05/04/shell-tricks-what-to-do-when-you-cant-do-internet/
5set -o errexit
6set -o nounset
8# A truly atrocious way to get your attention
9nag() {
10 while true; do
11 for phrase in "$@"; do
12 afplay /System/Library/Sounds/Ping.aiff
13 say "$phrase"
14 sleep 3
15 done
16 done
19# Poll a DNS resolver to see when you can reach it, then notify
20imdown() {
21 until ping -W1 -c1 8.8.8.8; do
22 sleep 5;
23 done
24 nag \
25 "internet connection is back up\!" \
26 "Skynet is thinking" \
27 "your tribulation is over\!" \
28 "Praise what gods may be. internet\!" \
29 "O M G we're online" \
30 "In the words of Dr. Frankenstein, it's alive\!"
33imdown