Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mpris utils scripts
#!/bin/sh
# example: sh get_property_player.sh CanPlay/CanSeek/CanGoNext/Rate/...
# get first mpris interface
bus=$(dbus-send --session \
--dest=org.freedesktop.DBus \
--type=method_call \
--print-reply=literal \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames |
tr ' ' '\n' |
grep 'org.mpris.MediaPlayer2' |
head -n 1)
echo $bus
gdbus call -e \
-d $bus -o /org/mpris/MediaPlayer2 \
-m org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player \
$1
#!/bin/sh
# example: sh method.sh play/pause/...
case "$1" in
play-pause )
func=PlayPause
;;
next )
func=Next
;;
previous )
func=Previous
;;
play )
func=Play
;;
pause )
func=Pause
;;
stop )
func=Stop
;;
* )
exit 3
esac
# get first mpris interface
bus=$(dbus-send --session \
--dest=org.freedesktop.DBus \
--type=method_call \
--print-reply=literal \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames |
tr ' ' '\n' |
grep 'org.mpris.MediaPlayer2' |
head -n 1)
echo $bus
dbus-send --type=method_call --dest=$bus /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.$func
dbus-monitor --session "path=/org/mpris/MediaPlayer2,member=PropertiesChanged" --monitor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment