Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations)
Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations)
- Subject: Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations)
- From: "Nathaniel Gray" <email@hidden>
- Date: Sun, 18 Nov 2007 22:14:44 -0800
Apologies for the quoting. GMail isn't smart enough to handle the
'blockquote' style of quoting properly.
On Nov 18, 2007 4:20 PM, Ben Byer <email@hidden> wrote:
>
>
> On Nov 18, 2007, at 2:31 PM, Nathaniel Gray wrote:
> > I'm pretty happy with the new way, but I *would* like a bulletproof
> > way of knowing if $DISPLAY is connected to a running X server.
>
> Why? :D
Is it really so hard to imagine a situation where you don't want to
launch an X server if it's not already running? Even if we ignore the
X11.app icon bouncing up in the dock it's not like ~/.xinitrc is
guaranteed to be free of side-effects.
> > I've got some code (mostly working around the lack of accessibility info in
> > X) that tries to connect to DISPLAY as a way of checking for a running
> > X server, since that seemed like the best way of detecting that.
>
> In all seriousness, what end goal are you trying to accomplish? Why do you
> need to know if an X server is running, unless you then want to use it (by
> connecting to $DISPLAY)?
Because my program is not primarily an X11 client, it's a multi-mode
program that has an X11 module. The current approach is that when
it's triggered it tries to connect to DISPLAY, and if that doesn't
work the X11 module does nothing. There's still lots of other
interesting work to be done, just not in X.
If you want to know the whole story, check out the website:
http://www.n8gray.org/code/forget-me-not
> Since that's no longer appropriate I need a replacement, and I really
> hope you aren't going to say "ps -a -U $USER | grep X11" or some such.
> ;^)
>
> How about this?
>
> # If no display has been specified, deduce local display number from X11
> process.
> if [ "$DISPLAY" = "" ]; then
> export DISPLAY = `ps auxww | grep $USER | egrep
> '(Xauthority|/Applications/Utilities/X11.app/Contents/MacOS/X11 .*:[0-9]+$)'
> | grep -v grep | sed 's/^.*\(:[0-9][0-9]*\)$/\1/'`
> fi
I just started to write an indignant reply but then I realized you're
probably kidding. You must be kidding, right? :-)
Cheers,
-n8
--
>>>-- Nathaniel Gray -- Caltech Computer Science ------>
>>>-- Mojave Project -- http://mojave.cs.caltech.edu -->
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden