forked from albertlauncher/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
goldendict.py
33 lines (24 loc) · 950 Bytes
/
goldendict.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
"""Fire up an external search in GoldenDict.
Synopsis: <trigger> <query>"""
from shutil import which
from subprocess import run
from albertv0 import Item, ProcAction, iconLookup
__iid__ = "PythonInterface/v0.1"
__prettyname__ = "GoldenDict"
__version__ = "1.0"
__trigger__ = "gd "
__author__ = "Manuel Schneider"
__dependencies__ = ["goldendict"]
if which("goldendict") is None:
raise Exception("'goldendict' is not in $PATH.")
iconPath = iconLookup('goldendict')
def handleQuery(query):
if query.isTriggered:
return Item(id=__prettyname__,
icon=iconPath,
text=__prettyname__,
subtext="Look up '%s' using %s" % (query.string, __prettyname__),
completion=query.rawString,
actions=[ProcAction("Start query in %s" % __prettyname__,
["goldendict", query.string])])