Launch Chromium Kiosk on Startup and Auto-Relaunch

Created by Michael Lister, Modified on Mon, 9 Dec, 2024 at 10:40 AM by Michael Lister

This will show how to configure a Raspberry Pi to launch Chromium Kiosk Mode on startup and automatically relaunch it, if it is closed/crashes


Other programs could be used with this method, some lines may need to be added to perform correctly




1a. Initial Creation of Service Script


This can either be a text file you create from your PC

That you then move to the following directory

/lib/systemd/system/NameOfFile.service


super user access needed to move to that directory via:

sudo cp <path of file> <path of target>


Or


Directly on the Pi with:

sudo nano /lib/systemd/system/<NameOfFile>.service


1b. Service Script Content


[Unit] # Where we outline info on the service and how we want it to run
Description=VitaMojo Order Board 
# Custom Description/Name of the Script will be referred to in logs

Type=exec 
# Type of service | exec is a basic type that covers most jobs

After=multi-user.target 

[Service] # Where we outline what we want the service to do
Environment=DISPLAY=:0.0 
# Unique fix for Chromium, doesn't like being launched this way as is outside of GUI

Environment=XAUTHORITY=/home/pi/.Xauthority
# Unique fix for Chromium

User=ebm 
# User you wish to run this script as best practice to not use root

ExecStart= /usr/bin/chromium-browser --kiosk https://vmos3.vmos.io/ctv/dashboard/orders 
# ExecStart starts an executable |  followed by file path of chromium install | followed by start arguments --kiosk launches chrome in kiosk mode

Restart=on-failure
# Script will restart if the program it is launching is closed
# on-failure = it will only restart if the program is not cleanly shut down

RestartSec=1
# Period to wait before the script is actually restarted
# If no unit is defined then system will assume seconds
# Default without this line is 100ms

[Install] # How the script is called
WantedBy=multi-user.target


See link below for more info on settings within service files and examples

systemd.service (www.freedesktop.org)



1c. Setting File Permissions


The script file needs to have the correct Read/Write permissions applied

Run the following command to apply the permissions to the file


sudo chmod 644 /lib/systemd/system/<NameOfFile>.service


1d. Configuring systemd


Now that the script file is created we need to enable the service to be run


First we need to get systemd to update the directory so that it is aware of the new script file

(this is also the command to run if you ever update the script whilst the Pi is in use)






Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article