What I did to run Rpi touchscreen in Kiosk mode

So I have this project of linking together two machines. As I didn't want to relay on the router for local network and to control the central Rpi through the network with a tablet I decided two buy the official Rpi touchscreen and the superb Smartipi Pro case. Thus I needed the Rpi to function in kiosk mode. Here is the writeup of what I did. This has worked for me but I don't pretend that it is the right way to do it. Details have been copied from various sources.
I have Rpi 3 B with the Raspberry Pi OS with desktop and recommended software downloaded from the official site and Node-red installed with the install script.

An opinion on text editing
Using nano is possible, but I personally prefer to use SFTP to log into the target machine (using Cyberduck or FileZilla), so I have a good overview of file structure and locations. Also, I get to use my local text editors with mouse to edit the config files and save them directly to the Rpi.

Getting rid of the cursor
The touchscreen is set up, the orientation is correct (I didn't have to modify this?), time to get rid of the mouse cursor. I have edited the file /etc/lightdm/lightdm.conf and added, NB! after [Seat:*] the line xserver-command = X -nocursor. This removes the cursor for good.

Starting up the fullscreen browser
Autostart
I have added some necessary commands to the ~/.config/lxsession/LXDE-pi/autostart file. "~" means the user, in a standard installation it is pi. Also, files and folders beginning with a "." are hidden by default, in Cyberduck I have to select View hidden files from View dropdown menu to see them.
So my autostart file looks like this:

@xset s off   # disable screen saver
@xset -dpms   # disable DPMS (Energy Star) features.
@xset s noblank  # don't blank the video device
@sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/chromium-browser Default/Preferences
@/home/pi/.config/lxsession/LXDE-pi/start-chromium.sh

The sed line is there so Chromium thinks it shut down cleaning, even if it didn't, to prevent tab restore warnings.

The last line launches another script, I think this is better to add the pause necessary.

start-chromium.sh
I have created another script file in the same folder as the autostart file: ~/.config/lxsession/LXDE-pi/start-chromium.sh . This filke needs to be given execute privileges. Again, in Cyberduck it is quite straightforward, but it could be done also by typing chmod 755 ~/.config/lxsession/LXDE-pi/start-chromium.sh in terminal, once the file is created.
In this file I have the following lines:

#!/bin/sh
sleep 5
chromium-browser --display=:0 --kiosk --window-position=0,0 --disable-pinch --overscroll-history-navigation=0 --disable-translate  --noerrdialogs  http://127.0.0.1:1880/ui

most important stuff is after chromium-browser, we declare that is kiosk, so now frame or titlebar, there is the no-pinch, so no accidental zooming in or out, disabeling going back and forth between history states, to translation popups, no errors whatsoever.

I have given node-red 5 seconds to start up before launching Chrome, so there shouldn't be the flash of "this website is not reachable".

No selecting text
I have added the following CSS rule to a dashboard template node:

body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
html {
touch-action: none;
}

Thanks to everybody who has written all this down before me.

6 Likes

Nice project!

If you do not disable the screen saver and energy saving, will the display go out after a while? So that the display is actually dark (e.g. at night, when no one uses it). And will it "wake up" if you touch the screen?

Nice work, thanks for sharing.

In regard to remote editing - you might want to look at VSCode with the official remote extension that lets you edit files over an SSH connection - it also gives you a tree view of your files and folders of course and even gives you a remote command line. All integrated into the VSCode IDE - and all for free!

You can save the config as a "workspace" or project so that you can go straight into a remote session. I find this massively helpful to working on more complex uibuilder front-end apps and messing around with my production home automation server.

I guess that would be the case, in our use the operator turns all the machinery off after finishing the task.

This is something I didn't mention - I have a button on the dashboard that sends sudo halt to the exec node so we can turn off the Rpi from the touch interface. And I have added a switch to the case that shorts the 5&6 GPIO pin to turn the Rpi on.

1 Like

Ok, nice, I'll look into it.

I did the same with mine, with the exception of the screen blanking... I do allow the screen saver (blank screen), simply because I don't want the 'glow' at night.

I did add the Sleep to my start-chromium.sh file as well... as occasionally on restarts I would see that message and have to 'reload' the page. I just hadn't gotten around to figuring out a solution.... waiting 5 seconds is good!

Thank you for posting that helpful information.

Yes.. see my note below.. that is what I did so that it goes dark...