Raspberry Pi Kiosk using Chromium

For this Raspberry Pi Kiosk tutorial, we will be showing you how you can set up your Pi as a Kiosk using the popular web browser, Chromium.

Raspberry Pi Kiosk

We utilize Chromium as it is one of the best-supported web browsers and openly supports the functionality to act in a kiosk mode.

It is also easy to control through key presses which we can simulate using the xdotool that we install during this guide.

This guide will give you a good idea on how to use autologin tasks and simple bash scripts to perform numerous tasks.

Please note to do this tutorial you will need to be running the full version of Raspbian as this relies on the GUI that comes with it to properly operate.

Equipment List

The entire list of all the pieces of equipment that we made use of for this Raspberry Pi Kiosk tutorial is listed below.

Recommended

Optional

Video Tutorial

In this video, we show you the process of setting up your Raspberry Pi to operate as a Chromium powered kiosk as well as showing you how to get it to start at boot.

If you prefer a written and more thorough explanation, then check out our written guide below.

Adblock removing the video? Subscribe to premium for no-ads.

Setting up the Raspberry Pi Kiosk

1. Before we get started with this tutorial, we will be first removing some packages that we don’t need for our Raspberry Pi kiosk.

Removing these packages will free up some much-needed memory and reduce the number of packages that will be updated every time you update your Raspberry Pi.

To do this just run the following three commands on your Raspberry Pi. We have split these into three different commands to make them easier to copy and write out.

sudo apt purge wolfram-engine scratch scratch2 nuscratch sonic-pi idle3 -y
sudo apt purge smartsim java-common minecraft-pi libreoffice* -y

2. Now that we have removed these numerous packages from our Raspberry Pi Kiosk we will need to run some cleanup commands.

To remove any unnecessary lingering packages and to clean out the local repository of retrieved packages run the following two commands on your Raspberry Pi.

sudo apt clean
sudo apt autoremove -y

3. Now that we have removed the bulk of the unnecessary applications, we must now make sure that our installation of Raspbian is up to date. Also, make sure you have SSH enabled as it is very handy if you need to edit any files later on.

We can use the following two commands within the terminal on our Raspberry Pi to update all the packages to their latest versions.

sudo apt update
sudo apt upgrade

4. We now need also to install xdotool. This tool will allow our bash script to execute key presses without anyone being on the device. We also install the unclutter package, this will enable us to hide the mouse from the display.

Just run the following command on your Raspberry Pi to install the package.

sudo apt install xdotool unclutter sed

5. Now that those packages have been installed we can now proceed to the next stage of this tutorial. That is setting up Raspberry Pi OS to auto login to our user. Having to log in every time for a kiosk would be an annoyance.

Desktop autologin is the default behavior but if for some reason you have changed it follow the next few steps to switch it back. Otherwise, skip to step 6 of this tutorial.

5a. Run the following command on your Raspberry Pi to load up the Raspi-config tool. We will be using this tool to enable auto login.

sudo raspi-config

5b. Now within the tool go to 1 System Options -> S5 Boot / Auto Login -> B4 Desktop Autologin

5c. Desktop autologin should now be enabled and you can safely quit out of the raspi-config tool.

6. Now that we have enabled desktop autologin we need to go ahead and write our kiosk.sh script.

Writing the Raspberry Pi Kiosk Script

The kiosk script will handle the bulk of the work for our Raspberry Pi Kiosk, including launching Chromium itself and also simulating key presses.

1. Begin writing our kiosk bash script by running the following nano command on the Raspberry Pi.

nano ~/kiosk.sh

2. Within this file enter the following lines of code, we will explain the important parts of the script so you can better bend it to your needs.

#!/bin/bash

The very first line defines what the command line interpreter (CLI) should use to try and execute this file.

This is useful for cases where you don’t want to have to specify the specific application required every time you run the script.

xset s noblank
xset s off
xset -dpms

These three lines are pretty important as they help us stop the Raspberry Pi’s display power management system from kicking in and blanking out the screen.

Basically, these three commands set the current xsession not to blank out the screensaver and then disables the screensaver altogether.

The third line disables the entire “display power management system” meaning that the desktop interface should never blank out the screen.

unclutter -idle 0.5 -root &

This line runs the program we installed earlier called unclutter.

This application will hide the mouse from the display whenever it has been idle for longer then 0.5 seconds and will remove it even if it is over the root background.

You can adjust the idle timer to the number of seconds you want with each decimal place being a fraction of a second.

If you would prefer to remove the mouse instantly, then remove the -idle 0.5 from the  command.

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/$USER/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/$USER/.config/chromium/Default/Preferences

These two lines of the script use sed to search through the Chromium preferences file and clear out any flags that would make the warning bar appear, a behavior you don’t really want happening on your Raspberry Pi Kiosk.

If Chromium ever crashes or is closed suddenly, the lines above will ensure you don’t have to get hold of a mouse and keyboard to clear the warning bar that would typically appear at the top of the browser.

/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk https://pimylifeup.com https://www.adafruit.com &

This line launches Chromium with our parameters.

We will go through each of these parameters so you know what you can modify, and how you can modify it.

--kiosk

This flag sets Chromium to operate in Kiosk mode, this locks it into a particular set of features and only allows limited access to both the web browser and any other OS functionality.

Chromium’s kiosk functionality takes full control of the screen, maximizing Chromium to the full size of your screen and stops user input from being accepted by the OS, effectively trapping the end user within a sandbox.

--noerrdialogs

This option tells Chromium that it should not display any of its error dialogs to the end user.

It is crucial if you don’t want the end user to know if anything has or is going wrong with Chromium, this goes alongside our code to clear the “exited_cleanly” and “exit_type” state earlier in the code.

--disable-infobars

We use this to disable Chromium from displaying its info bar to the end user.

The info bar can be used by Chromium to notify them of certain things such as that Chromium is not their default web browser.

Of course, as we are using this as a kiosk, we don’t need the user to know any information that Chromium might want to display.

https://pimylifeup.com https://www.adafruit.com

These are the two web pages that the script will open, each will be opened in a new tab.

You can add additional web pages/tabs by adding to this list by separating each one with a space.

while true; do
         xdotool keydown ctrl+Next; xdotool keyup ctrl+Next;
      sleep 15
done

These lines run a very simple infinite while loop that uses xdotool to mimic pressing CTRL + Pgdn. Making Chromium switch to the next tab. “Next” is a alias for the “PG DN” key.

After xdotool has executed its key presses, it then puts the loop to sleep for 15 seconds.

To change how long the loop sleeps for before it executes the xdotool command again just change the sleep 15 command.

You can also use this method to add a screen refresh, this may be important when you want to display live scores.

The command for this should look something like what we have shown below.

xdotool keydown ctrl+r; xdotool keyup ctrl+r;

3. Once you have entered all the code for our Raspberry Pi kiosk script, it should look somewhat similar to what we have displayed below.

#!/bin/bash
xset s noblank
xset s off
xset -dpms

unclutter -idle 0.5 -root &

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/$USER/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/$USER/.config/chromium/Default/Preferences

/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk https://pimylifeup.com https://www.adafruit.com &

while true; do
   xdotool keydown ctrl+Next; xdotool keyup ctrl+Next;
   sleep 10
done

4. Once you are sure everything is correct, save the file by pressing CTRL + X then Y and finally ENTER.

5. After creating this script we should make sure that our user has execution privileges for it.

You can give the user that owns the script execution privileges by running the following command.

chmod u+x ~/kiosk.sh

Setting up the Raspberry Pi Kiosk to start at boot

1. Before we get started we need to first utilize the following command to work out what the current display value is.

This value is used for the operating system to know what screen to display the Chromium kiosk to, without it the kiosk will either fail to load or load up on the incorrect screen.

Run the following command to print out the value of the “$DISPLAY” system variable. This command must be run directly on your Raspberry Pi and not over SSH.

echo $DISPLAY

Make sure you remember this value as you may need it in step 3 of this section.

2. To get our Raspberry Pi Kiosk to start at boot we will need to go ahead and create a service file by running the command below.

This service file will tell the operating system what file we want to be executed as well as that we want the GUI to be available before starting up the software.

sudo nano /lib/systemd/system/kiosk.service

3. Within our kiosk service file, enter the following lines of text.

These lines are what will define our service kiosk service, and that we want to run our kiosk.sh script when the system loads into the operating system.

While entering these lines you may have to modify the “Environment=DISPLAY=:” line, replacing the “0” with the value that you retrieved from the command you used in step 1 of this section.

Additionally, you will need to make sure you replace “pi” with the name of your user. For example, with the username “pimylifeup“, the path “/home/pi/kiosk.sh” would become “/home/pimylifeup/kiosk.sh“.

[Unit]
Description=Chromium Kiosk
Wants=graphical.target
After=graphical.target

[Service]
Environment=DISPLAY=:0.0
Environment=XAUTHORITY=/home/pi/.Xauthority
Type=simple
ExecStart=/bin/bash /home/pi/kiosk.sh
Restart=on-abort
User=pi
Group=pi

[Install]
WantedBy=graphical.target

Once you have entered everything into the file, save the file by pressing CTRL + X followed by Y then ENTER.

4. Now that we have created the service file for our Raspberry Pi Kiosk we can go ahead and now enable it by running the following command.

By enabling the service, we will allow our Chromium Kiosk to start up at boot automatically and will enable the systemd to service manager to monitor it.

sudo systemctl enable kiosk.service

5. With the Kiosk service now enabled you can either choose to restart the Raspberry Pi or start the service now by running the following command.

sudo systemctl start kiosk.service

6. If you ever want to check the status of your Raspberry Pi Kiosk’s service, you can run the command below.

This command will return various information about the service, including previously returned lines from the software which can help you debug what’s going wrong when the service is failed.

sudo systemctl status kiosk.service

If this command shows the status as “Active: active (running)” then everything is now working as it should be, and your Raspberry Pi Chromium Kiosk should be up and operating correctly.

7. Now with everything up and running correctly, if there is for any reason you want to stop the service from running, you can utilize the following command.

sudo systemctl stop kiosk.service

By stopping the kiosk service, the service manager will kill off all processes associated with it.

This command will stop our kiosk.sh script from running while also terminating the open Chromium browser.

8. Finally, if you ever want to disable your Kiosk, you can utilize the following command.

sudo systemctl disable kiosk.service

This command will stop the Kiosk service from running on boot until you re-enable it.

Enforcing the Resolution on a Raspberry Pi Kiosk

1. One thing you might want to do is to enforce the resolution that the Raspberry Pi is going to use. Setting the resolution can be quite handy as the Raspberry Pi’s built-in detection can sometimes be a bit flakey.

To begin setting the resolution, we must first load up the Raspberry Pi configuration tool by running the following command.

sudo raspi-config

2. Within the configuration tool, you will want to start by going to “7 Advanced Options“.

3. Now that we are in the advanced options section you should see an option labeled “A5 Resolution” select that option.

4. Within here find and select the resolution that best fits your screen and press ENTER.

5. With your resolution now set you will need to restart the Raspberry Pi. Do this by first exiting out of the configuration tool by pressing ESC, then entering the following command into the Raspberry Pi’s terminal.

sudo reboot

6. Your Raspberry Pi should now restart and be running at the specified resolution.

Conclusion

There are so many ways you can extend this tutorial. For example, you can set up a web server on the Raspberry Pi and have it serve local web pages to be displayed on your Kiosk.

It’s perfect if you want the results of a competition or basically any other sort of information you want to be displayed.

By now you should have your Raspberry Pi successfully booting into the Kiosk mode of Chromium. If you have any issues with this Raspberry Pi kiosk tutorial or want to leave feedback, then feel free to leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *

129 Comments

  1. Avatar for Kevin Shumaker
    Kevin Shumaker on

    Emmet:
    Thank you for your tutorial. I had a client who was using Raspberry Pi, 3.5″ display & web camera and wanting to use them as a ‘virtual’ peephole by the front door.
    He wanted to use motionEye for recording, and live view on the display.
    Got everything set up except the final display. Came across this wonderful, little, simple tutorial, and WOW. Now all works as expected.
    Excellent work, sir. If you ever need a beta tester, I’d love to help you out. I do Help Desk support on an Enterprise level, and am always looking for outside the box solutions.

  2. Avatar for Winston Wolf
    Winston Wolf on

    If you knew how long I have been bashing my head against a concrete wall to get this working you would laugh endlessly. Thank you for such a great write up.

  3. Avatar for Abi
    Abi on

    Hey, Thank you for the tutorial. I have a quick question. The website I am displaying is actually from an visualization application and it requires its own login. How do I automatically log in to the application when it loads the page display ? because it currently asks me to log in everytime the Raspberry Pi reboots.

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Abi,

      Sadly automatically logging into web pages within Chromium is not a simple task.

      You could potentially do something with xdotool to enter the username and password and login but that could be finicky and break easily.

      From my quick research there is no easy way of doing this within Chromium itself.

      Cheers,
      Emmet

    2. Avatar for Jeff
      Jeff on

      Have you checked whether the app can work with basic authentication? If so, you simply make the URL “http://user:password@/ to feed it the credentials. It’s worth trying that anyway, nothing to lose!

  4. Avatar for Bonzadog
    Bonzadog on

    As a person that does not to use Google products, is there a way to get this running on Opera or Firefox?

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Bonzadog,

      Sadly Opera is not supported on the Raspberry Pi and the version of Firefox that is currently available for the operating system does not support Kiosk mode.

      Of the other major web browsers available for the system, Vivaldi doesn’t support a kiosk mode either.

      Cheers,
      Emmet

  5. Avatar for Chris
    Chris on

    Hi,

    I like your tutorials – clear, concise and to the point ! I am using the Kiosk and this works fine, but I would like to change the webpage according to the time; eg from 09:00 ’till 22:00 show pages 1 & 2 and after 22:00 till 09:00 pages 1 & 3. Additionally, allow different pages to display during the weekend ?
    Is this possible within the kiosk.sh script ? Because I have the webserver locally installed on the rpi, I am considering using the same name for the local webpage (eg info.html), but renaming page1.html to info.html after 22:00 and later page2.html to info.html at 09:00 ? Would that work ? And how could I do that ?
    thx
    Chris
    Belgium

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Chris,

      There is a couple of ways you could handle this.

      You can modify the bash script so that it retrieves the current time each loop, then act dpending on whether it sits within your brackets.

      #!/bin/bash
      xset s noblank
      xset s off
      xset -dpms
      
      unclutter -idle 0.5 -root &
      
      sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
      sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences
      
      /usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk https://pimylifeup.com https://www.adafruit.com https://raspberrypi.org https://pimylifeup.com/raspberry-pi-kiosk/ https://pimylifeup.com/jenkins-raspberry-pi/ https://pimylifeup.com/raspberry-pi-ftp/ &
      
      while true; do
         currenttime=$(date +%H:%M)
         if [[ "$currenttime" > "09:00" ]] || [[ "$currenttime" < "22:00" ]]; then
           xdotool keydown ctrl+1; xdotool keyup ctrl+1;
           sleep 10
           xdotool keydown ctrl+2; xdotool keyup ctrl+2;
           sleep 10
         else
           xdotool keydown ctrl+1; xdotool keyup ctrl+1;
           sleep 10
           xdotool keydown ctrl+3; xdotool keyup ctrl+3;
         fi
      done

      This little snippet should switch between the tabs 1 and 2 between 9am and 10pm.
      Outside of those hours it switches between tabs 1 and 3.

      On the weekend it does the same thing but uses the tabs 4, 5 and 6.

      #!/bin/bash
      xset s noblank
      xset s off
      xset -dpms
      
      unclutter -idle 0.5 -root &
      
      sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
      sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences
      
      /usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk https://pimylifeup.com https://www.adafruit.com https://raspberrypi.org &
      
      while true; do
         currenttime=$(date +%H:%M)
         dow=$(date +%u)
         if [[ "$dow" < "6" ]]; then
           if [[ "$currenttime" > "09:00" ]] || [[ "$currenttime" < "22:00" ]]; then
             xdotool keydown ctrl+1; xdotool keyup ctrl+1;
             sleep 10
             xdotool keydown ctrl+2; xdotool keyup ctrl+2;
             sleep 10
           else
             xdotool keydown ctrl+1; xdotool keyup ctrl+1;
             sleep 10
             xdotool keydown ctrl+3; xdotool keyup ctrl+3;
             sleep 10
           fi
        else
            if [[ "$currenttime" > "09:00" ]] || [[ "$currenttime" < "22:00" ]]; then
             xdotool keydown ctrl+4; xdotool keyup ctrl+4;
             sleep 10
             xdotool keydown ctrl+5; xdotool keyup ctrl+5;
             sleep 10
           else
             xdotool keydown ctrl+4; xdotool keyup ctrl+4;
             sleep 10
             xdotool keydown ctrl+6; xdotool keyup ctrl+6;
             sleep 10
           fi   
      done

      With this solution you just need to make sure you launch chromium using the tabs in the right order.

      It's a bit clunky but it should achieve what you are trying to do.

      Let me know if you need anything explained a bit more.

  6. Avatar for Paden
    Paden on

    Thanks for the great guide. One issue that we are having is that after a period of time chromium will trigger a popup that says Chromium needs an update. When this happens whatever page is currently visible will stop any refresh actions and we have to restart the kiosk service via SSH.

    Is there a way to disable these either with a startup flag or something else? From my understanding chromium can’t be updated from the browser but instead needs to be installed via apt-get or source but no new package is available at the moment.

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Paden,

      Sadly there doesn’t appear to be any flags in specific that we can use to hide the popup.

      You could try increasing the update check interval time and see if that helps stop it from messaging.

      Using the following flag will tell Chromium to only check for updates every 7 days, the time for this is the amount of seconds that should occur before checking for an update.

      --check-for-update-interval=604800

      Let me know if this helps with the issue.

      Cheers,
      Emmet

    2. Avatar for Brandon
      Brandon on

      Paden,

      I am new to the Raspberry Pi and I was running into the same issue. I found the following forum in regards to it and it worked for me. At first I did as it mentions and added –check-for-update-interval=1 to have it check for the update 1 second after starting. That way the popup appears instantly. Then I added the “–simulate-critical-update” part and rebooted again. This let me see quickly if the popup appeared instead of having to wait hours for it to appear. It has been working on my Pi for a few days.

      Add –check-for-update-interval=1 –simulate-critical-update to the file

  7. Avatar for Dr Dubya
    Dr Dubya on

    Many, many thanks for creating this tutorial Gus, I’m happy to say it worked first time round; you’ve solved a massive problem for me, my company is now in a position to allow students to do their exams online without the possibility of them cheating by using a search engine.

  8. Avatar for 5artist5
    5artist5 on

    Hi, Im having trouble with the systemctl.
    If I do the:
    sudo systemctl start kiosk.service
    It starts the Kiosk and loads the page.
    But if I do:
    sudo systemctl enable kiosk.service
    it errors and says that unit files have no installation config

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi,

      I just ran through the tutorial to verify everythings still working and the service succesfully enabled on my Raspberry Pi.

      Can you please verify the contents of your /lib/systemd/system/kiosk.service file?

      Make sure that the following text is located at the bottom.

      [Install]
      WantedBy=graphical.target

      Cheers,
      Emmet

  9. Avatar for alankk
    alankk on

    How much RAM do I need on a PI to run chromium in kiosk mode?

    1. Avatar for Gus
      Gus on
      Editor

      You can get away with 1gb, but more is always better.

  10. Avatar for DARIN L SCHOLLMEYER
    DARIN L SCHOLLMEYER on

    Thank you so much! I needed a way to display a Node-red dashboard on boot, I tried several other methods (wasting a better part of the day) and this is the first one to work!

    1. Avatar for Dean
      Dean on

      After spending more time than I care to admit, this worked the first time, right out of the box! I needed to set up a PI to run Plex for the family room, so that it is as bullet-proof as possible! The Plex server is on one PC server in the computer room, and the File server is on another, also in the server room, so that files can’t be added/deleted/ or changed without the admin (me) doing it from a controlled environment. Thanks for such a WONDERFUL tutorial!

    2. Avatar for Dean
      Dean on

      Also, another tip: For those using a RPi 4, the HDMI audio ONLY plays thru HDMI 0, the one on the left. That one bit me for a LONG time!

  11. Avatar for Cameron Sylvester
    Cameron Sylvester on

    Hi, I cant wait to try this. I am curious if you could let me know how to refresh the browser once every hr or whatever I set it to. ie 1 minute or 24 hrs.

    I would like to use this to display a google slides presentation as a messaging display at work and would like it to refresh the slide/message without having to manually reload the page.

    1. Avatar for Cam Sylvester
      Cam Sylvester on

      I figured it out in your code:
      while true; do
      xdotool keydown ctrl+Tab; xdotool keyup ctrl+Tab;
      sleep 10
      done

      sub in ctrl+r instead of ctrl+tab
      and have it sleep for 60 for 1 min or 86400 for 24 hrs

  12. Avatar for Matt
    Matt on

    Let’s say you have 2 different tabs, and you want to play for 60 seconds, but the other 120 seconds before switching. How would that be scripted?

    1. Avatar for Gus
      Gus on
      Editor

      Hi Matt,

      The code below should do what you’re after. It will display the first tab for 60 seconds then switch to the next tab for 120 seconds.

      xdotool keydown ctrl+Tab; xdotool keyup ctrl+Tab;
      sleep 60
      xdotool keydown ctrl+Tab; xdotool keyup ctrl+Tab;
      sleep 120
    2. Avatar for Johnathan C
      Johnathan C on

      You actually want something a little different in-case the tabs get messed up
      Below will switch to the first tab in Chrome, wait 60 seconds, then go to the 2nd tab for 120 seconds you can do this with multiple tabs in any order

      xdotool keydown ctrl+1; xdotool keyup ctrl+1;
      sleep 60
      xdotool keydown ctrl+2; xdotool keyup ctrl+2;
      sleep 120

  13. Avatar for Mansoor
    Mansoor on

    Hi Emmet,
    I must say your tutorial is awesome. But I would like to know if Chromium running in kiosk mode and there is not keyboard and mouse attached to pi screen attached to pi can support touch but when chromium is running if any form fill needs to happen on web how can we invoke matchbox-keyboard.
    I will wait to hear from you.
    Much appreciated.

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Mansoor,

      I don’t have a touch screen to test this with but could you try adding “–touch-events” to the arguments list for chromium.

      So the line should become something like this:
      /usr/bin/chromium-browser --touch-events --noerrdialogs --disable-infobars --kiosk https://pimylifeup.com https://www.adafruit.com &

      Cheers,
      Emmet

  14. Avatar for LiamBradfordBBC
    LiamBradfordBBC on

    Emmet, this has been a game-changer for me, thank you so much for taking the time to publish this. I’m, however, having some issues with scrolling through the tabs in Chrome, I’ve followed the instructions and have this is in kiosk.sh file:

    while true; do
    xdotool keydown ctrl+Tab; xdotool keyup ctrl+tab
    sleep 10
    xdotool keydown ctrl+r; xdotool keyup ctrl+r
    sleep 20
    done

    but it doesn’t seem to be working? If you can help, I’d be hugely appreciative

    Kind Regards Liam

    1. Avatar for LiamBradfordBBC
      LiamBradfordBBC on

      Just to clarify, this is only a problem when in full screen mode. It works perfectly well outside of full screen…

    2. Avatar for Emmet
      Emmet on
      Editor

      Hi Liam,

      This definitely does seem peculiar, while I couldn’t reproduce this behaviour myself I have tried to come up with a solution.

      Can you please try replacing the “while” loop with the block below. The addition i made here was to make xdotool search for the chromium browser and force it in to focus.

      while true; do
         xdotool search --onlyvisible --class Chromium windowfocus
         xdotool keydown ctrl+Tab; xdotool keyup ctrl+Tab;
         sleep 10
      done

      Let me know if this helps you out.

      Cheers,
      Emmet

  15. Avatar for Kjell Gustafsson
    Kjell Gustafsson on

    Hello, and thanks for the script. My problem is that it will not open/start since (failed = exit-code, code-exited status 1/failure)
    The program is loaded but not active. Have no ideas, unless time settings are involved. My settings are CEST+1 (Sweden)

    1. Avatar for Kjell Gustafsson
      Kjell Gustafsson on

      Reply to myself; check your display with echo $DISPLAY and use the value it generates. In my case it was 0.0
      Happy ending 😉

  16. Avatar for Shae.Da
    Shae.Da on

    Thank you for your time and knowledge Emmet.

  17. Avatar for Shae.Da
    Shae.Da on

    Hi, what a great tutorial. Thank you so much! It’s working great and I just wanted to add that it works on folders as well. I’m hardly a programmer or anything but replacing the the URLs with

    /home/username/foldername/*.jpg

    will start a slide show. I suppose *.* will work as well.

    I just thought I’d share.

    One question. This might be outside the scope of this .sh but is there a way to set a auto on/off? For instance: having it start the kiosk at 9AM and powering off the kiosk at midnight (local time of course) without shutting the system down? Just turning off the service and powering off the screen.
    Or even just powering off at a specific time would be great. I tinkered with it but couldn’t figure out how.

    Thank you again!

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Shae.Da,

      In answer to your question, one of the easiest ways to handle this would probably be to just use a crontab to stop and start the device.

      Adding the following lines to the crontab should work but i havent tested this myself.

      Begin by opening up the crontab editor with the following command.

      sudo crontab -e

      Then add the lines below into it.

      0 0 * * * systemctl stop kiosk.service
      0 0 * * * tvservice -o
      0 9 * * * systemctl start kiosk.service
      0 9 * * * tvservice -p

      Hopefully that works.

      Cheers,
      Emmet

  18. Avatar for Boris
    Boris on

    Thank you very much for the tutorial.
    I follow all the steps but can’t make it running. Chromium doesn’t start automatically.
    This is what the status shows:

    pi@raspberrypi:~ $ sudo systemctl status kiosk.service
    ● kiosk.service – Chromium Kiosk
    Loaded: loaded (/lib/systemd/system/kiosk.service; enabled; vendor preset: en
    Active: inactive (dead) since Thu 2019-04-25 22:43:22 PDT; 17min ago
    Process: 562 ExecStart=/bin/bash /home/pi/kiosk.sh (code=exited, status=0/SUCC
    Main PID: 562 (code=exited, status=0/SUCCESS)

    Apr 25 22:43:22 raspberrypi systemd[1]: Started Chromium Kiosk.
    lines 1-7/7 (END)…skipping…
    ● kiosk.service – Chromium Kiosk
    Loaded: loaded (/lib/systemd/system/kiosk.service; enabled; vendor preset: enabled)
    Active: inactive (dead) since Thu 2019-04-25 22:43:22 PDT; 17min ago
    Process: 562 ExecStart=/bin/bash /home/pi/kiosk.sh (code=exited, status=0/SUCCESS)
    Main PID: 562 (code=exited, status=0/SUCCESS)

    Apr 25 22:43:22 raspberrypi systemd[1]: Started Chromium Kiosk.

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Boris,

      Have you made any changes to the kiosk.sh script??

      If you have removed the section that changes the tabs can you please try removing the & symbol thats at the end of the chromium-browser call and let me know whether that resolves your issues.

      Cheers,
      Emmet

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Brian,

      I see a few people are seeming to run into similar issues with the display not working as it should be which is bizzare.

      We will likely add a troubleshooting section to reflect the potential need to add export DISPLAY=:0 to the script but just want to gather some more information on it.

      Cheers,
      Emmet

  19. Avatar for Mike
    Mike on

    Hi! Quick question, I’m running a online calendar on my kiosk.
    I have a couple of pages that would need to be used on a firefox user agent. I’m using “user-agent switcher” as the extension
    How will I be able to have Chromium run this extension first then load the pages because I get an error saying that the page I’m trying to access is not available on the browser without it.

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Mike,

      Apologies for taking a few days to reply, I went and looked into this and you may be able to avoid relying on an extention by passing it few as an argument.

      Modify the following line in the kiosk.sh file
      /usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk https://pimylifeup.com https://www.adafruit.com &

      And change it so it looks something like what we have below. You can specify your own user agent of course, we are just using an example one we grabbed off of Firefox’s developer webpage.


      /usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk https://pimylifeup.com https://www.adafruit.com --user-agent "Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0" &

      Let me know if this works out for you, if it works as it should we will go ahead and add a section to the tutorial on this as I reckon others may need this to.

      Cheers,
      Emmet