-
-
Save nico202/6fe051af59e336c23be2cfb9a51074f1 to your computer and use it in GitHub Desktop.
Control a player implementing MPRIS D-Bus Specification v2.2
This file contains 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 | |
name="$1" | |
shift | |
PATHS="org.mpris.MediaPlayer2.$name /org/mpris/MediaPlayer2" | |
DBUS_SEND="dbus-send --type=method_call --dest=$PATHS" | |
RC="$DBUS_SEND org.mpris.MediaPlayer2.Player" | |
if [ "$@" = "prev" ]; then | |
$RC.Prev | |
elif [ "$@" = "stop" ]; then | |
$RC.Stop | |
elif [ "$@" = "toggle" ]; then | |
$RC.PlayPause | |
elif [ "$@" = "next" ]; then | |
$RC.Next | |
elif [ "$@" = "random" ]; then | |
current=$(mdbus2 $PATHS org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Shuffle) | |
if [ "$current" = "( true)" ]; then | |
other=false | |
else | |
other=true | |
fi | |
$DBUS_SEND org.freedesktop.DBus.Properties.Set string:org.mpris.MediaPlayer2.Player string:Shuffle variant:boolean:$other | |
else | |
echo "Command not found for player $name: $@" 1>&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment