Network Change Event to Trigger Action to Mount Network Share

I’m trying to come up with a way to have KM trigger an action based on when my network connection / name changes. When I connect my Mac to work, either through ethernet, WLAN, or VPN, I want to open and connect to a Network Share on our work network. Is there a way to trigger an action based on Network Name change?

There is a Trigger for Wireless Networks, but not expicitly for a wired ethernet connection. So, two questions:

  1. Do you always use a wireless connection?
  2. Do you always login first?

If yes to #1, then you can use the Wireless Network trigger.
If no, but yes to #2, then you can use the Login trigger, and then get the connection information to determine which network you have logged in to.

Use this command in an Execute Shell script:
system_profiler SPNetworkDataType

like this:
image

You can then use an IF/THEN Action with this RegEx to determine if you have an ethernet connection:
(?mi)^ ([\w-_ ]+):\n\n +Type: Ethernet\n +Hardware.+\n +BSD Device Name: (.+)\n +IPv4 Addresses: (192[\.\d]+)$

like this:
image

Questions?

  1. No I don’t connect to my work’s wireless network.
  2. I don’t login either when I get to work. I just open my MacBook Pro and wake it from sleep, and then I plug in my thunderbolt 3 dock which has an Ethernet connection. It then immediately connects to the wired network over Ethernet.

I was hoping there was a way to detect when the network name changes.

Then you could use the Wake trigger, and use the scripts I gave you to test the network connection.

BTW, IMO it is highly dangerous to allow use of your Mac (or any computer) without a login.

Oh, I do have a login and a strong password, but when I wake my machine from sleep, I unlock with Touch ID, since I have one of the newer MacBook Pro models. Not sure if that would trigger a login event?

It should. You're just using a different method of providing credentials.
Try it -- create a simple test macro that shows a notification when triggered by login.

Doesn’t seem to work. I put my machine to sleep, woke it up, logged in, both with touch id, and again with password, and it didn’t work.

Please post your macro. Something's not setup right.

You are using the

Right?

No, I’m testing with the Login trigger.

image