Commit 6a294a49 authored by Daniel Stan's avatar Daniel Stan

remote: control player failproof

parent 32f5904d
......@@ -35,21 +35,15 @@ def get_interface(prog):
proxy = bus.get_object('org.mpris.MediaPlayer2.%s' % prog, '/org/mpris/MediaPlayer2')
return dbus.Interface(proxy, dbus_interface='org.mpris.MediaPlayer2.Player')
_player = get_interface('spotify')
def player_action(action):
global _player
try:
vlc = get_interface('vlc')
getattr(vlc, action)()
return
except dbus.exceptions.DBusException:
pass
try:
getattr(_player, action)()
except dbus.exceptions.DBusException:
_player = get_interface('spotify')
getattr(_player, action)()
players = ['vlc', 'spotify']
for pl in players:
try:
handle = get_interface(pl)
getattr(handle, action)()
return
except dbus.exceptions.DBusException:
pass
bus = dbus.SessionBus()
proxy = bus.get_object('org.gnome.ScreenSaver', '/org/gnome/ScreenSaver')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment