user3166269
user3166269

Reputation:

How can I determine where my Emacs session is being displayed?

I often forward my X session from my home server (Slackware) to my work desktop (Cygwin/Windows 7). I.e. ssh -X home-server; emacs &. I'd like to know (programmatically) where my Emacs session is being displayed, but the DISPLAY environment isn't very helpful:

(getenv "DISPLAY")
"localhost:10.0"

Any thoughts?

Update: I should have been more clear; I'm looking for the name of the host on which my X session is runnning (my work desktop, in this case). Calling, say, (system-name), or (getenv "HOSTNAME") will return "home-server", where Emacs is actually running.

Update 2: I've been trying to respond to Tobias, below, but trying to get the formatting to work in the comments has been driving me nuts:

Thanks, Tobias, but it seems that xauth only deals with authorization data:

Using authority file /home/mgh/.Xauthority
home-server/unix:0  MIT-MAGIC-COOKIE-1  c545124...
localhost.localdomain/unix:0  MIT-MAGIC-COOKIE-1  c5451...
home-server/unix:14  MIT-MAGIC-COOKIE-1  7b7be...
home-server/unix:13  MIT-MAGIC-COOKIE-1  96d13...
home-server/unix:12  MIT-MAGIC-COOKIE-1  8b186...
home-server/unix:11  MIT-MAGIC-COOKIE-1  28a0a...
home-server/unix:10  MIT-MAGIC-COOKIE-1  bbf6c...

Update 3:

Tobias, it shows this:

xauth -v nlist
Using authority file /home/mgh/.Xauthority
0100 0007 4261672d456e64 0001 30 0012 4d49542d4... 0010 c5451248...
0100 0015 6c6f63616c686f73742e6... 0001 30 0012 4d4954... 0010 c545124...
...
0100 0007 4261672d456e64 0002 3130 0012 4d49542d4d... 0010 bbf6c4d...

Upvotes: 6

Views: 174

Answers (3)

Stefan
Stefan

Reputation: 28571

I don't know if the X protocol offers a way to ask the X server to give you the hostname of the machine on which it's running. You might get by with other info, such as the RandR data (whose EDID info might include a brand name of the monitor, for example).

Upvotes: 0

jpkotta
jpkotta

Reputation: 9437

I asked this on the Unix stackexchange. The short answer is

(getenv "SSH_CLIENT")

Upvotes: 1

PythonNut
PythonNut

Reputation: 6419

These are just regular linux variables:

(getenv "HOSTNAME")
(getenv "TTY")

They should give you the machine you are on, and your location on that machine.

Upvotes: 0

Related Questions