For getting pictures off my camera I use an external card reader. Unfortunately none of the applications for pulling files off there automatically do what I want, which is to move the files to a date-named directory, and automatically launch Capture One (or other app of choice), and loading the just copied files in the process.
So I figured out that in order to do this in perl you have to have a proper mac application - a plain shell script doesn't cut it sadly. So I decided to have a go at CamelBones. Once you have a proper Mac app you can tell the Image Capture preferences to use this app whenever a camera is connected (or in this case whenever my card is inserted).
It's a bit of effort to create the GUI, but I got what I needed working quite easily.
The hard part was that in order to have a progress bar you can't block the GUI "thread". So not only was this my first adventure in CamelBones, but also my first venture into perl threads.
The main thread updates the GUI with a ticker that checks for data on a queue. The "child" thread moves the files over and watches for start/cancel data on another queue.
The final piece of the puzzle was launching Capture One LE (my RAW conversion app of choice) and getting it to see the right directory. Launching was simple, but passing the directory in on the command line didn't work. So I had to resort to AppleScript, or so it seemed.
Mac::Glue to the rescue there. I've never used Mac::Glue before, but it was a good experience. Created the "stub" with the macglue command line app, and then I could just do:
my $obj = Mac::Glue->new('Capture_One_LE'); $obj->open($self->{dir});Which is really simplicity defined, compared to the ugliness of AppleScript.
Sweet.my $mount = $self->{mount};
$mount =~ s/^.*\///;
Mac::Glue->new('Finder')->eject($mount);
Re:Aha!
pudge on 2005-06-07T23:34:53
Yay!:)
Re:Hmm
Matts on 2005-06-08T13:47:20
OSX not only mounts it immediately, but it also launches an app you pick to copy the files off.
I don't want to plug it in, then have to find a terminal window that isn't ssh'd into somewhere else, then type in the name of an application/script. OSX does this all for me. Now all I have to do is click "Start".
The complication comes in that apple has special Foo.app applications which are really a directory of binary + everything it needs to run. The application that you pick to copy the files off the drive has to be one of these. Doing it in CamelBones seemed like the easiest way to get this done.
I'll demo it for you next time I'm in the UK.Re:Hmm
merlyn on 2005-06-08T14:29:11
An applescript can be saved as an.app file. I've been using that for startup items to call scripts in my $HOME/bin. Re:Hmm
Matts on 2005-06-08T14:39:37
Yeah I think you told me that before. I think CamelBones might just be easier than AppleScript though:-)