The Raspberry Pi has proven itself to be a great computing device while keeping cost as low as possible. For less than $40 you are getting a great little device with its 64-bit ARM processor. This made me think, would it be a good idea to turn the Raspberry Pi 3 into a kiosk?
The software that you'll need
A list is not even needed, because you only need three things: Raspbian Jessie Lite installed as the OS, the X11 display stack installed and the Chromium webbrowser installed on the Pi.
Why Chromium
Chromium is the open source variant of the popular Google Chrome
browser. It has great potential for this project because of the --kiosk
flag. With this option you can create a full-screen browser window inside your empty X11 session.
Installing the X11 display stack
You can install the X11 display stack on your Raspberry Pi with the following command:
sudo apt install xserver-xorg xinit
This will install the X11 server on your Pi together with the X11 server initialisation program. You also have to run this command:
sudo dpkg-reconfigure x11-common
To select who's authorized to start the X11 server. Make sure it is set like this:
Installing Chromium
Just run sudo apt install chromium-browser
to install Chromium on your Pi. It's literally that simple.
Writing the .xinitrc script
When you execute the xinit
command on your Pi, you will
see a terminal window instead of Chromium. To fix this, you'll need to
write a file in your home directory called ~/.xinitrc
. This file contains everything that gets run when the X11 server starts up. So, edit this file with nano
(or any other text editor) and make sure it looks like this:
Save it, and try running Chromium by invoking the xinit
command on your Pi.
But... my window is not fullscreen!
It could be that your Pi shows black borders around the screen, which has to do something with overscan. Open your /boot/config.txt
file (with sudo) and add disable_overscan=1
to this file like this:
Reboot your Pi and the problem should magically disappear! (at least, that's what happened to me...)
Starting X11 at boot
Raspbian comes with a built-in tool to configure your Pi: raspi-config
. Run this command on your Pi and you will be greeted with a command-line dialog window. Go to option 3 and press enter:
And then go for option 2:
Press enter, go to finish and when the program asks for a reboot choose yes.
Once you have rebooted your Pi, you'll have to do one more thing to
finish this project: finally starting X11 at boot! My method might be
more sophisticated than needed, but hey: it worked for me. Edit the ~/.bashrc
file in your favourite text editor and add the following to the bottom of the file:
if [ -z "$SSH_CLIENT" ] || [ -z "$SSH_TTY" ]; then
xinit -- -nocursor
fi
save the file and reboot your Pi. Enjoy your beautiful self-made Raspberry Pi Kiosk!
Load webpage from an URL specified in a file
A Raspberry Pi with the default partition layout contains two
partitions: the OS partition, and the BOOT partition which is formatted
in FAT32 and gets automatically mounted at boot. For example: create a
new file in /boot/ called website.txt and put your desired URL in it.
Finally to make it work you simply replace the URL in your ~/.xinitrc
file with $(cat /boot/website.txt)
and it should work! The thing is that you can actually see and modify
contents of this file in Windows, since the BOOT partition is
partitioned as FAT.