I've created sample daemon app for this purpose. You can find it on Github.
To make it run:
- Compile it using Xcode.
Network Listener.app to
.networkDisconnected to Your
It will automatically run when You log in to Your account. If You want to test it run this in Terminal:
launchctl load -S Aqua -w ~/Library/LaunchAgents/Network-Listener.plist
Scripts receive SSID name as arguments.
Feel free to change it for Your needs. In case of any problems let me know.
Everything was created to show the possibilities, a lot of things can be improved.