有谁知道OSX在“系统偏好设置">中将设置存储在何处.键盘>修饰键? [英] Does anyone know where OSX stores the settings in System Preferences > Keyboard > Modifier Keys?

查看:97
本文介绍了有谁知道OSX在“系统偏好设置">中将设置存储在何处.键盘>修饰键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显然不是唯一想知道的人(中更改修改器键.我曾尝试用dtruss观看系统偏好设置"应用程序,但在10.10.3上似乎无法实现(这就是我现在正在使用的功能),我甚至不确定这是否完全可以如果系统偏好设置"只是从cfprefsd获取设置,则很有用.用dtruss观看cfprefsd似乎无法捕获相关的文件访问.

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.

有人知道要获取此信息的API吗?也许是格式塔里的东西?

Does anyone know of an API to get this information? Something in gestalt perhaps?

推荐答案

好-回答我自己的问题.我编写了一个小程序,该程序使用kqueues监视文件系统更改.在系统偏好设置"中更改设置时,我看着文件系统进行了修改,并且看到:

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:

'/Users/ted/Library/Preferences/ByHost/.GlobalPreferences.3F1C...9C34.plist.V1Ut9hp' kevent: ident=44, filter=KQ_FILTER_VNODE, flags=KQ_EV_ADD|KQ_EV_CLEAR, fflags=KQ_NOTE_WRITE|KQ_NOTE_CHILD|KQ_NOTE_PDATAMASK

因此设置在~/Library/Preferences/ByHost/.GlobalPreferences.<UUID>.plist中.我不确定UUID是什么-与OpenDirectory有关系吗? (更新:显然,此UUID是您计算机的标识符.)

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).

无论如何,在.GlobalPreferences.<UUID>.plist中,我们看到如下条目:

Anyways, in .GlobalPreferences.<UUID>.plist, we see entries like:

<key>com.apple.keyboard.modifiermapping.1452-610-0</key>
<array>
    <dict>
        <key>HIDKeyboardModifierMappingDst</key>
        <integer>2</integer>
        <key>HIDKeyboardModifierMappingSrc</key>
        <integer>0</integer>
    </dict>
</array>

1452:610是我的2012 Macbook Pro中USB键盘/触控板组合的十进制VID:PID,已插入计算机并重新映射了修饰符设置的任何其他键盘也会有一个类似的条目. 0似乎是Caps Lock键,210似乎是左右CTRL,311似乎是左右Option,而412似乎左右命令.

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 and 10 seem to be left and right CTRL, 3 and 11 seem to be left and right Option, and 4 and 12 seem to be left and right Command.

因此,从上面可以看到,我的Caps Lock键映射到了左侧的CTRL.

So from the above, you can see that I have my Caps Lock key mapped to left CTRL.

.GlobalPreferences.<UUID>.plist中的设置似乎是标准用户默认设置的一部分.这样一来,您就可以轻松轻松地获得这些设置

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 doing

[[NSUserDefaults standardUserDefaults] objectForKey:@"com.apple.keyboard.modifiermapping-1452-610-0"];

这篇关于有谁知道OSX在“系统偏好设置"&gt;中将设置存储在何处.键盘&gt;修饰键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆