Add playerctl.py

This commit is contained in:
Ceda EI 2018-12-17 15:02:33 +05:30
parent afc2b77806
commit c75a3afb50
1 changed files with 27 additions and 0 deletions

27
playerctl.py Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env python3
import dbus
import sys
session_bus = dbus.SessionBus()
mpris_players = []
for i in session_bus.list_names():
if str(i)[:22] == "org.mpris.MediaPlayer2":
mpris_players += [session_bus.get_object(i, '/org/mpris/MediaPlayer2')]
for i in mpris_players:
iface = dbus.Interface(i, 'org.mpris.MediaPlayer2.Player')
if sys.argv[1] == "previous":
iface.Previous()
elif sys.argv[1] == "toggle":
iface.PlayPause()
elif sys.argv[1] == "next":
iface.Next()
elif sys.argv[1] == "play":
iface.Play()
elif sys.argv[1] == "pause":
iface.Pause()
elif sys.argv[1] == "stop":
iface.Stop()