Last active
December 23, 2015 09:19
-
-
Save mrnovalles/6614060 to your computer and use it in GitHub Desktop.
A small script to quit Transmission as soon as the VPN connection is down.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on idle | |
tell application "System Events" | |
tell current location of network preferences | |
set vpnConnection to the service "VPN" | |
-- Check if Transmission is running | |
tell application "System Events" | |
set transmissionIsRunning to (count of (every process whose name is "Transmission")) > 0 | |
end tell | |
-- Check if VPN is down | |
if current configuration of vpnConnection is not connected then | |
if (transmissionIsRunning = true) then | |
set app_name to "Transmission" | |
do shell script "killall " & app_name | |
end if | |
connect vpnConnection | |
-- Check if VPN is up | |
else if current configuration of vpnConnection is connected then | |
if (transmissionIsRunning = false) then | |
tell application "Transmission" to activate | |
end if | |
end if | |
end tell | |
return 10 | |
end tell | |
end idle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment