Jeff Weisberg on Wed, 23 Jul 2003 14:36:07 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] given a display, find a host


| I have a program that knows that it's window is displayed on
| $DISPLAY. It would really like to know what host it is displayed on. I
| wonder if this is possible.
| 
| Before you suggest grabbing the part before the colon, note that this
| is all through ssh, so DISPLAY typically equals something like
| localhost:17.0.


well, if you cannot use the DISPLAY string itself, you are
left with: 'can you query the X server for the hostname?'

no, there is no (standard) query that will return the
server's hostname.

but, if 'manual preparation' is an acceptable solution, you can
stick the hostname into a root-window property or resource
when you start the X server, and then query for it later.

for example, in your X startup file, after firing up the server:
	xprop -root -f server_name 8s -set server_name `hostname`

later you can do:
	xprop -root | awk '/^server_name/ {print $3}'


see also: man pages for:
	xrdb
	xprop



	--jeff

_________________________________________________________________________
Philadelphia Linux Users Group        --       http://www.phillylinux.org
Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce
General Discussion  --   http://lists.netisland.net/mailman/listinfo/plug