Browser Kiosk with a Raspberry Pi

Raspberry Pi-driven meetup info board behind the NoVALabs front desk.
Raspberry Pi-driven meetup info board behind the NoVALabs front desk.

I’ve been working lately on making some TVs mounted around my local maker space more useful, displaying event information pulled from meetup.  I opted to generate the displays with HTML, and wanted a no-frills thin client that would boot straight to a full screen web browser to display the info.  This kind of setup would also be useful for a dedicated web-app on a kiosk with a touch screen.

Here’s how I did that on a Pi B+ and 3, but the following instructions should work with any Raspberry Pi:

  1.  Download and extract Raspbian Jessie Lite to an SD card.  2GB was plenty big for my application
  2. Update the base packages and install our needed applications.  Do not install unclutter if you want to see your cursor (e.g. for a kiosk with a physical mouse)
    sudo apt-get update && sudo apt-get upgrade
    sudo apt-get install --no-install-recommends xserver-xorg xinit
    sudo apt-get install fvwm iceweasel unclutter
  3. Set a static IP and hostname, if desired. Note that this process is different in Jessie than it has been in prior Debian distros.
  4. Run sudo raspi-config and select:
    1. Internationalisation Options > Change Timezone and set local timezone.
    2. Select Advanced > Overscan > “No” to disable overscan.
    3. Enable Wait for Network at Boot.
    4. Set GPU memory split to 128 or higher, if desired.  128 works well for the Pi 3.
  5. Out of the box, the Pi has some aggressive screen blanking settings, configured for both the console and X. Edit/etc/kbd/config and change the following lines:

    Edit /etc/X11/xinit/xinitrc and append the following:
    xset s off
    xset -dpms
    xset s noblank

  6. There are probably better ways to auto-start X using systemd, but nothing I tried work. Instead we’ll rely on rc.local compatibility, but to do so we need to change the X security model to allow a non-console user to start the server.  Run sudo dpkg-reconfigure x11-common and select “Anybody”.
  7. Issue startx to load fvwm, open an xterm window by right clicking on the desktop and following the menu, and run iceweasel -ProfileManager. Create a new profile called “Kiosk” and start that session. Install the R-kiosk plugin.  This will force the browser full-screen, disable right-click, and disable the majority of browser controls and shortcuts.
  8. mkdir -p ~/.config/autostart
  9. Create new file ~/.config/autostart/ with the following contents (be sure to replace <URL> with the URL you want the browser to load:
    # Set the date (novalabs has a very restrictive firewall, no NTP outbound.)
    # Remove this line if NTP works for you
    sudo date -s "$(wget -qSO- --max-redirect=0 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
    /sbin/ifconfig | grep inet > /tmp/ifconfig
    xmessage -file /tmp/ifconfig &
    xmessage -center -timeout 30 "Loading display..." &
    /usr/bin/iceweasel -P 'Kiosk' -no-remote <URL>
    rm /tmp/ifconfig
  10. Make the script executable: chmod u+x ~/.config/autostart/
  11. Create ~/.fvwm/config and add these contents:
    DestroyFunc StatFunction
    AddToFunc StartFunction
    + I Test (Init) Exec ~/.config/autostart/
  12. Edit /etc/rc.local and put this line before exit 0:
    exec su -l pi -c startx

Reboot, and you should be greeted by your URL loaded full screen.  If you want to check the IP of the Pi to control it over ssh, etc, connect a keyboard and Alt+Tab to see that message window.  If you are using a mouse and keyboard on your kiosk, you will need to tweak the fvwm configuration to remove the extra desktops and further lock down the keyboard shortcuts.