-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItemEnterEventListener.py
35 lines (29 loc) · 1.22 KB
/
ItemEnterEventListener.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
import playerctl
from ulauncher.api.client.EventListener import EventListener
class ItemEnterEventListener(EventListener):
def on_event(self, event, extension):
data = event.get_data()
extension.logger.debug(str(data))
if data["action"] == "jump":
playerctl.jump(data["pos"])
elif data["action"] == "playpause":
playerctl.playpause()
elif data["action"] == "next":
playerctl.next()
return extension.render_main_page("next")
elif data["action"] == "prev":
playerctl.prev()
return extension.render_main_page("prev")
elif data["action"] == "mute":
playerctl.mute("0")
elif data["action"] == "set_vol":
amount = int("".join(filter(str.isdigit, data["amount"])))
control_volume = data["global_or_player"]
if amount > 100:
amount = 100
playerctl.volume(amount, control_volume)
elif data["action"] == "show_player":
return extension.render_main_page("change_player")
elif data["action"] == "change_players":
player_chosen = data["player"]
playerctl.change_player(player_chosen)