I'm apparently not the only one who wants to know (How can I change modifier keys in "System Preferences > Keyboard > Modifier Keys..."). I've tried watching the System Preferences app with dtruss, but that doesn't seem to be possible on 10.10.3 (which is what I'm on right now), and I'm not even sure that that would be at all useful if System Preferences is just getting settings from cfprefsd. Watching cfprefsd with dtruss doesn't seem to catch the relevant file access.
Does anyone know of an API to get this information? Something in gestalt perhaps?
Ok - answering my own question. I threw together a little program that uses kqueues to watch file system changes. I watched my file system for modifications when I changed the setting in System Preferences, and I saw:
So the setting is in
~/Library/Preferences/ByHost/.GlobalPreferences.<UUID>.plist
. I'm not sure what the UUID is - something do to with OpenDirectory? (UPDATE: apparently this UUID is an identifier for your machine).Anyways, in
.GlobalPreferences.<UUID>.plist
, we see entries like:1452:610 is the decimal VID:PID for the USB keyboard/trackpad combo in my 2012 Macbook Pro, and any other keyboard that's been plugged in to my computer and has had modifier settings remapped will have a similar entry.
0
seems to be the Caps Lock key,2
and10
seem to be left and right CTRL,3
and11
seem to be left and right Option, and4
and12
seem to be left and right Command.So from the above, you can see that I have my Caps Lock key mapped to left CTRL.
It looks like the settings in
.GlobalPreferences.<UUID>.plist
are a part of your standard user defaults. So you can get at these settings easily enough just by doingAll user Preferences are stored in
~/Library/Preferences/com.apple.???