I've set up a bunch of scripts that need to happen when I connect my thunderbolt dock at home (disable wifi, enable bluetooth, ...).
To detect the thunderbolt dock I make use of the following
<?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>
This service listens to
launchd for a network change to happen (detecting the wired network that is connected to the dock). This setup seems to work but it is really slow to detect and act when the dock is connected.
It already takes a long time for the dock network to be set up, but after that it also takes another 5 seconds before the script actually gets called.
Is there a way to make the service detect the network changes any faster (without setting up a polling service)?