Previously, metallicburgundy published a hint showing how to create a droplet that would let you load pictures from iPhoto into the Gimp. It used perl to parse the file name and required that you manually start XDarwin and the Gimp before using it.
The following script makes all that work unnecessary. It uses the newest extensions to AppleScript to detect XDarwin and start it if it isn't running, and uses the new POSIX command to convert the file name to a format that the gimp will understand. The upshot is that the first time you drop something on this script, it will automatically start X and the Gimp for you. This can be slow that first time (starting X can take a while) but it saves you a couple of steps.
Read the rest of the article for the script...
Here's the AppleScript source:
on check_for_x()Note: I believe that "do shell script" requires that you have built this script with Project Builder, not the Script Editor.
tell application "Finder"
if ((name of processes as list) does not contain "XDarwin") then
launch application "XDarwin"
delay 30
end if
end tell
end check_for_x
on open these_items
check_for_x()
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items)
--display dialog "export DISPLAY=localhost:0.0;/sw/bin/gimp-remote -n " ¬
& "\"" & POSIX path of this_item & "\""
do shell script "export PATH=\"$PATH\":/sw/bin;export ¬
DISPLAY=localhost:0.0;gimp-remote -n " & "\"" ¬
& POSIX path of this_item & "\""
end repeat
end open
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020430090950359