-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
72 lines (61 loc) · 2.5 KB
/
__init__.py
File metadata and controls
72 lines (61 loc) · 2.5 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import subprocess
from albert import *
md_iid = '2.4'
md_version = '1.0'
md_name = 'Koi theme switcher'
md_description = 'Switches between dark/light themes using Koi'
md_lib_dependencies = ['dbus-python']
__py_deps__ = ["dbus-python"]
import dbus
class ThemeSwitcherController():
def __init__(self):
self.session_bus = dbus.SessionBus()
def invoke_koi(self, method_name):
service_name = "dev.baduhai.Koi"
object_path = "/Koi"
interface_name = 'local.KoiDbusInterface'
proxy_object = self.session_bus.get_object(service_name, object_path)
method = proxy_object.get_dbus_method(method_name, dbus_interface=interface_name)
method()
def light_mode(self):
self.invoke_koi('goLightMode')
def dark_mode(self):
self.invoke_koi('goDarkMode')
def toggle(self):
self.invoke_koi('toggleMode')
class Plugin(PluginInstance, TriggerQueryHandler):
def __init__(self):
PluginInstance.__init__(self)
TriggerQueryHandler.__init__(self, id='koi_theme_switcher', name=md_name, description=md_description, defaultTrigger='koi ')
self.controller = ThemeSwitcherController()
def handleTriggerQuery(self, query):
items = []
if not query.string or query.string.lower() in "toggle":
items.append(
StandardItem(
id = self.id + "-togglemode",
iconUrls=["xdg:koi_tray"],
text = 'Koi: Toggle mode',
actions = [Action('koi toggle', 'Koi: Toggle mode', lambda ctl=self.controller: ctl.toggle())]
)
)
if not query.string or query.string.lower() in "light":
items.append(
StandardItem(
id = self.id + "-lightmode",
iconUrls=["xdg:flashlight-on"],
text = 'Koi: Light mode',
actions = [Action('koi lightmode', 'Koi: Light mode', lambda ctl=self.controller: ctl.light_mode())]
)
)
if not query.string or query.string.lower() in "dark":
items.append(
StandardItem(
id = self.id + "-darkmode",
iconUrls=["xdg:flashlight-off"],
text = 'Koi: Dark mode',
actions = [Action('koi darkmode', 'Koi: Dark mode', lambda ctl=self.controller: ctl.dark_mode())]
)
)
if items:
query.add(items)