7

How do I create a new Desktop ("Space") on macOS using only the keyboard?

4

Found a solution with apple script here, credit to @codehearts: https://github.com/ianyh/Amethyst/issues/143

tell application "System Events"
  do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
  click button 1 of group "Spaces Bar" of group 1 of group "Mission Control" of process "Dock"
  do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
end tell

The script can be either saved as a ...applescript file with #!/usr/bin/osascript line to run in the shell, or bind to a key directly in Alfred to start a new desktop through Mission Control.

1
  • Note that in Big Sur the location should be changed to /System/Applications/Mission\ Control.app
    – Yar
    Sep 15 at 0:22
1

I'm not sure there are any native solution to this problem, but there are third-party applications that can help.

One of them is BetterTouchTool, a program that can aid operating a Mac in several ways.

Another is Hammerspoon, but that requires you to write some code yourself.

I doubt these are the only two, only the two I know of.

1
  • 1
    Have you checked yourself? I have BetterTouchTool but there is only keyboard shortcut option to switch to (already created) desktop but doesn't create new one.
    – zcahfg2
    Aug 20 '19 at 10:18
0

I'm using yabai as a tilling window manager. It has two commands to create and destroy desktop respectively, i.e.

#Create space on the active display

yabai -m space --create

#Delete focused space and focus first space on display

yabai -m space --destroy

Then I use skhd to bind hotkey with these commands as

cmd + alt - n : yabai -m space --create

cmd + alt - w : yabai -m space --destroy

The manpage about yabai and skhd are listed as:

  1. yabai

  2. skhd

1
  • 3
    This will work only if System Integrity Protection(SIP) is disabled Dec 23 '20 at 19:42
0

Building on @Ipstone's answer, for BigSur I had to add quoted form of and update the location of Mission Control to get it to work.

So my apple script looks like:

#!/usr/bin/osascript

tell application "System Events"
  do shell script quoted form of "/System/Applications/Mission Control.app/Contents/MacOS/Mission Control"
  click button 1 of group "Spaces Bar" of group 1 of group "Mission Control" of process "Dock"
  do shell script quoted form of "/System/Applications/Mission Control.app/Contents/MacOS/Mission Control"
end tell

Then I can run it with osascript create_new_space.scpt or bind it to a keystroke with skhd.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .