4

As many people, i'm looking to use my pi as a kiosk. I have managed to get everything running when starting the kiosk.

my kiosk.sh script, which works fine

#!/bin/bash

URL="http://127.0.0.1"
xset s noblank
xset s off
xset -dpms

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

unclutter -idle 0.5 -root &

/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk $URL &

I am able to autostart this script thorugh /etc/xdg/lxsession/LXDE-pi/autostart

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
#@xscreensaver -no-splash
point-rpi

@bash /home/pi/kiosk/kiosk.sh

However, when I try the same using a unit file, that does not work. I commented out the last line of autostart before starting the service

[Unit]
Description=Chromium Dashboard
Requires=graphical.target
After=graphical.target

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

[Install]
WantedBy=graphical.target

this is the output of systemctl status pi@kiosk.service

● pi@kiosk.service - Chromium Dashboard
   Loaded: loaded (/etc/systemd/system/pi@kiosk.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2019-10-21 20:38:56 CEST; 2s ago
  Process: 1417 ExecStart=/home/pi/kiosk/kiosk.sh (code=exited, status=0/SUCCESS)
 Main PID: 1417 (code=exited, status=0/SUCCESS)

Oct 21 20:38:55 countdown systemd[1]: Started Chromium Dashboard.
Oct 21 20:38:56 countdown systemd[1]: pi@kiosk.service: Succeeded.

so I would like to know where I am going wrong here. I should get the same response both ways but I dont.

2

The Unit file looks very good for a program to start as service. systemd runs services automatically in the background. But your script is sending unclutter and chromium-browser to the background additional using &. After doing that the bash script terminates successful with exit code 0 and that is what systemctl status show you with:

Process: 1417 ExecStart=/home/pi/kiosk/kiosk.sh (code=exited, status=0/SUCCESS)

Everything is OK from the view of systemd but it has lost any control about chromium-browser that is running everywhere in the background. You should be able to find it with ps aux | grep chromium-browser. If you really want to run it as old-style daemon by sending it to the background you may have a look at man systemd.service using Type=forking and maybe PIDFile= and other things to control forked daemons. But I don't believe that it will work because the commands are wrapped into a bash script and systemd cannot see them.

I would suggest to delete the last two lines from the script and try this Unit:

[Unit]
Description=Chromium Dashboard
Requires=graphical.target
After=graphical.target

[Service]
Environment=DISPLAY=:0.0
Environment=XAUTHORITY=/home/pi/.Xauthority
ExecStartPre=/home/pi/kiosk/kiosk.sh
ExecStart=usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk $URL
Restart=on-abort
User=pi
Group=pi

[Install]
WantedBy=graphical.target

This is only to give an idea how it could work. Of course you have to look how to define $URL within the Unit. I don't know your setup. You cannot start a second service unclutter e.g. with ExecStartPre=/full/path/to/unclutter -idle 0.5 -root. If you need to run it in the background before chromium-browser then you have to make its own Unit and start kiosk.service After that.

| improve this answer | |
  • 1
    thank you. with some tweaking this worked perfectly. I ended up running unclutter as part of /etc/xdg/lxsession/LXDE-pi/autostart and running both an ExecStartPre script (as you suggested) and an ExecStartPost script which takes care of tabbing for me if I want to open multiple pages and automatically tab between them. – Marc Wagner Oct 23 '19 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.