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.shsudo cp ./com.mine.toggleairport.plist /Library/LaunchAgents/sudo chown root /Library/LaunchAgents/com.mine.toggleairport.plistsudo chmod 644 /Library/LaunchAgents/com.mine.toggleairport.plistlaunchctl load /Library/LaunchAgents/com.mine.toggleairport.plist
sudo rm /Library/Scripts/toggleAirport.shlaunchctl unload /Library/LaunchAgents/com.mine.toggleairport.plistsudo rm /Library/LaunchAgents/com.mine.toggleairport.plistrm /var/tmp/prev_eth_onrm /var/tmp/prev_air_onrm /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_*