Bash script that will automatically turn your WiFi OFF if you connect your computer to an ethernet connection and turn it back ON when you unplug your ethernet cable/adapter/dongle.
Thanks to all folks in https://gist.github.com/albertbori/1798d88a93175b9da00b
- Mac OSX 10+ (tested on Catalina)
- Administrator privileges
cd toggleAirPort/
sudo cp ./toggleAirport.sh /Library/Scripts/
sudo chmod 755 /Library/Scripts/toggleAirport.sh
sudo cp ./com.mine.toggleairport.plist /Library/LaunchAgents/
sudo chown root /Library/LaunchAgents/com.mine.toggleairport.plist
sudo chmod 644 /Library/LaunchAgents/com.mine.toggleairport.plist
launchctl load /Library/LaunchAgents/com.mine.toggleairport.plist
sudo rm /Library/Scripts/toggleAirport.sh
launchctl unload /Library/LaunchAgents/com.mine.toggleairport.plist
sudo rm /Library/LaunchAgents/com.mine.toggleairport.plist
rm /var/tmp/prev_eth_on
rm /var/tmp/prev_air_on
rm /var/tmp/prev_toggle_airport_run
To debug, just run: sudo /Library/Scripts/toggleAirport.sh
and add echo's wherever you'd like
If you get a message that Airport was already ON, try deleting /var/tmp/prev_*