mocp rand

music-score I’m quite sure everyone reading this must have a respectable, if not massive, music collection. In this days and age is difficult finding someone who doesn’t. It’s also difficult to choose one, and only one, disk to listen at any given moment. Until we’re upgraded to support concurrent music listening we’re better of with a random disk selector, which is exactly what this little script does:


while (( 1 )); do
NUM_DISCS=$(find $SEARCH_DIR -type d|wc -l)
RAND_DISC=$(find $SEARCH_DIR -type d | head -n $RAND | tail -n 1)

# Wake up moc
mocp -FS 2>/dev/null >/dev/null &
mocp -pca "$RAND_DISC" &
echo "Playing $RAND_DISC"

# Start from a random file?
if (( $START_RANDOM )); then
mocp --on shuffle &
mocp -f &
mocp --off shuffle &

Of course, it requires mocp, my favorite music (on console) player. And obviously, you’ll have to configure SEARCH_DIR but I’m sure some bash hacking is not that hard.
Beware though, using this + cron may have the undesired effect of awakening to the pleasant music of Cannibal Corpse.

One Comment on “mocp rand”

  1. […] And now you can sort by random your output using sort -R. Why would this be useful? Well, I updated my mocp random script with a […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s