Fandom

Music Player Daemon Community Wiki

Hack:mpdshuf

525pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Small shellhack that will move songs around on your playlist. This was written in a few minutes and I'm not a bash guru, so bear with me.

I release this in an almost-PD license: copy it, edit it, change it, but please give credit, that's pretty much all I ask.

Code
#!/bin/bash

# mpcshuf.sh: "Shuffles" the mpd playlist.
# By Renan Birck, '09. 
# Last updated: 02/04/09.

UPPER=`mpc | sed '2q;d' | cut -f 2 -d ' ' | cut -f 2 -d '/'` # How many times max. to shuffle?

for X in `seq 0 $UPPER`; do
MAXSONG=$UPPER;
RANFROM=$RANDOM;
RANTO=$RANDOM;


let "RANFROM = $RANFROM % $MAXSONG + 1";
let "RANTO = $RANTO % $MAXSONG + 1";


mpc move $RANFROM $RANTO;
echo "Moved song " $RANFROM " to " $RANTO; # For debugging, remove if you want.
done

Author
renan.dream AT gmail.com

Also on Fandom

Random Wiki