atomic-chrome icon indicating copy to clipboard operation
atomic-chrome copied to clipboard

Can't open frame when running in emacs --daemon

Open sheijk opened this issue 6 years ago • 3 comments

Reproduction steps:

  1. Make sure no Emacs instance is running
  2. (setq atomic-chrome-buffer-open-style 'frame)
  3. Start 'emacs --daemon'
  4. Close Emacs frame (C-x 5 0)
  5. 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)

sheijk avatar Oct 22 '19 03:10 sheijk

Work-around: call emacsclient -e '(setenv "DISPLAY" ":0")' after starting emacs daemon

sheijk avatar Oct 22 '19 03:10 sheijk

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.

CRTified avatar Jan 24 '23 23:01 CRTified

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.

CRTified avatar Jan 25 '23 23:01 CRTified