This post shows steps to setup a web kiosk using Raspberry Pi. The goal is to load a web page using a browser in full-screen kiosk mode directly after boot up.
I tested it with Raspberry Pi 3 B+ running Raspbian Stretch (November 2017 version) with Raspberry Pi official 7″ display. I used Chromium as browser. Also, Internet connection is required since the kiosk access a web site on the Internet.
Steps
1. install software
Install unclutter which hides mouse cursor.
sudo apt-get update
sudo apt-get install unclutter -y
2. Screen setting
2-1. Create .xinitrc in home directory.
nano ~/.xinitrc
2-2. Copy below lines, save and close the file.
#!/bin/sh
# disable blank screen
xset s off
xset -dpms
xset s noblank
# hide mouse cursor when it's not moving
unclutter -idle 0.1 &
# launch browser
exec chromium-browser --window-size=800,480 --incognito --kiosk --window-position=0,0 https://www.wunderground.com/fullscreenweather
Line 4-6 disables blank screen. [1]
Line 9 enables the mouse pointer only when it’s moving.
The browser loads full-screen weather [2] which is great for kiosk example. (Line 12)
‘incognito’ option disables session restore prompt on Chrome browser. [3] (Line 12)
3. Setting for launching browser when login
3-1. Open .bashrc.
nano ~/.bashrc
3-2. Add below lines at the end of the file.
if [ -z "${SSH_TTY}" ]; then
startx > /dev/null 2>&1
fi
At this point, full-screen weather (specified at line 12 in step 2-2) will be shown after boot up. Check it by rebooting the board.
Below steps are to remove unnecessary stuff for kiosk, such as Rainbow image, Raspberry logo, Desktop GUI, login messages, etc
4. Disable Desktop Environment (PIXEL/LXDE)
Since desktop environment is not required for kiosk, let’s disable it.
4-1. Launch raspi-config.
sudo raspi-config
4-2. Navigate to “Boot Options” > “Desktop / CLI“, then select “Console Autologin“.
5. Disable “Welcome to PIXEL” splash
Disable plymouth-start service.
sudo systemctl mask plymouth-start.service
6. Remove Rainbow Screen
6-1. Open “/boot/config.txt”.
sudo nano /boot/config.txt
6-2. Add below at the end of the file.
# Disable rainbow image at boot
disable_splash=1
7. Remove Raspberry Pi logo and blinking cursor
7-1. Open “/boot/cmdline.txt”.
sudo nano /boot/cmdline.txt
7-2. Add below at the end of the line.
logo.nologo vt.global_cursor_default=0
‘logo.nologo’ and ‘vt.global_cursor_default=0’ remove Raspberry Pi logo and blinking cursor, respectively.
8. Remove login message
8-1. Create ‘.hushlogin’ file in home directory.
touch ~/.hushlogin
It removes login message below [4]:
Last login: Tue Nov 21 14:51:56 2017
Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
9. Remove autologin message by modify autologin service
9-1. Open the unit file for autologin service.
sudo nano /etc/systemd/system/autologin\@.service
9-2. Modify the line starts with “ExecStart”
From:
ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM
To:
ExecStart=-/sbin/agetty --skip-login --noclear --noissue --login-options "-f pi" %I $TERM
It removes autologin message below:
Raspbian GNU/Linux 9 raspberrypi tty1
raspberrypi login: pi (automatic login)
10. Verify
Now, everything should be ready. Reboot the board and see if it works properly.
sudo reboot
In case a lightning bolt icon is shown in the right-top corner of the screen, see this post.
References
[1] How do I prevent the screen from going blank?
[2] https://www.wunderground.com/fullscreenweather
[3] How to hide chrome warning after crash?
[4] Remove GNU licence and ‘no warranty’ thing when logging into ssh
[5] Setup a Raspberry Pi Kiosk with Chromium
[6] How to build a web kiosk with Raspberry Pi and make the SD read-only