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

19Dec/093

Install SCMPC – Audioscrobbling MPD to Last.fm in Ubuntu 9.10

leopard

I've been using SCMPC to scrobble my music played with MPD to Last.fm for a couple of years now. I can't find a package for it in the repositories, but it's easy to install from source. The source hasn't changed in almost 3 years, but it still seems to be working fine.

Here's how I installed it in Ubuntu 9.10 Karmic Koala.

The SCMPC homepage is here. You can download the source at this link.

First install the dependencies you'll need:

sudo apt-get install libargtable2-dev libconfuse-dev libdaemon-dev

You may also need libcurl (I apparently already had it).

Then extract the source code (the file was scmpc-0.2.2.tar.bz2 in my case) by right-clicking and selecting "Extract here". In a terminal, cd into the directory you just extracted. Then just:

./configure
make
sudo make install

That should install it. Now create a directory for the config file in your home directory:

mkdir ~/.scmpc

You can copy a template for the config file:

cp /usr/local/share/scmpc/scmpc.conf ~/.scmpc/

And then fill in your own details.

Or you can just make your own. Here's copy of mine.

log_level = debug
log_file = "/home/james/.scmpc/scmpc.log"
pid_file = "/home/james/.scmpc/scmpc.pid"
cache_file = "/home/james/.scmpc/scmpc.cache"
mpd {
	#host = "localhost"
	#port = 6600
	#timeout = 5
	#password =
}
audioscrobbler {
	username = "my_user_name"
	password_hash = "a_hash_of_my_password"
}

I keep all of SCMPC's operating files in ~/.scmpc

I use password_hash= instead of password= so I don't have to store my password in plain text. You can get a hash of your password like this:

echo -n your_password | md5sum

Don't include any spaces or the dash ( - ) symbol that follow the hash.

Now just start SCMPC and restart MPD. Add SCMPC to your startup programs (System -> Preferences -> Startup Applications) if you want it running at startup.

scmpc
sudo /etc/init.d/mpd restart

11Dec/094

Installing MPD & MPC in Ubuntu 9.10 Karmic Koala

more flowers by Abbie F (C) via Flickr

(The above photo is "more flowers", by Abbie F (C) via Flickr).

EDIT: After running the setup described herein for several days, I've uninstalled PulseAudio and use ALSA instead. While PulseAudio may be a theoretically better system, its implementation in 9.10 is perfectly awful. Not only was MPD/MPC constantly crashing, but sometimes I'd lose sound system-wide. Also once Pulse is gone, you can roll back to Adobe Flash 9 (with sound!), which is infinitely better on my machine than 9.10's implementation of Flash 10.

The installation wasn't as straight-forward as I'd hoped, so maybe these notes will help others. This is specifically for Ubuntu 9.10 Karmic Koala (I'm running the 32 bit / i386 desktop edition), running the default pulse audio.

Install from official sources:

sudo apt-get install mpd mpc

Symlink your music folders to MPD's default watch folder:

sudo ln -s /path/to/music /var/lib/mpd/music

Update your MPD database. The new version of MPD has changed some things about the "mpd --update-db" command, so you should use:

mpc update

At this point I could play music, I just couldn't change the volume. I got the following error:

error: ACK [52@0] {setvol} problems setting volume

The problem was that MPD was trying to use ALSA instead of pulse audio. Edit the MPD configuration file to enable pulse audio. Find the Audio Output section of the file and add or un-comment the following lines:

audio_output {
type "pulse"
name "My MPD PulseAudio Output"
}

I did follow the instructions at http://ubuntuforums.org/showthread.php?t=1298789 regarding the PulseAudio Preferences (paprefs), but I don't know if it's necessary.

Finally, add the user "mpd" to the PulseAudio groups in order to give it permission to use PulseAudio:

sudo usermod -aG pulse,pulse-access mpd

Restart MPD:

sudo /etc/init.d/mpd restart

That's what worked for me.