How Do I Detect If I am Connected to a Wired, Ethernet Network?

I need a macro that will connect via Wi-Fi IF my Mac is NOT connected via a Ethernet cable, and IF I am connected via Ethernet, then disable Wi-Fi.

But I do not see a way to determine IF my Mac is connected via Ethernet.
Note that even when I am connected via Ethernet, the WiFi connection is also available.

Any ideas?

Hey JM,

Here’s a place to start:


Thanks for the suggestion, Chris.
Unfortunately I’m so ignorant of shell scripts that I can’t really make use of anything from that reference.

Surely there must be a routine somewhere that can return true/false to isEthernetConnected()

I’ll keep looking. . .

Hey JM,

Run this from an Execute a Shell Script action:

ifconfig -a

Then search for a line that looks like this:

media: autoselect (100baseTX ) status: active

If you find it then your Ethernet is active.

You can use something like this to toggle Wi-Fi on/off.


1 Like

Thanks, Chris.

From your two scripts, I have cobbled together this simple test macro.
It seems to work, but I still hope to find direct AppleScript solution to detecting the Ethernet connection.

###MACRO:   Turn off wi-fi when on ethernet

~~~ VER: 1.0    2016-11-05 ~~~

Turn off wi-fi when on ethernet.kmmacros (6.8 KB)



Here's the RegEx I used:
(?im)media: autoselect \(1000?baseT.+\n.+status: active$