Johnny Matthews | Create a new virtual desktop in MacOS.

MacOS has the ability to create multiple virtual desktops. I find this feature super handy because it allows me to have separate desktops for separate pieces of work. Annoying, Apple doesn't include a built-in hot-key to create a new desktop. However, with the use of Albert, we can create a script to create a new desktop for us! This was written on 31st of May 2021.

  1. Install Alfred.

  2. Buy the pro version.

  3. Select Workflows and create a blank workflow.

  4. Enter the following info:

    Field Value
    Name Create a new desktop.
    Description Creates a new virtual desktop using a script.
    Category Productivity

    Create a workflow screen.

  5. Click Create.

  6. Right-click in the workflow panel and select Input > Keyword.

    Select input > keyword.

  7. Enter the following information:

    Field Value
    Keyword desktop
    Arguments dropdown No arguments
    Title Desktop
    Subtitle Creates a virtual desktop.

    Create a keyword.

  8. Right click the block that was just created and select Insert after > Actions > Run script.

    Select Insert after > Actions > Run script.

  9. Set the Language to osascript (AS).

  10. Leave with input as argv and running instance sequentially as their defaults.

  11. Paste the following code into the textbox:

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

  13. Open Alfred and search for desktop.

    Search for desktop.

  14. That’s it!

Now, every time you search for desktop in Alfred, MacOS should create a new desktop for you! You could also follow the steps above to create a script to delete an open desktop if you were so inclined.