April 26, 2009

How-To: Enable Last.fm Song Submission in CMus in Debian and Ubuntu

CMus is a very powerful audio player for the console with a ncurses-based interface, support for themes and highly configurable.

Although (at least in Debian) CMus does not come with Last.fm song submission support by default, there is a script available here as a patch, which you can apply to the source, compile CMus again and enable Last.fm support.

Here's what you have to do:

1. Enable sources repositories
Edit the /etc/apt/sources.list file as root with your favourite text editor (e.g. nano /etc/apt/sources.list or kdesu /etc/apt/sources.list) and make sure you have a line which starts with deb-src, as in the example below:

deb-src ftp://ftp.ro.debian.org/debian/ lenny main contrib non-free

You can replace the TLD with the one of your country (e.g. instead of ro use fi for Finland, de for Germany etc.) Next, update the packages list as root:

apt-get update


2. Get the CMus source code
Type, as normal user:

apt-get install git-core

Now issue the command:

git clone git://repo.or.cz/cmus.git

3. Get the Last.fm patch
Go here and download the patch (direct link here). Save it inside the cmus directory. The file is called as.patch

4. Apply the patch
To apply the patch, make sure the current working directory is cmus and type:


patch < as.patch

5. Install CMus dependencies
To install the needed libraries for the compilation, type as root:

apt-get install libncurses5-dev
apt-get build-dep cmus

6. Compile and install CMus
Just type the usual:

./configure
make
make install

The last one as root.

7. Enable the Last.fm song submission script
You can either copy the following three lines inside the ~/.cmus/rc file:

set as_enable=true
set as_user=Lastfm_USER
set as_pass=Lastfm_PASS

Or run the same commands in CMUS like this:

:set as_enable=true
:set as_user=Lastfm_USER
:set as_pass=Lastfm_PASS


Just make sure to replace Lastfm_USER and Lastfm_PASS with the appropiate values.