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


Click here to return to the 'Associate X11 applications with filename extensions' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Associate X11 applications with filename extensions
Authored by: ssevenup on May 16, '03 03:18:41PM
Several comments...

First.. I have the PATH variable set in my "~/MacOSX/environment.plist" as per this hint . I also have my "DISPLAY=:0.0" set there. The interactions between environment.plist and your shell environment "dot" files is not well documented, so use at your own risk.

Second.. I prefer to check to see if X11 is already running.

Third.. I had a few issues with syntax, so I tweaked some of the quoting. Here is the beef...


#!/bin/sh

# Not needed if set in ~/.MacOSX/environment.plist
#
# PATH=/sw/bin:/sw/sbin:/usr/bin:/bin
# DISPLAY=:0.0

StartX11 ()
{
x11pid=$( ps -auxww | grep X11.app | grep -v grep | awk '{ print $2 }' )
if [ -z "${x11pid}" ]; then
	/usr/bin/open -a X11.app
fi
}

StartX11

for file in $@
do
	/sw/bin/gv "${file}"
done

I found that the file opened in gv faster if the PATH was set in environment.plist instead of the shell script. You will also notice that I use the full path to the binaries just on general principals. I never figured out how to pass gv the path to gs to eliminate the need for the PATH completely, but I'm convinced it's possible.

Using Open Menu I can now right click a ".ps" file, and open it straight into gv... pretty cool, and it opens the door to many other possibilities.


---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.

[ Reply to This | # ]

Associate X11 applications with filename extensions
Authored by: cedric on May 16, '03 03:55:14PM

I have used your version of the script, but still, it does not resolve the problem of "Unable to open display". The script works by itself very well from the command line, but not with DropScript. Maybe it's a problem with DropScript (I'm not a expert at all on Cocoa app).

Any clue?
Thanks.

Cedric



[ Reply to This | # ]
Associate X11 applications with filename extensions
Authored by: ssevenup on May 16, '03 07:38:51PM

Uncomment the PATH and DISPLAY lines or follow the tip for adding them to your ~/.MacOSX/environment.plist like I did.

--MM

---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
Associate X11 applications with filename extensions
Authored by: ssevenup on May 16, '03 08:03:52PM

Remember to log out and back in after changing the environment.plist.

--MM


---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
Associate X11 applications with filename extensions
Authored by: KOHb on May 17, '03 12:18:52PM

If you really want to get rid of the PATH dependence, you can use .Xdefaults and set "GV.gsInterpreter". (Look at man gv.) It looks like it'll even use a ".gv" file if you want.

I timed (using zsh's 'time') checking for X11 already running versus just running "open -a X11" (which doesn't seem to do anything except gain window focus) and open was faster. YMMV.

One could probably write an all-in-one Unix opener (per extension) by copying the idea of UnShove.sh (from DropScript's example).

So far I use the idea to open postscript, dvi, and occasionally vim.

BTW, a quick way to make these dropscripts is to do "open -a DropScript script.sh".



[ Reply to This | # ]
Associate X11 applications with filename extensions
Authored by: unforeseen:X11 on Jun 07, '03 08:17:03PM
by editing gv to gimp, this script opens dropped pics with my fink-installed Gimp. the problem is that every image gets opened within a "new" gimp, means that the gimp starts up several times. has anyone figured out how to pass the variables to the (eventually) already running gimp??

[ Reply to This | # ]