Check folder for new images and display them on Linux/RPi command line

208 Views Asked by At

My script downloads a new image from a web resource once per hour.
I want to display that image on a monitor connected to a raspberry pi.

What works:

  • downloading an image via cron job every hour
  • deleting any previous downloaded images from the downloads folder
  • displaying the image from the downloads folder on boot

What doesn't work:

  • updating the displayed image with the new one automatically when it changed or every hour

My /etc/profile/ has this line added:

/home/pi/code/display/display-image.sh

Which executes the script on boot.

display-image.sh is just a two-liner:

killall fbi
fbi -noverbose -a /home/pi/code/display/images/*.png

which does work fine.

Now the problem I face is that I need fbi (or fim or feh, I tried them all) to check if the image in the downloads folder has been updated and therefore display the new one.

I see two options:

  • a setting within fbi, fim or feh that checks for new files in a folder (which would be the best option, but I haven't found that option and it seems they all cache the file list on start)
  • executing a cron job which kills fbi/fim/feh and restarts it

I tried the cron job (via crontab -e): */6 * * * * DISPLAY=:0 /home/pi/code/display/display-image.sh

But I must make an error here in some way, as the cron job doesn't succeed displaying the image. The output gives me ioctl VT_GETSTATE: Inappropriate ioctl for device (not a linux console?), but I'm not sure if this is the problem or how to solve that.

How can I update my display with the newly downloaded image?

0

There are 0 best solutions below