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

remote: control player failproof

parent 32f5904d
...@@ -35,21 +35,15 @@ def get_interface(prog): ...@@ -35,21 +35,15 @@ def get_interface(prog):
proxy = bus.get_object('org.mpris.MediaPlayer2.%s' % prog, '/org/mpris/MediaPlayer2') proxy = bus.get_object('org.mpris.MediaPlayer2.%s' % prog, '/org/mpris/MediaPlayer2')
return dbus.Interface(proxy, dbus_interface='org.mpris.MediaPlayer2.Player') return dbus.Interface(proxy, dbus_interface='org.mpris.MediaPlayer2.Player')
_player = get_interface('spotify')
def player_action(action): def player_action(action):
global _player players = ['vlc', 'spotify']
try: for pl in players:
vlc = get_interface('vlc') try:
getattr(vlc, action)() handle = get_interface(pl)
return getattr(handle, action)()
except dbus.exceptions.DBusException: return
pass except dbus.exceptions.DBusException:
try: pass
getattr(_player, action)()
except dbus.exceptions.DBusException:
_player = get_interface('spotify')
getattr(_player, action)()
bus = dbus.SessionBus() bus = dbus.SessionBus()
proxy = bus.get_object('org.gnome.ScreenSaver', '/org/gnome/ScreenSaver') 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