Extras
Scripting
You can use Apple Script (or Java Script with 3rd party addition) to
- start profile
- stop profile
- list all profiles
Download:
These are examples which demonstrate how to do it:
List all profiles
set reportText to ""
tell application "AlmostVPNProMenuBar"
repeat with i from 1 to count profiles
set
reportText to reportText & return &
(name of profile i) & " " &
(state of profile i) & " (" &
(stateComment of profile i) & ")"
end repeat
end tell
display alert reportText
Download:
Start Profile
display dialog "Enter Profile Name:"
default answer "default" buttons {"Cancel", "OK"} default button 2
set the profileName to the text returned of the result
tell application "AlmostVPNProMenuBar"
start (profile named profileName)
end tell
Download:
Stop Profile
display dialog "Enter Profile Name:"
default answer "default" buttons {"Cancel", "OK"} default button 2
set the profileName to the text returned of the result
tell application "AlmostVPNProMenuBar"
stop (profile named profileName)
end tell
Download:
Start/Stop All Profiles
Download:
JavaScript instead of AppleScript
Thanks to OSA it is possible to use JavaScript for your scripting needs instead of AppleScript. In order to be able to do it, you need to install JavaScript OSA component. Once you have completed installation instructions you should be good to go.
var avpn = MacOS.appBySignature( "aVPN" );
// To get profile object for profile "foo"
var profileFoo = avpn.profiles[ "foo" ];
// To start profile "foo"
avpn.start( profileFoo );
// To stop profile "foo"
avpn.stop( profileFoo );
// To start ALL profiles
for( var i = 0; i < avpn.profiles.length; i++ ) {
avpn.start( avpn.profiles[ i ] );
}
// To list all profiles
var message = ""
for( var i = 0; i < avpn.profiles.length; i++ ) {
message = message + avpn.profiles[ i ].name + " " + avpn.profiles[ i ].state + "\n";
}
MacOS.message( message );
Command Line Interface
This is for you, command line junkies. avpnctrl allows you to:
- start profile
- stop profile
- list all profiles
- wait for profile to get into state
Download:
avpnctrl start
To start profile with given name
avpnctrl start <profile name>
avpnctrl stop
To stop profile with given name
avpnctrl stop <profile name>
avpnctrl startAll
To start ALL profiles
avpnctrl startAll
avpnctrl stopAll
To stop ALL profiles
avpnctrl stopAll
avpnctrl list
To get list of all profiles with state
avpnctrl list
Result looks like this
<profile name>|<profile state> ... <profile name>|<profile state>
avpnctrl wait
To wait for profile to get into particular state
avpnctrl wait <profile name> <running|idle|fail> [<timeout>]
NOTE If timeout is not specified or is 0, avpnctrl will wait forever
NOTE If timeout specified, exit code will be 0 if profile have got into the state and 1 if timeout occur.