Opening X11 App by double-clicking a file

My favorite text editor, NEdit, is an X11 (X Windows) program. I would like to open files with certain extensions in NEdit by double-clicking on the file icon (or some similarly direct mouse method). Is there any way to do this?

I tried the usual method, the "Choose Application" dialog. I can browse to NEdit, but it is grayed, and can't be selected. I can open it from the command line, or by double-clicking on the program's icon, but there doesn't seem to be anything I can do from the Finder in the directory where the text file lives.

This is common to all X11 applications. None of them can be selected from the "Choose Application" dialog. Am I overlooking something obvious?

PowerPC G5, Mac OS X (10.4.7)

Posted on Jul 9, 2006 9:19 PM

Reply
3 replies

Jul 9, 2006 9:43 PM in response to BobPG

Create an Applescript application (using Applications>Applescript>Applescript Utility) that simply runs a shell command. The command would be "nedit", plus some variable to accept command-line arguments (see link below). The Applescript will be your double-clickable program. You should be able to then assign documents to open with this Applescript.

See this doc for more details:

http://developer.apple.com/technotes/tn2002/tn2065.html

Jul 10, 2006 7:23 PM in response to BobPG

Sometimes a program will be greyed out at first when you choose the "open with..." option. In that same window there is an option where you can choose between "Recomended Applications" and "All Applications." The second option will allow you to choose any applicationthat you want. I'm not sure this will fix your problem, or you may have already tried it but it is worth a try. I use open office (runs in X11) and I can double click office files and open office will open, so what you want to do can be done.

Jul 11, 2006 12:04 PM in response to Rafe H.

Rafe H. set me on the right track, but he glossed over how to get the file name into the script. I ended up with a slightly different solution: In Automator, I created a two-step workflow:

1. Get Selected Finder Items, from the Finder library.

2. Run Shell Script, from the Automator library. I set the "Pass Input" selection to "as arguments", and the Shell to /bin/bash (my usual shell). The script is:

for f in "$@"
do
~/Software/bin/nc -display 😮.0 "$f"
done

The absolute path and -display option proved necessary because the bash is not run as a login shell, so it doesn't run ~/.bash_profile, where I normally set PATH and DISPLAY. Another option is to add ". ~/.bash_profile" as the first line.

BTW, nc is nedit's client mode, not the "netcat" in /usr/bin/nc.

Then I used "Save As...", selected File Format: Application, and saved it as ~/Software/bin/NEdit.app. After that, I could use the usual mechanism to assign my new Application as the one to run when I double-click files with the appropriate extensions.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Opening X11 App by double-clicking a file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.