Hello everyone,
I have a simple query regarding the "Add New Space to Mission Control" feature in BetterTouchTool. I'm interested in knowing how to use this feature not just to add a new desktop via Mission Control, but also to automatically switch to it as soon as it's created.
Are there specific steps or shortcuts I should follow to activate this function? Any guidance or tips on how to effectively use this feature would be greatly appreciated.
Thank you for your assistance.
Best regards,
John Jace
1 Like
Are there any solutions, friends? 
I got a hacky solution.
Implementation
Make sure you have a trigger for “Move Right a Space (Without Animation”.
We need the Apple Script to get the trigger. Do so by right clicking on the action and pressing
Copy Apple Script to Activate the Trigger
It should look something like this:
open "btt://execute_assigned_actions_for_trigger/?uuid=EXAMPLE-UUID"
Use this shell script, call it create_space.sh. Put the command where it says CUSTOM COMMAND GOES HERE.
#!/usr/bin/env bash
# Create a new Desktop Space via Mission Control UI (no keystrokes).
# Requires: System Settings -> Privacy & Security -> Accessibility for your terminal (and launcher, if any).
osascript <<'APPLESCRIPT'
do shell script "open -b 'com.apple.exposelauncher'"
delay 0.2
tell application id "com.apple.systemevents"
tell (every application process whose bundle identifier = "com.apple.dock") to ¬
click (button 1 of group 2 of group 1 of group 1)
delay 0.2
key code 53 -- esc key
end tell
APPLESCRIPT
space_number=$(defaults read com.apple.spaces | \
plutil -convert json -o - - | \
jq '.SpacesDisplayConfiguration["Space Properties"] | length')
if [[ -z "$space_number" || "$space_number" -eq 0 ]]; then
echo "Could not determine number of spaces. Exiting."
exit 1
fi
echo "Detected $space_number desktop spaces."
# run the BTT trigger that many times
for ((i=1; i<=space_number; i++)); do
echo "Running trigger for desktop $i..."
# ->CUSTOM COMMAND GOES HERE <-
sleep 0.05 # add a small delay for stability
done
Then save the script and give it execute permissions:
chmod o+rx create_space.sh
run the command in your terminal to see if it works.
./create_space.sh
The first time you run this script you will get a popup asking for interoperability between your terminal and BTT. Select: “Yes, don’t ask again”. Then try running it again to see if it works for you. If it does, then remove the Action: “Add new Space to Mission Control” and create a new Action with that same keybind named “Execute Terminal Command(Async, non-blocking)”. Then add the absolute path to the script.
Here is me running it from the terminal. Adding this command to a keybinding as I explained before is pretty straight-forward.
How it can be improved
The script basically gets the number of spaces n after adding the new space and then does Switch Right n amount of times. This is because as of right now, the action "Switch to Desktop #n" has the animation delay. If there were a new action added to BTT called "Switch to Desktop #n (Without Animation)" for example, then the script can be changed to automatically switch to that Desktop with no animation delay.
2 Likes