ShowerThoughts and EarthPorn: Make an Inspiring Raspberry Pi Photo Frame
Digital photo frames are certainly nice to look at, but they can be rather inflexible, and family photos can be a little … well, boring. But if you add a screen to a Raspberry Pi, you can make something quite unique, by overlaying photos from r/earthporn with “inspirational” quotes from r/showerthoughts (or any combination of your favorite subreddits).
Want to make your own dynamic, digital, Raspberry Pi-powered talking point? Read on.
Prepare Your Pi
You’ll need to have the latest version of Raspbian installed for this project, so if necessary download and write to your SD card . Once you’ve done that, take the time to setup wireless networking and enable SSH .
With all of this done and correctly configured, ensure that you have connected your Pi successfully to the intended display. This might be an old laptop monitor, a disused tablet or Kindle reader, or one of the displays designed for the Pi .
You should also take the steps required to expand the Raspberry Pi filesystem. This can be done in raspi-config in the command line or in the Menu > Preferences > Raspberry Pi Configuration box on the desktop.
Getting Content from Reddit
Rather than cycle through some photos stored on your Pi, you can use a Python script to find images from the web. The Reddit channels r/EarthPorn (beautiful, stunning photos of the Earth, and totally safe for work!) and r/ShowerThoughts are great candidates, and you can download the code from this scul86’s Github page. Download ep_st.py, ep_st.config and template.html and save all three files into the same location on your Raspberry Pi (perhaps home/pi/Frame), before editing ep_st.config:
sudo nano /home/pi/Frame/ep_st.config
Here, look for the text headed [FILEPATHS] and change these to match the location where you have saved the three files. If you’re not sure what the full filepath should be, cd into the file in the command line, and type pwd.
Note that you can also adjust the subreddits from which the script pulls text and images, though we’d suggest leaving them at the defaults for now.
When you’re done, hit Ctrl + X, then Y to confirm the changes.
Next, you need to install praw, a Python wrapper for the Reddit API. Install this with
sudo pip install praw
Wait while this is done, and then turn your attention to giving the ep_st.py the necessary permissions:
sudo chmod 777 /home/pi/Frame/ep_st.py
You should then make the file executable:
sudo chmod +x /home/pi/Frame/ep_st.py
To test the slideshow, cd into the Frame directory and run
In the GUI, browse to the Frame directory and find the newly-created ep_st.html. This is the result of the Python script and the settings you specified in the config file, so open this to see the results. The page is set to automatically refresh, and should update itself whenever a new inspirational image is created. If you’re worried about filling up your Pi drive space with these, don’t be: the images aren’t actually downloaded, it’s just creating an HTML file that points to them remotely (probably an IMGUR url) with a textual overlay.
At this stage, all that is left to do is set the slideshow to launch automatically when you boot your Raspberry Pi. To make this happen, we need the Python script to run, and the HTML file to open.
Begin by installing and configuring a browser. We’re going to use Midori, but you can select and configure pretty much any Pi-compatible browser.
First, open sudo raspi-config and Disable Overscan. Then, install the browser:
sudo apt-get install midori x11-xserver-utils matchbox unclutter
Next, open nano to create a script:
sudo nano /home/pi/fullscreen.sh
Here, enter the following:
unclutter & matchbox-window-manager & midori -e Fullscreen -a [URL]
Substitute [URL] with the webpage you wish to load at boot. For our ep_st.html file, saved in the /home/pi/Frame subdirectory, the line would read:
midori -e Fullscreen -a Frame/ep_st.html
Save this with Ctrl + X and confirm with Y.
Next, make it executable with
sudo chmod 755 /home/pi/fullscreen.sh
You should then edit the autostart file:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
At the end of the file (you may have some lines in here already from the setup of your Pi’s touchscreen display ) add:
@xset s off @xset -dpms @xset s noblank @/home/pi/fullscreen.sh
Save and exit, then edit the rc.local file:
sudo nano /etc/rc.local
Here, add a new line above exit 0:
su -l pi -c startx
Save and exit, then reboot.
Keeping the Lights On
By default, the Pi display — whatever display is connected — will be switched off after a few minutes of inactivity. We can deal with this by connecting via SSH (or using the Terminal if you have a keyboard plugged in) and editing the lightdm.conf file.
sudo nano /etc/lightdm/lightdm.conf
Find [SeatDefaults] (the brackets are included; you’ll find it towards the end of the file) and add this line under it:
xserver-command=X -s 0 -dpms
Save and exit with Ctrl + X and reboot:
Your Own Inspirational Digital Picture Frame!
Let us know in the comments how this project went for you! Have you stuck with the defaults, or did you find some other sub-reddits that work well together? Or did you run into problems? Whatever happened, whatever you’ve done with this project, tell us about it in the comments!