5

I'm new to bash scripting and just a little familiar with basic Linux. We've setup a Pi showing dashboards using the code below:

@chromium-browser --disable-infobars --disable-session-crashed-bubble --kiosk http://www.url.com

which is located in this directory /home/pi/.config/lxsession/LXDE-pi/autostart.

But I'd like to create a solution where the URLs that are opened are more easily maintained. Therefore, I figured I could create a .txt file, which a bash script could read and create the command with all the listed URLs.

This is what I've tried:

In /home/pi/.config/lxsession/LXDE-pi/autostart:

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

@sh ~/startChrome.sh

In /home/pi/startChrome.sh:

#!/bin/bash
input="$HOME/websites.txt"
sites=""
while IFS= read -r var
do
  sites=$sites" "$var
done < "$input"

chromium-browser --disable-infobars --disable-session-crashed-bubble --kiosk $sites

Example content of /home/pi/websites.txt:

http://www.google.com
http://www.somewebsite.com

I've tried to test this by running the startChrome.sh file, but this returns an error:

pi@TeamMBA:~ $ sh startChrome.sh 
[977:977:0601/113521:ERROR:browser_main_loop.cc(271)] Gtk: cannot open display: 

Any suggestions on how to fix this? Or maybe I'm overthinking this and there is an easier way to fix this?

3

Adding export DISPLAY=:0.0 to my bash script solved my problem.

3
  • It would be appreciated if you could mark this answer as correct, since it solved your problem.
    – Darth Vader
    Jun 1 '17 at 13:13
  • Yeah love to do that but I cannot accept my own answer yet as it does not allow me to do that yet ("you can accept your own answer in 2 days")
    – Casper
    Jun 1 '17 at 13:33
  • Ok, be sure to mark it as such when you can, thanks for the response.
    – Darth Vader
    Jun 1 '17 at 13:37

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.