Skip to content

Instantly share code, notes, and snippets.

@bheisig
Last active January 15, 2024 08:05
Show Gist options
  • Save bheisig/fb7d25ec9516505a923f8d50fe8b4611 to your computer and use it in GitHub Desktop.
Save bheisig/fb7d25ec9516505a923f8d50fe8b4611 to your computer and use it in GitHub Desktop.
Run Raspberry 3 in digital signage mode with Chromium Web browser on a TV screen

Dashboard with a Raspberry Pi

Run Raspberry 3 in digital signage mode with Chromium Web browser on a TV screen

Pre-work

Download Raspbian Jessie Lite

Follow installation instructions

Login via SSH: ssh pi@ip-address. Password is raspberry.

Install some packages

Install some packages and reboot:

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install matchbox chromium-browser cec-utils xinit x11-xserver-utils ttf-mscorefonts-installer xwit sqlite3 libnss3
sudo systemctl reboot

Tweak Pi's config

Edit Pi's own configuration file /boot/config.txt. This works for me on a LG Full HD TV screen:

disable_overscan=1
framebuffer_width=1920
framebuffer_height=1080
hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=31

Check the best mode by running /opt/vc/bin/tvservice -m CEA. The TV screen has activated CEC support (called simplink). I use this feature to automatically turn on the TV while Pi is booting.

Prepare X server

Because there is currently (January 2017) a bug in X/xinit we need more privileges on /dev/tty*. Edit etc/rc.local. Add this:

if [ -f /boot/xinitrc ]; then
    chmod 0660 /dev/tty*
    ln -fs /boot/xinitrc /home/pi/.xinitrc;
    su - pi -c 'startx' &
fi

Allow user pi to start the X server:

sudo dpkg-reconfigure x11-common # Set to "Anybody"

Create file /boot/xinitrc:

#!/bin/sh

while true; do
    # Turn on TV
    echo "on 0" | cec-client -s

    # Clean up previously running apps, gracefully at first then harshly
    killall -TERM chromium-browser 2>/dev/null;
    killall -TERM matchbox-window-manager 2>/dev/null;
    sleep 2;
    killall -9 chromium-browser 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 &

    chromium-browser --disable-translate --app=https://example.net/
done;

Done

Reboot your Pi and you are hopefully done.

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment