---
title: a kiosk for my kitchen
date: 2020-08-05
---
{% extends 'templates/base.html' %}
{% block body %}
{{ title }}
{% markdown %}
In a corner of my kitchen, there is a little touchscreen interface for "kitchen things".
Below is why I have that, what it's made of, and how it works.
## Why?
There are two main reasons why I want a kitchen kiosk unit:
- I have too Internet of Things things in my kitchen, and getting my phone out to control it is annoying.
- I want to record when I drink coffee, when I snack, etc, and getting my phone out to log that is annoying.
## What?
I already have a Raspberry Pi in the Kitchen to provide [WiFi](/wifi) and [audio](/multi-room-audio), so extending that is a good start.
I could create a custom control panel with physical buttons, but adding a touchscreen to an existing unit is easier.
So I got the official Raspberry Pi touchscreen, a stand for the screen, and voila, the hardware side is done.
## How?
Continuing with the theme of minimal effort for maximum gain, I decided to use my existing skills and implement the UI with a website:
- I can hack up a webserver pretty fast.
- Chromium has a kiosk mode.
- Chromium can handle rendering and input.
This means that all I need to do is make Chromium start on boot, and write a simple webserver!
From a standard Raspbian image, install the relevant softwares:
$ sudo apt install chromium lightdm xinput
Then, create a user to run Chromium, here called `kiosk`:
$ sudo adduser kiosk
Next, we're going to use `lightdm` to bring up Xorg and automatically log in as `kiosk`:
$ cat /etc/lightdm/lightdm.conf
[Seat:seat0]
type=local
pam-service=lightdm-autologin
autologin-user=kiosk
autologin-user-timeout=0
xserver-command = X -nocursor
For our `kiosk` user to set the brightness, we need to add a `udev` rule to make it writeable:
$ cat /etc/udev/rules.d/50-backlight.rules
SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"
Finally, `kiosk`'s graphical login script (`~/.xsession`) will set the brightness and display-sleep modes, then start Chromium:
$ cat /home/kiosk/.xsession
readonly standby_seconds=60
readonly suspend_seconds=60
readonly off_seconds=60
readonly brightness_percent=50
# TODO: write a custom UI webserver.
readonly website="https://ethulhu.co.uk"
xset dpms "${standby_seconds}" "${suspend_seconds}" "${off_seconds}"
echo "${brightness_percent}" > /sys/class/backlight/rpi_backlight/brightness
exec chromium --noerrdialogs --kiosk --incognito "${website}"
Reboot the Raspberry Pi, and it should automatically log in as `kiosk` and run the website.
{% endmarkdown %}
{% endblock %}