Moving windows depending on which external monitor is connected - KM? SOmething else?

I have an M1 MBA that I bring between home and office.

At home, my primary monitor is an external ASUS display, and if it’s open at all, the built-in display is off to the left and decidedly secondary.

At work, the built-in display is my primary screen (laptop sits on a Rain Design mStand), and I have an external Dell off to the right, VESA-mounted on an arm - I do use that fairly often, but it’s a good 60 degrees off to the right, so not really glanceable.

The dock is set up to be in the appropriate place for each location.

What I want:

I would like to automatically move all open windows to the primary display when I change locations - to the internal display at home, and the external monitor at work. And I would like new windows to originate on the primary display by default. (Right now, if I am running Mail at home, close the laptop, and bring it to work, then not only is my Mail window on my external display (not primary at work), but even if I move it to the built-in display, if I hit Cmd-N to start a new email, the window open on the external monitor by default…)

I have gotten part of the way there with Keyboard Maestra - as it turns out, there is a shell script fragment that can detect the hardware description of any external display, and I can match for that to know where I am.

(If you’re curious, it’s:

system_profiler SPDisplaysDataType | grep -B 1 Resolution:

type or paste code here


However, I'm not finding an easy way to move windows en masse to a specific display. I do have Moom 4, which can run custom actions under some circumstances, but I don't see how to move all windows rather than just specific ones. There are some old Applescripts on the KM Discourse that don't seem to work. I'm kind of stumped - any advice would be most welcome.

You may wish to loop through the windows of each open app. That being said, I’d really recommend asking this over on their forum. Not because this is a bad place for it, but just because you’ll get 20x the engagement over there, and it’s set up for people to upload example macros directly to that forum.

1 Like

I believe you want to use Moom’s Layout action, not the move action. Save a layout for each set of apps in each location. Then activate the appropriate Layout as needed.