Maintain allocation of windows to spaces on restart and external monitor unplugging I use spaces heavily and I have my windows arranged in a particular order. If I restart every application will be launched in the same space with many empty spaces.

If I unplug my external monitor, instead of adding those spaces to the others, the windows in them get resized and dumped into the macbook screen. They may or may not go back at funny sizes when the monitor is plugged back in.

I'd like to keep windows in specific spaces regardless of what else is going on.
After some experimentation, I've been able to keep all windows in the proper spaces across unplug/replug by adding 1 extra blank space on my laptop screen.
While plugged in to external monitor, I have #1 on monitor and #2 &amp; 3 on the laptop (call these 1a, 2a, 3a).  #2a is kept blank.
Upon unplugging, there is some merging and rearranging of the Spaces happening:

1a + 2a -&gt; 1b   (This is why I left 2a blank)
3a -&gt; 2b

End result when unplugged is my original stuff which was separated is still separated, I just don't have the extra blank display.
There's probably some way to extrapolate this merging behavior with more than 3 displays.