Last active
August 17, 2020 22:01
-
-
Save ChunMinChang/06a776185055d03ec52cdc1539fd3c23 to your computer and use it in GitHub Desktop.
mpris utils scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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