You are not logged in.
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
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.
//github/
Offline
Hello Klazsick!
Like brisbin33 said udev rules will be your choice, i think:
http://reactivated.net/writing_udev_rules.html
Offline
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