Thanks! That's exactly the post I came across after and ended up implementing. I was not super keen on having something run in background perpetually every N seconds. Right now I compiled script as an app and run it under my "Login Items" but its not ideal because I have the app open in my task switcher. I tried to run under apple launchd which worked ok except that on shutdown the script does not stop and causes an abnormal OS shutdown.
Be really nice if there was a way to have BTT trigger.
Check out SwitchResX. It monitors... monitors. When you switch to certain layouts or certain conditions are met that quality for a layout you've defined (aka Monitors A, B, C are present), if can fire off a script of your choosing.
You can create a conditional activation group that matches the resolutions you have when your external monitor is connected. Then you can setup a trigger that activates if this conditional activation group becomes true.
tell application "Image Events" to set m to count displays
tell application "BetterTouchTool"
set c to get_number_variable "MonitorCount"
if c is missing value then
set_number_variable "MonitorCount" to m
if m = c then
else if m > 1 and c = 1 then
tell application "BetterTouchTool" to set_number_variable "MonitorCount" to 2
launch application "HazeOver"
launch application "LinearMouse"
launch application "MonitorControl"
else if m = 1 and c > 1 then
tell application "BetterTouchTool" to set_number_variable "MonitorCount" to 1
quit application "HazeOver"
quit application "LinearMouse"
quit application "MonitorControl"
script detects you got multi monitor or not. im just using 1 external not sure works on 3 or more screens correctly. you must change numbers in conditions if you have 2 monitors then detecting third one