Configure Linux to Automatically Download Images From Your Memory Card

I have a Dell 2405FPW Monitor. This monitor has an integrated memory card reader. After after some investigation I was able to get a mountable device to automatically show up when I plug in a memory card (how to do this is discussed here). For even greater convenience, I also configured software that will automatically copy the images off the memory card and on to my computer. This page discusses the steps I took to get this working.

Contents


Tools

I am using HAL and ivman along with a perl script that I wrote. HAL automatically detects hotplug events and maps them into more user understandable events. ivman allows the user to match events and run programs when particular events occur.

On Gentoo, you can simply emerge hal ivman to get these packages installed.

HAL Setup

The only thing I had to do was set HAL to be added to my default run level so that it is automatically started when my machine boots. On gentoo, you have to run rc-update add hal default.

ivman Setup

There are two ways to run ivman, one global version that is run on startup and owned by root, or on a per user basis. Although it might seem desirable to run a single global instance of ivman, it makes more sense to run it on a per user basis. This way, any automatically configured events will occur with the same permissions as the user. I run E17, and so I've created a ivman.eapp file and added it to my $HOME/.e/e/applications/startup directory. This was, ivman is automatically started when I start E17. For more information on configuring ivman, see this page.

When running ivman as a user, it will read configuration files from $HOME/.ivman. The main file I changed was IvmConfigActions.xml. The rules in this file are checked when devices (such as a memory card) are attached to the computer.

This is the rule I added:

    <ivm:Match name="hal.info.product" value="NIKON D70">
        <ivm:Option name="mount" value="false" />
        <ivm:Option name="exec" value="$HOME/bin/getpictures -dialog" />
    </ivm:Match>

Where $HOME is my home drive. This rule matches and devices with hal.info.product set as NIKON D70. My memory cards are such devices. To determine the setting to use for your memory cards, plug your card into the card reader and run lshal. lshal lists all the variables of all the devices that HAL is monitoring. You can find the one corresponding to your memory card (or even you camera if you plug it in via USB) and find the correct values. You could even use a different HAL variable. I chose info.product because it was clearly identified as my memory card.

There are two actions taken when this rule is matched. First, the memory card is not automatically mount. This is because the getpictures script will mount and then unmount the card. The second rule is that the getpictures script will be run.

The getpictures script performs two basic operations, first it copies the images from the memory card onto my computer. Secondly, it will rename the images based on the date and time the image was taken, the shutter speed, aperature, focal length and shutter count (the number of images take by the camera, modulo 10000). I find this information useful and as I can't automatically give the files descriptive names, these work fairly well.

The getpictures script is available here. The script is run with the -dialog option. Using this option causes it to open a dialog window when it begins downloading the images and another when the download is complete. This allows the user to know that the download was started and alerts the user when the download is complete. As the script manages its own mounting, once the finished dialog is displayed, it is safe to remove the memory card.

Retrieved from "http://www.floccinaucinihilipilification.net/wiki/index.php/Automatically_Fetch_Images_Using_ivman"

This page has been accessed 1,376 times. This page was last modified 23:27, 8 July 2007.