Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

A Simple Slideshow with Raspberry Pi

Wed Dec 06, 2017 6:29 pm

All I wanted was a slideshow that would run on bootup, for my first Raspberry Pi project. But it took a lot more work than I expected.

Googling around, I found many too many ways to start the slideshow on bootup, and to blank the screen. But most of them didn't work because they ran before the desktop did.

Here's what finally worked for me, using feh for the slideshow and xscreensaver to keep the screen from blanking.

  1. Bought a Raspberry Pi 3 and some 16 Gb class 10 micro SD cards.
  2. Installed NOOBS on an SD card using my Windows 10 PC.
  3. Booted up the Pi with a USB mouse and keyboard I had, using a 1 amp phone charger as power supply. If you see a yellow lightning flash in the upper right of the screen, you need more power. 1 amp worked for me but 800 ma didn't.
  4. Connected to my LAN. I used wifi but an ethernet cable would be just as good.
  5. Opened a terminal window and did:
    sudo apt-get install feh
    sudo apt-get install xscreensaver
  6. Under Preference - Screensaver used xscreensaver preferences to disable blanking and turn the screensaver off entirely.
  7. Put my image files on a thumb drive, plugged it into the Pi and used File Manager to put them into a folder /home/pi/Pictures/Slides.
  8. In the home directory /home/pi, created a file runslideshow.sh with these three lines:
    #!/bin/sh
    cd /home/pi/Pictures/Slides
    feh -Z -z -F -D 300 --hide-pointer --auto-rotate
  9. Using File Manager, changed the mode of runslideshow.sh to 755.
  10. To get the slideshow to run on boot, in a terminal (command) window, ran the commands
    cd /home/pi/.config/lxsession/LXDE-pi
    sudo nano autostart
    That opened the editor, where I inserted the line
    @/bin/sh /home/pi/runslideshow.sh
    (A later poster said the directory for this should be /etc/xdg/lxsession/LXDE-pi.)
  11. I had wifi enabled while doing all the trial and error, to be able to google solutions. Once the slideshow was working, for security, I turned wifi off as follows:
    In /etc/modprobe.d add a file raspi-blacklist.conf with the lines:
    #wifi
    blacklist brcmfmac
    blacklist brcmutil
  12. Made a duplicate of the SD card for backup following these directions.

I'm sure there are other and probably better ways, but this worked for me. I hope this helps some other newbies spend less time on this simple application than I did.
Last edited by Toolworker on Tue Mar 09, 2021 2:58 pm, edited 6 times in total.

W. H. Heydt
Posts: 15435
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: A Simple Slideshow with Raspberry Pi

Wed Dec 06, 2017 6:58 pm

I did something like this using a Pi0 and a 3.5" LCD display attached to the GPIO header. I suggest using "fbi" (frame buffer image). It will cycle through--sequentially or randomly--a set of images in a directory. Time between images and type of transition can be set on the command line. Raspbian Lite is sufficient to run it as it doesn't require X.

angus1024
Posts: 15
Joined: Thu May 10, 2018 6:10 am

Re: A Simple Slideshow with Raspberry Pi

Fri May 11, 2018 5:35 am

Thanks. I want to do something similar, but leave it unattended for maybe a year switching the power on and off each day without a 'shutdown'. I worry there may be writes to the SD cards which could cause damage if switched off at the wrong time.

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Tue May 07, 2019 3:09 pm

angus1024 wrote:
Fri May 11, 2018 5:35 am
Thanks. I want to do something similar, but leave it unattended for maybe a year switching the power on and off each day without a 'shutdown'. I worry there may be writes to the SD cards which could cause damage if switched off at the wrong time.
I do something like that, switching the monitor power off and on using an X-10 motion detector. The Pi draws negligible power so I leave it on. That said, I have unplugged the Pi a number of times without shutting down and haven't seen problems so far.

toddlikesbeer
Posts: 1
Joined: Wed Jun 12, 2019 3:37 pm

Re: A Simple Slideshow with Raspberry Pi

Wed Jun 12, 2019 5:53 pm

THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU

After bricking a few Pis, and even a Roku, in my quest to create a Stats Dashboard I came across your post; I had it done in no time. And I'm just a moderately technological middle manager. I work at a company in Seattle that manages over 10,000 mobile apps on the various stores. My Release Engineers update or submit ~50 apps a day, of various priorities. Your code will allow us to track that work and see anomalies.

Awesome work man, I can't believe such a complex script worked so flawlessly.

LordHiler
Posts: 1
Joined: Fri Aug 09, 2019 3:31 pm

Re: A Simple Slideshow with Raspberry Pi

Fri Aug 09, 2019 3:34 pm

This is awesome and working great. However, what if I want to go to the desktop while this is running? Is that possible? What about accessing file manager to, for instance, change the photos in the slideshow folder?

W. H. Heydt
Posts: 15435
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: A Simple Slideshow with Raspberry Pi

Sat Aug 10, 2019 12:23 am

LordHiler wrote:
Fri Aug 09, 2019 3:34 pm
This is awesome and working great. However, what if I want to go to the desktop while this is running? Is that possible? What about accessing file manager to, for instance, change the photos in the slideshow folder?
If you have enabled ssh, you can log in remotely and/or remote copy new files to the Pi. My preferred tools for this are PuTTY and pscp, but there are others that will work just fine.

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Sat Aug 10, 2019 3:51 pm

LordHiler wrote:
Fri Aug 09, 2019 3:34 pm
This is awesome and working great. However, what if I want to go to the desktop while this is running? Is that possible? What about accessing file manager to, for instance, change the photos in the slideshow folder?
Glad to hear this is working for you.

I now put the photos on a thumb drive and plug it into one of the USB ports. It can be removed to change the photos. runslideshow.sh has to be edited with the path to the thumb drive, which doesn't seem to change.

W. H. Heydt
Posts: 15435
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: A Simple Slideshow with Raspberry Pi

Sat Aug 10, 2019 7:10 pm

Toolworker wrote:
Sat Aug 10, 2019 3:51 pm
LordHiler wrote:
Fri Aug 09, 2019 3:34 pm
This is awesome and working great. However, what if I want to go to the desktop while this is running? Is that possible? What about accessing file manager to, for instance, change the photos in the slideshow folder?
Glad to hear this is working for you.

I now put the photos on a thumb drive and plug it into one of the USB ports. It can be removed to change the photos. runslideshow.sh has to be edited with the path to the thumb drive, which doesn't seem to change.
In general, the path to a removable device will be /media/<userid>/<devicename> where the <userid> is typically "pi" and the <devicename> is whatever name you give it. I was doing some recent testing with a Lexar USB3 stick and it came up as /media/pi/Lexar, for instance.

NTTD
Posts: 1
Joined: Tue Oct 22, 2019 2:40 pm

Re: A Simple Slideshow with Raspberry Pi

Tue Oct 22, 2019 3:18 pm

This works awesome in my testing with an external USB drive. I'm able to remove the drive, add/remove pics, re-insert and re-start the Pi.

My path to the drive was /media/pi/[name of the drive].
W. H. Heydt wrote:
Wed Dec 06, 2017 6:58 pm
...I suggest using "fbi" (frame buffer image). It will cycle through--sequentially or randomly--a set of images in a directory. Time between images and type of transition can be set on the command line. Raspbian Lite is sufficient to run it as it doesn't require X.
I think fbi would be great for a Pi Zero and/or where the pics will not be changed often.

With fbi as near as I can tell you have to name each file in the code (can't just point it to a folder of files). This is not conducive to easy editing of the photos on the slideshow.
In the use case I'm setting up for, other people will be the ones managing the photos, and it will be running on a 3b so this thread's method should work fine.

Youredone82
Posts: 4
Joined: Sat Dec 07, 2019 4:39 pm

Re: A Simple Slideshow with Raspberry Pi

Mon Dec 09, 2019 1:02 pm

Hey all, got stuck at step 10, this is my first project so still a very noob. Believe I was able to get step 9 done via terminal? Using sudo chmod 755 runslodeshow.sh?
Any help would be appreciated
Alexander Kravitz

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Mon Dec 09, 2019 2:17 pm

Sorry, this was a little unclear.

Open a terminal (command) window. (Someone else may be able to tell you the icon to click - I'm a noob myself.)

Then type the commands:

cd /home/pi/.config/lxsession/LXDE-pi
sudo nano autostart

That opens the editor, where you can insert the line

@/bin/sh /home/pi/runslideshow.sh

I've made these changes in the original post.

Youredone82
Posts: 4
Joined: Sat Dec 07, 2019 4:39 pm

Re: A Simple Slideshow with Raspberry Pi

Thu Dec 12, 2019 11:48 pm

hey, I got everything to work, however the start on boot up does not work.
followed directions, any ideas? its a pi 3b
Alexander Kravitz

triherd
Posts: 1
Joined: Wed Jan 08, 2020 2:54 am

Re: A Simple Slideshow with Raspberry Pi

Wed Jan 08, 2020 2:58 am

Another NOOB also stranded on step 10. How is this accomplished?

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Wed Jan 08, 2020 3:29 pm

Where are you stuck?

Opening the terminal window?
Running the two commands?
Having the editor open?
Making the change in the editor and saving the file?

If something unexpected is happening, please describe it, including any error messages.

Gawldy
Posts: 1
Joined: Fri Jan 31, 2020 7:32 am

Re: A Simple Slideshow with Raspberry Pi

Fri Jan 31, 2020 7:36 am

I got the slideshow working but how do I exit it?
I tried alot but I get a black screen if I close the image.

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Fri Feb 14, 2020 5:10 pm

Gawldy wrote:
Fri Jan 31, 2020 7:36 am
I got the slideshow working but how do I exit it?
I tried alot but I get a black screen if I close the image.
I'm a total noob myself, so probably the wrong one to ask.
But I just hit ESC on the keyboard and it got back to the desktop.

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Fri Feb 14, 2020 5:27 pm

I just did some fiddling with this, so wanted to share a few things.

1. I did this project to run on a 32" monitor that's hanging on the wall using sturdy picture wire. Because of the mounting screw positions, the monitor has to hang upside down. So I rotated the slideshow images 180 degrees and they display right side up. (Though it looks awfully strange when it's booting.)

2. I wanted to modify the feh parameters temporarily to use a different image folder and delay. This is a PITA because the whole assembly has to be disconnected, taken off the wall, plugged into a different power supply, and a keyboard and mouse attached. So I changed the runslideshow.sh batch file to:

cp /media/pi/SLIDESHOW/slideshow.sh
chmod 0755 slideshow.sh
/bin/sh slideshow.sh

and put a batch file sideshow.sh, with the feh command line, on the thumb drive. Now I can just remove the thumb drive and change slideshow.sh.

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Mon Feb 17, 2020 6:17 pm

A correction and a modification.

I didn't give the complete the cp command.

And this might not be necessary if you keep everything in user pi, as in my example, but I put this under another user, so needed to change the chmod command to let my user copy over the file. So my file is now:

cp /media/pi/SLIDESHOW/slideshow.sh slideshow.sh
chmod 0777 slideshow.sh
/bin/sh slideshow.sh

Another problem I ran into. Some combination of pulling the thumb drive and removing power from the Pi has created multiple copies of the drive in /media/pi. That is, the drive is named SLIDESHOW but somehow that turned into a phantom drive and my real drive now mounts as SLIDESHOW1 and the script stops working. The repair to /media/pi is discussed here, but I'm not sure how to avoid making the problem happen. I'll try pulling the power before removing the thumb drive.

sukanth
Posts: 1
Joined: Sun Mar 29, 2020 8:53 pm

Re: A Simple Slideshow with Raspberry Pi

Sun Mar 29, 2020 9:00 pm

Hi Guys,

Can we do the same thing but the photos streaming from google photos? I tried running the slideshow from chromium-browser. It worked fine for one hour or so then the system got slowed down drastically and then the PI got turned off .. probably because of huge data or something. Is there a best way that we can slideshow photos from google photos on to raspberry PI?

I tired balena-cloud to achieve this.. it worked fine but the same thing happened after some time. Do you guys know any other efficient way that we can achieve it ?

Thanks in advance.

rickymadethat
Posts: 1
Joined: Mon May 25, 2020 5:17 pm

Re: A Simple Slideshow with Raspberry Pi

Mon May 25, 2020 5:20 pm

Is there a way to set the duration of each image?

It's currently a couple of minutes in between each image but I'd like to shorten it to 30 seconds.

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Tue May 26, 2020 1:47 am

rickymadethat wrote:
Mon May 25, 2020 5:20 pm
Is there a way to set the duration of each image?
Glad to hear it's working for you.

In the batch file runslideshow.sh, change the -D argument for feh to the desired number of seconds delay.

For other changes, see the manual page for feh.

shosterman
Posts: 21
Joined: Wed Apr 20, 2016 10:26 pm

Re: A Simple Slideshow with Raspberry Pi

Mon Oct 12, 2020 2:57 pm

I've been trying to do something like this, but I can't get feh to start. I found this thread, but I don't have an autostart file in the location you describe.
under /home/pi/.config I don't have the lxsession folder

Brand!n
Posts: 1
Joined: Tue Mar 09, 2021 2:14 am

Re: A Simple Slideshow with Raspberry Pi

Tue Mar 09, 2021 2:20 am

I registered just to say thanks to the OP. I dont know if your still on here these days, but THANKS!
Ive tried about 15 different tutorials online to get a simple slideshow to run automatically when a Zero boots up.
I dont know what was different here, but it was the only thing that actually worked the first time, and after weeks of trying things, then restarting over and over, I had to thank you.

I think other then the place the autostart file is (/etc/xdg/lxsession/LXDE-pi/autostart) your steps work great. Thanks again!

Toolworker
Posts: 12
Joined: Tue Nov 28, 2017 10:53 pm

Re: A Simple Slideshow with Raspberry Pi

Tue Mar 09, 2021 2:59 pm

Thanks! I'll add your comment about the directory to the instructions.

Return to “Beginners”