Can't open frame when running in emacs --daemon
Reproduction steps:
- Make sure no Emacs instance is running
- (setq atomic-chrome-buffer-open-style 'frame)
- Start 'emacs --daemon'
- Close Emacs frame (C-x 5 0)
- In Chrome edit text and click Atomic Chrome button
This will create the editing buffer in Emacs but will not show up a new frame. If step 3 is omitted and a frame is open everything works fine.
One issue seems to be that (getenv "DISPLAY") will return nil if the Emacs daemon has no open windows (happening in atomic-chrome-show-edit-buffer). Also the attempts to bring the current frame to front after that will fail if no frame is open. So this won't work with split/full, either.
The cause of the original problem in issue #2 seems to be the same (although that hasn't been addressed)
Work-around: call emacsclient -e '(setenv "DISPLAY" ":0")' after starting emacs daemon
I was not able to make it work with your workaround. I'm suspecting the following section causes the problem: https://github.com/alpha22jp/atomic-chrome/blob/master/atomic-chrome.el#L186-L198
When no frame is active, window-system is nil, dropping through all cases down to the simple (make-frame frame-params).
Note that your workaround probably worked at its time, as in 2019 there was no check for wayland.
My workaround now is a bit hacky, but it works now without opening some frame at all:
(setq window-system 'x)
(setq x-display-name (getenv "DISPLAY"))
DISPLAY is set in the systemd unit that I'm using.