Add playerctl.py
This commit is contained in:
parent
afc2b77806
commit
c75a3afb50
|
@ -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()
|
Loading…
Reference in New Issue