Back to notes

macOS

14.09.2026
•

Testing

Reaching internet connection (macOS)

Sometimes my laptop loose internet connection. Then I usually check reaching sever 8.8.8.8 and when it's back (and I did not notice) I want to be informed by "beep" sound.
sh
while true; do if ping -c 1 8.8.8.8 &> /dev/null; then printf "%s %s\n" "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" success && afplay /System/Library/Sounds/Funk.aiff else printf "%s %s\n" "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" fail fi; sleep 5; done