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
1
2
|
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.
1
|
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:
1
2
3
4
5
|
[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:
1
2
|
[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:
1
2
3
4
5
|
[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!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/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/"exited_cleanly":false/"exited_cleanly":true/' /home/kiosk/ .config /chromium/Default/Preferences sed -i 's/"exit_type":"Crashed"/"exit_type":"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: //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.
1
|
sudo killall kiosk.sh && sudo service lightdm restart |