Shell Person Help me keep the shell people alive.

22Apr/103

MPC Script – Quickly Find and Play by Album

This is a simple script for MPD & MPC users. It allows you to quickly queue and play an album. I name the script "album" and put it in ~/bin (which is included in my $PATH).

#!/bin/bash
## Shortcut to search, add, and play an album (after clearing current playlist).
## Use -a (for "add") to add the album to the playlist without clearing current playlist.

if [ $1 = -a ]
then
shift
mpc search album "$*" | mpc add ; mpc play
exit
fi

mpc clear
mpc search album "$*" | mpc add ; mpc play

The usage is simple:

album abbey

The above command would stop the song currently playing, clear the current playlist and replace it with The Beatles' Abbey Road, and start playing it. If I had another album with "abbey" in the name, it would have loaded that one as well. Spaces are included as part of the search string -- for example, this also works:

album abbey road

You can use the "-a" switch to add the album to the current playlist. It won't interrupt what's currently playing, it will only put the new album in the queue.

album -a abbey road

Comments (3) Trackbacks (0)
  1. Handy Script Thanks!

  2. Glad it was helpful.

  3. shell.person, you’re a great person!

    For other noobs like me: Just replace “album” with “title” in the script and “save as” “title” and then make this new file executable . Now you have another script. Instead of “album” enter “title something” in terminal.

    By the way, use quake or yakuake (for KDE) instead of other terminal emulators for easy access.

    Thank you.


Leave a comment

No trackbacks yet.