Mac OS X,  Mass Deployment

Defaults & symbolichotkeys in Mac OS X

Front Row is awesome. Hot keys are awesome. Typos are not. While zipping along, typing my fool heart out, I tend to fat finger about enough to drop my words per minute in half at times. Occasionally, my typos will land me in an annoying spot, with some application opening: often that application is Front Row. Which led me to unmapping the hot key. But then of course, since I reimage my machines a lot, I wanted to put that into my image…

Hot keys are stored in com.apple.symbolichotkeys.plist, in a users ~/Library/Preferences. You could setup a system with the exact key mappings that you wish to have, use managed preferences to send specific key strokes into the property list or script the augmentation of the file with the defaults command.

Within the com.apple.symbolichotkeys.plist file a dictionary called AppleSymbolicHotKeys and a number of options that correspond to options in the Keyboard Shortcuts defined in the Keyboard System Preference pane, under the Keyboard Shortcuts tab.

Each shortcut entry is a nested dictionary, with a boolean key for whether it is enabled or not and a value dictionary nested even further within that. The value dictionary has a parameters array for the keys that invoke the action and a key that is a string for type (that is always set to standard). That parameters array is comprised of three items, aptly named: Item 0, Item 1 and Item 2. Those items are filled with numbers that map to a key on the keyboard or a 0 if the key is not used. Some of these keys include:

  • 50: ~
  • 52: Enter
  • 53: Escape
  • 122: F1
  • 120: F2
  • 99: F3
  • 118: F4
  • 96: F5
  • 97: F6
  • 98: F7
  • 100: F8
  • 101: F9
  • 109: F10
  • 103: F11
  • 111: F12
  • 105: F13
  • 107: F14
  • 113: F15
  • 131072: Shift
  • 262144: Control
  • 524288: Option
  • 1048576: Command

Note: A useful tool for finding key codes for combinations of keys is Full Key Codes, from bajram.com.

Some of the entries in the list that can be controlled, along with their corresponding numeric identifier in the file:

  • 32: All Windows
  • 33: Application Windows
  • 36: Desktop
  • 62: Dashboard
  • 73: Front Row (my goddess of the fat finger)

Note: If you have one that is not in this list, then simply copy the plist, make the change, open both in your favorite property list editor and either eyeball them for the delta or use the diff command.

Now, let’s look at setting that symbolichotkeys property list to set the Front Row (Dictionary 73 within Dictionary AppleSymbolicHotKeys to disable, by changing the enabled key to 0, and then leaving the value dictionary as is by copying it back in with the same values (if you care: delimited from the enabled key with a ; and defined as a a dictionary based on the content between the {} with an array inside of it, defined using parenthesis to start and stop the array, followed with another semicolon to delimit the end of that key followed by the type keypair followed by yet another semicolon to end each open key).

defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 73 “{enabled = 0; value = { parameters = (65535, 53, 1048576); type = ‘standard’; }; }”

To then re-enable:

defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 73 “{enabled = 1; value = { parameters = (65535, 53, 1048576); type = ‘standard’; }; }”
You could also map different keystrokes by sending different numerical values (some are shown above) into the parameters array.