-
Notifications
You must be signed in to change notification settings - Fork 3
/
dbus.js
180 lines (163 loc) · 6.71 KB
/
dbus.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
const Gio = imports.gi.Gio;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const DBusIface = '<node>\
<interface name="org.freedesktop.DBus">\
<method name="GetNameOwner">\
<arg type="s" direction="in" />\
<arg type="s" direction="out" />\
</method>\
<method name="ListNames">\
<arg type="as" direction="out" />\
</method>\
<signal name="NameOwnerChanged">\
<arg type="s" direction="out" />\
<arg type="s" direction="out" />\
<arg type="s" direction="out" />\
</signal>\
</interface>\
</node>';
const DBusProxy = Gio.DBusProxy.makeProxyWrapper(DBusIface);
const PropertiesIface = '<node>\
<interface name="org.freedesktop.DBus.Properties">\
<method name="Get">\
<arg type="s" direction="in" />\
<arg type="s" direction="in" />\
<arg type="v" direction="out" />\
</method>\
<method name="GetAll"> \
<arg direction="in" type="s"/> \
<arg direction="out" type="a{sv}"/> \
</method> \
<signal name="PropertiesChanged">\
<arg type="s" direction="out" />\
<arg type="a{sv}" direction="out" />\
<arg type="as" direction="out" />\
</signal>\
</interface>\
</node>';
const PropertiesProxy = Gio.DBusProxy.makeProxyWrapper(PropertiesIface);
const MediaServer2Iface = '<node>\
<interface name="org.mpris.MediaPlayer2">\
<method name="Raise" />\
<method name="Quit" />\
<property name="CanRaise" type="b" access="read" />\
<property name="CanQuit" type="b" access="read" />\
<property name="HasTrackList" type="b" access="read" />\
<property name="Identity" type="s" access="read" />\
<property name="DesktopEntry" type="s" access="read" />\
</interface>\
</node>';
const MediaServer2Proxy = Gio.DBusProxy.makeProxyWrapper(MediaServer2Iface);
// For some reason the Nuvola dev was told to scab in a non-spec
// prop and method for the support of setting ratings instead of
// making a seperate ratings extension interface.
// Oh well, they really don't hurt anything. No other player will try
// to use them anyway...
const MediaServer2PlayerIface = '<node>\
<interface name="org.mpris.MediaPlayer2.Player">\
<method name="PlayPause" />\
<method name="Next" />\
<method name="Previous" />\
<method name="Stop" />\
<method name="SetPosition">\
<arg type="o" direction="in" />\
<arg type="x" direction="in" />\
</method>\
<method name="NuvolaSetRating">\
<arg type="d" direction="in" />\
</method>\
<property name="NuvolaCanRate" type="b" access="read" />\
<property name="CanPlay" type="b" access="read" />\
<property name="CanPause" type="b" access="read" />\
<property name="CanSeek" type="b" access="read" />\
<property name="CanGoNext" type="b" access="read" />\
<property name="CanGoPrevious" type="b" access="read" />\
<property name="Metadata" type="a{sv}" access="read" />\
<property name="Volume" type="d" access="readwrite" />\
<property name="LoopStatus" type="s" access="readwrite" />\
<property name="Shuffle" type="b" access="readwrite" />\
<property name="PlaybackStatus" type="s" access="read" />\
<signal name="Seeked">\
<arg type="x" direction="out" />\
</signal>\
</interface>\
</node>';
const MediaServer2PlayerProxy = Gio.DBusProxy.makeProxyWrapper(MediaServer2PlayerIface);
const MediaServer2PlaylistsIface = '<node>\
<interface name="org.mpris.MediaPlayer2.Playlists">\
<method name="ActivatePlaylist">\
<arg type="o" direction="in" />\
</method>\
<method name="GetPlaylists">\
<arg type="u" direction="in" />\
<arg type="u" direction="in" />\
<arg type="s" direction="in" />\
<arg type="b" direction="in" />\
<arg type="a(oss)" direction="out" />\
</method>\
<property name="PlaylistCount" type="u" access="read" />\
<property name="Orderings" type="as" access="read" />\
<property name="ActivePlaylist" type="(b(oss))" access="read" />\
<signal name="PlaylistChanged">\
<arg type="(oss)" direction="out" />\
</signal>\
</interface>\
</node>';
const MediaServer2PlaylistsProxy = Gio.DBusProxy.makeProxyWrapper(MediaServer2PlaylistsIface);
const MediaServer2TracklistIface = '<node>\
<interface name="org.mpris.MediaPlayer2.TrackList">\
<method name="GetTracksMetadata">\
<arg type="ao" direction="in" />\
<arg type="aa{sv}" direction="out" />\
</method>\
<method name="GoTo">\
<arg type="o" direction="in" />\
</method>\
<property name="Tracks" type="ao" access="read" />\
<signal name="TrackListReplaced">\
<arg type="ao" direction="out" />\
<arg type="o" direction="out" />\
</signal>\
<signal name="TrackAdded">\
<arg type="a{sv}" direction="out" />\
<arg type="o" direction="out" />\
</signal>\
<signal name="TrackRemoved">\
<arg type="o" direction="out" />\
</signal>\
<signal name="TrackMetadataChanged">\
<arg type="o" direction="out" />\
<arg type="a{sv}" direction="out" />\
</signal>\
</interface>\
</node>';
const MediaServer2TracklistProxy = Gio.DBusProxy.makeProxyWrapper(MediaServer2TracklistIface);
function DBus() {
return new DBusProxy(Gio.DBus.session, 'org.freedesktop.DBus',
'/org/freedesktop/DBus');
}
function Properties(owner, callback) {
new PropertiesProxy(Gio.DBus.session, owner,
'/org/mpris/MediaPlayer2',
callback);
}
function MediaServer2(owner, callback) {
new MediaServer2Proxy(Gio.DBus.session, owner,
'/org/mpris/MediaPlayer2',
callback);
}
function MediaServer2Player(owner, callback) {
new MediaServer2PlayerProxy(Gio.DBus.session, owner,
'/org/mpris/MediaPlayer2',
callback);
}
function MediaServer2Playlists(owner, callback) {
new MediaServer2PlaylistsProxy(Gio.DBus.session, owner,
'/org/mpris/MediaPlayer2',
callback);
}
function MediaServer2Tracklist(owner, callback) {
new MediaServer2TracklistProxy(Gio.DBus.session, owner,
'/org/mpris/MediaPlayer2',
callback);
}