加快launchctl执行速度
我已经设置了一堆脚本,当我在家里连接我的霹雳码头时需要发生这种情况(禁用wifi,启用蓝牙......)。 为了检测霹雳码头,我使用了以下launchctl服务: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>romeovs.dock.agent</string> <key>ProgramArguments</key> <array> <string>/Users/romeovs/.bin/dock/run.sh</string> </array> <key>RunAtLoad</key> <true/> <key>LaunchEvents</key> <dict> <key>com.apple.notifyd.matching</key> <dict> <key>com.apple.system.config.network_change</key> <dict> <key>Notification</key> <string>com.apple.system.config.network_change</string> </dict> </dict> </dict> </dict> </plist> 此服务侦听launchd是否发生网络更改(检测连接到扩展坞的有线网络)。此设置似乎有效,但在连接扩展坞时检测和操作非常慢。 设置dock网络需要很长时间,但之后在脚本实际调用之前还需要5秒钟。 有没有办法让服务更快地检测到网络变化(没有设置轮询服务)?