Created
September 7, 2014 18:08
-
-
Save emanchado/40918ae4e6ec4b3fa2c8 to your computer and use it in GitHub Desktop.
Sets the playlist in Amarok to a given list of files, set loop mode, and play (using DBUS)
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/bash | |
if [ "$#" -ne 1 ]; then | |
echo "ERROR: Need one parameter" 2>&1 | |
echo "SYNTAX: amarok-set-playlist [some.playlist]" 2>&1 | |
echo "Where some.playlist is a file with one absolute path per line" 2>&1 | |
exit 1 | |
fi | |
PLAYLIST=$1 | |
if [ ! -r "$PLAYLIST" ]; then | |
echo "ERROR: Can't read playlist $PLAYLIST" 2>&1 | |
exit 1 | |
fi | |
listLength=$(dbus-send --session --print-reply --dest=org.kde.amarok --type="method_call" /TrackList org.freedesktop.MediaPlayer.GetLength 2>/dev/null | grep int32 | sed -e 's/ //' | cut -d ' ' -f 2) | |
for (( i=0; i<$listLength; i++ )); do | |
dbus-send --session --dest=org.kde.amarok --type="method_call" /TrackList org.freedesktop.MediaPlayer.DelTrack int32:0 | |
done | |
dbus-send --session --dest=org.kde.amarok --type="method_call" /TrackList org.freedesktop.MediaPlayer.SetLoop boolean:true | |
while read filepath; do | |
dbus-send --session --dest=org.kde.amarok --type="method_call" /TrackList org.freedesktop.MediaPlayer.AddTrack string:"$filepath" boolean:false &>/dev/null | |
done <$PLAYLIST | |
dbus-send --session --dest=org.kde.amarok --type="method_call" /Player org.freedesktop.MediaPlayer.Stop &>/dev/null | |
dbus-send --session --dest=org.kde.amarok --type="method_call" /Player org.freedesktop.MediaPlayer.Play &>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on https://github.com/seanhodges/Tesla/blob/master/docs/amarok-set-playlist.sh