Unplugging external monitor converges both 1st spaces into 1st internal space


My setup looks like this:

MacOSX 10.9.4
Internal: 9 spaces
External: 3 spaces

As soon as a I unplug the external monitor, I have 11 internal spaces, instead of 12. Space 1 from the external monitor converges with Space 1 from my MacBook. Space 2 and 3 of the external monitor are appended to my internal spaces, so that Space 2 becomes Space 10 and Space 3 becomes Space 11.

I would assume that all Spaces from the external monitor are appended to the internal Spaces (1->10, 2->11, 3->12), but that’s not happening.

Issue: Desktop disappearing when external monitor disconnected


Indeed, space 1 is special on each monitor, and is not appended like the other ones are when the monitor is unplugged.

Even though TotalSpaces arranges your spaces in a grid, the underlying spaces are managed by OSX, and this is an OSX behaviour. But to be honest I do not know why apple decided to do this.

It is a reasonable argument for TotalSpaces2 to manage this somehow, but working round this problem is pretty hard because each space has a pretty complex setup that would need transferring.

It hasn’t been a huge priority though because it hasn’t generated very much feedback.


Thank you very much for the info.

I didn’t know that this was normal behavior. Too bad, because it is really annoying. Anyways, I don’t expect you to fix this. I just noticed it and thought it might be a bug.


Former Linux Mint (Cinnamon) user here and this is really my only (but dealbreaker) issue with the app. I wanted to use default OSX but the only way to sync spaces (sync grids) on OSX nukes the menu bar on the secondary monitor so this app seemed the best solution.

On Mint, there is ONLY synced grids, such that when you unplug the secondary display, applications and windows on the secondary display on space X would be moved to space X on the primary display (minimised apps would stay minimised).

That said, not sure on the best solution for users who don’t have sync grids checked - perhaps minimise to dock on unplug, and when they click on that app, it’ll open on their current space.

In all cases, when replugging the secondary display, all spaces on secondary display would be empty?


My problem only described that the first space of the external monitor would merge with the internal first space. After replugging the external display, the stuff is moved back to the first space on the external monitor.
I don’t know how this works with synced grids, but I believe the behavior should be similar. So no, the spaces on the external display would not be empty. The would be as they were before.

So internally MacOSX must still keep track of the spaces and which windows belong to them.

I’ve even started to use 2 external monitors plus the internal from the MacBook, so this gets even weirder. After unplugging I have basically 3 spaces on my internal display in parallel. But w/o the possibility to differentiate. Just all the windows and apps from those 3 spaces are in one space. After re-plugging the external displays, the windows are magically put back to their respective first spaces just as they were before.


This is still there with High Sierra. It beings down my productivity when I unplug my monitor and work with my Macbook Pro’s display. I hope that it gets fixed soon, not from apple, but at-least a workaround from TotalSpaces. I will definitely pay again just to see this feature! :slight_smile:


I did make a helper app that may help. It’s called Display Spaces Manager, and you can find it here:

It allows you to save and restore your spaces setup depending on which displays you have connected.

Does this go any way to resolving the issue? If not, then let me know exactly how you’d like things to work and I’ll look at it.

ps. you need a licensed copy of TotalSpaces2 for helper apps to work.


Hello Stephen, I am afraid it does not address the problem

Here is my scenario

I usually use my Macbook Pro in Camshell mode (with display lid closed) when I am in my office desk.

I have two 4k monitors hooked with my MBP (it pretty much gives you a desktop like scenario, because I hide by MBP under the table :wink: )

I have seven spaces in each monitor totalling 14 spaces and I have sync grids checked and also “Displays have separate Spaces” under Mission Control Preferences.

Here is the screen shot of my layout for both monitors

Now when I unplug my external monitors and work with my MBP display the layout automatically transforms to two row (this is expected, each row corresponds to spaces in external monitors when they were connected), and when I reconnect my monitors again the layout automatically gets restored with 7 spaces for each monitor like it were before I disconnected them.

The actual problem is that the first space from each monitor gets merged into single space, this makes only 13 spaces instead of actual 14. However OS X somehow seems to remember which window in the merged spaces belongs to which monitor (first space) so when I reconnect them they automatically gets moved to respective monitor (spaces) like how they were before.

Merging of spaces makes it difficult to navigate between the respective space from the monitors using up & down arrow. First row contain all the spaces of Monitor 1 but second row contains N - 1 (6 spaces) from monitor two, hence they loose the association.

This is how the layout looks after disconnecting monitors. I expect all the 14 spaces be there or atleast a empty space in the second row’s first position so the mapping between monitors are preserver when navigating using up & down arrow.


I understand.

Each monitor has one space (the first one) that belongs to that monitor only - when the monitor is unplugged macOS removes that space completely.

TotalSpaces isn’t involved in this, and I think it would be a great deal of work to modify the system behaviour correctly.

I think it’s probably possible to make a plugin to fix this though. The behaviour you want is: when a space is removed (via monitor unplug), to have it replaced by creating a new space and placing it in position 8. And when a space is added (via monitor plugging in), you want to remove the extra space that was added in position 8.

Is that correct?


@stephen You are correct, that’s the behaviour I want. Plugin is great. if it is too complex to implement then consider the following as alternate approach (it will work for me since I don’t actually use the first space in all my monitor due the space merge problem)

Since the problem I am facing is related to navigation between the rows. If there is an option to alter the shortcut to go to correct space on up/down arrow then it would solve the problem.

so if I am in row one lets say space number 4, if I click down arrow currently it takes me to 11 which is expected behaviour but since the second row has a missing space in first position the correct order would be to go to space 10.

Here is use case

if current space is 4 click down arrow then go to 11 - 1 (subtract one for missing space). if current space is in 10 and pressing up arrow should take to 3 + 1 (add one since the top row has an extra space in first position which is missing in current row)

Addition and subtraction has only to be done when navigating between the Row 0 & Row 1 since Row 2,3,… if present will be compatible (since they too miss a space in first position) with others expect Row 0


I made a plugin for you.


Note: you must successfully run

gem install totalspaces2

in a terminal window before this plugin will work.

(I tried to bundle the required ruby libraries, but it wouldn’t work because of differences in ruby versions between OS versions.)

When you run it there will be an icon in the menu bar that you need to click on each time you plug or unplug your monitor. The script will then try to balance your spaces by adding or removing one depending.

Simply clicking on the menubar item is enough, you don’t need to choose the menu item (it’s informational).

This will only work with a registered copy of TotalSpaces2.


@stephen There is an error upon running the plugin app.

I did install ruby library using gem install totalspaces2. I use rvm to manage my ruby version and my current default ruby version is 2.4.1 (stable), I hope this information helps.


It’s trying to use system ruby, so please install the gem there.


rvm use system
sudo gem install totalspaces2

Let me know if that works


By the way, the script is very simple, and you can see the source here:

The app is just a wrapper for this made with Platypus.


@stephen I tried using system ruby, the error is still occurring.


Can you paste me the output of this?

rvm use system
sudo gem install totalspaces2

Also do you find you can run desktop_equaliser.rb from the command line? (If you download it from the github gist)



The script is executing without any error when run in terminal but it doesn’t seem to work as intended.
TotalSpaces2.number_of_spaces returns 7 even though I have 14 spaces, I am tinkering it (https://github.com/binaryage/totalspaces2-api/tree/master/ruby), is there any document on the exposed api?


API docs here:


FWIW, this issue really annoys me too. If you could find it in your heart (and calendar) to try to resolve it, we’d all be eternally grateful.