In this tutorial, we will show you how to set up a web kiosk on the Ubuntu operating system using Chromium.
Setting up a web kiosk is a very useful way to display information on your Ubuntu system. It enables you to display a web page while hiding much of the web browser’s functionality. It is an excellent solution for displaying something such as a restaurant menu.
We achieve this on Ubuntu by utilizing the Chromium web browser. We use Chromium because it has a kiosk mode built into it. It also retains compatibility with the vast majority of websites since it has many features of the closed-source Chrome.
There are some big caveats to using Chromium as a kiosk on Ubuntu. It is reasonably easy for a user who knows what they are doing to exit the kiosk since we’re still running a full operating system under the hood.
We expect you to run the desktop version of Ubuntu for this tutorial. This is because it saves us from having to install and set up a window manager ourselves.
By the end of this guide, you will have a simple kiosk powered by Chromium that can display a single web page on your screen.
These steps have been tested on Ubuntu 22.04, but due to how we set up services, they should also work for older Ubuntu releases.
Setting up a Kiosk on Ubuntu using Chromium
Over the following sections, you will learn how to set up a Kiosk on your Ubuntu system using the Chromium web browser.
Before you continue, you should ensure that you have SSH set up on your Ubuntu device and a static IP address configured to make managing your kiosk easier.
Preparing Ubuntu to run Chromium
1. Our first step is to ensure we have an updated version of the Ubuntu operating system.
We can update the package list cache and upgrade any out-of-date packages using the following two commands.
sudo apt update
sudo apt upgrade -y
2. After updating the system, we must install a few packages to your system. You can install the Chromium web browser to Ubuntu and a few other packages we require by using the command below.
chromium-browser
– The first package we install is the Chromium browser itself. We utilize this browser because it has a built-in kiosk mode and is compatible with almost every website.sed
– We will use the sed package to search for and change lines within the preferences file. These file changes basically ensure we don’t run into any unwanted messages when the browser starts.xdotool
– This tool allows us to perform key presses from the command line. We will use it to change tabs within our kiosk on Ubuntu.unclutter
– The final package we are installing will automatically hide the mouse from the screen after some inactivity.
sudo apt install chromium-browser sed xdotool unclutter
Creating a User to Run Your Kiosk on Ubuntu
3. Our next step is to create a user called “kiosk
“. We will be using this user to run the Chromium kiosk.
You can create this user by using the useradd command. By using the “-m
” option, we also create a home directory for our new user.
sudo useradd -m kiosk
Enabling Automatic Login to Your New User
4. Next, we must reconfigure Ubuntu to log in to our new user automatically and turn off Ubuntu’s usage of Wayland.
You can edit the custom configuration file using the nano text editor.
sudo nano /etc/gdm3/custom.conf
5. You will want to find the following lines within this file. These lines may already be uncommented if you have enabled automatic login previously.
# [daemon]
# AutomaticLoginEnable=true
# AutomaticLogin=<USERNAME>
Once found, you will want to adjust the lines to look like what we have shown below. Here, we have automatic login enabled and specify our “kiosk
” the user as the one it should log into.
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=kiosk
6. While in this configuration file, we will want to disable Wayland. Wayland makes things more tricky when setting up a Chromium web kiosk on Ubuntu.
Luckily, Ubuntu 22.04 still has the X window manager installed. To disable Wayland, first look for the following line within the file.
#WaylandEnable=false
Once you have found the above line, change it to what we have shown below.
WaylandEnable=false
7. After making these changes, you can save and quit by pressing CTRL + X, Y, and then ENTER.
Writing a Script to Clean Up the Ubuntu Chromium Kiosk on Launch
8. We can now begin writing and setting up our scripts to handle the Chromium Kiosk on Ubuntu.
Let us start by creating a directory where we will store our scripts.
sudo mkdir -p /opt/kiosk/
9. After creating the “/opt/kiosk
” directory, we will write our clean-up script called “cleanup_kiosk.sh
“.
This script will update two values to ensure that Chromium doesn’t complain about having crashed when it restarts.
By running the command below, you can begin writing this file using the nano text editor.
sudo nano /opt/kiosk/cleanup_kiosk.sh
10. Within this file add the following lines. Here is where we use the “sed
” tool we installed earlier.
#!/bin/bash
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/$USER/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/$USER/.config/chromium/Default/Preferences
11. You can save these changes by pressing CTRL + X, Y, and ENTER.
12. After saving these changes, assign execute privileges to the “cleanup_kiosk.sh
” script. This will allow any user to be able to run this script.
To give this script execute privileges, we can use the chmod command.
sudo chmod +x /opt/kiosk/cleanup_kiosk.sh
Getting your Kiosk to Start when Ubuntu Does
11. Our next step is creating a service to launch the Chromium Kiosk on our Ubuntu operating system.
You can begin writing this service by running the command below.
sudo nano /lib/systemd/system/kiosk.service
12. Within this file, type in the following lines.
While typing out these lines, you can specify the websites you want displayed within your kiosk. In the code below, we have two pages specified. You can pick as many pages as you want. Just separate each one by a single space.
[Unit]
Description=Chromium Kiosk
Wants=graphical.target
After=graphical.target
[Service]
Environment=DISPLAY=:0
Type=simple
ExecStartPre=/opt/kiosk/cleanup_kiosk.sh
ExecStart=/usr/bin/chromium-browser -noerrdialogs --disable-infobars --no-first-run --start-maximized
--kiosk https://pimylifeup.com/ https://pimylifeup.com/category/ubuntu/
Restart=always
User=kiosk
Group=kiosk
[Install]
WantedBy=graphical.target
13. After filling out the service file, save and quit by pressing CTRL + X, Y, and then ENTER.
14. Our next step is to enable our new kiosk service to start when Ubuntu starts.
All we need to do to enable the service is to use the following command.
sudo systemctl enable kiosk
Changing Tabs Automatically
If you are using multiple tabs in your Chromium Kiosk you will want to automatically change tabs.
The easiest way to do this is to write a small bash script that continually sends the keys to change to the next tab.
Writing your Change Tabs script
15. Let us create a new file called “switch_tabs.sh
” and begin editing it using the nano text editor.
This script will be super simple and continually send the keys CTRL + NEXT to the window.
sudo nano /opt/kiosk/switch_tabs.sh
16. Within this page, type in the following code. By default, this script will sleep for 10 seconds before changing tabs.
You can change how long the script sleeps before changing tabs by adjusting “10
” to the number of seconds you want between tab changes.
#!/bin/bash
while true; do
xdotool keydown ctrl+Next; xdotool keyup ctrl+Next;
sleep 10
done
17. Once you have filled out this file, save and quit by pressing CTRL + X, Y, and then ENTER.
Running the Change Tabs Script at Boot
18. We will now want to create a separate service that handles our new tabs script.
Separating it into its own service allows the system manager to detect when Chromium crashes and restart it.
Let us begin writing this service by using the following command.
sudo nano /lib/systemd/system/kiosk_tabs.service
19. Within this file, type in the following lines. This service is pretty straightforward and is used to launch the “switch_tabs.sh
” script we wrote earlier.
[Unit]
Description=Chromium Kiosk Tabs
Wants=kiosk.service
After=kiosk.service
[Service]
Environment=DISPLAY=:0
Type=simple
ExecStart=/opt/kiosk/switch_tabs.sh
Restart=always
User=kiosk
Group=kiosk
[Install]
WantedBy=graphical.target
20. With the service file created, save and exit by pressing CTRL + X, Y, and ENTER.
21. Like with our kiosk service earlier, we will want to enable this one so it will also start when Ubuntu powers on.
To enable the new service, use the command below.
sudo systemctl enable kiosk_tabs
Starting up your Ubuntu Chromium Kiosk
22. We will restart our device to get the Chromium kiosk started on our Ubuntu operating system. Restarting ensures all of our changes take effect.
sudo reboot
23. Once Ubuntu finishes restarting you should, have your kiosk displayed on your screen.
Conclusion
Hopefully, at this stage, you will have your Chromium-powered kiosk up and running on your Ubuntu system.
Chromium is an excellent solution for running a web kiosk as it boasts great security and compatibility with websites.
Please feel free to comment below if you have had any issues with getting this kiosk running.
We recommend checking out our many other Ubuntu guides if you want to learn more.