4

I can't get my raspberry pi to display images using feh at startup. I have tried placing my simple feh command wrapped in a shell in cron jobs, /etc/rc0-9.d, and init.d but nothing is working.

I tried placing it at ~/.config/lxsession/LXDE-pi as is suggested here (Execute script on start-up) as well, but it still is not working.

What I am able to get is an error just before my command terminal allows me to start typing. That error is: feh ERROR: Can't open X display. It *is* running, yeah?

I've gotten this error alot. I think it's due to where in time the program runs, and if the display drivers and such are ready to put up images.

I know that init.d, cron, rc.local (not existent on raspberry pi jessie pixel) , and dot files on the desktop are useful for this startup task.

What is the easiest solution to this if I have a shell script that I know works and want to start it automatically as soon as humanly possible when the raspberry pi is turned on.

I am doing this to make a fancy picture slideshow for someone who knows nothing of computers. Any solution such as downloading something like magic mirror software will be fine as long as it is simple to get working.

1
  • sadly, when I hit this I just added a sleep 4 to the script. Apparently something new in Jessie means the scripts can run before X is ready. 4 being the number of seconds to wait and YMMV
    – rob
    Commented Mar 15, 2017 at 13:19

1 Answer 1

4

to avoid the error feh ERROR: Can't open X display. just execute this line of code in a terminal:

@export DISPLAY=:0

after this your code will work fine.

to execute commands "at boot", if autologin is enabled (since what it really does it execute them when the pi user logs in), i'd suggest editing the autostart file wich is in the ~/.config/lxsession/LXDE-pi/ directory. just add these two lines at the end of the file:

@export DISPLAY=:0
@epiphany /path/to/your/file.png &

P.S. you need to have root permissions to edit autostart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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