MacOS – Restoring window configuration for monitor setups

configurationdisplaymacos

I would like to achieve the same effect as is described in this question, which doesn't seem to have a suitable answer.

I develop on a macbook pro. Often I use it on its own, but sometimes I connect it to an external display (of various sizes).

When I connect to an external display, all of my applications move to that display as it is plugged in. I then need to move most of them back on to the smaller (built in) display by hand and resize them to the smaller screen: I generally only have my development environment and terminals running on the larger display.

When I disconnect from the external display, all my Apps move back on to the built in display, but aren't resized.

The behaviour I would like (or a close approximation):

  • When I connect an external display, the OS remembers the window layout from the last time this display was used and restores it.
  • When I disconnect the display, the OS remembers the layout I had in the disconnected state and restores that.
  • When I connect a new display, nothing happens. The OS leaves it to me to move windows on to it that I want to be there.

I note that the OS seems to know connected monitors by name, so it should be possible to have the configuration be specific to the particular monitor that I have plugged in.

If there are no existing Apps that support this, I'd love any leads on the APIs I should be looking at that will let me develop an App to do this.

I'm currently using Mavericks, but I'll probably upgrade to Yosemite fairly soon.

Thanks.

Best Answer

The App "Stay" that I discovered today does this extremely nicely.

Thanks to this answer on the Super User S.E. for the link.