Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

Matts
  (email not shown publicly)

I work for MessageLabs [messagelabs.com] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Tuesday June 07, 2005
02:26 PM

First real CamelBones app

[ #25085 ]

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.

Now I just need to figure out how to tell Finder to eject my card when it's finished.

If anyone wants a copy of the app to do something similar but matching their needs they are more than welcome to it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • It's just as simple:
    my $mount = $self->{mount};
    $mount =~ s/^.*\///;
    Mac::Glue->new('Finder')->eject($mount);
    Sweet.
  • I've just started playing with CB and, like you, I want my app to download camera images. May I have a copy of your app, please? It might save me a bit of re-inventing the wheel. Thx
  • Hmm. When JonM borrowed my USB flash card reader, he plugged it into his Linux laptop and said it just mounted it under /mnt automatically. Does OSX/BSD not do this? I'd have thought there would have been a simpler way via fstab to mount the device as straightforward storage, thus making it just as accessible as any folder via Perl, Bash etc. So then it's just a case of moving some files using a script, and firing off a commandline to launch the app with that directory as a parameter, surely?
    • 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
      • An applescript can be saved as an .app file. I've been using that for startup items to call scripts in my $HOME/bin.
        --
        • Randal L. Schwartz
        • Stonehenge
        • Yeah I think you told me that before. I think CamelBones might just be easier than AppleScript though :-)