Automatically disable WiFI when ethernet is connected

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 (:crossed_fingers:t2::crossed_fingers:t2::crossed_fingers:t2:). So I figured I’d share it as a contribution back to this community.

It’s only been tested on macOS 14.3.

  1. Download the script and save in somewhere in your path as wifi-toggle.sh (any name will work).

  2. Open a terminal and make the script executable: chmod 755 wifi-toggle.sh

  3. 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 )

  4. 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"

  5. 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)
1 Like

Do you unlock your Mac or approve some operations with your Apple Watch?

I think for that you need WiFi enabled, even when connected via Ethernet?

Not sure sorry, I don’t have an Apple Watch.

I can say that the sharing of the cut & paste clipboard between macOS and iOS works with only Bluetooth enabled.

Location Services requires WiFi be on, so I never turn it off. However I do make sure the service order has Ethernet above Wi-Fi. System Settings → Network → … → Set Service Order:

I guess I’m just not really sure what the benefit here is.

Having connected Wi-Fi and ethernet at the same time, so long as like @tomalmy pointed out your service order has ethernet (thuderbolt bridge and USB LAN too if they’re present) prioritised above Wi-Fi then there are still only benefits and no downsides to having your Wi-Fi enabled.

adamshand,
Thank you for this script. That really helped easing the pain…
I have both a CalDigit TS3 Plus and a CalDigit TS4 dock.
Using this:
ETHERNET_REGEX=“Thunderbolt Ethernet”
enables the script to operate for both docks on macOS 14 Ventura and macOS 15 Sequoia.