Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what do the parameter values in AppleSymbolicHotKeys plist dict represent?

tl;dr

what does the first parameters value in com.apple.symbolichotkeys:AppleSymbolicHotKeys represent?

details...

the AppleSymbolicHotKeys structure

the OS X symbolic hotkeys plist file at

~/Library/Preferences/com.apple.symbolichotkeys.plist

stores hotkeys in a dict called as 'AppleSymbolicHotKeys' with entries that look like

<action:int> = Dict {
    enabled = <enabled:bool>
    value = Dict {
        type = <type:string>
        parameters = Array {
            <param_1:int>
            <param_2:int>
            <param_3:int>
        }
    }
}

example:

10 = Dict {
    enabled = true
    value = Dict {
        type = standard
        parameters = Array {
            56
            28
            1572864
        }
    }
}

pro tip: you can take a look with

/usr/libexec/PlistBuddy -c "Print :AppleSymbolicHotKeys" ~/Library/Preferences/com.apple.symbolichotkeys.plist

the values

action:int

this is the id of the action the hotkey will take. there are reasonably complete lists around the net, do some googling 'cause i don't have enough points to post links or whatever.

enabled:bool

whether the hotkey is enabled.

type:string

always seems to be 'standard'.

param_1:int

this is the one i can't get. it doesn't seem necessarily connected to params 2 and 3, though it often changes when the other params are changed. for instance...

i can click Restore Defaults in the System Preferences -> Keyboard -> Shortcuts -> Mission Control view, and it will set "Switch to Desktop 1" to "ctrl + 1". reading the value for that action (number 118), i see that param_1 is set to 65535. if i manually set the key combo to "ctrl + 1" in the UI, i get param_1 set to 49. the values of param_2 and param_3 stay the same throughout.

param_2:int

this seems to be key codes from

/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h

for the non-modifier key to be pressed, except for the value 65535, which is very common in param_1, and shows up in param_2 on my local machine for actions 160, 163 and 175.

param_3:int

seems to indicate the modifier key to be depressed, as according to

MODS = {
  0=>"No modifier",
  131072=>"Shift",
  262144=>"Control",
  524288=>"Option",
  1048576=>"Command",
  393216=>"Shift + Control",
  655360=>"Shift + Option",
  1179648=>"Shift + Command",
  786432=>"Control + Option",
  1310720=>"Control + Command",
  1572864=>"Option + Command",
  917504=>"Shift + Control + Option",
  1441792=>"Shift + Control + Command",
  1703936=>"Shift + Option + Command",
  1835008=>"Control + Option + Command",
  1966080=>"Shift + Control + Option + Command",
}

where you will notice the numbers representing multiple modifiers are the sum of the modifiers they represent, e.g.

"Shift + Control" = 393216 = 131072 + 262144 = "Shift" + "Control"

so...

any insight would be greatly appreciated, and hope this can serve as a reference for the info i dug up to anyone else approaching the subject.

like image 222
nrser Avatar asked Feb 19 '14 10:02

nrser


2 Answers

It is the ascii code of the letter on the key, or -1 (65535) if there is no ascii code. Note that letters are lowercase, so D is 100 (lowercase d).

Sometimes a key that would normally have an ascii code uses 65535 instead. This appears to happen when the control key modifier is used, for example with hot keys for specific spaces.

There is a nice list of keys and values from 2011 here, along with some other good details:

http://hintsforums.macworld.com/showthread.php?t=114785

like image 51
drawnonward Avatar answered Nov 15 '22 06:11

drawnonward


The numerical values in nrser's answer make more sense when viewed in hexadecimal form:

0x000000 => "No modifier",
0x020000 => "Shift",
0x040000 => "Control",
0x080000 => "Option",
0x100000 => "Command",

The others are simply bit-wise-ORs of the above values, for example:

0x060000 => "Shift + Control",
0x180000 => "Command + Option",
like image 31
Alex Tomlinson Avatar answered Nov 15 '22 07:11

Alex Tomlinson