Add my imdown script
- ID
a3ab84a- date
2022-03-19 10:00:07+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
f52a701- message
Add my imdown script Co-authored-by: Brett Terpstra <me@brettterpstra.com>- changed files
1 file, 32 additions
Changed files
imdown (0) → imdown (751)
diff --git a/imdown b/imdown
new file mode 100755
index 0000000..c8d0c31
--- /dev/null
+++ b/imdown
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# Bash functions for notifying when your internet connection comes back up
+# From https://brettterpstra.com/2018/05/04/shell-tricks-what-to-do-when-you-cant-do-internet/
+
+set -o errexit
+set -o nounset
+
+# A truly atrocious way to get your attention
+nag() {
+ while true; do
+ for phrase in "$@"; do
+ afplay /System/Library/Sounds/Ping.aiff
+ say "$phrase"
+ sleep 3
+ done
+ done
+}
+
+# Poll a DNS resolver to see when you can reach it, then notify
+imdown() {
+ until ping -W1 -c1 8.8.8.8; do
+ sleep 5;
+ done
+ nag \
+ "internet connection is back up\!" \
+ "Skynet is thinking" "your tribulation is over\!" \
+ "Praise what gods may be. internet\!" \
+ "O M G we're online" \
+ "In the words of Dr. Frankenstein, it's alive\!"
+}
+
+imdown