0

I am used to Linux environments but I have to use a Mac for work. Now I am wondering why it seems to be impossible to open new workspaces in OSX without using the mouse? I know how to switch between them or move windows in different workspaces, when they are already open, but there seems no way to open or close a workspace just by keyboard shortcuts. I am already using Amethyst but it seems not to help with this problem. Does anybody know a solution?

I already tried using an AppleScript, that I found in another thread. But it doesn't work since, Mission Control is not available as an application in the current OSX.

User
tell application "System Events"
    do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control"
    tell process "Dock"
        set countDesktops to count buttons of list 1 of group 1
        --new desktop
        click button 1 of group 1
        --switch to new desktop
        repeat until (count buttons of list 1 of group 1) = (countDesktops + 1)
        end repeat
        click button (countDesktops + 1) of list 1 of group 1
    end tell
end tell

I asked ChatGPT to adjust it and this came out:

tell application "System Events"
    -- This would be where you'd simulate opening Mission Control, 
    -- but since we can't directly do "Control + Up Arrow", we might consider other methods 
    -- or manual activation before running the script.
    tell process "Dock"
        set countDesktops to count buttons of list 1 of group 1
        -- Assuming Mission Control is already open, attempt to create a new desktop
        click button 1 of group 1
        delay 1 -- Wait for the animation to complete; adjust delay as necessary
        -- Attempt to switch to the new desktop, assuming it's been created
        set newCountDesktops to count buttons of list 1 of group 1
        if newCountDesktops > countDesktops then
            click button newCountDesktops of list 1 of group 1
        end if
    end tell
end tell

I saved it as an AppleScript in Automator and assigned a hotkey to it. When I now open mission control manually and press my assigned hotkeys, nothing happens.

How may I debug this?

9
  • Might be easier to create all the Spaces/Desktops you need up front, and the just switch between them.
    – nohillside
    Commented Feb 25 at 17:43
  • How to do it "up front" without using a mouse?
    – jo87casi
    Commented Feb 25 at 17:46
  • Enter Mission control and click on the "+" to create all the spaces you might need (up to 16). This needs the mouse, but you only have to do it once.
    – nohillside
    Commented Feb 25 at 18:02
  • this comment doesnt relate to my question. im fully aware that i can use the mouse instead.
    – jo87casi
    Commented Feb 25 at 18:10
  • IMHO using the mouse once to create all spaces is easier than creating and debugging a script which does the same (and will only be used a few times).
    – nohillside
    Commented Feb 25 at 18:20

1 Answer 1

0

Better Touch Tool (BTT) can be used to do this.

Open the BTT configuration window. Select Keyboard Shortcuts from the top dropdown list. There are two plus sign buttons at the bottom of the window, click the rightmost to Add a New Trigger. Enter a keyboard shortcut as the Tigger Name (mine is ⇧⌃⌥⌘ C; note that I've mapped the modifiers to the capslock key as a "hyperkey"). Then in the Action Configuration panel, select the macOS Functionality section, and then the Add New Space to Mission Control action.

This shows my setup:

enter image description here

You must log in to answer this question.

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