MOC - autorun - how?

Hello!
How add MOC to autorun in Ubuntu? What commands I need? I know /usr/bin/mocp -S will run server, but it can't be used with -p (play). I want run my computer and hear music, you know.

Thanks for all answers,
ixjakub :)

That's an easy fix. Create a file in your home directory named '.play-moc' and put in the following:


#!/bin/bash
mocp -S && \
mocp -p

and then in the terminal:


chmod 755 ~/.play-moc

Go into the Startup Applications menu and enter in ~/.play-moc . The bash file will take care of calling up the MOC server and also playing it.

This might be over the top, but I created an init.d script. It was my first one (and could probably use a lot of cleaning up), but it could help you out.

This is much prettier in Pastebin: http://pastebin.com/gPXfRq56

#!/bin/sh
### BEGIN INIT INFO
# Provides: MOCP Application Instance
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of mocp
# Description: starts instance of mocp using start-stop-daemon
### END INIT INFO


case "$1" in
start)
if ! pidof -o %PPID mocp > /dev/null; then
export HOME=/home/USER
sleep 5
start-stop-daemon --start --chuid USER --exec /usr/bin/mocp -- -S
/usr/bin/mocp --volume 100 --play
sleep 5
/usr/bin/mocp --on shuffle
/usr/bin/mocp --on autonext
/usr/bin/mocp --on repeat
echo "Starting MOCP..."
else
echo "MOCP Already Running..."
fi
;;


stop)
start-stop-daemon --stop --exec /usr/bin/mocp -- -x
;;


restart)
start-stop-daemon --stop --exec /usr/bin/mocp -- -x
sleep 1
if ! pidof -o %PPID mocp > /dev/null; then
export HOME=/home/USER
sleep 5
start-stop-daemon --start --chuid USER--exec /usr/bin/mocp -- -S
/usr/bin/mocp --volume 100 --play
sleep 5
/usr/bin/mocp --on shuffle
/usr/bin/mocp --on autonext
/usr/bin/mocp --on repeat
echo "Restarting MOCP..."
else
echo "MOCP Already Running, Restart Failed"
fi

;;


status)
if pidof -o %PPID mocp > /dev/null; then
echo "Running"
exit 0
else
echo "Not running"
exit 1
fi
;;


*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1