| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
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
Attachment:
FMN-X11-launchd.patch
Description: Binary data
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? :-)
_______________________________________________ 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
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.