-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgestaltbus.py
73 lines (52 loc) · 1.9 KB
/
gestaltbus.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
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
72
import dbus
import dbus.service
import dbus.glib
import sys
ROOT_IFACE = 'org.mpris.MediaPlayer2'
PLAYER_IFACE = 'org.mpris.MediaPlayer2.Player'
PLIST_IFACE = 'org.mpris.MediaPlayer2.Playlist'
BUS_NAME = 'org.mpris.MediaPlayer2.Gestalt'
OBJECT_PATH = '/org/mpris/MediaPlayer2/Gestalt'
class GestaltBus(dbus.service.Object):
def __init__(self, player):
self.player = player
bus_name = dbus.service.BusName(BUS_NAME, bus=dbus.SessionBus())
dbus.service.Object.__init__(self, bus_name=bus_name, object_path=OBJECT_PATH)
def mset(self, interface_name, properties):
self.props[interface_name].update(properties)
self.PropertiesChanged(interface_name, properties, [])
# root interface (org.mpris.MediaPlayer2)
@dbus.service.method(dbus_interface=ROOT_IFACE)
def hello(self):
return "Gestalt!"
@dbus.service.method(dbus_interface=ROOT_IFACE)
def Quit(self):
# not sure how to make this work, sys.exit will quit (with errors)
loop.quit()
#sys.exit()
@dbus.service.method(dbus_interface=ROOT_IFACE)
def Raise(self):
# Do nothing (CanRaise is false)
pass
# player interface (org.mpris.MediaPlayer2.Player)
@dbus.service.method(dbus_interface=PLAYER_IFACE)
def Play(self, uri):
self.player.playFile(uri)
@dbus.service.method(dbus_interface=PLAYER_IFACE)
def Stop(self):
pass
@dbus.service.method(dbus_interface=PLAYER_IFACE)
def PlayPause(self):
pass
@dbus.service.method(dbus_interface=PLAYER_IFACE)
def Next(self):
pass
@dbus.service.method(dbus_interface=PLAYER_IFACE)
def Previous(self):
pass
@dbus.service.method(dbus_interface=PLAYER_IFACE)
def OpenUri (self, uri):
pass
@dbus.service.method(dbus_interface=PLAYER_IFACE)
def ActivePlaylist(self, playlist_id):
pass