Raspberry Pi as a Kiosk Terminal - Version 2

Raspberry Pi as a Kiosk Terminal

Version 2

October 2018

Goal: To have the RPi boot Chromium only, not the full desktop. Chromium will restart after 5 minutes of inactivity clearing any of the users cookies, history, new bookmarks, setting changes, etc. 

A majority of the steps assume you SSH into the Pi.

Steps highlighted blue are optional. 

  1. Image Raspbian to SD card 

  1. Set basic settings 

    • Plug in and boot your RPi

    • Open Terminal

    • sudo raspi-config

      • Set Localization 

        • Locale

        • Timezone

        • Keyboard - No AltGr key, No compose key, do not use Ctrl+Alt+Backspace to terminate X server

        • Wifi Country

      • Interfacing Options

        • Enable SSH

  1. Reboot

  1. Change pi user password

    • sudo raspi-config

    • Change password

  1. Setup Wireless connection (Optional if you’re using an Ethernet connection with DHCP)

  • Edit the following two files to match what is written below.

    • sudo nano /etc/network/interfaces

auto lo

iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0

auto wlan0

iface wlan0 inet manual

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

  • sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

    • (Leave the quotes for the ssid and password)

country=US

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

network={

ssid="wifi network name"

scan_ssid=1

psk="password"

mode=0

proto=WPA2

key_mgmt=WPA-PSK

pairwise=CCMP

group=CCMP

auth_alg=OPEN

id_str="raspi"

priority=1

}

  • Reboot and make sure it received a valid IP address (“ifconfig” command)

  1. Remove unused software and update  

    • sudo apt remove geany scratch scratch2 sense-emu-tools sense-hat sonic-pi minecraft-pi

    • sudo apt update && sudo apt upgrade -y

    • sudo apt autoremove

  1. Install other software packages 

    • sudo apt install numlockx xprintidle

  1. Add secondary user and set auto login

    • The remainder of these instructions assume you are using the users “pi” as admin and “catalog” as the secondary user.

    • sudo adduser catalog

    • sudo nano /etc/lightdm/lightdm.conf

    • Uncomment (If needed) and change:

      • autologin-user=catalog

  1. Setup a tmpfs for the Chromium user profile. This may help extend the life of the SD card by reducing the amount of writes to it. (Optional)

  • su catalog

  • mkdir -p /home/catalog/.config/chromium/Default/

  • exit

  • sudo nano /etc/fstab

  • Add the following line to the fstab file (all on one line).

tmpfs   /home/catalog/.config/chromium/Default/tmpfs  defaults,noatime,uid=catalog,gid=catalog,mode=0777,size=128m0  0

  1. Create start.sh script

    • sudo mkdir /catalog/

    • sudo nano /catalog/start.sh

#Disable DPMS (Energy Star) features.

xset -dpms

#Don’t blank out video device

xset s noblank

#Disable Screensaver

xset s off

#Turn Numlock on

numlockx on

/catalog/chromium.sh &

/catalog/inactivity.sh

  1. Create chromium.sh script

    • sudo nano /catalog/chromium.sh

while true;

do

#rm -rf /home/catalog/.config/chromium/Default/*

#cp -R /home/catalog/.config/chromium/Backup/Default/* /home/catalog/.config/chromium/Default

chromium-browser --start-maximized --no-first-run  --disable-infobars --ignore-certificate-errors --ignore-ssl-errors https://www.search.pvld.org

done

  • Those two lines will be uncommented after Chromium is personalized.

  1. Create inactivity.sh script

    • sudo nano /catalog/inactivity.sh

# Wanted trigger timeout in milliseconds.

IDLE_TIME=$((5*60*1000))

# Sequence to execute when timeout triggers.

trigger_cmd() {

    echo "Triggered action $(date)"

}

sleep_time=$IDLE_TIME

triggered=false

# ceil() instead of floor()

while sleep $(((sleep_time+999)/1000)); do

    idle=$(DISPLAY=:0 xprintidle)

    if [ $idle -ge $IDLE_TIME ]; then

        if ! $triggered; then

            trigger_cmd

            $(pkill -f -- "chromium-browser")

            triggered=true

            sleep_time=$IDLE_TIME

        fi

    else

        triggered=false

        # Give 100 ms buffer to avoid frantic loops shortly before triggers.

        sleep_time=$((IDLE_TIME-idle+100))

    fi

done

  • The “5” in the IDLE_TIME=$((5*60*1000)) line sets the inactivity for 5 minutes.

  1. Create monitoroff.sh script

    • sudo nano /catalog/monitoroff.sh

tvservice -o

  1. Add execute permissions to the new scripts 

    • sudo chmod +x /catalog/start.sh && sudo chmod +x /catalog/chromium.sh && sudo chmod +x /catalog/inactivity.sh && sudo chmod +x /catalog/monitoroff.sh

  1. Reboot

  1. Edit the panel so it is mostly hidden

    • su catalog

    • If there is no file (it’s blank), try right clicking the panel and go to properties as catalog user

  • nano /home/catalog/.config/lxpanel/LXDE-pi/panels/panel

    • edge=bottom

    • align=right

    • width=0

    • height=0

    • transparent=1

    • autohide=1

    • heightwhenhidden=0

  1. Remove keyboard shortcuts

  • As catalog user (su catalog): 

    • mkdir /home/catalog/.config/openbox/

  • Switch back to pi user (exit).

  • sudo cp /etc/xdg/openbox/lxde-pi-rc.xml /home/catalog/.config/openbox/ 

  • sudo nano /home/catalog/.config/openbox/lxde-pi-rc.xml

  • Delete all lines in the following sections. The keybinding you see below allows for user logout using Ctrl+Alt+L

    •   (except Alt+F4)

 <keybind key="A-F4">

  <action name="Close"/>

</keybind>

  • <!-- Launch Task Manager with Ctrl+Alt+Del →

  1. Disable Ctrl+Alt+F1-F12

    • sudo nano /etc/X11/xorg.conf

Section "ServerFlags"

    Option "DontVTSwitch" "true"

EndSection

  • This step may no longer be needed.

  1. Remove all items in the Main Menu (as catalog user)

  • Press the windows key on the Pi keyboard to pull up the main menu.

  • Use the Main Menu Editor and remove everything from the main menu.

  • Or just right click the menu and Remove!

  1. Add start.sh to autostart

    • As catalog user”

      • mkdir -p /home/catalog/.config/lxsession/LXDE-pi/

      • nano /home/catalog/.config/lxsession/LXDE-pi/autostart

      • Add the following to end and save:

      • @/bin/bash /catalog/start.sh

    • Reboot and test that there is no menu items, Chromium autostarts, and you cannot do any combinations with Ctrl, Alt, F1 keys, etc.

  1. Setup Chromium and create a clean profile 

    • Make any changes to Chromium that you want to remain throughout restarts such as bookmarks, bookmark bar, home button, home page. Here are the changes I made:

      • Bookmark bar with bookmarks

      • Start page

      • New tab to search.pvld.org

      • Home button

      • Disable Use system title bar and borders

      • Disable autofill and save password

      • Remove apps shortcut on the bookmarks bar (right click on it)

      • Clear browsing history (I left the cache for better performance)

    • SSH into the Pi as catalog user and enter the following commands:

    • mkdir /home/catalog/.config/chromium/Backup

    • cp -r /home/catalog/.config/chromium/Default /home/catalog/.config/chromium/Backup

    • nano /home/catalog/.config/chromium/Backup/Default/Preferences

      • Search for exited_cleanly and make sure that says “True”

      • exit_type “Normal”

  1. Setup Cron jobs

    • The following set of cron job will shut off the monitor at 8:15 pm and restart the RPi at 8:45 am (to turn the monitor back on).

    • sudo crontab -e

    • “1” for nano

    • Paste in the following at the bottom of the file

15 20 * * * /catalog/monitoroff.sh

45 8 * * * /sbin/shutdown -r

  • (EXPERMENTAL!!) Possible automatic updates as a cron job?

* 1-6 * * 0-6 /usr/bin/apt update && /usr/bin/apt upgrade -y

  1. Final settings

  • sudo nano /catalog/chromium.sh

    • Uncomment the 2 lines (Remove the two #).

  • Reboot and test the browser. Make changes - create/delete bookmarks, settting changes, etc. Make sure after the browser restarts after 5 minutes inactivity (or just close it) all profiles reset properly. 

Prep for imaging and future rollouts:

  •  sudo nano /etc/lightdm/lightdm.conf

  • Comment out autologin-user=catalog (#autologin-user=catalog)

Limit websites (whitelists) 

Multiple RPi Installations

  1. Use your imaging program (very first step) to make a copy of your SD card.

  2. On new installations:

    • Change the hostname

      • sudo raspi-config

      • Network

    • Re-enable auto login

      • sudo nano /etc/lightdm/lightdm.conf

      • Uncomment autologin-user=catalog

    • Review network settings

    • Reboot

Editing the Chromium Profile After Deployment

  1. Make the changes in Chromium (add/remove bookmarks, change homepage button, etc.)

  2. Within 5 minutes of making the changes (due to the inactivity timer) run the following through SSH:

  3.  rm -r /home/catalog/.config/chromium/Backup/

  4. cp -r /home/catalog/.config/chromium/Default /home/catalog/.config/chromium/Backup

  5. Reboot and test

Sample Change:

sudo nano /catalog/chromium.sh

Remove the --ignore-certificate-errors --ignore-ssl-errors arguments

sudo nano /home/catalog/.config/chromium/Default /home/catalog/.config/chromium/Backup/Default/Bookmarks

Change Join PVLD URL to:

https://palos.ent.sirsi.net/client/en_US/default/search/registration/$N/SYMWS/true?

Leave a Comment

Your email address will not be published.