-
-
Save jotachango/4aee9ac8afe5bdd63450 to your computer and use it in GitHub Desktop.
Revisions
-
captsens created this gist
Feb 16, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #!/bin/sh ### BEGIN INIT INFO # Provides: mpd-autoplay # Required-Start: mpd # Required-Stop: # Should-Start: # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Ensures that mpd plays on startup # Description: Starts after mpd, and uses the mpc client to tell mpd to play ### END INIT INFO # # Requires mpd and mpc # # To install, use 'insserv mpd-autoplay' . /lib/lsb/init-functions case "$1" in start) mpc play ;; stop|restart) ;; status) echo "Nothing to see here, move along..." ;; *) echo "Usage: $0 start|stop|restart|status" exit 2 ;; esac This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ ## Introduction This gist describes a means of getting mpd (music player daemon) to auto-play when it starts. This may be of interest to those (like me) using computers like the Raspberry Pi as a music player connected to a stereo amp. There's probably a way of getting mpd to auto-play directly, but I haven't found it. My solution was therefore to create a daemon init script which starts after mpd, and which uses mpc (an mpd client) to start mpd playing. If you've got mpd configured to store its state on exit, this means that it should start at the same place in the play list as when it shut down. These instructions use the LSB init mechanism, which is supported by Debian (and variants, such as Raspbian). It should be trivial to convert them to using the standard SysV init mechanism, if you want. ## Requirements - A distro with support for LSB init scripts (see intro) - mpd (installed, and starting via an LSB init script) - mpd configured to store playing state (probably via the `state_file` setting in `/etc/mpd.conf`, or wherever the config is on your system) - mpc (installed) ## Instructions Note: these instructions are for a Raspberry Pi system running Volumio (volumio.org) Log in as root, and install the mpd-autoplay file: # cp /where/you/put/mpd-autoplay /etc/init.d/mpd-autoplay # chmod 755 /etc/init.d/mpd-autoplay # insserv mpd-autoplay || echo "Oops - failed to install!" The last line ensures that the script is executed whenever the system starts, after mpd is running. To test without restarting the box: - Ensure that mpd is running, with some songs in the playlist - Pause playback in mpd, via whatever client you use - Execute the following as root: `service mpd-autoplay start`, and mpd should start playing again.