-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
35 lines (21 loc) · 968 Bytes
/
main.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
from ulauncher.api.client.Extension import Extension
from ulauncher.api.client.EventListener import EventListener
from ulauncher.api.shared.event import ItemEnterEvent, KeywordQueryEvent
import utils
spotify = utils.Spotify()
results = utils.ResultsRenderer()
class ControlSpotifyExtension(Extension):
def __init__(self):
super(ControlSpotifyExtension, self).__init__()
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
self.subscribe(ItemEnterEvent, ItemEnterEventListener())
class ItemEnterEventListener(EventListener):
def on_event(self, event, _extension):
spotify.execute_command(event.get_data())
return results.menu_items(spotify)
class KeywordQueryEventListener(EventListener):
def on_event(self, _event, extension):
results.update_preferences(extension.preferences)
return results.menu_items(spotify)
if __name__ == '__main__':
ControlSpotifyExtension().run()