May 20, 2014

Day & Night Sampler - a raspberry pi mpd mini boombox Part 4: Starting the Boombox Automatically

See Part 3 of this project, Configure MPD Player.

Let's start making the software work together. First, copy code from github to your target raspberry pi. You should have already completed this in Part 2 of this project. You'll need the and scripts for the basic boombox functions. You can copy these to /home/pi.

Now we'll add software changes that make the raspberry pi act more like consumer electronics. It won't be "instant on", but it will start up in a minute or so and the script will start shortly after that. The following script can be copied from github, it's name is You should have already copied this in Part 2.

We need to start the main python script at power on.
Here is the script:
# Provides: rpi_boombox - now playing / date time /weather
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Main Menu shown on Vacuum Flourescent Display
# Description: now playing / date time /weather

#! /bin/sh
# /etc/init.d/rpi_boombox

export HOME
case "$1" in
        echo "Starting rpi_boombox"
        /home/pi/  2>&1 &
        echo "Stopping rpi_boombox"
    rpi_boombox_PID=`ps auxwww | grep | head -1 | awk '{print $2}'`
    kill -9 $rpi_boombox_PID
        echo "Usage: /etc/init.d/ {start|stop}"
        exit 1
exit 0

Add this script in /etc/init.d/rpi_boombox.

Reboot and the python script in /home/pi/ should start up auto-magically!

Continue to Part 5: Hardware Configuration

No comments:

Post a Comment