Friday, November 6, 2026

Raspberry Pi Kiosk Mode on Trixie Wayland

The default Raspberry Pi OS Trixie now runs Wayland as the default display server using rpd-labwc, a modified labwc window compositor. The difference is that rpd-labwc runs labwc with the --merge-config option so autostart will run both the user and system wide desktop programs.

  • User autostart: $HOME/.config/labwc/autostart
  • System autostart: /etc/xdg/labwc/autostart

This behavior differs from the vanilla labwc which lets the user autostart replace the system autostart.

The rpd-labwc merge-config will always start the default desktop environment in the system autostart and then run the user autostart. This is undesirable for kiosks. If the kiosk program crashes, the default desktop environment is exposed, and anyone can control the kiosk and run arbitrary programs.

Since Raspberry Pi OS starts the autologin using lightdm, here is the cleanest way to configure autologin without the desktop environment:

  • Default Raspberry Pi OS already autologin to desktop; if not, configure it using "sudo raspi-config"
  • Edit /etc/lightdm/lightdm.conf and replace autologin-session=rpd-labwc with autologin-session=labwc
  • Place your kiosk script into $HOME/.config/labwc/autostart

Here is a minimal user autostart:

/usr/bin/swaybg -c 000000 &
/usr/bin/kanshi &

Swaybg sets the background to black, and kanshi reconfigures the display on monitor changes. If necessary, use wlr-randr to rotate display as well. The display names reflect the physical ports, e.g. on a Raspberry Pi, the two HDMI outputs are HDMI-A-1 (left) and HDMI-A-2 (right).

The autostart does not need the shebang line, and it does not need to be executable.

In my case, I am playing the video remotely over ssh using a script like this:

#!/bin/bash

unset DISPLAY
export WAYLAND_DISPLAY=wayland-0

trap 'exit 0' INT TERM
trap 'kill 0; killall mpv' EXIT

wlr-randr --output HDMI-A-1 --transform flipped-270
wlr-randr --output HDMI-A-2 --transform flipped-90

MPV='mpv --vo=dmabuf-wayland --hwdec=v4l2m2m'
$MPV -fs --fs-screen=1 --loop=inf left.mp4 &
$MPV -fs --fs-screen=2 --loop=inf right.mp4 &

while true; do
  sleep 3600
done

This executable shell script remotely starts two videos on the two kiosk display in a loop. They are flipped because the kiosk uses rear projection. Projector on the left is rotated left (clockwise 270 degrees), and the projector on the right is rotated right (clockwise 90 degrees). The videos are H.264 in the vertical format (720x1280), which is hardware accelerated on Raspberry Pi 4 model B.

Allegedly, Raspberry Pi 5 only supported hardware decoding of HEVC (H.265) but dropped H.264 (see this Hacker News post). If hardware decoding is desired, the video codec has to be adjusted to match.