Boot a Raspberry Pi into a browser
March 2, 2015
(2016-05-16 Updated for latest Raspbian Jessie)
With the advent of the Rasperry Pi 2, it’s time to get into the Pi-ecosystem again and one of the things I wanted to see if there was more performance on was the use of chromium in my stats board.
I followed this guide a while back and I completely lost it at one point so I wanted to document my configuration changes to make a Raspberry Pi boot into a full-screen browser window. Useful in a kiosk or scoreboard/wallboard application with your favourite AJAXy application.
Install the latest version of Raspian, available from the Raspberry Pi foundation download page, to a fresh SD/MicroSD card (depending on your Pi version).
Update the OS and download chromium and it’s dependencies…
$ wget -qO - http://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
$ echo "deb http://dl.bintray.com/kusti8/chromium-rpi jessie main" | sudo tee -a /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install matchbox chromium-browser x11-xserver-utils ttf-mscorefonts-installer xwit sqlite3 libnss3 xserver-xorg-legacy
$ sudo reboot
Modify the /boot/config.txt to enable overscan if you have black edges around the Pi. You may also need to change the TV setup to “Just Scan” or equivalent to make this work nicely.
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1
Add the command to startx after boot, just before the exit 0 line in /etc/rc.local
su - pi -c 'startx' &
In Jessie you need to allow “anybody” to run X for this to work so make that change in /etc/X11/Xwrapper.config
#allowed_users=console
allowed_users=anybody
Create the Chromium profile info:
$ 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);";
Create the /home/pi/.xinitrc file
#!/bin/bash
while true; do
# 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;
# 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 http://peter.sh/experiments/chromium-command-line-switches/)
# I like to have the system tell me who it is in my app so I tack on the MAC address and IPv4 address
# (this makes debugging on a specific Raspberry Pi easier)
MAC=$(/sbin/ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | awk '{print tolower($0)}')
IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
/usr/bin/chromium-browser --app=https://weezey.com/awesome-app?mac=$MAC\&ip4=$IP
done;
Now just reboot and you’ll boot into the lightweight browser-only, full-screen page!
wget -qO - http://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
echo "deb http://dl.bintray.com/kusti8/chromium-rpi jessie main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install chromium-browser
Leave a Reply