You are not logged in.
just noticed this thread,http://crunchbanglinux.org/forums/topic … -use/page/ and it seems a lot of people were having trouble with mpd, just set it up myself so ive written this how to.
first of all install mpd:
sudo apt-get install mpd
then because its a daemon (Music Player Daemon) you need something to control it with:
sudo apt-get install mpc
next you need to sort out a configuration file:
zcat /usr/share/doc/mpd/examples/mpd.conf.gz > ~/.mpdconf
also create a file for later:
mkdir ~/.mpd
and now to edit:
nano ~/.mpdconf
(or your prefered editor)
in the 'Files and directories' section
change 'music_directory' from /var/lib/mpd/music to point to where your music is
change other '/var/lib/mpd' lines to ~/.mpd so '/var/lib/mpd/tag_cache' would be '~/.mpd/tag_cache'.
do the same for the 'optional paths'
in 'General music daemon options' comment out 'user' (add a # to the start of the line) and uncomment
'#auto_update "yes"'
and
'#auto_update_depth "3"' (remove the leading #).
and finally in 'Audio Output' make sure the alsa audio driver is uncommented.
this bit:
audio_output {
type "alsa"
name "My ALSA Device"
device "hw:0,0" # optional
format "44100:16:2" # optional
}
now it should work so start mpd
mpd
mpc ls
should show your albums, this can be piped like so:
mpc ls | mpc add
and then:
mpc play
by this point you should hear sound (hopefully)
last thing is to have it start automatically,
add:
mpd
to your ~/.config/openbox/autostart.sh
(you can add an & suffix it you want, its a daemon so doesnt really matter.)
UPDATE:
a few people have been reporting problems with mpd running as root automatically at startup, errors such as "problem opening log file "/root/.mpd/mpd.log" (config line 11) for writing",or "unable to bind port 6600: Address already in use" or not finding your music folder
if you have this problem modify /etc/default/mpd.conf
sudo nano /etc/default/mpd
and change the START_MPD option to false
START_MPD=false
then
sudo mpd --kill
to end the mpd currently running as root
now one of the great things about mpd is you can control it from anywhere, console, desktop, internet.
there are a whole host of front ends, ive heard good things about sonata, but ill cover standard crunchbang integration.
keyboard shortcuts
############
keybindings are kept in
'~/.config/openbox/rc.xml' accessible through the menu in preferences-->openbox
and add something like this to the keyboard section (around about line 160)
<!-- mpd bindings -->
<keybind key="W-Up">
<action name="Execute">
<command>mpc toggle</command>
</action>
</keybind>
<keybind key="W-Down">
<action name="Execute">
<command>mpc stop</command>
</action>
</keybind>
<keybind key="W-Left">
<action name="Execute">
<command>mpc prev</command>
</action>
</keybind>
<keybind key="W-Right">
<action name="Execute">
<command>mpc next</command>
</action>
</keybind>
'keybind key' is the keybinging so <keybind key="W-Up"> is windows key plus up.
'<command>mpc toggle</command>' is the command in this case toggle (play pause).
check out the manpage for mpc
man mpc
for a full list of commands.
* See this post for XFCE keybindings http://crunchbanglinux.org/forums/post/78771/#p78771
conky integration
###########
conky has a list of options for displaying output from mpd.
the conkyrc is by default at '~/.conky' (i think) also in the menu under preferences.
this is my setup, although for a full list http://conky.sourceforge.net/variables.html
${if_mpd_playing} ${hr}
$mpd_artist
$mpd_album
${mpd_title 15}
$mpd_elapsed/$mpd_length
$mpd_status
${mpd_bar 5,180}
${execi 2 ~/.config/conky/mpd-albumart.py}
${image /tmp/mpd.jpg -s 80x80 -p 100,349 }
$endif
NB. at the moment ${if_mpd_playing} isn't working properly, it should hide when mpd is stopped but doesn't, its fixed in conky v1.8 so hopefully in karmic
the eagle eyed may have noticed:
${execi 2 ~/.config/conky/mpd-albumart.py}
${image /tmp/mpd.jpg -s 80x80 -p 100,349 }
its for displaying album art.
heres mpd-albumart.py
#! /usr/bin/env python
import sys,mpd,os,socket
musiclocation = '~/music' #location of music
artlocation = '~/.mpd/covers' #where you want albumart storing
tmp_path = '/tmp/mpd.jpg' #location for temporary file so conky can find it
musiclocation = os.path.expanduser(musiclocation)
artlocation = os.path.expanduser(artlocation)
client = mpd.MPDClient()
try:
client.connect("localhost", 6600)
except socket.error:
sys.exit(1)
song = client.currentsong()
artist = song['artist']
album = song['album']
covername = os.path.join( artlocation, artist+'-'+album+'.jpg')
covername = covername.replace(' ','_')
if covername == os.path.realpath(tmp_path): # already have correct album cover
sys.exit(0)
try:
os.remove(tmp_path)
except OSError: pass
if os.path.basename(covername) in os.listdir(artlocation):
os.symlink(covername, tmp_path)
else:
from urllib import FancyURLopener
class MyOpener(FancyURLopener): version = ''
try:
s = MyOpener().open('http://www.amazon.com/gp/search/keywords=%s+%s'%
(artist.replace(' ','+'),album.replace(' ','+'))).read()
import re
link = re.findall('http://ecx.images-amazon.com\S*.jpg',s)[0]
pic = MyOpener().open(link).read()
open(covername ,'w').write(pic)
os.symlink(covername, tmp_path)
except IOError:
pass
save it some where, change the paths (line 7,8 (9 if you really want to)).
make it executable:
chmod +x mpd-albumart.py
install python-mpd (needed to get track info):
sudo apt-get install python-mpd
add this to your conkyrc:
imlib_cache_size 0
some where before TEXT (this ensures the picture will actually change)
the script will load, the picture, if there isnt one, will get one from the internet
${execi 2 /path/to/mpd-albumart.py} #change to correct path (the will run every 2 seconds)
${image /tmp/mpd.jpg -s 80x80 -p 100,349 }# this will load the image from /tmp/mpd.jpg, ( -s is size, -p is placement)
pipemenu
######
you can control mpd fully from your main menu
i wrote a script for a menu option which i started this thread with
http://crunchbanglinux.org/forums/topic … nu-thread/
and thats it, a fully integrated mpd setup
EDIT: 25/4/11 simplified config file setup, and modified to reflect newer config file
Last edited by benj1 (2011-04-25 20:40:21)
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
i get this error: brandon@brandon-laptop:~$ mpd
** ERROR **: problems opening file /etc/mpd.conf for reading: Permission denied
aborting...
Aborted
Offline
i get this error: brandon@brandon-laptop:~$ mpd
** ERROR **: problems opening file /etc/mpd.conf for reading: Permission denied
aborting...
Aborted
are you sure youve got the .mpdconf in your home directory, mpd will search there first if it cant find that it will then try to use /etc/mpd.conf
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
glad to be of service
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
thanks a lot, great post! i have additionally installed the ncmpc as frontend.
greetings!
Sweaty lads picking up the soap | I love the new "Ignore user" button
Offline
For some extra functionality you might try ncmpcpp:
tag editor * playlists editor * easy to use search screen * media library screen * lyrics screen * possibility of going to any position in currently playing track without rewinding/fastforwarding * multi colored main window (if you want) * songs can be added to playlist more than once * and a lot of minor useful functions.
Offline
Awesome post, thanks !!
Offline
OK benj1, so I followed your instructions to the letter, and I get this when I try to run MPD:
unable to bind port 6600: Address already in use
maybe MPD is still running?
Aborted
Do I just tell it to use a different port? What else might be bound to this port?
Offline
if 'pgrep mpd' gives you anything, its running
mpd --kill will kill mpd
it is possible that something else is using the port, i dont know how to check definitively though
if you need to you can change the port in .mpdconf
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
pgrep mpd returns 3087.
mpd --kill returns
** ERROR **: unable to open pid_file "/home/peter/.mpd/pid": No such file or directory;;aborting;aborted
(semicolons are newlines)
Any ideas?
Offline
first off have you made an ~/.mpd directory? if not do that
if not try 'killall mpd' and then restart it
failing that im guessing youve started it and then changed the pid file?
try changing the conf file to point to '/var/run/mpd/pid'
see if that works
Last edited by benj1 (2009-10-30 20:18:18)
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
Offline
Something is starting mpd as root at startup. It isn't in autostart.sh or the autorun directory. Where could it be? I've looked everywhere I can think of, and many places I couldn't think of. I hate having to sudo killall mpd just to run it again with luser rights.
Last edited by pvsage (2009-10-30 23:18:41)
Offline
Ya know what? I'm not gettin' *any* album art in Sonata! Nuttin! Even the Yes album 90125, which shows up with every other media player I've tried that shows album art, isn't coming up. WTF?
Going back to MoC for music play & Banshee just to cache album art. Bash script to show MoC in Conky, and another to grab album art from Banshee's cache (based on MoC) and throw that to Conky. It's a kludge, but it took a lot less headache to get this kludge set up than setting up a proper Sonata + mpd.
Offline
@ pvsage
After following this post, I had the problem of mpd running at start. Could only kill from sudo. Fixed as follows:
Make sure you have user as "your user name" in both the ~/.mpdconf AND the etc/mpd.conf files.
Then start mpd at openbox start by adding mpd &
Offline
Since I can't imagine my Mini running as an actual server, I fixed my mpd problem by going back to MoC. MoC is uglier than a Fender Tweed amp, and sounds just as beautiful.
Offline
Thanks for this nice guide! I've used mpd once before on a ubuntu box and it was a real pain to set up via trial and error.
About the mpd running as root on startup: you can disable that from the file /etc/default/mpd
like this, for example: "sudo nano /etc/default/mpd" and change the line
START_MPD=true
to
START_MPD=false
Offline
Thanks for this nice guide! I've used mpd once before on a ubuntu box and it was a real pain to set up via trial and error.
About the mpd running as root on startup: you can disable that from the file /etc/default/mpd
like this, for example: "sudo nano /etc/default/mpd" and change the line
START_MPD=true
to
START_MPD=false
hmm i wonder why its a problem for some and not others, what problems/error messages were you getting, so i can update the guide
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
I'll wager his problems were the same as mine - mpd starting either at boot or at login, forcing a sudo killall to release port 6600. I think the update should be to add his bit about editing /etc/default/mpd.
I wonder if simply deleting /etc/default/mpd would also fix the problem?
Maybe another option would be to simply let mpd run as root, and have a symlink in /var/lib/mpd/music that points to ~/music, so if you have multiple accounts on the computer they can all use their own music folders?
EDIT: Incidentally, mpd started automatically as root the moment I installed it.
Last edited by pvsage (2009-11-02 15:18:42)
Offline
I'll wager his problems were the same as mine - mpd starting either at boot or at login, forcing a sudo killall to release port 6600. I think the update should be to add his bit about editing /etc/default/mpd.
Yep. That was it.
Maybe another option would be to simply let mpd run as root, and have a symlink in /var/lib/mpd/music that points to ~/music, so if you have multiple accounts on the computer they can all use their own music folders?
Running it as root and pointing to ~/music would make it search for music from root's home folder (mpd doesn't know what user is controlling it through mpc/sonata/etc). If you run it as root or as mpd's own user (default is a user named "mpd"), you should use the full path to the music and make sure that the user mpd is being run under has permissions for that folder. This is the way mpd is usually run. It's quite cool in a way, you can log out, switch users or do pretty much anything other than turning the computer off and the music just keeps playing.
That's the way I ran it the last time, but especially making sure the "mpd" user had the rights and privlidges to access the music was a little confusing. Unlike when you run it under your own user, where if you can access the music yourself, so can mpd.
Last edited by MacAnkka (2009-11-02 15:47:25)
Offline
well ive added an update section saying if you get errors such as
"problem opening log file "/root/.mpd/mpd.log" (config line 11) for writing"
or mpd not finding music files, im guessing those would be the symptoms?
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
If you run it as root or as mpd's own user (default is a user named "mpd"), you should use the full path to the music and make sure that the user mpd is being run under has permissions for that folder.
IOW, dump all music in e.g. /music and set that directory's owner as mpd, but give all users permissions to that folder so they can add music to it? That sounds like it could become an even bigger quagmire if you have luser accounts on your system. Giggity giggity!
I suppose it might be best to just go through the trouble of setting up mpd for the individual client first, then copy .mpdconf to the individual user and luser home directories as needed.
Offline
The specific error I found due to mpd autostart (assuming I had edited .mpdconf properly) was
unable to bind port 6600: Address already in use
maybe MPD is still running?
Aborted
when I tried to run mpd as a regular user.
Offline
ok ive added that bit as well
- - - - - - - - Wiki Pages - - - - - - -
#! install guide *autostart programs, modify the menu & keybindings
configuring Conky *installing scripts
Offline
The file in /etc/default is mpd, not mpd.conf. But thanks for updating the instructions!
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat