Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Autostart XDarwin and The Gimp from AppleScript Apps
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()
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
Note: I believe that "do shell script" requires that you have built this script with Project Builder, not the Script Editor.

[Editor's note: 'porkchop' provided both a precompiled binary version of the script and the Project Builder source files. You can download either one (binary, source files) from my iDisk.]
    •    
  • Currently 3.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[10,806 views]  

Autostart XDarwin and The Gimp from AppleScript | 6 comments | Create New Account
Click here to return to the 'Autostart XDarwin and The Gimp from AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Wonderful
Authored by: Anonymous on Apr 30, '02 06:56:55PM

Thank you very much for this fantastic hint and script.



[ Reply to This | # ]
great, but small problem
Authored by: elmer-12 on May 01, '02 01:34:46PM

I can't seem to open two pics at a time with this method. I put the binary posted here in the dock and dragged a photo onto it. OK, X and gimp open and there's the photo. Drag another photo onto the same dock icon. Nothing happens. Quit the gimp and gimp immediately restarts with the second photo! I can queue up lots of photos this way but you only see one in the Gimp at a time and you have to wait through the Gimp splash screen in between.
Is this unusual behaviour for this script? I'm new to scripts.



[ Reply to This | # ]
There's always something...
Authored by: porkchop_d_clown on May 01, '02 03:25:26PM

Okay, I think I've worked this out.

I can make this problem happen - if "Open In Gimp" starts Gimp, only the first picture gets loaded. If the Gimp is already running, the problem doesn't happen.

this makes no sense to me at all, but I'll look into it. "do shell script" must not return if it starts the gimp.



[ Reply to This | # ]
Bug fixed!
Authored by: porkchop_d_clown on May 01, '02 04:05:40PM

Nailed it. The problem is that when the script starts the Gimp, the Gimp is left "attached" to the script. Effectively, the script freezes until you quit the Gimp.

I added a few bits to make sure that the Gimp gets disconnected from the script. It should work "as designed" now.

Get it from my iDisk

[ Reply to This | # ]

Bug fixed!
Authored by: theolog on Aug 19, '02 11:53:43AM

Any chance you'd be willing to modify this so that it uses OroborOSXv0.75a4r2 instead of XDarwin?

Also, I must launch gimp using the following:

gimp1.2 --no-shm --no-xshm &

don't know if that makes a difference -- but this script doesn't seem to work with these packages (from http://www.osxgnu.org):

XFree86 4.2.0 (XDarwin)
OroborOSX-v0.75a4r2.pkg (I start XDarwin with this instead of the standard XDarwin app)
gimp-1.2.1_2.pkg
dlcompat-10505X.pkg

:-)



[ Reply to This | # ]
Bug fixed!
Authored by: rflorence on Nov 25, '02 06:35:30PM

Alas, the .mac address you gave for the fixed
version of Open-in-Gimp seems not to work. I'd
very much appreciate if you could point me to a
site where I could find this. It's a very convenient
utility, but the version I have seems to attach
itself to gimp so that gimp must be killed and
restarted for each file/photo.

Thanks,



[ Reply to This | # ]