Setting up Digital Signage with Raspberry

Quick tutorial for setting up Raspberry as Digital Signage and stream a video to it. It includes setup of a customised splash screen during boot, configuration of a light Windows Manager on Linux and auto-launch of Chrome browser to browse the vide.

Kick off installation with:

apt-get update
apt-get install apache2 php5 php5-gd chromium vlc fbi scrot
apt-get install matchbox chromium x11-xserver-utils xorg sqlite3 libnss3

X Org/Chromium on Start Up

First thing to do is set the screen resolution for full range;

cd /boot/
cp config.txt config.txt.20150210
vi config.txt

Add this to the config.txt;

# uncomment to force a console size. By default it will be display's size minus
# overscan.

Next add the following to /etc/rc.local so that it recognizes the config set;

# Wait for the TV-screen to be turned on...
while ! $( tvservice --dumpedid /tmp/edid | fgrep -qv 'Nothing written!' ); do
        printf "===> Screen is not connected, off or in an unknown mode, waiting for it to become available...\n"
        sleep 10;

printf "===> Screen is on, extracting preferred mode...\n"
eval $( edidparser /tmp/edid | fgrep 'preferred mode' | tail -1 | sed -Ene 's/^.+(DMT|CEA) \(([0-9]+)\) ([0-9]+)x([0-9]+)[pi]? @.+/_GROUP=\1;_MODE=\2;_XRES=\3;_YRES=\4;/p' );

printf "===> Resetting screen to preferred mode: %s-%d (%dx%dx%d)...\n" $_GROUP $_MODE $_XRES $_YRES $_DEPTH
tvservice --explicit="$_GROUP $_MODE"
sleep 1;

printf "===> Resetting frame-buffer to %dx%dx%d...\n" $_XRES $_YRES $_DEPTH
fbset --all --geometry $_XRES $_YRES $_XRES $_YRES $_DEPTH -left 0 -right 0 -upper 0 -lower 0;
sleep 1;

Restart the server and ensure the display shows correctly on monitor attached.

Next add a new file called xinitrc in the /boot/ directory;

Add the following;

while true; do

        # Clean up previously running apps, gracefully at first then harshly
        killall -TERM chromium 2>/dev/null;
        killall -TERM matchbox-window-manager 2>/dev/null;
        sleep 2;
        killall -9 chromium 2>/dev/null;
        killall -9 matchbox-window-manager 2>/dev/null;

        # Clean out existing profile information
        rm -rf /home/pi/.cache;
        rm -rf /home/pi/.config;
        rm -rf /home/pi/.pki;

        # Generate the bare minimum to keep Chromium happy!
        mkdir -p /home/pi/.config/chromium/Default
        sqlite3 /home/pi/.config/chromium/Default/Web\ Data "CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); INSERT INTO meta VALUES('version','46'); CREATE TABLE keywords (foo INTEGER);";

        # Disable DPMS / Screen blanking
        xset -dpms
        xset s off

        # Reset the framebuffer's colour-depth
        fbset -depth $( cat /sys/module/*fb*/parameters/fbdepth );

        # Hide the cursor (move it to the bottom-right, comment out if you want mouse interaction)
        xwit -root -warp $( cat /sys/module/*fb*/parameters/fbwidth ) $( cat /sys/module/*fb*/parameters/fbheight )

        # Start the window manager (remove "-use_cursor no" if you actually want mouse interaction)
        matchbox-window-manager -use_titlebar no -use_cursor no &

        # Start the browser (See
        chromium  --app=http://localhost/myvideo.mp4


Copy your favourite video (in this case myvideo.mp4) to /var/www assuming that this is your root www document directory.

cp /boot/xinitrc /home/pi/.xinitrc

Next, let’s get X started straight after boot by editing /etc/rc.local:

# Boot X on start up
if [ -f /boot/xinitrc ]; then
        ln -fs /boot/xinitrc /home/pi/.xinitrc;
        su - pi -c 'startx' &

Install Video Streaming for Apache

Follow howto instructions to install Video Streaming

Splash Screen

Copy your favourite logo (mylogo.png) to the tmp directory on the server. This will section will force your logo to show on boot instead of server startup script;

cp /tmp/mylogo.png /etc/splash.png

vi /etc/init.d/asplashscreen and add the following to file

#! /bin/sh

# Provides:             asplashscreen
# Required-Start:       
# Required-Stop:        
# Default-Start:        S
# Default-Stop:         
# Short-Description:    Show custom splashscreen
# Description:          Show custom splashscreen 
do_start () {

    /usr/bin/fbi -T 1 -noverbose -nofitwidth /etc/splash.png    
    exit 0

case "$1" in
    echo "Error: argument '$1' not supported" >&2
    exit 3
    # No-op
    exit 0
    echo "Usage: asplashscreen [start|stop]" >&2
    exit 3

Set image file permissions:

chmod a+x /etc/init.d/asplashscreen 
insserv /etc/init.d/asplashscreen

Backup original boot line text and then amend to below in cmdline.txt:

cd /boot/
cp cmdline.txt cmdline.txt.20150210
vi cmdline.txt

This should look something like:

dwc_org.1pm_enable=0 console=ttyASMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Change it to:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait logo.nologo

Thats it, restart and check it out!!