1

I am having some issues with automating tasks at boot on the Pi. I have tried numerous different methods to do this including the systemd method and the .bashrc method. The command is a simple one used to open chromium fullscreen and direct to a URL that acts as a ping board. I have no real use for a script as only one command is needed, the last lines of my .bashrc read as so

if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion

  fi

fi 

chromium-browser --start-fullscreen preferred_URL &

Fairly simple command, opens the browser fullscreen and directs straight to the URL and the ampersand is there to keep the process from forking and I have tried it without. This is all well and good, and works fine as a command, but for some reason it does not work on boot. It will work when I open a terminal. which tells me the command is functional, but that is all. Because this method did not work I decided to try and put the command in to a script and run it on boot as a daemon service. So I created the service in the relevant location /lib/systemd/system/Panel.service that reads as so;

[Unit]
Description=Opens Chromium Browser and directs to PingBoard
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/Panel.sh

[Install]
WantedBy=multi-user.target

And the script reads quite simply;

#!/bin/bash

chromium-browser --start-fullscreen Required_URL &

fi

And I run the commands as per the tutorial I was following:

sudo systemctl daemon-reload
sudo systemctl enable Panel.service
sudo chmod 644 /lib/systemd/system/Panel.service

Upon reboot the browser still does not launch and I am struggling to find out why, hence this post, I have seen quite a few posts on here about issues faced when doing these things and have tried the solutions to no avail, I have a feeling it is something very simple that I am overlooking. Please bear in mind that, although reasonably familiar with Linux, it is my 3rd day using a Pi and my very first time trying to automate a program via a command/script so please try not to make your answers too complex. Thanks in advance!

So I have since been informed of the

sudo journalctl -u Panel.service

Command which helped me gather more information on the issue, it said that there was a problem at line 5 which was the fi in the script, I removed this since, re-ran the relevant daemon commands and still no dice. I ran journalctl command and got this output.

- Logs begin at Thu 2017-09-14 14:41:29 UTC, end at Thu 2017-09-
14 14:44:52 UTC. --
Sep 14 14:42:28 raspberrypi systemd[1]: Started Opens Chromium 
Browser and directs to PingBoard.
Sep 14 14:42:34 raspberrypi Panel.sh[477]: 
[484:484:0914/144234.717436:ERROR:browser_main_loop.cc(582)] 
Failed to put Xlib into threaded mode.
Sep 14 14:42:34 raspberrypi chromium-browse[484]: cannot open 
display: 
Sep 14 14:42:34 raspberrypi systemd[1]: Panel.service: Main 
process exited, code=exited, status=1/FAILURE
Sep 14 14:42:34 raspberrypi systemd[1]: Panel.service: Unit entered 
failed state.
Sep 14 14:42:34 raspberrypi systemd[1]: Panel.service: Failed with 
result 'exit-code'.

This issue has been solved. What I learned was that there was an autostart file within /home/pi/.config/lxsession/LXDE-pi that read as so;

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

All I had to do was insert my command @chromium-browser --start-fullscreen Required_URL just before the @xscreensaver -no-splash line and Chromium starts at boot and directs to the relevant URL. The issue was caused by the fact that the command was previously being run before the GUI had initialised and therefore was not working correctly, this way the command is run after the GUI is initialised and works without issue. I am now to lengthen the script to automate login.

2
  • Any useful logs from sudo journalctl -u Panel.service?
    – Aurora0001
    Sep 13, 2017 at 15:27
  • So I ran that command, very useful one thanks for the info, and got a result mentioning an issue at line 5 which was the "fi" at the end of my script. I then removed that line, re-ran all the relevant commands and still no dice.
    – JayBuckel
    Sep 14, 2017 at 14:53

1 Answer 1

1

Chromium requires a working display manager to run. Running your service at multi-user.target is too early for this — X.Org probably isn't ready at this point, so Chromium fails when trying to access your display.

Instead, you can use XDG Autostart Files to start your service after the DM is ready. All files in ~/.config/autostart/ ending in .desktop will be checked. For example, you could create a file called ~/.config/autostart/ChromiumPanel.desktop, with the following contents:

[Desktop Entry]
Version=1.0
Type=Application
Name=ChromiumPanel
Exec=/usr/bin/chromium-browser --start-fullscreen Required_URL

Note that since this configuration file is stored in the user's home directory, the autostart only works for the user you choose.

1
  • This was very helpful! You were correct, the command was being run without a GUI therefore was automatically failing. There was slight variation in the way it was solved, there was a file rather than a folder, but you were exactly right in what caused the issue and pointed me in the right direction to solve it. I have updated my post to reflect the solution, many thanks!
    – JayBuckel
    Sep 15, 2017 at 8:56

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.