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

A simple way to open files in X11 applications UNIX
Here is the easiest way, to my knowledge, to associate file extensions with X11 applications: just use the open source X11 Extension program. On the disk image, you'll find a new ExtManager System Preferences panel. Install it, then open it in System Preferences. The next step is to define file extensions and commands associated with them (e.g. /sw/bin/gv for EPS files).

There might be a small problem if you're using applications from outside standard PATHs (e.g. from Fink); in that case, you have to pass the PATH environmental variable to the X11 window manager. For some reason, the Apple xterm fails to assign the proper values to PATH if they're included in the .xinitrc file, and it doesn't read the .bash_profile file either. As a workoround, I suggest creating a .bashrc file with a single line (assuming the paths are already defined in the .bash_profile file, which is a routine for Fink and MacPorts users):
source .bash_profile
You should also set up X11 to launch at login, and you can then assign X11 apps simply by right-clicking (luckily Apple people reinvented the wheel and found out that the mouse can have multiple buttons...) the file and choosing ExtManager as the application to use to open the file.

Another small hint: to get the mouse support in mc, add this line to .bash_profile:
export TERM=dtterm
[robg adds: I haven't tested this one.]
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[10,184 views]  

A simple way to open files in X11 applications | 9 comments | Create New Account
Click here to return to the 'A simple way to open files in X11 applications' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A simple way to open files in X11 applications
Authored by: kneeslasher on Sep 19, '07 08:54:11AM

Superb. I just tried it and it finally allows double-clicked eps files to be opened for viewing via Fink's gv! What an excellent tip.



[ Reply to This | # ]
A simple way to open files in X11 applications
Authored by: hamarkus on Sep 19, '07 09:15:25AM

Would this work with Matlab? It requires X11 to run (but maybe only for drawing graphs) but the main app has a .app ending?



[ Reply to This | # ]
A simple way to open files in X11 applications
Authored by: LukeR on Sep 22, '07 02:17:11PM

I'm not sure, I stopped using Matlab when I installed Octave, but you can probably find Matlab executable somewhere in bin folder in the Matlab tree - try putting that as the command in X11 Extensions - hope it helps...



[ Reply to This | # ]
A simple way to open files in X11 applications
Authored by: Nem on Sep 19, '07 10:38:08AM

You should NOT have your .bashrc read your .bash_profile!!

The problem with xterm and the environment most likely has to do with the fact that the xterm launched with Apple's X11 is NOT a "login session" xterm. Neither are the xterms launched by using the Command shortcut with X11.

In both cases, add "-ls" to the xterm command (modify the .xinitrc and select Applications->Customize Menu in X11). Doing so will give you a "full" shell, with your environment (.bash_profile read in).

You're using the fact that the .bashrc is read in often for what are considered to be non-interactive shells (like 'xterm' by default or when running a remote command via SSH). However, you shouldn't use that force a full shell environment.

It is okay (and I often set it up so) for your .bash_profile to contain a "source ~/.bashrc" line, but you should NOT do it the other way around.

Standard practice is to put environment variables (PATH, MANPATH, etc.) and aliases into your .bashrc. Your .bash_profile should contain start-up commands, like bash 'shopt' calls, a nice daily 'fortune', and any 'stty' calls. Move your PATH assignment to your .bashrc and have your .bash_profile read it and most of your problems will be solved.

---
Nem W. Schlecht
http://geekmuse.net/



[ Reply to This | # ]
A simple way to open files in X11 applications
Authored by: n8gray on Sep 20, '07 10:34:47AM
Standard practice is to put environment variables (PATH, MANPATH, etc.) and aliases into your .bashrc. Your .bash_profile should contain start-up commands, like bash 'shopt' calls, a nice daily 'fortune', and any 'stty' calls.

Interesting. The various rc files I've inherited have always had it the other way around, though they could certainly be wrong.

When the login vs. non-login shell issue comes up it's always presented as, "for login shells these files get loaded and for non-login shells these ones do," but what I've never heard explained is why anybody should care about login vs. non-login shells. I understand why interactive vs. non-interactive is important, but what's the difference if a shell is login or non-login?

[ Reply to This | # ]

A simple way to open files in X11 applications
Authored by: Nem on Sep 21, '07 10:36:59AM

The simplest case I can give you about why you would want to differentiate is this: I'm on host-a and I want to run a "mybackup" script that I wrote on host-b. I can do this:

ssh host-b /some/weird/path/mybackup

But typing in that path is cumbersome. If "/some/weird/path" is defined as a part of my PATH in my .bashrc, I don't need to type it, I can just do:

ssh host-b mybackup

If my PATH is defined in my .bash_profile, this second ssh command will fail ("mybackup not found").

Another important reason is if you use X11 most of the time (as I do, even on my Mac), you need access to the 'xauth' program for remote windows to work properly. The path to the X11 binaries is often NOT included in the system default PATH, thus you need to put it into your .bashrc. Again, if you have your PATH in your .profile, then this command won't work (for several reasons):

ssh host-b xterm


The next question is, why would you put anything in your .bash_profile? And actually, my .bash_profile is pretty sparse. The main thing I have are things relating to the shell. Things like "shopt -s cdspell" only make sense when a shell is interactive. Another thing I have is a program that spits out any calendar appointments I have for that day. You definitely would not want that spat out every time you 'ssh' to a box to run a command - you only want something like that when your session interactive.

I've seen a lot of programs spit out a message along the lines of "add this PATH statement to your .bash_profile" - it's unfortunate, and many people won't really notice, but that's not the way this was all designed to work. It's a simple distinction, but an important one if your stuff isn't working the way you want it to!

---
Nem W. Schlecht
http://geekmuse.net/



[ Reply to This | # ]
A simple way to open files in X11 applications
Authored by: n1mie on Sep 20, '07 01:59:36PM

I don't use Apple's X11 but rather XFree86 and it behaves that way too. And NO, I do NOT want an XTerm window to open every time I launch XWindows. What is the purpose of a GUI if I MUST have a CLI running active? Then when you accidentally close the CLI window the GUI closes since it is dependant.

Maybe we need to get the word to the developers to fix the real problem which is that it isn't reading in both environmental files.

---
--Chip



[ Reply to This | # ]
A simple way to open files in X11 applications
Authored by: LukeR on Sep 22, '07 02:20:58PM

How to avoid launching xterm when starting X11: take a look at my xinitrc:


#!/bin/sh
# $Id: xinitrc,v 1.3 2004/06/11 04:37:23 jharper Exp $

test -r /sw/bin/init.sh && . /sw/bin/init.sh
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f "$sysresources" ]; then
    xrdb -merge "$sysresources"
fi

if [ -f "$sysmodmap" ]; then
    xmodmap "$sysmodmap"
fi

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"
fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi
quartz-wm

You just have to remove "xterm" line if you have them somewhere in your .xinitrc



[ Reply to This | # ]
A simple way to open files in X11 applications
Authored by: n8gray on Sep 20, '07 10:14:09AM

Thanks for the hint! That's a really interesting app.



[ Reply to This | # ]