- Prerequisites
- Step-by-Step
- Configure the raspberry pi
- Update package (apt) data.
- Install x server and tools
- Install openbox and chromium
- Install mesa drivers for hw acceleration
- Edit /etc/xdg/openbox/autostart as root, and add the following content
- Edit /etc/xdg/openbox/environment as root, and add the following
- Edit/append to ~/.bash_profile
- Reboot
- Bonus
- References
Tested on the Raspberry Pi 2B and higher, as well as the Pi Zero W. This configuration will also work for touch screens.
These instructions will work for HDMI and on-board display connections.
Prerequisites
- Some basic Linux terminal knowledge
- Flash Raspberry Pi OS Lite
- Wifi/network and SSH access.
- A connection to the internet
Step-by-Step
Configure the raspberry pi
Enter the command below, and use the configuration that follows. raspi-config
may have different menu structures, but the options should still be there.
sudo raspi-config
- Change the password
- Set Timezone (ie. America/Vancouver)
- Set Keyboard (optional, only if not using SSH)
- Choose “Generic 104-key PC” for US/Canada, 105-key PC (intl.) for the rest of the world
- Choose “Other Language -> English (US)”
- Update hostname
- Display Options -> Underscan -> No Compensation
- System Options -> Boot/Autologin -> Console Autologin -> Yes
- Set gpu memory to 128mb or more
- Set GL graphics driver the FakeKMS. Others may not display properly, or audio may not work
- Finish and Reboot
Update package (apt) data.
IMPORTANT! Do this before installing other packages.
sudo apt update
Install x server and tools
sudo apt install -y --no-install-recommends xserver-xorg xinit x11-xserver-utils xdotool
Install openbox and chromium
sudo apt install -y --no-install-recommends openbox chromium-browser
Install mesa drivers for hw acceleration
sudo apt install -y libgles2-mesa mesa-utils libsdl2-dev
Edit /etc/xdg/openbox/autostart
as root, and add the following content
xset -dpms # turn off display power management system
xset s noblank # turn off screen blanking
xset s off # turn off the screen saver
# Set manual resolution for X
# xrandr --output HDMI-1 --mode 1280x720 --rate 30
# Prevent chromium crash error popups
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences
# Run chromium with the KIOSK_URL env variable
chromium-browser --noerrdialogs \
--disable-infobars \
--kiosk $KIOSK_URL \
--check-for-update-interval=31536000 \
--ignore-gpu-blacklist \
--use-gl=egl \
--enable-native-gpu-memory-buffers \
--enable-accelerated-2d-canvas \
--force-gpu-rasterization \
--cast-app-background-color=000000ff \
--default-background-color=000000ff
# --disable-gpu-compositing \ # Do not disable gpu compositing. Canvas effects are smoother this way
Hint: Shift-Insert to paste into putty+vim in insert mode
Hint: Use the command :set
paste and :set nopaste
within vim, if auto-formatting is a problem when pasting.
Edit /etc/xdg/openbox/environment
as root, and add the following
export KIOSK_URL=http://localhost:3530
This will be the URL that will be opened when the RPi boots up.
Edit/append to ~/.bash_profile
# Start X server on boot
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
Reboot
sudo reboot
If X server gives an error and chromium doesn’t start, try setting a screen resolution in sudo raspi-config
or changing the GL driver. FakeKMS is preferred.
Bonus
In addition to serving up a webpage online, you can always host your own webserver right on the Pi! My preferred flavor is to run NodeJS+Express+ReactJS. This will allow for an offline- or unstable internet-capable device.
Git and docker can also be easily installed for automation and updates. (For earlier versions of RPi such as the Zero W, you will have to download and install Node.js specifically for ARMv6.)