I have a Python script running on a Raspberry Pi Zero W that calls the image program feh in order to loop through some directories and display the enclosed images. The script is supposed to run on startup - think of it as a sort of headless image-display program. I'm running not the latest version of Stretch, but the one released in Oct. 2018.
In order to get everything to run on startup, I've edited the ~/.config/lxsessions/LXDE-pi/autostart
file. I'm using an external projector, so in order to display the images correctly, my autostart file looks like this:
DISPLAY=:0
/usr/bin/python /home/pi/myscript.py
Then my Python script basically looks like
import os
import psutil
import time
while True:
os.system('feh --hide-pointer -x -q -B black -g 1280x720 ' + img_dir + ' &')
time.sleep(4)
for process in psutil.process_iter():
if 'feh' in process.cmdline():
process.terminate()
and I loop through different image directories. I know that using os
to make system calls is deprecated, but it's the only way I could get this particular call to work.
So here's the problem: if I reboot the Pi from the command line, everything works swimmingly. The Pi boots up, the Python starts running, and the images are displayed correctly, looping forever. If I do a cold start, however, only the Python script runs - no images are displayed. I know this is happening because I can log in remotely and see that the Python program is indeed running, but feh is not, while it is running after a reboot.
The only other thing I can think might be relevant is that I had issues with the Pi's projector/display going to sleep (i.e., going dark after no external input after a minute or so), so I edited the /etc/lightdm/lightdm.conf
file and added
xserver-command=X -s 0 -dpms
What's going on with feh? Is there a log file somewhere I can look at to see if it's throwing any errors? Is my no-sleep call screwing things up? Why does the Python run without fail, but not feh? Any input here is welcome!