[modules/spotify] make global dbus object
instead of creating a new dbus instance during each update interval, reuse one dbus instance. see #702
This commit is contained in:
parent
f37eb31f94
commit
fcbb89db90
1 changed files with 3 additions and 2 deletions
|
@ -39,6 +39,7 @@ class Module(core.module.Module):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.__bus = dbus.SessionBus()
|
||||||
self.__song = ""
|
self.__song = ""
|
||||||
self.__pause = ""
|
self.__pause = ""
|
||||||
self.__format = self.parameter("format", "{artist} - {title}")
|
self.__format = self.parameter("format", "{artist} - {title}")
|
||||||
|
@ -82,7 +83,7 @@ class Module(core.module.Module):
|
||||||
return self.string_song == ""
|
return self.string_song == ""
|
||||||
|
|
||||||
def __get_song(self):
|
def __get_song(self):
|
||||||
bus = dbus.SessionBus()
|
bus = self.__bus
|
||||||
spotify = bus.get_object(
|
spotify = bus.get_object(
|
||||||
"org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2"
|
"org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2"
|
||||||
)
|
)
|
||||||
|
@ -103,7 +104,7 @@ class Module(core.module.Module):
|
||||||
if widget.name == "spotify.pause":
|
if widget.name == "spotify.pause":
|
||||||
playback_status = str(
|
playback_status = str(
|
||||||
dbus.Interface(
|
dbus.Interface(
|
||||||
dbus.SessionBus().get_object(
|
self.__bus.get_object(
|
||||||
"org.mpris.MediaPlayer2.spotify",
|
"org.mpris.MediaPlayer2.spotify",
|
||||||
"/org/mpris/MediaPlayer2",
|
"/org/mpris/MediaPlayer2",
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue