Created
December 2, 2014 12:16
-
-
Save exic/1d051e3a15f61e06caf4 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.Previous | |
elif [ "$@" = "stop" ]; then | |
$RC.Pause | |
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
Note: Insert
export DISPLAY=:0
at line 2 to make this work via ssh.