MacOS – How to change Mission Control shortcuts from the command line

macosmission-controlshortcutterminal

I have been trying to figure this out for a long time. I have a pretty typical Mac OS provisioning script:

https://gist.github.com/ryanpcmcquen/b2e608311f286a4ab3e1

I would like to change the Mission control shortcuts to all be Ctrl+Alt+... instead of Ctrl+.... For example, the default is: Ctrl+Up to activate Mission Control. I would like to change this to Ctrl+Alt+Up, because the current shortcut conflicts with other programs I use.

Note that I am already aware of how to do this through System Preferences > Keyboard > Shortcuts, I am looking for a scriptable, command line solution.

EDIT:
Thanks to @user3439894 I went through and made a script to change all the plist keys to what I want them to be. The only issue is, it does not work. 🙁

Here is what I have so far:

#!/bin/bash
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 32 "{enabled = 1; value = { parameters = (65535, 126, 2883584); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 33 "{enabled = 1; value = { parameters = (65535, 125, 2883584); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 34 "{enabled = 1; value = { parameters = (65535, 126, 3014656); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 35 "{enabled = 1; value = { parameters = (65535, 125, 3014656); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 79 "{enabled = 1; value = { parameters = (65535, 123, 2883584); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 80 "{enabled = 1; value = { parameters = (65535, 123, 3014656); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 81 "{enabled = 1; value = { parameters = (65535, 124, 2883584); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 82 "{enabled = 1; value = { parameters = (65535, 124, 3014656); type = standard; }; }"
chown -Rf `whoami` ~/Library/Preferences/com.apple.symbolichotkeys.plist;
defaults read com.apple.symbolichotkeys

Best Answer

This is not a direct answer although I hope the information presented herein will help you get to a direct answer.

I can tell you what changes in which file when you change the default keyboard shortcut for Mission Control from Control-Up Arrow to Control-Option-Up Arrow. It's the "Item 2 Number" of the "parameters" Array in the "value" Dictionary of the "32" Dictionary and "34" Dictionary of the "AppleSymbolicHotKeys" Dictionary in the /Users/$USER/Library/Preferences/com.apple.symbolichotkeys.plist file.

Here's a defaults read representation of the com.apple.symbolichotkeys.plist file structure as it relates to the changes made under the defined circumstances above.

Mission Control with the default of Control-Up Arrow

{
    AppleSymbolicHotKeys =     {
        32 =         {
            enabled = 1;
            value =             {
                parameters =                 (
                    65535,
                    126,
                    2359296
                );
                type = standard;
            };
        };
        34 =         {
            enabled = 1;
            value =             {
                parameters =                 (
                    65535,
                    126,
                    2490368
                );
                type = standard;
            };
        };
    };
}

Mission Control changed to Control-Option-Up Arrow

{
    AppleSymbolicHotKeys =     {
        32 =         {
            enabled = 1;
            value =             {
                parameters =                 (
                    65535,
                    126,
                    2883584
                );
                type = standard;
            };
        };
        34 =         {
            enabled = 1;
            value =             {
                parameters =                 (
                    65535,
                    126,
                    3014656
                );
                type = standard;
            };
        };
    };
}

The BUGS section of the defaults man page says:

Defaults can be structured in very complex ways, making it difficult for the user to enter them with this command.

And this is a perfect example as it will be a very complex command line using defaults to write the target values to the target array elements, if it's even doable. Just an FYI... If you're going to attempt to do a defaults write com.apple.symbolichotkeys ... command make sure you've backed up the target file first.

The other option is to use an AppleScript to change the settings by navigating the System Preferences GUI and that too will be a little complex in comparison to setting a top level object, which the target here is not. I'm not even sure it's doable however if I needed an automated way then I'd figure it out however I do no have the time to figure out either method, sorry.

At least you now know what changes where and from there you may be able to either figure it out on your own or get additional help with knowing this little bit more.

Here's a clipped image in Xcode of the com.apple.symbolichotkeys.plist file.

enter image description here

BTW I trapped the changes using a third party utility that logged the filesystem changes and then converted that information to a more human readable output to provide this information.