Monday, December 20, 2010

Dropbox Photo Frame

I have a couple of older laptops that I am converting to digital picture frames. There are number of guides out there on how to do this, but none of them did exactly what I wanted, so I'm going to document my own efforts here.

I wanted something that would work on older hardware, so it had to be light. Damn Small Linux has been the go-to light distribution for years, but getting wireless cards to work with it, especially using WPA, can be a real nightmare. I also wanted to run dropbox on it, for seamless, automatic gallery updates. The perfect distro for this seems to be puppy linux, which I'm really growing fond of.

  • Light - runs puppy linux
  • Wifi support
  • Automatic gallery updates via Dropbox
There are number of tasks, some of which I will cover in more detail than others:
  1. Install Puppy Linux
  2. Install Dropbox
  3. Install gqview picture viewer
  4. Modify startup script
  5. Create a cron job
 Install Puppy Linux
Head over to Puppy Linux and download the proper distribution for your machine. I used version 5.1. If you decide to use a newer version, your mileage may vary. Burn the image to a disk, and boot it up.

I'm going to assume you have some experience in installing operating systems, especially of the Linux flavor. I'll detail how I did the installation, so if you want to deviate from my instructions, you're on your own.

The first order of business is to get your network connection working. The installation process accesses the internet to do some updates, and without it, the installation is much messier. So, GET YOUR NETWORK WORKING FIRST!  There is a connection application on the desktop that works fine. I recommend just using a wired ethernet connection during installation, then switching later to wireless if so desired.

Once your internet is working (verify by using the simple net browser application in the "internet" menu), you can begin the installation. Click on the "install" desktop icon, then pick the Universal Installer option. Next, you need to decide where you want to install Linux, which for me was the hard drive (Internal IDE or SATA hard drive). On the next screen you are asked to select a partition, or create one to install to. I chose to partition the disk, which brought up Gparted, a simple graphical disk partitioning application. I erased all the existing partitions, then created one partition with about 500 MB of linux swap, and the rest with ext3. After applying the changes, close Gparted, and you should return to the partition selection dialog. Pick your newly created partition (sda2 in my case), and proceed. Click through the confirmation prompt, then choose "CD" at the next prompt. When prompted to choose between "Frugal" and "Full", choose "Full". You have to wait a while now, while the files are copied to your HD. Next you will install a boot loader.

Installing GRUB
I chose the "GRUB" option, then picked "Install". There will be a prompt about the grubconfig scrip, which you will click through, then choose the simple installer option. For screen resolution, I just picked the standard option. At the next screen you will be asked where to place the GRUB files. The default option is your installation partition. Only change this if you know what you are doing.

At the next screen you need to need to switch to the MBR option (assuming this is NOT a dual boot machine) and proceed. Leave the next screen blank, and hit OK. Hopefully you will get a message saying that GRUB was successfully installed on the MBR. Click on OK, then on "NO" to indicate that you are done with the installation. Take the install disk out, and reboot your machine.

Now that you have Puppy installed on the hard drive you should get your wireless network set up. Again I just used the the connection icon on the desktop, and followed the instructions.

Gqview installation and setup
We need to install "gqview" for displaying the slideshow. This can easily be done with puppy's package manager. First, click on the desktop install icon again, and now pick "Puppy Package Manager". The packages we need to install are not in the default repository, so click on "configure package manager". Lucid-official should be selected by default, so add puppy 4 and puppy 5 to the list. Click on OK, then exit out of the package manager, and restart it. (this is necessary for the new repositories to be recognized.) Search for "gqview", and install it. While you're here, also search for and install the "unclutter" package.
Now that gqview is installed, start it up from the start menu, and go to preferences. Under the general tab, make sure random and repeat are selected, and under Image, select "fit image to window". Apply the changes and exit out.

Dropbox installation and setup
Now, you will need to install the Dropbox application, which is really the heart of this project. Fortunately, the installation only consists of downloading and unzipping the application. One caveat that I should mention is that you need to make sure the system time on your computer is set correctly (within reason). If not, dropbox's certficates will be bad, causing you to read countless posts for hours and even days, trying to figure out why dropbox doesn't connect to the server. (trust me, I know)

In puppy, I was unable to use the basic net browser to download files, so I ended up installing opera. Firefox would work as well. Just click on the "internet" desktop icon, then choose any of those browsers, and it should install automatically for you. Using firefox or Opera, follow this link to download the application. Open and unzip this file to the default location (it should unzip to /root/.dropbox-dist). When done, open a console window, and enter the command:
/root/.dropbox-dist/dropbox &
At this point you should get a dropbox configuration screen. It will ask if you already have an account. If you don't, I would recommend going to a different computer to create one first. Afterward, enter your account info and proceed. It will ask where you want to place your files. I just went with the default location, which was /root/Dropbox. Inside the dropbox folder, I created another folder called "Photos".

Startup scripts and such
Now, all we have left are a few system startup tweaks to automatically start up the slide show, and to disable the screen saver and such. First, you will need to edit the /root/.xinirc file. I used vi, but you are welcome to use whatever editor you find handy in puppy. First, find the line that says:

xset s 600 600 s blank

change it to:

xset s 0 600 s off

This disables the screen saver. Now, go to the end of the file, and right before the line:
gqview -r -t -d10 -f &
sleep 10
/root/.dropbox-dist/dropbox &
unclutter &
xset s off
gqview -r -sr/root/Dropbox/Photos &

These start up the slide show and dropbox, and turn off the mouse pointer.

Now we need to tell the slideshow to look for new files in the dropbox folder every once in a while. We do this by restarting the slideshow once every hour. Use the Pschedule application, and set it up as follows:

(note the minutes is changed to "00").

Next we will tell GRUB to continue booting the system at startup, instead of waiting for a prompt. Edit the file /boot/grub/menu.lst, and find the line:
# timeout 30
and change to
timeout 5
Finally the last task is to help puppy recover after an improper shutdown. I've found that pulling the plug on a puppy installation causes it to not boot properly. This is not an option for a picture frame, so I found a workaround which allows it to reboot after a loss of power. Add the following to your /etc/rc.sysini script just after the line "ln -s /proc/mounts /etc/mtab".
#If we were not shutdown cleanly, try and recover
if [ -f /tmp/RUNNING ];then
 echo -n "(Cleaning up after unclean shutdown)" >/dev/console
 rm -f /var/log/X*
 rm -rf /tmp/*
 rm -f /var/lock/LCK*
 rm -f /var/run/*.pid
 rm -rf /root/tmp 2> /dev/null
 rm -rf /root/.thumbnails/* 2> /dev/null

#create a file in tmp that should be deleted on a clean shutdown

echo 'this file is deleted during a clean shutdown' > /tmp/RUNNING

That's it. When you reboot your machine, it should start up a slideshow on your /root/Dropbox/Photos folder. If you add files to your dropbox account, they should show up on the frame within 1 hour. Now, follow any of the excellent guides out there on mounting the laptop into a picture frame.

No comments:

Post a Comment