Saturday, August 27, 2016

Raspberry Pi 2 or 3 Setup Chromium as Kiosk

These instructions are for setup of the image to be used in a Raspberry Pi 3 attached to the official 7 inch touch screen monitor.
It is possible that not all instructions are applicable, but are noted here in case they are needed.

Burn Image to SD Card

Use Win32DiskImager to load the image 2016-05-27-raspbian-jessie.img onto an 8GB or larger SD Card.
Insert the card into the Pi, connect a network cable and power up the device.

Connect to the Pi using PuTTY

Download PuTTY. It can be found here at the time of this writing
PuTTY is used to connect remotely (my preference) to the Raspberry Pi terminal window. PuTTY is enabled by default in the loaded image from above.
You will need to know the IP address of the device in order in initiate the connection.
To get the IP address hover over (touch the screen - causing a dropdown to display - remove finger) the network icon in the upper corner. A gray popup will display the connection address.

Launch PuTTY and initiate a session on the default port with directed to the ip address of the device.
The default username is "pi"
and the default password is "raspberry"

Install Chromium Browser

Connect using PuTTY (or use a terminal session) and complete the following steps:
  1. Edit the application source list
    1. type: "sudo nano /etc/apt/sources.list" - NOTE: sudo is needed to run with elevated priveleges
    2. Add the following to to bottom of the file and save:
      deb http://ppa.launchpad.net/canonical-chromium-builds/stage/ubuntu vivid main
      #deb-src http://ppa.launchpad.net/canonical-chromium-builds/stage/ubuntu vivid main
    3. Add public key for repository by typing:
      sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DB69B232436DAC4B50BDC59E4E1B983C5B393194
  2. Update the packages so the installation will work:
    1. type: "sudo apt update"
    2. type: "sudo apt install chromium-browser"
  3. Launch Chromium from the start menu -- Internet -- Chromium Web Browser to verify it is working

Install "unclutter" - hides the cursor when not active

Connect using PuTTY (or use a terminal session) to support command prompt actions.

  1. type: "sudo apt install unclutter"

Rotate Screen (if needed)

You can do this by booting up your Pi, going into the Raspberry menu, picking "Accessories" and then "Terminal" (or use PuTTY).
  1. In Terminal, type "sudo nano /boot/config.txt" - NOTE: sudo is needed to run with elevated priveleges
  2. Add the line "lcd_rotate=2" to the top of the file. - NOTE: THERE ARE NO SPACES ON EITHER SIDE OF THE "=".
  3. Press CTRL+X.
  4. Then Y.
  5. Then Enter.
  6. And reboot! (type in terminal "sudo  reboot")

Update / Upgrade the image to the latest release

Connect using PuTTY (or use a terminal session) and type: sudo raspi-config.
  1. In Terminal, type "sudo apt update" (only needed if you did not already do this) - NOTE: sudo is needed to run with elevated priveleges
  2. In Terminal, type "sudo apt upgrade"
  3. hit 'y' when upgrade process asks if you want to continue. - this process will take a while
  4. Once done type "sudo reboot" to reboot the device

Initial Setup/Localization

Connect using PuTTY (or use a terminal session) and type: sudo raspi-config.
There are several configuration options available. - NOTE: With the May, 2016 Jessie image it is not necessary to "expand the file system"
  1. In Terminal, type "sudo raspi-config" - NOTE: sudo is needed to run with elevated priveleges
  2. Change User Password to "dothedew" - NOTE you will need to use this password for future PuTTY connections
  3. Enter Internationalisation Options
    1. Change Locale: use down arrow and spacebar to change the selection - remove the en_GB.... and add en_US.UTF-8 UTF-8
      use tab to highlight "OK" and press "Enter"
    2. Set the defaults local for hte system environment to en_US.UTF-8 (arrow key / tab / enter)
  4. Go back into the Internationalisation Options
    1. Select "Change Timezone
    2. Select "US"
    3. Select the correct timezone
  5. Go back into the Internationalisation Options
    1. NOTE: I did not need to do this step on my initial setup
    2. If pressing shift-3 in the PuTTY window does not type "#" then Select "Change Keyboard Layout".
    3. Go through the menus setting it to the defaults for a US keyboard.
  6. Go back into the Internationalisation Options
    1. Select Change Wi-fi County
    2. Set to "US"
  7. Reboot when it requests

Disable Screen Blanking / Screen Saver and set Chromium to start in Kiosk Mode

Connect using PuTTY (or use a terminal session) and type:
The autostart file for X moved with the release of Jessie.
Wheezy was located at /etc/xdg/lxsession/LXDE-pi/autostart If using Wheezy, you will want to modify the file location
  1. In Terminal, type "sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart" - NOTE: sudo is needed to run under elevated priveleges
  2. Modify this file by commenting out "@xscreensaver -no-splash"
    Add the following 5 lines to the end:
    1. @xset s off
    2. @xset -dpms
    3. @xset noblank
    4. @chromium-browser --disable-session-crashed-bubble --disable-infobars --kiosk http://www.PageToDisplay.com
      NOTE THIS IS THE LINE THAT HOLDS THE WEB ADDRESSS YOU WANT IT TO DISPLAY - See my new post from 9/21/2016
  3. Save changes to this file and reboot ("sudo reboot") to test that it is working

Install Real VNC for remote access

These instructions can be found here: https://www.realvnc.com/docs/raspberry-pi.html#vnc-and-raspberry-pi
Connect using PuTTY (or use a terminal session) and type the following lines.
  1. curl -L -o VNC.tar.gz https://www.realvnc.com/download/binary/latest/debian/arm/
  2. tar xvf VNC.tar.gz
  3. sudo dpkg -i VNC-Server-5.3.2-Linux-ARM.deb (modify version if needed)
    NOTE: make sure to copy the name with the correct CaSe
  4. sudo vnclicense -add XXXXX-XXXXX-XXXXX-XXXXX 
    • if you do not have a key you may need to buy or register a new (free for home use) one
    • replace above with your license key
  5. sudo vncpasswd -service
    enter the password "dothedew"
  6. Set for auto startup:
    1. Debian 8 Jessie: sudo systemctl enable vncserver-x11-serviced.service
    2. Debian 7 Wheezy sudo update-rc.d vncserver-x11-serviced defaults
  7. sudo reboot - NOTE VNC will not be available until after the reboot (it will start as a service from step 6)

Customize the Look and Feel

Insert a USB storage device containing the image you want to use on the Desktop background (if you want to use something other than the RPi default images.
Connect using PuTTY (or use a terminal session with attached keyboard and mouse) to support command prompt actions

NOTE to find the ip address, touch the network icon and release. After the menu disappears a gray popup will display with the connected address (or you can type "ifconfig" in the terminal window).

Connect to device with Real VNC Viewer if you do not have a keyboard and mouse attached.
  1. Copy the image file from USB attched storage to the device
    1. Use PuTTY or terminal window and type:
      1. On Jessie: type ls /media/pi to discover the USB DEVICE NAME (On Wheezy use: ls /media)
      2. On Jessie: sudo cp /media/pi/<UNIQUE USB DEVICE NAME>/<IMAGE NAME.png(.jpg,etc...)> /usr/share/raspberrypi-artwork (On Wheezy use /media not /media/pi)
Initiate VNC Connection or use a mouse and keyboard the the next steps
  1. Set the background image
    1. right click in the desktop
    2. Select "Desktop Properties"
    3. Click the browse button to pick a different image. It will open to the location we copied it to. (pick the file that looks right on the display you are using)
  2. Hide the Trash from the desktop
    1. right click on the desktop
    2. Select "Desktop Preferences"
    3. Select the Desktop Icons Tab and deselect Show "Trash Can" folder on the desktop
  3. Auto hide menu at the top
    1. right click on the task bar and select panel settings form the context menu
    2. Click the Advanced tab
    3. check "Minimize panel when not in use" (leave setting as 2 pixels)

ALL DONE !

Connect using PuTTY (or use a terminal session) to support command prompt actions.
  1. type: "sudo reboot" verify it is working correctly.

8 comments:

  1. Hey Doug.

    Thanks for the excellent write up. I have a question about the difference between chromium instantiated with autostart vs a GUI click by a user.

    Are there different features/capabilities that would change the behavior of a "cover flow" (horizontal drag) type JS?

    ReplyDelete
    Replies
    1. Forum link - https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=158692

      Delete
    2. Unknown,
      I am not familiar with the capabilities of Chromium instantiated with the kiosk switch vs a GUI click. This was one of my first tasks with a Raspberry Pi. All I was looking for is something that would auto-start and display the page I directed it to in full screen allowing keyboard input (no mouse).

      I must give credit to Dan Purdy and his site: https://www.danpurdy.co.uk/web-development/raspberry-pi-kiosk-screen-tutorial/ for the LXDE autostart code.

      I created this page here as a reference for myself when I am wanting to build a new card.

      Delete
  2. Hi Doug...Doug B. here. I'm trying to build a message board that automatically cycles through several web pages. I also used the Dan Purdy post as an example. I can get chromium-browser to load into kiosk mode with 3 tabs but I can't get xdotool to cycle through them. If I run my xdotool manually in a terminal window it works but I need it to load unattended. After disabling screensaver and load chromium I use a small batch file to insert a delay then try to load this:

    @lxterminal watch -n 10 'xdotool search --onlyvisible --class "chromium" windowfocus && xdotool key ctrl+Tab'

    If I open a terminal window and enter the above command starting with "watch" chromium starts rotating the tabs. But in the autostart file it doesn't work. Any thoughts? Thanks!
    Doug B.

    ReplyDelete
  3. OK, I finally got it to work by putting my watch command and xdotool command line in a simple .bash script and launching it with the @lxtermial. It works...It may not be pretty but it works.

    ReplyDelete
  4. Hello,
    Great information, I was tasked with setting up a kiosk at my job. I went crazy trying to get it working, but I found this site and provided the information and guide I needed. I'm using Jesse, anyways I had to create a script to perform what I needed, after banging my head to many times I got it working. Hope it helps to someone that is having the same issues. Thanks again
    #!/bin/bash
    export DISPLAY=:0
    WID=$(xdotool search --onlyvisible --class chromium|head -1)
    xdotool windowactivate ${WID}
    lxterminal --command watch -n25 xdotool key ctrl+Tab
    xdotool key F5
    dotool mousemove 9000 9000

    ReplyDelete
  5. Hello!
    I've been on the same journey, and your article has been very helpful.

    I have been unable to solve the problem on Ctrl_Alt_F1, or Ctrl_Alt_F-whatever. The "F1" brings me to a terminal command prompt, all signed in!! The F2 thru F6 give me tty2-tty6 terminal sign-ins.

    How have you dealt with this??

    Thanks in advance!
    -Brian

    ReplyDelete
  6. Hello!

    Wouldn't you just after I finally ask for help, I find the answer.

    http://www.linuxquestions.org/questions/debian-26/disable-ctrl-alt-f1-under-lxde-4175462672/

    shows the good trick for disabling switching in LXDE.

    Thanks!
    -Brian

    ReplyDelete