Automating Framebuffer Digital Photo Frame

dpf6We have seen in my previous post how I setup the DPF to work against the framebuffer. Now it was time to automate things a bit.

Task List:

  • Autologin on Startup
  • Start gnu screen on Boot
  • Uploading New Images
  • Screen On/Off Timer
  • Reboot Timer
  • Shutdown Timer
  • Unique names/shuffle for file list
  • Cycle Colour Change for Clock ?


Autologin on Startup

This is fairly straight-forward, requiring the editing of one file:

To auto login user “dpf” on first console terminal (tty1) edit file /etc/init/tty1.conf and replace last line:

with this:

Reboot and enjoy 😉

Start gnu screen on Boot

The answer for this one was found over on superuser.com:

and add this to the bottom

Uploading New Images

I’m not going to automate this I’ll just use scp to upload or ssh in if I need to have a clear out.

I am fitting a PCMCIA network card which will automatically connect with my wireless network (WPA2 secured)

Screen On/Off Timer

I have also added the following in ~/.profile

This stops the terminal screen from blanking. These codes will not work in gnu screen for me. But to actually turn off the display, for example, overnight, I would normally use xrandr, but the clue is there in the “x”, so I could to use vbetool to do the job. This will require sudo to work, so I could cheat and feed it the password with sudo -S as follows:

 


Running the on and the off command ensures I have only to arrow up twice and press enter to get the display back on :)

I will could pop these commands into a crontab to turn off the display overnight and to turn it on again in the morning.

Reboot Timer

You never know, the machine might be grateful of a reboot, even once a week, just to get itself together. Again for the crontab:

Shutdown Timerdpf4

My laptop has a startup timer in the bios. I will use this to startup @ 0600 hours everyday. Therefore I will set that for the morning, and then use the crontab to shut it down overnight:

The crontab command looks like this:

(I am a night bird so this shuts down the laptop at 0130 hours each night)

To access cron simply type:

in a terminal.

Unique names/shuffle for file list

I covered this in the previous post, using a small script to sha1sum the filename. This is fine unless i have identical filenames. Therefore I added a bit more randomness into the script by adding a multiple of two random numbers to the filename before the sha1sum.

Again this went into ~/.profile just above the call to run gnu screen. I put in a 5 second sleep just to give everything a chance to finish properly.

Revised script (gives a long but unique name):

Cycle Colour Change for Clock ?

I’ve not implemented this one, but can be easily done by running a small script that restarts screen and alternative .screenrc’s with a different colour choice.

There you go, a fully automated cli / framebuffer solution for a digital display frame :)

Addendum:

mplayer doesn’t always play nice, and can crash unexpectedly, but in a good way by leaving an image on the screen. In order to remedy this I had to come up with a crontab job to regularly check that mplayer was still running. I used “top” with “grep” to discern whether mplayer was running (R) or sleeping (S). Had to run top every second for @ 3 minutes in order to “catch” an “R”. Then as it was running in a script from a crontab job, had to find a way to exit screen and restart the main script. This was achieved with a screen -X quit command and by using openvt to run the main script. The crontab job was set to run every 10 minutes.

4 thoughts on “Automating Framebuffer Digital Photo Frame

  1. Pingback: Digital Picture Frame & Clock on the Framebuffer! | METRIC RAT

  2. Hmmm, I have been getting artifacts and screen disarray (!) when mplayer does it’s -loop 0 thing, so have adjusted the fps to only show each photo once in the 18 hour period the laptop is on. At present, until I load it up with a few more images, this is every 480 seconds or for mplayer fps=0.00208 😉

  3. A bit more on the issue above. I wrote a small script to replace the mplayer line in .screenrc. What the script does is count the number of files in ~/Pictures, then it works out how long each image should be displayed, so that in a day you only see each picture once. The script has a single parameter, the number of hours the machine will be on for.

    So, .screenrc changes from:

    to

    The contents of settime.sh are as follows:

    This gets me over the graphical glitches and artifacts I was getting from the -loop 0 code

  4. Another update. in order to make “sshing” into the DPF easier I have created an alternate screenrc file. screen is able to call different files for configuration from the command line. I therefore needed to replace the call for screen in ~/.profile with a small read script that allows for user input for 5 seconds before running the DPF. In fact, I have shifted all the commands out of ~/.profile and run them from this script. Much better :)

    Here is the interactive script:

Leave a Reply

Your email address will not be published. Required fields are marked *