It seems that on system startup emacs process is started without proper XAUTHORITY
$ grep -az XAUTHORITY= /proc/$(pidof emacs)/environ :: returned empty string
And
$ emacsclient --create-frame :: returns
Error: Display 0.0 can’t be opened
After killing server emacs process with
$ emacsclient -t --eval ‘(progn (server-save-buffers-kill-terminal 1) (save-buffers-kill-emacs 1))’
On the new emacs process XAUTHORITY is set:
$ grep -az XAUTHORITY= /proc/$(pidof emacs)/environ :: returnes
XAUTHORITY=/run/user/1000/gdm/Xauthority
And new graphical frames are opened correctly
I am on nixos 20.09, with home-manager installed from nixpkgs
You should additionally use home-manager xsession manager (xsession.enable) which injects some env vars into the proper places (XAUTHORITY is already in that list). Or do something similar yourself.
Thank you very much for the response!
At the time (about a year ago) I tried to figure it out and apply to my situation, but didn’t fully get it.
Currently I upon revisiting same problem, I actually understand what you meant and, yes, I suspect that it might be a way to solve this.
I still sometimes encounter this problem, when gdm fails to start “none+xmonad”
and this might be because emacs server is being started, but I only connect to X session after retry and it’s a different one?
My current hack that helps with the problem is to do “systemctl --user restart emacs”
I suspect that adding that requirement would help
One reason I’m not trying it now is that I suspect that I will more often use emacs from tty when X doesn’t start after an upgrade
And adding requirement for graphical session would mean that I’d probably need to manually start/restart emacs service when log into tty without graphics
This didn’t work for me with Gnome Shell.
The Emacs daemon worked without a problem on qtile before.
As reported restarting the daemon after logging in works but is a bit annoying to do. emacsclient -tc works as well but then I would’ve to find a workaround for the clipboard.
I’m having this same issue with gnome. I even tried to put it after network-online.target, but still no luck. Have to manually restart the service once for this.