Skip to content
Is that a bad idea? I mean, do you anticipate any changes to the directory layout or config file metadata comments in the foreseeable future?
Cheers,
James
how will i get the mentioned list of all connections?
Thanks!
Help with new AppleScript support
Got a problem with Viscosity or need help? Ask here!
I noticed that there were some additions to the AppleScript library for Viscosity.
I maintain the Quicksilver plug-in and some features can be added if I could query the state of a connection, but I can’t seem to get it to work. (I know very little about AppleScript.)
When I do something like this:
I maintain the Quicksilver plug-in and some features can be added if I could query the state of a connection, but I can’t seem to get it to work. (I know very little about AppleScript.)
When I do something like this:
Code: Select all
The result is:tell application "Viscosity"
set someVar to the state of "My Connection"
end tell
error "Can’t get state of \"My Connection\"." number -1728 from «class stat» of "My Connection”I know the name of the connection is valid because I have no problem with:
Code: Select all
Am I doing this right?tell application "Viscosity”
disconnect "My Connection"
end tell
Hi Skurfer,
The old connect/disconnect functions reference directly by name, which isn't a nice way of doing things. We've kept them around for backwards compatibility, but also introduced the ability to get a list of all connections (a list of connection objects). You could loop through this list to find the connection you want (and get its name/state, or tell it to connect/disconnect), or do something like so:
James
The old connect/disconnect functions reference directly by name, which isn't a nice way of doing things. We've kept them around for backwards compatibility, but also introduced the ability to get a list of all connections (a list of connection objects). You could loop through this list to find the connection you want (and get its name/state, or tell it to connect/disconnect), or do something like so:
Code: Select all
Cheers,tell application "Viscosity"
set someVar to state of connections where name is equal to "My Connection"
end tell
James
Web: https://www.sparklabs.com
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
The old connect/disconnect functions reference directly by name, which isn't a nice way of doing things.OK, then I should probably start doing this instead of using the name directly, right?
Code: Select all
Seems to work.tell application "Viscosity" to connect (connections where name is connName)
We’ve … introduced the ability to get a list of all connections (a list of connection objects). You could loop through this list to find the connection you want (and get its name/state, or tell it to connect/disconnect), or do something like so:I started down the path of using AppleScript to index the connections, since that seems like the most reliable way to get them, but then it occurred to me that this only works if Viscosity is running (or if not, it will launch the application). Quicksilver should be able to index the connections without the app running, so I’m going to stick with the current method of scanning config files in ~/Library/Application Support/Viscosity/OpenVPN.
Is that a bad idea? I mean, do you anticipate any changes to the directory layout or config file metadata comments in the foreseeable future?
OK, then I should probably start doing this instead of using the name directly, right?Ideally, yes.
Is that a bad idea? I mean, do you anticipate any changes to the directory layout or config file metadata comments in the foreseeable future?It's not pretty, but if it works, it works! No changes are currently planned to the way connections are stored.
Cheers,
James
Web: https://www.sparklabs.com
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
- Posts: 2
- Joined: Fri May 23, 2014 1:34 am
James wrote:Hi Skurfer,Hi James,
The old connect/disconnect functions reference directly by name, which isn't a nice way of doing things. We've kept them around for backwards compatibility, but also introduced the ability to get a list of all connections (a list of connection objects). You could loop through this list to find the connection you want (and get its name/state, or tell it to connect/disconnect), or do something like so:
Code: Select allCheers,tell application "Viscosity" set someVar to state of connections where name is equal to "My Connection" end tell
James
how will i get the mentioned list of all connections?
Thanks!
Hi markco3000,
Please see the following support article for how to control Viscosity using AppleScript:
http://www.sparklabs.com/support/contro ... _with_app/
If, for example, you wanted to output a list of connection names:
James
Please see the following support article for how to control Viscosity using AppleScript:
http://www.sparklabs.com/support/contro ... _with_app/
If, for example, you wanted to output a list of connection names:
Code: Select all
Cheers,tell application "Viscosity"
repeat with conn in connections
name of conn
end repeat
end tell
James
Web: https://www.sparklabs.com
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
- Posts: 2
- Joined: Fri May 23, 2014 1:34 am
Thanks a lot James,
maybe i write some more about my intention. I try to integrate Yubikey in our VPN. To do so, i need to alter the keychain objects from viscosity with the one time password before starting the viscosity connection with a "before connect" script.
As you store the keychain objects by the "internal" number of the connection, i would need that number too. Is there a way to get this connection number?
Example:
name: my VPN connection
keychain item: Viscosity/4/ovpn
I
maybe i write some more about my intention. I try to integrate Yubikey in our VPN. To do so, i need to alter the keychain objects from viscosity with the one time password before starting the viscosity connection with a "before connect" script.
As you store the keychain objects by the "internal" number of the connection, i would need that number too. Is there a way to get this connection number?
Example:
name: my VPN connection
keychain item: Viscosity/4/ovpn
I
Hi markco3000,
I'm afraid you'd need to examine the file system to find out the raw connection IDs: they're not available through AppleScript.
That said, for things like YubiKey we recommend using Viscosity and OpenVPN's static challenge support which is built especially for one time passwords (instead of using the Username/Password dialog). Information about static challenge support can be found in the following post:
http://www.sparklabs.com/forum/viewtopi ... 3677#p3677
Cheers,
James
I'm afraid you'd need to examine the file system to find out the raw connection IDs: they're not available through AppleScript.
That said, for things like YubiKey we recommend using Viscosity and OpenVPN's static challenge support which is built especially for one time passwords (instead of using the Username/Password dialog). Information about static challenge support can be found in the following post:
http://www.sparklabs.com/forum/viewtopi ... 3677#p3677
Cheers,
James
Web: https://www.sparklabs.com
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
8 posts
Page 1 of 1