It’s always annoyed me that when I connect my MacBook to my CalDigit that the WiFi doesn’t automatically turn off. I’ve worked around this in a few ways over the years, but finally wrote a simple tool to solve this annoyance.
I’ve been using it for the last couple weeks and so far, it’s been working flawlessly (). So I figured I’d share it as a contribution back to this community.
It’s only been tested on macOS 14.3.
-
Download the script and save in somewhere in your path as
wifi-toggle.sh
(any name will work). -
Open a terminal and make the script executable:
chmod 755 wifi-toggle.sh
-
Run
networksetup -listnetworkserviceorder
to find the name of your ethernet device. The name you need is after the number in parens (eg. for me that’s(2) CalDigit TS3
) -
Open the script in a text editor and change the variable
ETHERNET_REGEX
to match the name of your ethernet device (without the(#)
). For me that’s it would look like:
ETHERNET_REGEX="CalDigit TS3"
-
Run
wifi-toggle.sh on
and it will install a launchd service in~/Library/LaunchAgents
.
Now …
- If your ethernet is active, your wifi will automatically turn off
- If your ethernet is inactive, your wifi will automatically turn on.
If you want to stop the automatic toggle, run wifi-toggle.sh off
.
❯ wifi-toggle.sh help
Automatically toggle macOS Wi-Fi based on ethernet status (using launchd)
Usage: wifi-toggle.sh [ on | off | help ]
on - start automatically toggling Wi-Fi (install launchd service)
off - stop automatically toggling Wi-Fi (uninstall launchd service)
run - Toggle Wi-Fi status (run by launchd)