script: stop at track

One feature I was wanting in MOC was a "stop at this track" flag, but after installing the 2.5.0-alpha3 version, I realized I could do this with the OnSongChange handler, so here's what I did, in case anyone else wants this feature...

First, you might need to set up your ExecCommands to run from an external script for this to work - that's how I do things, and I haven't tried it otherwise, but I don't think the redirect works from within MOC, so something like

ExecCommand10 /home/me/.moc/stop_here %f

in your config, and then .moc/stop_here script does

echo "$1" > ~/.moc/stopfile

and also in config:

OnSongChange = /home/me/.moc/check_stopfile %f

and finally .moc/check_stopfile does

if [ "$1" == "$(cat ~/.moc/stopfile)" ]
then mocp --pause && rm ~/.moc/stopfile
fi

This is a simplified version of what I did (all my ExecCommands are in one script) and it could probably be improved, but it seems to work quite well, and I'm happy with the results. The only catch is that you have to select the song you want to stop *before* when setting the stop point, rather than the last track to play as in certain other music players.