Using hotplugging with digiKam

Introduction


With Kernel 2.4 came a hotplug support into Linux. This feature is also supported by gPhoto, which is used as camera driver from digiKam. So it should (and is) possible to add an hotplug feature into digiKam. This article tells you what are the requirements and what you have to do.

When you put a device into a hotplug bus like USB, the kernel detects it and looks if it has a suitable driver compiled inside. If not, the hotplug module is called and asked what to do. gPhoto2 offers a way to configure hotplug for USB cameras. Doing so, the hotplug module will call a gphoto2 library to add a driver and afterthat a customizable script calls the application that should interact with the device. This implementation uses two scripts. The first one, usbcam, is called as root and his job is to determine the active user and call the 2nd script digikam-hotplug using the users id. Both scripts could be downloaded here.

Requirements


The following requirements should be fullfilled to use digiKam with the hotplugging feature. Notice, it is also possible to change some of the requirements, but then you&apsll have to do additional research to get the solution up and running.
  • Linux with Kernel >= 2.4, compiled with hotplugging Support
  • gphoto 2.x and libgphoto 2.x
  • Perl 5.6.x
  • KDE 3.x
  • digiKam digiKam 0.7.1+
As an additional remark, i should mention that the digikam-hotplug script that you could donwload requires KDE not only installed, it has to be the active Window Manager.

Installation and Configuration


This section gives the same information like chapter 4.3 from the gPhoto manual. It simply describes howto setup the kernel hotplugging feature. The only difference are digiKam specific scripts.

Checking the kernel hotplugging feature

First you should check whether your kernel comes with the required hotplugging feature. Therefore look if you have a file

cat /proc/sys/kernel/hotplug

and if it points to a valid hotplug binary. If not, you'll have to compile a new kernel with hotplugging support. It does'nt matter whether the hotplugging support is directly compiled into the kernel or if it is compiled as module.

libgphoto comes with the program print-usb-usermap which is usually located under

/usr/lib/libgphoto2/print-usb-usermap or /usr/local/lib/libgphoto2/print-usb-usermap

This program tells the hotplug module, which cameras are supported by the installed version from gPhoto. All you have normally to do is

/usr/lib/libgphoto2/print-usb-usermap > /etc/hotplug/usb/usbcam.usermap

Now you have to download the scripts, untar them using

tar xvzf usbcam.tar.gz

Notice: There are two versions of the scripts. The 0.2.x series support digiKam 0.6.x and the 0.3.x series digiKam 0.7.1+. Rename your version to usbcam and digikam-hotplug, and copy them to

/etc/hotplug/usb/usbcam

and make usbcam executable for root and digikam-hotplug executable for the users that it should work for. For security reasons you should also check, that only root has write permissions on each file.

To test your installation, you’ll have to unplug your camera, wait a few seconds and plug it in again. After a few moments digiKam should start and connect automaticly to your camera.

If you have problems doing this, you should read the original gphoto documentation and check the syslog for notices from the two scripts.

Copyright

This script was writen by Oliver Dörr based on the usbcam script original distributed from the gPhoto Project. Because i'm using their code using the GPL license, this code is also distributed under the same license.