Switch all apps to new monitor in one key stroke

Hi have 2 screens and work 20 minutes on each. I want to be able to switch all currently open windows/apps from one screen to another in one command. Can I do this with total spaces? I figure mission control should do this also but will not allow switch between screens. only between alternate desktops on each screen. please help

Actually you could do this with a script using the TotalSpaces2 API.

If you have a fully licensed copy of TotalSpaces2 I could send you a script that would do the job.

Hi Stephen, Thanks for the reply. Happy to buy it but it is telling me it wont work on the current os 10.11 (El Capitan). I just upgraded as it said the mission control functionality had been upgraded. Wait … saw your note have done the terminal changes, paid for app. please send me the script.

OK… do you have the same number of spaces on each screen?

(I assume you are running with Displays have Separate Spaces turned on?)

yes and yes

The ruby script is here:

You have to
sudo gem install totalspaces2
before you can run it, which will require Xcode installed.

Alternatively, and easier if you aren’t a developer, I packaged a version for you here:


Thank you. I am not a developer. I downloaded the zip, uncompressed it , double clicked swapscreens. terminal said process completed. (I also tried putting “sudo gem install totalspaces2” into terminal and this did not work. I also put the whole script into terminal and it gave this “Error :failed to build gem native extension”).

how do i now activate it/ use it - is there a window in total spaces2?


Ok, so when I unpack the archive I get this

The first time I run it, I need to ctrl-click on SwapScreens and choose open.

Then it opens a terminal and runs the command. The result for me is as follows:

That’s ok, because I do not have my external screen with me. But if both screens were plugged in, and have the same number of spaces, then the windows should move. Or it will print an error as to why not.

Thank you Stephen.

I have run the terminal successfully. I cannot see how it changes things though. I do, show grid (F6 is my shortcut) , click on say a chrome window. I can as usual switch between spaces on each monitor. I can drag an application across from one monitor’s space to the other monitor’s space. I cannot though switch all spaces from one monitor to the other.

sorry to ask but cant see another way around.

Hi Adam,

When you run the program, it should move all the windows from one display to the other.

It only does this if you have exactly the same number of spaces on each display. It doesn’t move the spaces, just the windows.

If it doesn’t work, I’m curious to know why - does the a terminal window stay on the screen after the program has run? If so does it have any error message such as in my example above?

Thanks Stephen. I now understand you need to run the command each time to invoke the switch. It does switch all the open applications (except mail which doesn’t move for some reason). It doesn’t show any errors. Is it possible to switch mail also ( i notice mail does not appear when you go to overview grid view)? and is it possible assign a sort cut to this terminal script?

I’m not sure why mail wouldn’t move - if it doesn’t show in the overview grid, that must mean that it’s not using a regular window. I’ll need to investigate that.

If you have Alfred it would be pretty simple to set up a workflow to trigger the script.

Otherwise there are a few hints on the net, for instance: http://blog.fosketts.net/2010/08/09/assign-keyboard-shortcut-applescript-automator-service/

Or BetterTouchTool can do this kind of thing.

Thanks Stephen. Great help. I have solved the mail thing as I can have a mail window for each screen open simultaneously.