0% found this document useful (0 votes)
224 views

Setup A Kiosk With Ubuntu and Chromium - O'Brien Labs

The document describes how to set up a kiosk display using Ubuntu and Chromium. It involves installing Ubuntu, creating user accounts, configuring auto-login, installing required packages like Chromium and unclutter, creating a kiosk.sh script to launch Chromium in kiosk mode and cycle through tabs using xdotool, and exiting kiosk mode by killing processes. Configuring the system allows displaying web content in a full-screen, mouse-free environment for digital signage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
224 views

Setup A Kiosk With Ubuntu and Chromium - O'Brien Labs

The document describes how to set up a kiosk display using Ubuntu and Chromium. It involves installing Ubuntu, creating user accounts, configuring auto-login, installing required packages like Chromium and unclutter, creating a kiosk.sh script to launch Chromium in kiosk mode and cycle through tabs using xdotool, and exiting kiosk mode by killing processes. Configuring the system allows displaying web content in a full-screen, mouse-free environment for digital signage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

O'Brien Labs (/)

(/)
HOME (/) WEATHER WEBSITE (HTTPS://GO.OBRIENLABS.NET/BELCHERTOWN)
PORTFOLIO (/PORTFOLIO) SEARCH (/SEARCH) ABOUT (/ABOUT) CONTACT
(/CONTACT)

Home (/) » Tech Tips (/categories/#Tech Tips) » Setup a Kiosk with Ubuntu and
Chromium

Setup a Kiosk with Ubuntu and


Chromium
February 26, 2017 by Pat (https://obrienlabs.net) - 22 Comentarios (/setup-kiosk-
ubuntu-chromium/#isso-thread) - 5 mentions - 6 min read
Tech Tips (/categories/#Tech Tips) Tinkering (/categories/#Tinkering)

Recently I’ve had the need to setup 2 kiosk stations to display


an array of data on a digital signage screen which has no
keyboard or mouse attached to it. The idea in this post is to
explain how I did it. I installed Ubuntu with the Unity desktop,
set some auto-login tasks and run Chromium in kiosk mode.
Then using xdotool to cycle through the Chrome tabs at a set
interval. Lastly, the unclutter package will remove the mouse
cursor from the screen, giving a clean automated look.

I also show how I’ve set this up for a Raspberry Pi. (https://obrienlabs.net/setup-raspberry-
pi-kiosk-chromium/) It’s mostly the same, but a few things are different. Check it out if you
have a Raspberry Pi that you want to automate a display with!

Here’s how I did it:


Install Ubuntu

The first thing I did was get Ubuntu 16.04 Desktop installed. This worked for me with
Ubuntu 14.04 as well. Once you have that installed, and sudo apt-get update && sudo
apt-get upgrade to the latest and greatest, then move onto the next step.

Create User Accounts

Create 2 users. One user is already created – the account you’re logged in as. For this we’ll
assume the account name is obrienlabs. Create a second user named kiosk. This will
become the auto-logged in user.

The other account will be used to manage the system and any kiosk changes remotely via
SSH. If you SSH into this machine as the kiosk user, you’ll end up running duplicate scripts.

Add Users To sudoers

I chose to add the 2 users to the sudoers file so I wouldn’t get prompted for passwords all
the time. Run visudo and at the bottom add

kiosk ALL=(ALL) NOPASSWD: ALL


obrienlabs ALL=(ALL) NOPASSWD: ALL

Install Required Packages

We’ll need to install some software to accomplish this.

Chromium is the Chrome browser but with much more options.


Unclutter removes the mouse cursor from the screen, giving it a clean look.
xdotool can manipulate on screen elements using a virtual keyboard. We use it to
change tabs in Chromium.

sudo apt-get install -y chromium-browser unclutter xdotool

Setup Auto Login

Now we can setup the auto login process. We need the user Kiosk to auto login on every
reboot.
sudo nano /etc/lightdm/lightdm.conf and add:

[SeatDefaults]
autologin-user=kiosk
autologin-user-timeout=0
user-session=ubuntu
greeter-session=unity-greeter

Then run sudo mkdir /etc/lightdm/lightdm.conf.d && sudo nano


/etc/lightdm/lightdm.conf.d/50-myconfig.conf and add:

[SeatDefaults]
autologin-user=kiosk

Setup kiosk.sh Script

Now that we are auto logged in, let’s run our script.

Run sudo mkdir /home/kiosk/.config/autostart && sudo nano


/home/kiosk/.config/autostart/kiosk.desktop and add:

[Desktop Entry]
Type=Application
Name=Kiosk
Exec=/home/kiosk/kiosk.sh
X-GNOME-Autostart-enabled=true

Installing the kiosk.sh script is as simple as copying the code below. This script will be
launched every time the kiosk user logs in (even with SSH), so be sure to tailor it to your
needs!
#!/bin/bash

# Run this script in display 0 - the monitor


export DISPLAY=:0

# Hide the mouse from the display


unclutter &

# If Chromium crashes (usually due to rebooting), clear the crash flag so we d


on't have the annoying warning bar
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/kiosk/.config/c
hromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/kiosk/.config/chr
omium/Default/Preferences

# Run Chromium and open tabs


/usr/bin/chromium-browser --window-size=1920,1080 --kiosk --window-position=0,
0 http://google.com http://bing.com &

# Start the kiosk loop. This keystroke changes the Chromium tab
# To have just anti-idle, use this line instead:
# xdotool keydown ctrl; xdotool keyup ctrl;
# Otherwise, the ctrl+Tab is designed to switch tabs in Chrome
# #
while (true)
do
xdotool keydown ctrl+Tab; xdotool keyup ctrl+Tab;
sleep 15
done

Then make the script executable by running chmod +x kiosk.sh

As you can see Chromium runs in Kiosk mode. This means it’ll go full screen and take
minimal input from the keyboard and mouse (if one was plugged in). In this example,
Chromium will auto load Google and Bing in 2 tabs, and xdotool will cycle between the tabs
every 15 seconds. I’m also performing some Chrome clean up in case the system reboots
without closing Chrome. This will remove the nag bar.
Managing the system after it’s setup

To manage the system after it’s setup, you’ll need to find the IP of the device, and SSH into it
using the OTHER USER you setup. Do not SSH in as user kiosk, or you’ll end up opening
another Chromium instance, as well as kiosk.sh which will end up changing the tabs in more
frequent intervals since xdotool will be called twice as fast.

Other things you can add to kiosk.sh are running x11vnc and autossh to automatically
setup an SSH tunnel from the system to your centralized server, allowing you to SSH into
the device and even VNC to the monitor without needing to know the IP. Very useful!

If you make any changes and want to log Kiosk out without rebooting, I’ve found that this
command works. This will kill the kiosk.sh script and restart the Windows service which will
log out and log in the kiosk user.

sudo killall kiosk.sh && sudo service lightdm restart

How to exit Kiosk mode

Ubuntu Unity UI allows you to press the Windows key on the keyboard to open the
launcher. Once the launcher is open, type terminal. Once in the terminal type sudo
killall chromium-browser or press Alt+F4 to close Chromium.

The kiosk.sh script will still be running, this script has the xdotool keydowns running (see
above). We need to kill that too with sudo killall kiosk.sh. To remove it all
together, refer to the above to remove the /home/kiosk/.config/autostart/kiosk.desktop file.

That’s basically it! A quick way to get a Kiosk setup which shows multiple tabs of
information.

I hope this helps someone, and if you have any suggestions on improvements, let me know in
the comments!

You can start your DigitalOcean Ubuntu server for as low as $5/mo and be online in 1
minute. Best yet, if you use this link you get $10 credit for free
(https://go.obrienlabs.net/digitalocean)!
(https://go.obrienlabs.net/digitalocean)
Disclosure: Some of the links on this website are affiliate links. This means that, at zero cost
to you, I will earn an affiliate commission if you click through the link and finalize a purchase.

Share this post:


 (https://twitter.com/intent/tweet?text=Setup a Kiosk with Ubuntu and
Chromium&url=https://obrienlabs.net/setup-kiosk-ubuntu-chromium/) 
(https://www.facebook.com/sharer/sharer.php?u=https://obrienlabs.net/setup-kiosk-
ubuntu-chromium/)  (http://www.stumbleupon.com/submit?
url=https://obrienlabs.net/setup-kiosk-ubuntu-chromium/&title=Setup a Kiosk with
Ubuntu and Chromium)  (http://pinterest.com/pin/create/button/?
url=https://obrienlabs.net/setup-kiosk-ubuntu-
chromium/&media=https://obrienlabs.net/images/content/images/content/featured_image.jpg)
 (mailto:type email address here?subject=Check out this post from
OBrienLabs.net&body=Setup a Kiosk with Ubuntu and Chromium
https://obrienlabs.net/setup-kiosk-ubuntu-chromium/)

5 Responses

w
p/w💬
/o
lw
:p
s.th
t( www.oliprat.com (https://www.oliprat.com/wp_sita_C/2019/05/20/kiosque/): (menti…
o//💬
y
b :p
stht( geekyboi.co.uk (https://geekyboi.co.uk/tech/happy-frappe-pi-latte/): (mention)
e//💬:p
stht( askpythonquestions.com (https://askpythonquestions.com/2021/01/14/build-a-slee…
//💬:p
stht( receipt.techniciansalaryslip.com (https://receipt.techniciansalaryslip.com/auto-login-…
//💬:p
stht( letterflat.com (https://letterflat.com/login/auto-login-lubuntu/): (mention)

22 Comentarios

Escriba su comentario aquí (al menos 3 caracteres)

Nombre E-mail Sitio web (opcional) Enviar


Vista preliminar
Evryk • hace 2 meses

I have it working! Thank you for the massive Help. But i have one
little Problem, the Chromium window wont go Fullscreen until i click on it.
But I would prefer to not have any Kind of HID. Is there any way of getting
automatic Fullscreen?
Responder

Bartas • el año pasado

Hello, great advice, it was useful for me to run Kiosk on ubuntu


server 20.04. But I have a question, how to rotate 90 degrees so that the
image from browsers is displayed vertically. I have compiled Gruba and,
for example, the terminal works fine for me vertically. But at the time of
autologing, the browser image returns to the standard position. I am
asking for advice. Greetings from Poland :)
Responder

EpoDeluxe • hace 2 años

Hi, did somebody get it working on Ubuntu 20.04 Server ?


Responder

sopheak • hace 3 años

While the chromium is running , and then can i press any key to kill
it ? Example: I press 'ctrl+shift+x' to kill the chromium, and if it can
shutdown PC, it''s specially for me, Thanks
Responder

Linux信息亭 | Ubuntu Kiosk | 渔人小径 (http://fisherworks.cn/?


p=2517) • hace 4 años

[…] Setup a Kiosk with Ubuntu and Chromium […]


Responder
Michael • hace 4 años

Hi, when i boot the system it will not log in automatically into the desktop...i can see
the welcome screen and a raspi login: _ text appear...Can you help me in this case?
here my steps i did the install on a raspian lite stretch..

1.Backup Image durchführen

dann

1.sudo apt-get update && sudo apt-get upgrade 2.sudo -i // mit root Rechten arbeiten

https://www.hagenfragen.de/tipps-und-tr (https://www.hagenfragen.de/tipps-und-tr) ...


reloaded=1

1.sudo apt-get update && sudo apt-get upgrade 1.1 reboot

2.sudo -i // mit root Rechten arbeiten

3.sudo apt-get install --no-install-recommends xserver-xorg

4.sudo apt-get install --no-install-recommends xinit 4.1.sudo apt-get install raspberrypi-ui-


mods

5.useradd kiosk

6.visudo

7.//at the buttom at kiosk ALL=(ALL) NOPASSWD: ALL pi ALL=(ALL) NOPASSWD: ALL

8.reboot

9.sudo apt-get install -y chromium-browser unclutter xdotool

10.sudo nano /etc/lightdm/lightdm.conf and add: [SeatDefaults] autologin-user=kiosk


autologin-user-timeout=0 user-session=ubuntu greeter-session=unity-greeter

11.sudo mkdir /etc/lightdm/lightdm.conf.d && sudo nano /etc/lightdm/lightdm.conf.d/50-


myconfig.conf and add: [SeatDefaults] autologin-user=kiosk

12.sudo mkdir /home/kiosk/.config/autostart && sudo nano


/home/kiosk/.config/autostart/kiosk.desktop and add: [Desktop Entry] Type=Application
Name=Kiosk Exec=/home/kiosk/kiosk.sh (http://kiosk.sh) X-GNOME-Autostart-
enabled=true

1. Installing the kiosk.sh (http://kiosk.sh) script is as simple as copying the code below.
#!/bin/bash

Run this script in display 0 - the monitor


export DISPLAY=:0

Hide the mouse from the display


unclutter &

If Chromium crashes (usually due to rebooting), clear the


crash flag so we don't have the annoying warning bar
sed -i 's/"exitedcleanly":false/"exitedcleanly":true/'
/home/kiosk/.config/chromium/Default/Preferences sed -i
's/"exittype":"Crashed"/"exittype":"Normal"/'
/home/kiosk/.config/chromium/Default/Preferences

Run Chromium and open tabs


/usr/bin/chromium-browser --window-size=1920,1080 --kiosk --window-position=0,0
http://google.com (http://google.com) http://bing.com (http://bing.com) &

Start the kiosk loop. This keystroke changes the


Chromium tab
To have just anti-idle, use this line instead:
xdotool keydown ctrl; xdotool keyup ctrl;
Otherwise, the ctrl+Tab is designed to switch tabs in
Chrome
while (true) do xdotool keydown ctrl+Tab; xdotool keyup ctrl+Tab; sleep 15 done

14.chmod +x /home/kiosk/kiosk.sh (http://kiosk.sh)


Responder
Stefan • hace 5 años

I strongly suggest to remove the "kiosk" user from sudoers. This account should be
as restricted as possible.
Responder

Pat (http://obrienlabs.net) • hace 5 años

I would agree if this kiosk had a keyboard/mouse attached to it. But if it's
for a wallboard with no real HID then it shouldn't pose a huge risk, no? If you'd like
to recommend a workaround, let me know.
Responder

robby • hace 5 años

hi pat i tried to change the default zoom percentage in chromuim but each time my
url its launched with your app , the chromuim browser dont use my zoom
percentage set up by default before
Responder

Pat (http://obrienlabs.net) • hace 5 años

Hi robby, what do you mean you changed the zoom percentage? In Chrome
so the website is bigger? That is not controlled by my script.

I did a Google search and found this answer.


https://askubuntu.com/a/997130/802852
(https://askubuntu.com/a/997130/802852). For example if you wanted to zoom to
79% add that line to the /usr/bin/chromium-browser section of the script.

The full line would be /usr/bin/chromium-browser --window-


size=1920,1080 --kiosk --window-position=0,0 --force-
device-scale-factor=0.79 http://google.com
(http://google.com) http://bing.com (http://bing.com) &
Responder

kiLLerFrOSt • hace 5 años

Worked magically for me. However, I could actually do "Ctrl+Shift+W" and exit the
browser and expose the underlying OS for me to do anything including run terminal
and systems settings. I guess there should be a security layer on this as well.
Responder

Fre • hace 5 años

Anyone found Solution to rotatie the screen? Can i use Xander or is this only for
gnome?
Responder

Rafal Bartz (http://itconcept.pl) • hace 5 años

Hi Pat,

Thanks for tutorial. Got small problem. My starting website is login page to the portal where
cant type nothing on keyboard. Checked if there is any problem with website but not, it is
working on root acount. Thanks for help.

Rafal
Responder
Frederick • hace 5 años

Hi,

ALl is working for me but I want to rotate the screen. ANyone know how to do?

Rgds, Fred
Responder

Deep • hace 5 años

Hello sir, i just Setup Kiosk with Ubuntu 16.04 and Chromium 62.0. it setup
successfully with create new user called "Kiosk". but problem is that when kiosk.sh
(http://kiosk.sh) script running it will show warning like that "unclutter: someone created a
sub window to my sub-window! giving up". and one more thing when the script(kiosk.sh
(http://kiosk.sh)) is running then cycle between the tabs or any other editor screen it will
move up very fast. how can i disable the cycle. can we do like person manually changes the
tab in Chromium browser.? can you please help me to solved the problem?

Thanks.
Responder

Pat (http://obrienlabs.net) • hace 5 años

I'm not sure about that unclutter error - never seen that before! For the
kiosk.sh (http://kiosk.sh) question, if you log in via SSH or anything as the kiosk
user it'll run multiple kiosk.sh (http://kiosk.sh) files. Which means it'll make more
and more timers to switch tabs. Your fix there is to create another user account
and log in as that and never log in as the kiosk user. That way you only have 1
kiosk.sh (http://kiosk.sh) running in the background.
Responder
suryaprakash (http://orientlabs.net) • hace 5 años

all ok,but i had error like this "unclutter : could n't open display (null)" .pls help me
to clear from d error....
Responder

Pat (http://obrienlabs.net) • hace 5 años

Make sure you specify export DISPLAY=:0 in your script.


Responder

Rocky • hace 6 años

Hi Pat,

Thanks for getting back to me. I figured out where I went wrong - I created the kiosk.sh
(http://kiosk.sh) file using a sudo nano, rather than just nano. By doing so, it gave that file
root permissions and when I went to issue the chmod, I had to sudo it as well. Your
procedure is fantastic - I'd recommend if you wanted to add the command (nano
/home/kiosk/kiosk.sh (http://kiosk.sh)) to create the script file for dummies that me that
follow paint by numbers, that would likely save anyone else the same headaches I had. To
overcome my error, I just added a call for the script in crontab and it worked, but that was a
kludge. Doing a clean install and following your process (without my sudo error!) worked
the first time. Thanks again.

Rocky
Responder

Rocky (http://www.blondinenterprises.com) • hace 6 años

Hi Pat, Thanks a ton for taking the time to create this tutorial. I want to achieve the
same result and there's something missing along the way as I can't get it to boot up
running the script. The script works - I call it from the terminal and I get a full-screen,
Chromium browser. But when I reboot, it launches into my root user - not the 'kiosk' one
and it goes downhill from there. I have tried other pages to change the autostart functions
but now I'm pretty close to crippled hardware (which is fine in getting these things going) so
I'm going to reinstall Ubuntu from scratch and try again. I know you're not looking for tech
support inquiries with these posts, but if you have a chance, I'd appreciate your insight. I'll
leave my contact info in the fields below and I'd love to pick your brain for 5 mins if possible.
I'll make sure you get a beer for your trouble!

Thanks.
Responder

Pat (http://obrienlabs.net) • hace 6 años

Hey Rocky, if on reboot your machine is auto-logging in as root, I'd make


sure you have the right configuration for the sudo nano
/etc/lightdm/lightdm.conf file where it specifies autologin-
user=kiosk. On Ubuntu I don't believe the root user logs in anyways - they
typically want you to log in as a user by default. So if root is logging in, maybe
there's another setting somewhere that's been changed, or there's a typo in the
lightdm.conf file. Off the top of my head that's what I'm thinking.
Responder

Kiosk Mode • hace 6 años

Hi Pat, Wonderful and easy tut!! I tried experimenting it and it actually helped me.
Thanks Pat
Responder
Copyright © 2010–2022 O'Brien Labs – All Rights Reserved – Use without permission is illegal.

You might also like