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


Click here to return to the 'A workaround for X11 sharing by multiple users' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A workaround for X11 sharing by multiple users
Authored by: Ptitboul on Feb 27, '04 06:29:16AM

You asked "Is there a way to get the automatic $DISPLAY setting in Xterm to work in Terminal.app?"

Not really. The biggest problem is that you have to guess which X11 server you want to use. When xterm is launched from within X11, then the guess is that all applications lauched within this xterm should be displayed on that X11 server. But that may be a bad guess, and that is the reason why DISPLAY can be changed and why most X11 programs understand the -display flag.
If an X11 server is already running when Terminal.app is launched, then your technique is quite good, because the best guess you can make is to find an X11 server you are allowed to talk with. But you should at least check that DISPLAY was not set. If there is a previous value for DISPLAY (e.g. if the shell was lauched from within an ssh with X11 forwarding), then you should not change it.
However, if no X11 server is running when Terminal.app is launched, then your technique is not so good, because you make the hypothesis that the owner of this Terminal.app will be the next one to launch a new X11. I would rather not set DISPLAY, and ask that anyone that may need a X11 server launches it at login.
This is what I do. But, since launching X11 automatically launches an xterm, I find this annoying (I prefer Terminal.app). Therefore I deleted the line "xterm &" from /etc/X11/xinit/xinitrc



[ Reply to This | # ]
A workaround for X11 sharing by multiple users
Authored by: speir on Feb 27, '04 04:32:22PM

Thank you for the additional advice and very helpful information! Much appreciated.



[ Reply to This | # ]
A workaround for X11 sharing by multiple users
Authored by: jhegarty on Apr 10, '04 05:44:18AM

Interesting. I also prefer the Terminal, but don't always start X before starting the Terminal. It also seems like when I put the machine to sleep, X gets confused and I have to restart it when I wake the machine up (but I don't want to close and then reposition all my terminals!). I worked around the problem of having the Terminal start first by adding

[ ! "$DISPLAY" ] && export DISPLAY=:0.0

to my /etc/profile. (i.e.: if DISPLAY is not set when the Terminal starts, set it to :0.0, otherwise use the existing $DISPLAY) Of course, I'm really the only regular user on this machine, and definitely the only one using X locally. Setting the display like this doesn't seem to break ssh for remote logins, by the way. If I login to this machine remotely and X is already running locally, ssh still sets the display correctly for forwarding.

** Note: This was a Physicist's hack. Less messy than the Biologist's hack, but much more spur-of-the-moment and broken. ;)

Hmm .. it might be worthwhile to write a script that checks for the ownership of the .X##-lock files, and sets the display according to which one you own. That way X can still give you whatever display it wants to, and it should be trivial for a user to run a single command if they discover their X isn't set correctly (without worrying about exactly what it's supposed to be set to), right?

---
--[ you cannot consistenly judge this statement to be true ]--



[ Reply to This | # ]