Categories
Stuff

Raspberry Pi Kiosk Mode

For home automation or such. Directly boot into a graphical screen and allow user interaction through a touchscreen.

Setup 1: Living Room Control Panel

Intention is that this is “off” by default, turns on when the screen is touched, then allows interaction with a browser, and after some time of no use turns off again.

The method I’m using follows what’s lined out here, or on various other pages. Basically configure the raspi to autologin with graphical UI, then configure the user’s X session in ~/.config/lxsession/LXDE/autostart like this:

@xscreensaver
@/usr/bin/chromium-browser --check-for-update-interval=31536000 --noerrdialogs --disable-features=TranslateUI --disable-infobars --incognito --kiosk http://192.168.5.73:1880/ui/

Using xscreensaver because here it’s trivial to include in the LXDE autostart. There’s also an .xscreensaver file for a simple blank screensaver:

timeout: 0:01:00
lock: False
splash: False
dpmsEnabled: True
dpmsQuickOff: True
mode: blank

To make the boot slightly faster and avoiding extra graphics the /boot/cmdline.txt includes logo.nologo and /boot/config.txt includes disable_splash=1

I should consider a regular reboot, but this is running stable enough not to require that. If I remember correctly I also struggled a lot with getting Chromium to properly output sound to a USB-connected soundcard/speaker, but I don’t remember what I did to get it to work – I think it was about running pavucontrol while Chromium was playing some sound, and then fixing devices/volumes in there. Side note: Chromium does not include Google’s Text-to-Speech system, and I could not get some system-side thing (e.g. espeak) to work.

Setup 2: Device Controller

I’m working on a little something that I’ll share more about later. This “needs” (*ahem*) a Raspberry Pi with a small touchscreen as a local interactive controller. I have an (old) Watterott 2.8″ touch display I want to use on a Raspberry 3a.

The setup needs to be a little different than the one described above. This will run a fullscreen Kivy app and the screensaver should be steered by this app and not happen automatically. The system might even be shut down between it’s use, I’ll see about that later.

The basic Kivy installation is described here.

I’m using chilipie-kiosk as the concept for the basic setup, steps:

  • raspi-config: System -> Boot -> Console Autologin for user kapet (that should be automatically the case if sudo from that user).
  • Couple of small tweak/optimizations to make boot faster/cleaner:
    • Empty out /etc/motd, so it’s not shown when user is logged in.
    • Add disable_splash=1 to /boot/config.txt (not 100% sure this helps but it doesn’t hurt either…)
    • Make sure splash screen at boot is disabled, raspi-config: System -> Splash at boot
    • Add After=getty.target in the [Unit] section of /etc/systemd/system/raspi2fb@.service to show fewer of the boot msgs on the TFT (and maybe boot a tiny bit quicker).
  • And remember to enable the GL (not Legacy!) driver in raspi-config or Kivy will be nasty slow. “Fake KMS” GL driver works well on my Raspberry Pi 3a, but unfortunately X11 gets confused of the screen resolution and needs a manual hint by running xrandr in the .xsession file.

Add this at the top of ~/.profile to start X when auto-logged’in:

if [ "$(tty)" == "/dev/tty1" ]; then
    exec startx >/dev/null 2>&1
fi

Create an ~/.xsession file for X setup and starting the app:

#!/bin/bash

export DISPLAY=:0.0

# X11 gets the resolution wrong with the GL driver
xrandr --output HDMI-1 --mode 320x240

# disable automatic screensaver, app will handle this
xset s off
xset -dpms
xset s noblank

cd /home/kapet/ergo
bin/python3 ergo.py >stdout.log 2>stderr.log &

# a window manager is required of VNC doesn't work properly
exec matchbox-window-manager -use_titlebar no

Leave a Reply

Your email address will not be published. Required fields are marked *