Ideas on how to switch screen res when monitor connected

There’s a lot of similar topics out there, but I’m wondering if someone has a solution here:

I want to have my laptop screen resolution change when I plug in an external monitor. (Reason being that I keep my MBP’s screen res scaled for more room when I’m using the screen close up, but when it’s “docked,” i have it farther away and it’s tricky to read the small type with my middle-aged eyes.)

I’ve tried the two utilities mentioned in this hint: https://apple.stackexchange.com/questions/173866/how-can-i-set-the-display-settings-using-command-line

But these don’t seem to work with the latest version of the OS… or something. And I’m also a little unclear on how to trigger.

Anyone have ideas on how to do this? I’d rather avoid UI scripting opening system preferences and walking through all the buttons.

And I’m also a little unclear on how to trigger

Would a USB trigger? work

Or would it not work if it's not USB and, say, HDMI?

Good idea! I can't get the monitor as a USB device (it doesn't show up), but my dock DOES show up. I also found this swift script that lets you change the screen res and works in High Sierra.

So between the USB trigger and this script, I have a working solution.

The way this works is that it uses the swift script to identify the monitor with the right resolution, then switches the screen resolution of that monitor to the correct resolution. This WILL fail if you have multiple monitors with the same resolution. Then there's two macros - one for plug in, one for unplug.

You'll need to change the shell script paths and resolutions accordingly to your preferences.

Screen Res Switch on Dock Connection.kmmacros (5.6 KB)