diff --git a/PluginDirectories/1/viscosity.bundle/Icon.png b/PluginDirectories/1/viscosity.bundle/Icon.png new file mode 100644 index 00000000..e91b579d Binary files /dev/null and b/PluginDirectories/1/viscosity.bundle/Icon.png differ diff --git a/PluginDirectories/1/viscosity.bundle/examples.txt b/PluginDirectories/1/viscosity.bundle/examples.txt new file mode 100644 index 00000000..4c566eb2 --- /dev/null +++ b/PluginDirectories/1/viscosity.bundle/examples.txt @@ -0,0 +1,6 @@ +vis ~connection(MyVPN) +vis open ~connection(MyVPN) +vis connect ~connection(MyVPN) +viscosity ~connection(MyVPN) +viscosity open ~connection(MyVPN) +viscosity connect ~connection(MyVPN) diff --git a/PluginDirectories/1/viscosity.bundle/get_viscosity_connection.js b/PluginDirectories/1/viscosity.bundle/get_viscosity_connection.js new file mode 100644 index 00000000..bdb6e272 --- /dev/null +++ b/PluginDirectories/1/viscosity.bundle/get_viscosity_connection.js @@ -0,0 +1,5 @@ +ObjC.import('stdio') +function run(connName) { + var viscosity = Application('com.viscosityvpn.Viscosity') + return viscosity.connections[0].name() +} diff --git a/PluginDirectories/1/viscosity.bundle/info.json b/PluginDirectories/1/viscosity.bundle/info.json new file mode 100644 index 00000000..eff5b3f2 --- /dev/null +++ b/PluginDirectories/1/viscosity.bundle/info.json @@ -0,0 +1,9 @@ +{ + "name": "viscosity", + "displayName": "Connect to Viscosity", + "description": "Opens the named Viscosity connection.", + "examples": ["vis myvpn", "viscosity connect myvpn", "viscosity"], + "categories": ["Utilities"], + "creator_name": "Anatole Paine", + "creator_url": "github.com/springheeledjak" +} diff --git a/PluginDirectories/1/viscosity.bundle/open_viscosity_connection.js b/PluginDirectories/1/viscosity.bundle/open_viscosity_connection.js new file mode 100644 index 00000000..8138bf35 --- /dev/null +++ b/PluginDirectories/1/viscosity.bundle/open_viscosity_connection.js @@ -0,0 +1,14 @@ +ObjC.import('stdio') +function run(connName) { + var viscosity = Application('com.viscosityvpn.Viscosity') + var conns = viscosity.connections + var conn = (connName != '') + ? conns.whose({ + name: { _contains: connName } + })[0] + : conns[0] + + var name = conn.name() + $.printf("Connecting to '%s'", name) + viscosity.connect(name) +} diff --git a/PluginDirectories/1/viscosity.bundle/plugin.py b/PluginDirectories/1/viscosity.bundle/plugin.py new file mode 100644 index 00000000..7ee21aaa --- /dev/null +++ b/PluginDirectories/1/viscosity.bundle/plugin.py @@ -0,0 +1,24 @@ +import subprocess + +SCRIPT = 'open_viscosity_connection.js' + +def results(fields, query): + connection = fields.get('~connection') + if connection is None: + connection = getFirstConnection() + + return { + "title": "Connect to '%s' with Viscosity" % connection, + "run_args": [connection], + } + +def run(connection): + cmd = ['osascript', SCRIPT] + if connection is not None: + cmd.append(connection) + + subprocess.call(cmd) + +def getFirstConnection(): + cmd = ['osascript', 'get_viscosity_connection.js'] + return subprocess.check_output(cmd).strip()