Thunderbolt / usb-c dockingstation connection as a trigger? - HowTo?

Title says it all I guess: Is there a way to use the connection of a Thunderbolt / usb-c docking station to trigger Keyboard Maestro actions?

Ideally what I would like to acomplish:

Working on a i9 macbook I tend use Spaces for apps. I'm don't know if there's ways to automate Spaces.
In the office, I connect to an older Caldigit TS2 thunderbolt docking station. As the i9 macbook has 4 ubc-c / Thunderbolt ports, I need to use the Apple Thunderbolt 3 (usb-c) to Thunderbolt 2 adapter cable.

Ideally I would like to transform 3 Spaces to show up / move to 3 connected monitors. (Or 3 specific monitor locations (x, y & window size)
So that when connecting the dock, the Apps in the Spaces would show up on their respective monitor in their respective position. (supposin you have a very large monitor e.g. 49")

What I was thinking of:
System Information shows a particular UID, Vendor Name, Device ID.
Is that something that can be used in a trigger?

Looking forward to any helpful input!

Howdy, welcome to the forum! As you might have already figured out, this is a great community full of people who love to help.

This is definitely possible. I don’t use Spaces, so I can’t speak to the desired content of your macro, but I can shed some light on how to trigger it.

For example, I have a few macros that are triggered when I attach my TB4 dock. I use either the Power Status Changed trigger or the USB Device trigger for this. My first action is an if, which runs a shell script to determine if my particular device in question (for instance, my Stream Deck, ASUS monitor, Logitech speakers etc.) are connected. I have included one of my macros as an example on which you can base your own.

This example is triggered when my MBP is connected to power (since my TB4 dock provides power) or when my Stream Deck is connected/disconnected. Regardless of triggering method, the shell script returns a list of attached USB devices, and if the Stream Deck appears in that list, the macro launches the SD software (among other things); otherwise it quits the software. Again, this is just an example of how you can do things based on USB devices being connected/disconnected, as well as power status changes, since a lot of Thunderbolt docks also provide power when attached.

Let me know if you have any questions and we can chat further!


01)Stream Deck- Launch or quit with device connection.kmmacros (6.0 KB)

Macro Screenshot (click to expand/collapse)

I am looking to do something similar, only I am trying to monitor a Thunderbolt cable that gets connected to my MacBook Pro. is there any way to monitor for (Device Name:MacBookPro17,1) as it appears there is no way to monitor of the thunderbolt cable even though it is USB-C.

Any suggestions would be greatly appreciated....Thx

Perhaps you could use the USB Device trigger to detect when the cable is attached/detached? If it shows up in the device tree it might work. Try this example macro, and if it doesn’t work we can think of something else.

Alert if MacBook is attached or detached (for testing).kmmacros (5.9 KB)

Macro Screenshot (click to expand/collapse)

I do not believe it shows up under the USB tree but I will check when I get home and will also try your macro trigger….Thx

1 Like

As I suspected this Thunderbolt device is not seen as a USB device. I have looked for anything that I could use as a trigger under System Report and cannot find anything.

Hopefully you may have an idea that I have overlooked....Thx

Might not help you about triggering by thunderbolt connection to you MacBook, but I am able to use the connection of my HP Thunderbolt Dock G2 as a trigger as it also show up as an USB-hub:

It's device name shows up here in my System Information:

But I guess you've checked there to see if anything pops up when you've connected your Macbook?