启动的plist中无法识别LaunchEvents键(检测USB设备) [英] LaunchEvents key unrecognized in launchd plist (detecting USB device)
问题描述
当USB设备插入Mac OS X系统时,我想启动一个特定的应用程序.我遵循了这篇SO帖子中给出的食谱.但是它似乎无法识别LaunchEvents
键:当我重新启动系统时,在控制台上看到以下消息:
I want to launch a specific app when a USB device is plugged in to a Mac OS X system. I've followed the recipe given in this SO post. But it appears the LaunchEvents
key is not recognized: When I reboot my system, I see the following message on the console:
com.apple.launchd.peruser.501[173] (com.example.program) Unknown key for dictionary: LaunchEvents
我正在运行OS X 10.6.8,并且在此版本的OS X中完全不支持xpc_events.如果是这种情况,我有什么选择?
I am running OS X 10.6.8, and it's entirely possible that xpc_events aren't supported in this version of OS X. If this is the case, what are my alternatives?
(第二个较小的问题:是否有一种方法可以在不重新引导系统的情况下强制重新读取我的.plist文件?这将加快调试时间!)
(As a second, lesser question: is there a way to force a re-read of my .plist file without rebooting the system? It would speed up debugging time!)
~/Library/LaunchAgents/com.example.plist
的全部内容如下. (请注意,为了进行调试,我只是尝试使用/usr/bin/open启动Terminal.app.一旦我做了很多工作,我将交换我的真实程序.)
The entire contents of ~/Library/LaunchAgents/com.example.plist
follows. (Note that for debugging, I'm simply trying to launch the Terminal.app using /usr/bin/open. I'll swap in my real program once I get this much working.)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.program</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>/Applications/Utilities/Terminal.app</string>
</array>
<key>LaunchEvents</key>
<dict>
<key>com.apple.iokit.matching</key>
<dict>
<key>com.apple.device-attach</key>
<dict>
<key>idProduct</key>
<integer>8963</integer>
<key>idVendor</key>
<integer>1659</integer>
<key>IOProviderClass</key>
<string>IOUSBDevice</string>
<key>IOMatchStream</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
推荐答案
要重新加载,请先卸载然后再加载:
To reload first unload and then load:
launchctl unload ~/Library/LaunchAgents/com.example.plist
launchctl load ~/Library/LaunchAgents/com.example.plist
这篇关于启动的plist中无法识别LaunchEvents键(检测USB设备)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!