Skip to content

Instantly share code, notes, and snippets.

@xtolid
Created December 17, 2017 16:56
Show Gist options
  • Save xtolid/23a32b216663d9d3535312660d383105 to your computer and use it in GitHub Desktop.
Save xtolid/23a32b216663d9d3535312660d383105 to your computer and use it in GitHub Desktop.
Ubuntu 16.04 Kiosk using i3 Window Manager & Cockpit

I recently found myself in need of a kiosk setup at work. I also wanted to be able to easily monitor these computers remotely, so this is the solution I have chosen.

We start off with a fresh image of Ubuntu 16.04 server from the Canonical website.

Ubuntu Server

I won't detail how to install this iso as there are hundreds of threads about this already. We will begin after the installation has completed and a reboot has been performed.

First, we will make sure our packages are up to date.

sudo apt update
sudo apt upgrade

Now we will add needed repos.

sudo add-apt-repository 'deb http://dl.google.com/linux/chrome/deb stable main'
wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo add-apt-repository ppa:cockpit-project/cockpit
sudo apt update

At this point we will add the window/display manager and the requisites to use them.

sudo apt install --no-install-recommends lxdm
sudo apt install i3 xinit

For my purposes, I chose Chrome browser.

sudo apt install google-chrome-stable

Now we will add & enable Cockpit server manager. I will probably do a follow-up post on Cockpit to cover some of its features.

sudo apt install cockpit
sudo systemctl enable cockpit.socket
sudo systemctl start cockpit.service

This part is optional. I needed for the display on my kiosks to never sleep. I'm sure that a better way to do this exists, unfortunately my google-fu wasn't strong enough to find it. They say that posting the wrong answer on the internet is the surest way to find the correct one, so here is the solution I found.

sudo apt install caffeine

This is also an optional step to clean up the boot process. Proceed with caution.

Make a copy of your grub configuration in case of disaster.

sudo cp /etc/default/grub /etc/default/grub.old

Open the grub configuration file with the editor of your choice.

sudo vim /etc/default/grub

Change the line in the grub configuration from this:

GRUB_CMDLINE_DEFAULT=""

To this:

GRUB_CMDLINE_DEFAULT="quiet splash"

Save and exit the file.

Update grub so it will use the new configuration.

sudo update-grub

My preference is to create a user without admin rights to log into the kiosk.

sudo useradd kioskuser

Now we must tell the server to boot to the GUI.

sudo systemctl set-default graphical.target

Update and upgrade one more time for good measure.

sudo apt update
sudo apt upgrade

Reboot.

sudo reboot

If everything went correctly, the lxdm login page should be on your screen. Choose i3 as your window manager and log in with your main user account. It will prompt you to have i3 create a config file. Choose yes. The prompt will ask if the modifier key should be your windows key. I suggest keeping this default.

Once loaded, press the modifier key and enter at the same time to bring up a terminal.

We will need to configure lxdm to auto-login with our kioskuser.

sudo vim /etc/lxdm/lxdm.conf

Uncomment the autologin and session lines at the top of the configuration file. Change the user to your kioskuser and the session to i3. Save and exit.

Once we update the i3 config file, we will be ready to test our new kiosk. Append these lines to the end of your config file. Set the url to the site of your choice. I will be using google.com for this example.

#ClearCache
exec /usr/local/sbin/cachewipe.sh
#FullscreenChrome
for_window [class="google-chrome"] fullscreen
#StartChrome
exec /usr/bin/google-chrome --kiosk --no-first-run http://google.com
#StartCaffeine
exec caffeine

Save and exit.

This will delete the cache in the browser on boot.

sudo vim /usr/local/sbin cachewipe.sh

Put this in the file.

#!/bin/bash
rm -rf ~/.{config,cache}/google-chrome/

Save and exit

Make it executable.

sudo chmod +x /usr/local/sbin/cachewipe.sh

After rebooting, you should be greeted with the website that you chose in your i3 config file. Pressing the modifier key plus F will take you out of fullscreen. After exiting full screen, pressing the modifier key plus enter will open a terminal alongside the website. This is handy if you need to edit any settings on your kiosk. Type exit in the terminal to close it and the modifier plus F again to put your kiosk back in fullscreen mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment