I’ve setup my Raspberry Pi 3 to be a digital signage kiosk. I’ve installed the Adafruit 3.5″ PiTFT Plus touch screen, and am using it to show my weather station data in real time. This is done by having the Raspberry Pi auto log in and run Chromium to open a webpage.
I’ve shared how I’ve setup a full digital signage system using Ubuntu and Chromium for Kiosk mode. This post will repeat a lot of the same in that article, but tailor it to the Raspberry Pi. Here’s how I did it:
The first step is to get Raspbian Jesse installed, perform
sudo apt-get update && sudo apt-get upgrade and if you have the Adafruit 3.5″ touchscreen installed, run through their install process to install the kernel which has the software needed to get the display working.
I also chose to remove software that came preloaded because I don’t have a need for it.
sudo apt-get remove --purge wolfram-engine scratch nuscratch sonic-pi idle3 smartsim penguinspuzzle java-common minecraft-pi python-minecraftpi python3-minecraftpi
Once you have an updated machine, with updated hostname timezone and with a working display, continue onto the next step.
Setup Auto Login
The Raspberry Pi should auto log in by default, but if not you can check the setting for that by running
sudo nano /etc/lightdm/lightdm.conf and looking for:
Then we need to create the auto login task which will run the script. Run
nano /home/pi/.config/autostart/kiosk.desktop and add:
[Desktop Entry] Type=Application Name=Kiosk Exec=/home/pi/kiosk.sh X-GNOME-Autostart-enabled=true
Setup the kiosk.sh script
Now we need to setup the script which will run once we’re logged in. Run
nano /home/pi/kiosk.sh and add:
#!/bin/bash # Run this script in display 0 - the monitor export DISPLAY=:0 # Hide the mouse from the display unclutter & # If Chrome crashes (usually due to rebooting), clear the crash flag so we don't have the annoying warning bar sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences # Run Chromium and open tabs /usr/bin/chromium-browser --window-size=480,320 --kiosk --window-position=0,0 https://google.com https://bing.com & # Start the kiosk loop. This keystroke changes the Chromium tab # To have just anti-idle, use this line instead: # xdotool keydown ctrl; xdotool keyup ctrl; # Otherwise, the ctrl+Tab is designed to switch tabs in Chrome # # while (true) do xdotool keydown ctrl+Tab; xdotool keyup ctrl+Tab; sleep 15 done
Then make the script executable by running
chmod +x kiosk.sh
As you can see Chromium runs in Kiosk mode. This means it’ll go full screen and take minimal input from the keyboard and mouse (if one was plugged in). In this example, Chromium will auto load Google and Bing in 2 tabs, and xdotool will cycle between the tabs every 15 seconds. I’m also performing some Chrome clean up in case the system reboots without closing Chrome. This will remove the nag bar.
Managing the system after it’s setup
To manage the Pi after it’s setup, you’ll need to find the IP and SSH into it. Be careful because SSH’ing to the Pi as the user
pi will end up running 2 kiosk.sh scripts.
Other things you can add to
kiosk.sh are running
autossh to automatically setup an SSH tunnel from the system to your centralized server, allowing you to SSH into the device and even VNC to the monitor without needing to know the IP. Very useful!
If you make any changes and want to log out without rebooting, I’ve found that this command works. This will kill the kiosk.sh script and restart the Windows service which will log out and log in the kiosk user.
sudo killall kiosk.sh && sudo service lightdm restart
How to exit Kiosk mode
The Raspberry Pi PIXEL Desktop allows you to press the Windows key on your keyboard to open their menu. You can then navigate the menu to Accessories > Terminal. Once in the terminal type
sudo killall chromium-browser or just press Alt+F4 to close Chromium.
The kiosk.sh script will still be running, this script has the xdotool keydowns running (see above). We need to kill that too with
sudo killall kiosk.sh. To remove it all together, refer to the above to remove the /home/pi/.config/autostart/kiosk.desktop file.
That’s basically it! A quick way to get a Kiosk setup which shows multiple tabs of information.
I hope this helps someone, and if you have any suggestions on improvements, let me know in the comments!
You can start your DigitalOcean server for as low as $5/mo and be online in 1 minute. Best yet, if you use this link you get $10 credit for free!