Raspbian Jessie Kiosk

April 15, 2016
dev

Raspberry Pi


Who doesn’t love a Raspberry Pi? The little cruncher that can has spent the last couple of years redefining accessibility, portability, and utility in a palm-sized package. I’ve enjoyed their practicality and approachability at work and at play: app servers, radios, Hubots, and the list goes on. At work, one of the neater applications we’ve had for it has been as a series of kiosk displays around campus that report stats on sales, performance, and logistics to everyone.

Recently, we’ve been going through a re-imagining of the project. For the last couple of years, the displays have dished up a serviceable little in-house combo of AngularJS app on top of an ASP.NET API. Nothing special: mostly just tables and a few diagrams with the facts. But now we’re replacing it all. The Web API has already been swapped out for a super-fun Nancy service and we’re in the process of upgrading the hardware from Pi 1 Model A and Bs to Pi 3 Model Bs.

I wanted to work out the most dead-simple solution using the Pi 3’s default distribution, Jessie, for which Chromium (an integral part of our previous solutions) is presently not easily available. I ended up with a 2-file, 9-line solution that seems to work pretty well.

The Good Bits:

Autostart

Jessie handles LXDE autostart somewhat differently than I’m used to. As this Stack Exchange post explains, Jessie takes the liberty of silently giving the user an autostart file, so any changes you might hammer into the global autostart file get ignored. So we head to ~/.config/lxsession/LXDE-pi/autostart.

We make it look like this:

@xset s off
@xset -dpms
@start_kiosk.sh

Save that and create, as root, the referenced start_kiosk.sh file in /usr/bin/.

Startup script

#!/bin/sh

epiphany-browser -a --profile /home/pi/.config http://example.com &
sleep 5s
echo key F11 | xte

It’s worth noting this requires a single package that doesn’t come with the system image: xautomation. Don’t forget to install that or your kiosk won’t go fullscreen on launch. Epiphany-browser doesn’t seem to have a documented way to start fullscreen from the command line, so we’re using xte to actually create the F11 key press.

With this saved snugly in /usr/bin/ and therefore the path, make it executable (chmod +x). And that’s pretty much it. Boot up your little buddy and enjoy your kiosk!