Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin for Viscosity #521

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added PluginDirectories/1/viscosity.bundle/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions PluginDirectories/1/viscosity.bundle/examples.txt
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ObjC.import('stdio')
function run(connName) {
var viscosity = Application('com.viscosityvpn.Viscosity')
return viscosity.connections[0].name()
}
9 changes: 9 additions & 0 deletions PluginDirectories/1/viscosity.bundle/info.json
Original file line number Diff line number Diff line change
@@ -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"
}
14 changes: 14 additions & 0 deletions PluginDirectories/1/viscosity.bundle/open_viscosity_connection.js
Original file line number Diff line number Diff line change
@@ -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)
}
24 changes: 24 additions & 0 deletions PluginDirectories/1/viscosity.bundle/plugin.py
Original file line number Diff line number Diff line change
@@ -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()