Skip to content

Instantly share code, notes, and snippets.

@mkleucker mkleucker/VPN.scpt
Created Mar 9, 2012

Embed
What would you like to do?
Connects / Disconnects to a VPN and pushes its action to Growl
-- config: change the VPN name here (as listed under the network preferences)
set VPNname to "LRZ VPN"
tell application "System Events"
set isGrowlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
if isGrowlRunning then
tell application id "com.Growl.GrowlHelperApp"
set the allNotificationsList to ¬
{"Connection Status"}
set the enabledNotificationsList to ¬
{"Connection Status"}
register as application ¬
"VPN Connector" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Network Utility"
end tell
end if
tell application "System Events"
tell current location of network preferences
set VPNservice to service VPNname
if exists VPNservice then set isConnected to connected of current configuration of VPNservice
if isConnected is false then
connect VPNservice
if isGrowlRunning then
tell application id "com.Growl.GrowlHelperApp"
notify with name ¬
"Connection Status" title ¬
"Start VPN" description ¬
"Verbindung wird hergestellt" application name "VPN Connector" with sticky
delay 2
close all notifications
end tell
end if
else
disconnect VPNservice
if isGrowlRunning then
tell application id "com.Growl.GrowlHelperApp"
notify with name ¬
"Connection Status" title ¬
"Stop VPN" description ¬
"Verbindung wird beendet" application name "VPN Connector" with sticky
delay 2
close all notifications
end tell
end if
end if
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.