You are not logged in.

#1 2009-07-28 16:20:43

klazsick
Member
Registered: 2008-07-10
Posts: 12

[solved] mpd and external hard drive

Is there a way that i could make mpd start when i plug in my external hard drive and stop when i unmount it?

I'm using open box and pcmanfm if it matters.

Thanks

Last edited by klazsick (2009-07-31 23:56:09)

Offline

#2 2009-07-28 16:40:49

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [solved] mpd and external hard drive

this would be possible via udev rule that, on ADD, calls an external script to mount the drive and start mpd (and the reverse on REMOVE).  though, i don't remember the syntax and i'm not sure how that would play with our current hal situation.

Offline

#3 2009-07-31 21:01:12

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: [solved] mpd and external hard drive

Hello Klazsick!

Like brisbin33 said udev rules will be your choice, i think:
http://reactivated.net/writing_udev_rules.html

Offline

#4 2009-07-31 23:55:40

klazsick
Member
Registered: 2008-07-10
Posts: 12

Re: [solved] mpd and external hard drive

Thanks
It took me a while to figure out the syntax, but i eventually got there.  Anyway, if any one else wants to do this here are my udev rules.  You'll have to change the serial code to the serial code for your device, and change the symlinks and mount points to whatever you want.  It can be found out by: udevadm info -a -p `udevadm info -q path -n /dev/sda`

ACTION=="add", SUBSYTEM=="usb", ATTRS{serial}=="your serial here", NAME="%k", SYMLINK+="mybook", GROUP="storage"
ACTION=="add", SUBSYTEM=="usb", ATTRS{serial}=="your serial here", RUN+="/bin/mkdir -p /media/MyBook"
ACTION=="add", SUBSYTEM=="usb", ATTRS{serial}=="your serial here", RUN+="/bin/mount -t ext3 -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/mybook /media/MyBook"
ACTION=="add", SUBSYTEM=="usb", ATTRS{serial}=="your serial here", RUN+="/usr/bin/mpd", RUN+="/usr/bin/mpc play"
ACTION=="remove", ENV{ID_SERIAL_SHORT}=="your serial here", RUN+="/usr/bin/mpd --kill"
ACTION=="remove", ENV{ID_SERIAL_SHORT}=="your serial here", RUN+="/bin/rmdir /media/MyBook"

I don't have an umount line because i like to unmount my devices before I pull the plug and mpd has to be stopped before you can eject. If you don't have mpc, or don't want it to play when you plug it in change the RUN+="/usr/bin/mpc play" command.  And you might need to change the file type of the hard drive

Offline

Board footer

Powered by FluxBB