#!/bin/bash

URI=`gvfs-ls -c "$1/"`

if [ "${URI:0:10}" = "gphoto2://" ] ; then
    # Yield for f-spot since it wants to access the device directly
    #
    gvfs-mount --unmount-scheme gphoto2

    if [ "${URI:11:4}" = "usb:" ] ; then
        # Rewrite the uri to something f-spot can handle
        #
        bus="${URI:15:3}"
        dev="${URI:19:3}"

        URI="gphoto2:usb:$bus,$dev"
    fi
fi

f-spot --import "$URI"
