Saturday, 12 July 2008

Ubuntu Removable Drives and Media

I have had a photo importing script that worked very well- automatically executed when plugging in the SD card from my camera, importing photos, rotating, filing in date folders and copying to a network drive. The automatic behaviour was kicked off by changing the default application in the Preferences control panel 'Removable drives and media' in Ubuntu.

This worked very well- until it didn't. I just worked out what went wrong and this post is basically Google fodder for any other poor unfortunates who may have been struck by the same problem.

Basically in Ubuntu Hardy (8.04) Nautilus was changed over to use GVFS (the gnome virtual filesystem) and GIO (Gnome I/O abstraction layer) it also took over the functionality of handling certain media types- including removable media like photo CDs, digital cameras and so on. You can find this from the menus in any Nautilus window: Edit > Preferences > Media. Sadly this functionality is significantly less functional for my purposes. Where before I could simply substitute the path to my import script to get similar functionality I had to:

  1. As root create a new 'my-import.desktop' file in /usr/share/applications (example contents see below)
  2. Open nautilus media preferences (from the menus in any Nautilus window: Edit > Preferences > Media) and select 'Ask What To Do'
  3. Plug in the memory card and select the 'Open My Import Script' option and click the 'always use this option' checkbox

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=My Import Script
GenericName=Import Script
Comment=Run my import script
NoDisplay=true
Exec=import_script %u
Icon=f-spot
MimeType=x-content/image-dcf;x-content/image-picturecd
StartupNotify=true
Terminal=false
Type=Application
Categories=Graphics;Photography;GNOME;GTK;



These bug reports led me to the solution. There is some discussion about a fix for this backward step in functionality- hopefully their feedback will lead to an upstream fix in Gnome or a standing patch in Ubuntu to return something like the old behaviour.

No comments: