DEV Community

Leonardo Colman Lopes
Leonardo Colman Lopes

Posted on • Edited on

Expand your digital picture frame use cases with Pi3D integrated USB media stick support using UDiskie

I built and customized three instances of The Digital Picture Frame. It’s so simple yet such a great system setup that I fell in love.

Today I want to share a method to use USB Media Sticks to view our photos. This method uses Udiskie, while the traditional method (explained by Wolfgang Männel in Expand your digital picture frame use cases with Pi3D integrated USB media stick support) uses python scripts to achieve a very similar goal.

I recommend reading both articles and picking the method you feel more comfortable in. Both methods are mostly feature compatible in the end -- having an auto-mounted USB device.

What This Setup Does

  • Use Udiskie to manage USB auto-loading/reloading
  • Modify Picture Frame's configuration to read photos from the automount directory
  • Prepare the system to have Udiskie running when the system boots

Installing Udiskie

udiskie is a udisks2 front-end that allows to manage removable media such as CDs or flash drives from userspace.

Let's install udiskie by running one simple command:

sudo apt install udiskie udisks2
Enter fullscreen mode Exit fullscreen mode

And although we won't use it, udiskie has a cool UI!

udiskie interface

Setup Udiskie Auto-Start

To setup udiskie to work without password prompt and on boot we must first install PolicyKit:

sudo apt-get install policykit-1
Enter fullscreen mode Exit fullscreen mode

And then let's create a policy configuration with required permissions. Let's create the file with sudo nano /etc/polkit-1/rules.d/99-udisks2.rules and the following content:

polkit.addRule(function(action, subject) {
    if (action.id.indexOf("org.freedesktop.udisks2.filesystem-mount") === 0 &&
        subject.isInGroup("plugdev")) {
        return polkit.Result.YES;
    }
});

Enter fullscreen mode Exit fullscreen mode

Finally, let's create a udiskie.service file to ensure udiskie is working all the time. Let's use sudo nano /etc/systemd/system/udiskie.service:

[Unit]
Description=Auto-mount USB drives with udiskie
After=graphical.target network-online.target

[Service]
User=pi
ExecStart=/usr/bin/udiskie --automount
Restart=on-failure

[Install]
WantedBy=default.target
Enter fullscreen mode Exit fullscreen mode

Then let's restart all services that are used:

sudo systemctl enable polkit
sudo systemctl enable udisks2
sudo systemctl enable udiskie

sudo systemctl restart polkit
sudo systemctl restart udisks2
sudo systemctl restart udiskie
Enter fullscreen mode Exit fullscreen mode

And we're done with udiskie!

Modifying PicFrame Configuration

Configuration change to PicFrame is simple. We're going to change the photo directory to /media, the location where drives are mounted (e.g. /media/pi/E342-JS2J)

nano picframe_data/config/configuration.yaml
Enter fullscreen mode Exit fullscreen mode

And inside model, let's change this line:

pic_dir: "/media" # default="/home/pi/Pictures", root folder for images

Enter fullscreen mode Exit fullscreen mode

And we are done with PicFrame Configuration! With this we should be done! Reboot the system and insert a flash drive or two to see if pictures from all drives are coming to PicFrame.

Top comments (2)

Collapse
 
sweetryli profile image
Alex • Edited

I ran into a similar issue with random image ordering from a USB stick. What worked for me was renaming all the files with numbered prefixes to force the order. If you're also checking out other frame options, nixplay.com has some good setups that are easy to update remotely, especially if you're doing this for someone who doesn’t want to mess with USBs all the time.

Collapse
 
spicewood profile image
Alex

I added a simple script to auto-sync new files from the USB every hour, so I don’t have to reboot the Pi or re-plug the stick each time I update photos.