On Nov 18, 2007, at 2:31 PM, Nathaniel Gray wrote: On Nov 18, 2007 9:32 AM, Ben Byer <email@hidden> wrote:
Andrew's analysis is correct -- From now on, you should think of $DISPLAY as indicating a *capability*, and not as a way of "triggering
other random behavior".
Ambrose's response is also noted, but I'm going to stand up for myself
and say that it was not "overlooked". Rather, we came up with what we
thought was a more correct use of $DISPLAY, and so we implemented
according to that belief, fully knowing it would break some
assumptions that various scripts were making. It's the price of
progress.
I am more than happy to try to help anyone rewrite those scripts :)
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 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)? I've seen some pretty wacky things around here, but usually they're hacks to try to brute-force your poor system into running whatever X server it can find on your system, and then try to guess the correct socket to use to connect to that server. 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
(If you know where that code came from, you get a cookie!) -- Ben Byer CoreOS / BSD Technology Group, XDarwin maintainer |