From owner-freebsd-stable Fri Jul 27 5:21:50 2001 Delivered-To: freebsd-stable@freebsd.org Received: from guru.mired.org (okc-27-141-144.mmcable.com [24.27.141.144]) by hub.freebsd.org (Postfix) with SMTP id 37F7037B403 for ; Fri, 27 Jul 2001 05:21:46 -0700 (PDT) (envelope-from mwm@mired.org) Received: (qmail 61515 invoked by uid 100); 27 Jul 2001 12:21:45 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15201.23769.367007.292402@guru.mired.org> Date: Fri, 27 Jul 2001 07:21:45 -0500 To: "Chad R. Larson" Cc: Stable@FreeBSD.org Subject: Re: running on X server? In-Reply-To: <20010726150701.C9091@freeway.dcfinc.com> References: <20010726150701.C9091@freeway.dcfinc.com> <200107262222.f6QMMXO00601@bunrab.catwhisker.org> <20010726202622.A9940@freeway.dcfinc.com> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I think this belongs on -questions, not -stable, but I'm not going to move it. Chad R. Larson types: > Is there a simple, reliable way to determine if a script is running > in an X environment? What does "running in an X environment" mean? The best I can come up with is "can reach an X server that will talk to it." Determing that accurately is a non-trivial process, generally difficult, and probably best done by a human being. > I've seen too many scripts (such as the one shipped with urlview) > that test for the presence of the environmental variable DISPLAY, > but that's hardly foolproof. If you don't know which of the many possible ports on the internet the X server you're supposed to talk to might be listening on, you're pretty much screwed. DISPLAY tells you which of those X servers to use. Without it, the only safe assumption is that you don't have an X server to talk to. If it's wrong - well, you could try connecting to it and if that fails go back to the "no X" assumption. But failing and letting the user fix it is probably a better bet. Chad R. Larson types: > So, still looking for a clean, quick way to come up with what should > be set in the DISPLAY environmental variable (if anything) from > inside a login script. This is a completely different question. In general, the answer is don't do anything. It should be set by startx (or however you start x) if you log into a cli, by xdm or the equivalent if you log into an X environment, and passed over the wire by whatever remote connection protocol you're using. Like Harlan, I recommend ssh for the later, as it will go through a firewall without having to make the firewall resemble a tea strainer. Unless the remote protocol passes the information across the wire, you're pretty much screwed and will have to set it by hand. How else is the second machine I connect to going to know if I'm sitting in front of my workstation in an X environment, sitting in front of it at a console prompt, or ssh'ed in from my Palm(*)? You can set it to the most common case if it's not already set, and then have to deal with changing it instead of setting it. > Anyway, you get the drift. I believe there may be an oversight by > the X committee. Yeah, the should have adopted DWIM from Interlisp. Failing that, all they can do is provide a mechanism to let the user specify which of all the possible X server locations on the internet to actually use, and that mechanism is the display environment variable. BTW, qterm is in the netbsd ports tree. Or was. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message