On Mon, Aug 03, 2009 at 09:58:14PM +0400, Andrey wrote:
> 0) Start X session.
> 1) Switch to tty1 or any other console terminal and run "emacs --daemon"
> 2) Make sure you can connect to it by running "emacsclient -t"
> 3) Switch to X session and run "emacsclient -c" This fails with
>
> Waiting for Emacs...
> *ERROR*: Display :0.0 can't be opened
Is the XAUTHORITY environment variable defined within your X session?
If so, the reason the Emacs daemon can't connect to your X server is
because it is trying to use ~/.Xauthority, but the file is in some
other place.
GDM puts the .Xauthority file in a different place when $HOME is on a
root-squashed NFS filesystem, because when the file is created GDM
runs as root, and can't write the file to ~/.Xauthority as normal. It
sets the XAUTHORITY environment variable to the other place (in
/tmp/), so all the child processes know to look there.
But emacs --daemon was started outside of the GDM process tree, so it
doesn't "see" the XAUTHORITY environment variable.
When I ran into this problem (using screen, not emacs --daemon), I
worked around it with the following code in my .xsession file:
## Dance so screen subprocesses can talk to GDM-spawned X servers.
if test -n "$XAUTHORITY"
then
xauth extract - $DISPLAY |
xauth -f ~/.Xauthority merge -
unset XAUTHORITY
fi
Note that depending on your DM, .xsession may be called .xinitrc or
.Xclients. Typically you also have to choose "default X session" or
similar, rather than "GNOME" or whatever.
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]