Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations)



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)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/x11-users/email@hidden

This email sent to email@hidden

References: 
 >Re: Explanation of X implementations (From: John Bassett <email@hidden>)
 >Re: Explanation of X implementations (From: Ben Byer <email@hidden>)
 >Re: Explanation of X implementations (From: "Ambrose Li" <email@hidden>)
 >The meaning(s) of $DISPLAY (was Re: Explanation of X implementations) (From: Eric Gouriou <email@hidden>)
 >Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations) (From: "Ambrose Li" <email@hidden>)
 >Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations) (From: "Andrew J. Hesford" <email@hidden>)
 >Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations) (From: "Ambrose Li" <email@hidden>)
 >Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations) (From: Ben Byer <email@hidden>)
 >Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations) (From: "Nathaniel Gray" <email@hidden>)
 >Re: The meaning(s) of $DISPLAY (was Re: Explanation of X implementations) (From: Ben Byer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.