Detachable cmus / "daemon" mode

Cmus doesn't support detaching natively. However, using screen and a shell script, you can have very similar behavior. Save this bash script under a directory in your PATH that is read before the directory where the cmus binary is located, e.g. $HOME/bin/cmus:

cmus
#!/bin/bash
if ! screen -r -D cmus >/dev/null ; then
    screen -S cmus /usr/bin/cmus "$@"
fi

Make sure the script is executed instead of the normal binary by putting it at first position in your PATH variable, e.g. by setting

export PATH=$HOME/bin:$PATH

in your ~/.bashrc.

Now in cmus, set the q key to screen detach:

:bind -f common q shell screen -d cmus

Finished! This way, if you press q cmus will simply go in the background (really fast), and by typing cmus in the shell you just resume where you left of. If you want to really quit cmus, you can simply enter

:quit
 
detachable_cmus.txt · Last modified: 2012/09/15 13:04 by jmuc
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki