Ubuntu 12.04 Kiosk in 10 Easy Steps
As part of my ongoing project toward global domination, I have been working on a reliable kiosk environment for deploying self-service stations featuring a simple web application user interface, while providing secure communication with device hardware (thermal printer, barcode scanner, and so on).
I have experimented with various solutions ranging from modifying openbox, to tweaking gnome-desktop settings and session management. All of this seemed unnecessarily complicated and bloated for simply launching a browser session (hardware daemon is managed via upstart). What I finally arrived upon seems to be the easiest way to achieve what I desire.
So here is what I came up with…
- Compaq L2105TM LCD Touch Monitor (22” and the touch works with Ubuntu!)
- MSI E350IA-E45 Mini-ITX Motherboard (Tiny & already comes w/ processor)
- Mini ITX Case with 250w PSU (black) (small and black and unobtrusive)
- Patriot 4GB DDR3 Memory (4GB isn’t really necessary but it’s dirt cheap)
- Inexpensive optical drive (or you can install via USB if you prefer)
- WD 320GB SATA HDD (2.5” for less noise & heat output)
- 2.5” to 3.5” Bracket (or just duct tape it to the side of the case)
- VESA Wall Mount Bracket (this is the best part of the project)
- HDMI to DVI cable
Configuration is actually extremely minimal. The only part of the installation/configuration that I don’t really like is the fact that you have to manually set the size of the chromium window (just the first time) if you want it to display in full screen. If you are aware of a better way to do this please let me know.
Step 1) Setup & install dependencies;
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install xorg nodm chromium-browser
It’s also never a bad idea to edit your sshd config for “PermitRootLogin no”, and other goodies.
Step 2) Create your kiosk user, add it to any relevant groups (www-data?).
Step 3) Log in as your kiosk user.
Step 4) Create ~/.xsession, add the following;
#!/usr/bin/env bash chromium-browser
Step 5) Type `startx`… Chromium will start, and most likely occupy only half of the screen.
Step 6) Open the wrench menu, select “Settings”. Click on “Personal Stuff”.
Or just navigate to chrome://settings/personal for great justice.
Step 6a) Under “Appearance”, switch to “Hide system title bar and use compact borders”.
Step 7) Drag chromium to occupy the full screen (because F11 didn’t work, did it? Yeah.)
Step 7a) Switch back to “Use system title bar and borders” (which is none since we have no window manager! (thank you for following along))
Step 7b) You may find it advantageous to take this opportunity to disable saved passwords and autofill as well.
Step 8) Ctrl+Alt+F1 and then Ctrl+C to return to console and kill our X session.
Step 9) Edit ~/.xsession once again, change the last line so the file reads as follows;
#!/usr/bin/env bash while true; do chromium-browser --start-maximized --kiosk http://<your_app_url>/; sleep 5s; done
Step 9a) Save.
You may want to try running `startx` again to make sure you didn’t typo or screw anything up (which would be totally understandable). This time, if you Alt+F4 or otherwise cause chromium to crash, it will be restarted in 5 seconds. You can still return to the text console with Ctrl+Alt+F1 (which can be remedied (after you’re done configuring) with something like vlock).
At this point the only thing left to do is to return to your administrator user (someone with sudo capability), and make two small changes to your nodm config file (or more if you’re feeling fancy).
Step 10) Edit /etc/default/nodm, make it look like this; (don’t forget to sudo)
NODM_ENABLED=true NODM_USER=<kiosk_user> NODM_FIRST_VT=7 NODM_XSESSION=/etc/X11/Xsession NODM_X_OPTIONS='-nolisten tcp' NODM_MIN_SESSION_TIME=60
As you will notice, you are just editing the first two lines (how simple is that?).
Step 10a) Save.
Step 11) There is no step 11.
You should now be in possession of a fully functional web kiosk that will automagically boot to your application upon startup, restart when things crash, and keep the rest of your box relatively safe in the mean time. ♥
Arduino & Node.js Sensor / Security Hacking
So I’ve been prototyping an arduino device that serves as a monitor & access system for… restricted locations. I put together a list of things that I found necessary (or really helpful) in getting the project off the ground. Hopefully someone out there finds this useful in their endeavor to build something similar!
- Arduino UNO board
- Elenco 350 Piece Pre-formed Jumper Wire Kit
- Joe Knows Electronics 1/4W 86 Value 860 Piece Resistor Kit
- Helping Hands with Magnifying Glass — absolutely invaluable, you’ll see
- BB400 Solderless Plug-in BreadBoard, 400 tie-points, 4 power rails
- Solder Sucker
- Weller SP23LK 25-Watt Soldering Iron *
- Kester Pocket Pack Solder 60/40 0.031 0.50 oz. Tube *
- microtivity 5mm Assorted Clear LED w/ Resistors (6 Colors, Pack of 60)
- LCD Module for Arduino 20 x 4, Black on Green
- Gino 5pcs 1x40 Pin 2.54 mm Angle Single Row Pin Header Strip
- Ultrasonic Module HC-SR04 Distance Sensor For Arduino
- 1m USB 2.0 A/B Cable (3.2ft) — if you don’t have a spare
* I found slightly better options at a local Radio Shack (as unbelievable as that may sound)
I’ve also posted my source code (or ‘sketch’ in arduino-lingo) on GitHub @ nexxy/ultra-cinnamon.
At the moment the project includes functionality that obtains baseline distance measurements from the ultrasonic sensor, and alerts the host device if anything gets between it and whatever it’s looking at. Basic smoothing of the sample distance is done to avoid false alarms due to slight variations in the readout. The sketch will also write basic prompts to an LCD screen (any HD44780-compatible controller). I haven’t yet included the functionality to actually capture and send barcodes to the host device, but this is a scheduled feature.
Please contribute if this is something you find interesting. Ideally I would like to take a more modular approach with sensor readouts, but I am still re-learning C/C++ from long ago, so I am taking it slow to start with. Any assistance from interested parties in this regard would be greatly appreciated! It would be awesome to create a sort of multi-sensor device platform from this… There are bunches of potential applications (DIY physical security system, anyone?).
The other (host) component to this monitor project is a node.js process, (not yet open-sourced… (soon)) which I am running on a BeagleBoard. Serial communication on the Node.js side is done with voodootikigod/node-serialport (one of my favorite packages ever, by the way).
DISCLAIMER: Every last one of the links in the list above is an amazon affiliate link! Cool? Cool.