How can I open an application when a secondary monitor is connected?

I use SecondBar to add a menu bar to an external display. I've added it to my login items, but I don't want it to open when there isn't an external display. How do I open SecondBar when a secondary monitor is connected?


Take a look at the free/open source app ControlPlane.

You can trigger different actions based on context-sensitive rules, including launching an app in response to connecting a display.