fluxid / mocp-scrobbler

Last.fm scrobbler for MOC audio player, written in Python (version 3).
46 stars 5 forks source link

start together with mocp #5

Open eri451 opened 12 years ago

eri451 commented 12 years ago

of cause with -d an just once .. but how?

wideawakening commented 11 years ago

You could use an alias. ~/.bashrc

alias mocp='python3 /<path_where_script_is>/mocp-scrobbler.py -d ; mocp'
goetzc commented 9 years ago

Using this method causes mocp-scrobbler to kill itself and restart again after executing mocp.

$ mocp-scrobbler.py -d
Pidfile found! Attempting to kill existing scrobbler process...
Scrobbler daemon started with pid 6009

Why does this happen? Is there a way to prevent this?

mlyszczek commented 7 years ago

Best way is to create your own init script. This will start script on system startup and kill it on shutdown. With this solution you can relogin without killing neither moc nor moc-latfm.

For openrc it would be (just remember to change YOUR_USERNAME with your account username where moc is bein run)

#!/sbin/openrc-run

start() {
        ebegin "Starting mocp-lastfm"
        start-stop-daemon \
                --start \
                --make-pidfile \
                --pidfile /var/run/mocp-lastfm.pid \
                --background \
                --user YOUR_USERNAME \
                --name mocp-lastfm \
                --exec mocp-scrobbler.py -q
        eend $?
}

stop() {
        ebegin "Stopping mocp-lastfm"
        start-stop-daemon --stop --signal 15 \
                --pidfile /var/run/mocp-lastfm.pid
        eend $?
}