Skip to content

Instantly share code, notes, and snippets.

@drewmccormack
Last active March 13, 2021 20:27
Show Gist options
  • Save drewmccormack/78a1e9deb4f592822615 to your computer and use it in GitHub Desktop.
Save drewmccormack/78a1e9deb4f592822615 to your computer and use it in GitHub Desktop.
Keeps your OS X WiFi connected to the interwebs.
#!/usr/bin/env bash
# If your OS X WiFi connection stops working, but can be fixed by
# toggling WiFi off and then on, this script can help prevent mouse arm.
# Pings Apple's server repeatedly, toggling WiFi off/on when a connection times out.
while true ; do
curl --head --silent --connect-timeout 10 http://www.apple.com/my-wifi-keeps-dropping-out > /dev/null
if [ $? -ne 0 ] ; then
networksetup -setairportpower en1 off
networksetup -setairportpower en1 on
fi
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment