mmcirvin: (Default)
[personal profile] mmcirvin
I have tired of trying to make OroborOSX work in Panther for the moment. I think I'll wait for Adrian's next revision. I'll admit that Apple X11 does have its advantages; for instance, it launches faster and has better performance in general. But there are no Helper Scripts.

So it's back to Plan A, which I will now tell you.


The biggest problem using Unix applications in a Mac environment is that they don't take arguments in the same way as ordinary Macintosh applications. Suppose you want to open a file with some program. If it's a Mac program, you can drag and drop the file onto the program's icon; or you can do whatever needs to be done to set the program as the standard opener for that type of file, and then just double-click on the file.

Other means of opening things hook into these mechanisms. For instance, iPhoto has a setting to use an external editor to open a picture when you double-click on its thumbnail. But what it does is the logical equivalent of dropping the file on the editor program, so whatever you use has to be capable of opening things that way.

So suppose you want to use GIMP under Apple X11 to open these files. What do you do? There's no way to make dragging-and-dropping a picture file on something type the GIMP command line.

Or... is there? AppleScript has a command called do shell script that executes a line of Bourne shell expressed as a string, and it also has a property called POSIX path of that gives you the Unix-type pathname of any Mac OS file. Put these things together and you have real ultimate power. For instance, you can do this, which I gakked off a guy at Mac OS X Hints named porkchop_d_clown and then hacked a little to make it ultra-modern:

on check_for_x()
	tell application "Finder"
		if ((name of processes as list) does not contain "X11") then
			launch application "X11"
			delay 5
		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)
		do shell script "export PATH=\"$PATH\":/sw/bin;export DISPLAY=:0.0;
                     gimp-remote -n " & "\"" & POSIX path of this_item & "\" > /dev/null 2>&1 &"
	end repeat
end open


(The two lines beginning "do shell script" are actually all one line; you should remove the line break before "gimp-remote". I put it in there because otherwise this stupid layout becomes ultra-wide.)

Put this in Script Editor, compile it and save it as an application. What you then have is an application that opens a picture in GIMP. It uses the "gimp-remote" command so that you can open a new picture in an already-running instance of GIMP. It can also launch the X11 application if it's not already running. (You might conceivably have to tweak that delay time if your computer isn't fast enough on the draw.)

If you go into the iPhoto preferences and set this thing under "Double-click: Opens in other", then you can edit things with GIMP from right inside iPhoto. You could also set this application as the default opener for JPEGs or something, if you wanted to.

The application to other kinds of files and openers is left as an exercise for the reader. Presumably with enough cleverness you could adapt this to discriminate different kinds of file and make a single application that works as a multi-purpose opener. But it's probably easier to just have a lot of little AppleScript droplets for different kinds of files.

Update: This script is supposed to be able to open multiple files at once. I dimly remember that there was something wrong with it that kept it from being able to do so. But I can't remember what it was. Maybe it will come back to me.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

June 2025

S M T W T F S
1234567
89101112 1314
151617181920 21
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 23rd, 2025 01:39 pm
Powered by Dreamwidth Studios