forked from albertlauncher/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgnome_dictionary.py
35 lines (25 loc) · 1.02 KB
/
gnome_dictionary.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
34
35
# -*- coding: utf-8 -*-
"""Gnome dictionary.
Needs 'gnome-dictionary' to be already installed.
Sysnopsis: <trigger> <query>"""
from shutil import which
from subprocess import run
from albertv0 import *
__iid__ = "PythonInterface/v0.1"
__prettyname__ = "Gnome Dictionary"
__version__ = "1.0"
__trigger__ = "def "
__author__ = "Nikhil Wanpal"
__dependencies__ = ["gnome-dictionary"]
if which("gnome-dictionary") is None:
raise Exception("'gnome-dictionary' is not in $PATH.")
iconPath = iconLookup('accessories-dictionary')
def handleQuery(query):
if query.isTriggered:
return Item(id=__prettyname__,
icon=iconPath,
text=__prettyname__,
subtext="Search for '%s' using %s" % (query.string, __prettyname__),
completion=query.rawString,
actions=[ProcAction("Opens %s and searches for '%s'" % (__prettyname__, query.string),
["gnome-dictionary", "--look-up=%s" % query.string])])