This is a bit of a middle-ground between programming and server-admin, but this seems ultimately the most relevant place for it.
I'm looking for a way to determine if the variable '$DISPLAY
' is advertising an XServer we can actually connect to, that is, if all the authentication and whatnot is in place to permit further things to execute.
I'm ideally looking for something shell-end tool that returns true/false, which can be used in a build-script to determine if the other tests in it ( which I don't control ) should be run or not.
The tests at present simply check for the env
variable "$DISPLAY
", and if it's there, will try to connect, and when the connection doesn't work, the tests assume failure of the test, not simply the display is not connectible.
I just need to be able to do
if [[ ! can_connect_to_X ]] ; then
unset DISPLAY
fi
In order to stop these tests having severe mental problems.
In an ideal situation, the tool required to do this should come provided with the X Client libraries itself, so as not to incur special dependencies, and to be able to assume if the utility is not there we can't connect to any display.
You can try with the xset command :
I am guessing there is a better solution. But you can always just use a small tool like xclock and check the exit status.
But man, that is ugly :-)
Less Hacky, put the following in checkX.c:
Then:
Lastly:
Heres a possible WayToDoIt, not sure how good it is though.
This appears to be working.