[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get DISPLAY of emacsclient?

From: Max Nikulin
Subject: Re: How to get DISPLAY of emacsclient?
Date: Sat, 26 Nov 2022 10:36:30 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 25/11/2022 23:57, Stefan Monnier wrote:
Unfortunately the value of following expression is the DISPLAY environment
of the server process

     emacsclient --eval '(getenv "DISPLAY")'

There are different ways which will give you different answers in
different cases:

- you can check the `display` parameter of the selected frame (should
   handle the `emacsclient --display` case).

    emacsclient --display "$DISPLAY" \
        --eval "(frame-parameter (selected-frame) 'display)"

may be a workaround, thank you for the idea. A caveat is that --display parameter becomes mandatory, DISPLAY environment is not enough:

    emacsclient --eval "(frame-parameter (selected-frame) 'display)"

Emacs daemon may have no x frames yet at the moment of emacsclient invocation.

- you can check the `environment` parameter of the selected frame
   (probably not very useful).

     emacsclient --display :0 \
          --eval "(frame-parameter (selected-frame) 'environment)"

- You can check the `env` parameter (with `process-get`) of the proc
   object that represents (on Emacs's side) the emacsclient connection.
   For that you'll need to get access to this proc object, but I don't
   know offhand how to.

I am unsure that -display argument is added to the `env` parameter. I do not like the following approach since I am afraid of races. Anyway it does not work

     emacsclient --eval "(process-get (car server-clients) 'env)"

So I have no idea how to access `proc` passed to a process filter as well.

Though it does not answer to the question how to get DISPLAY, the following is at least a workaround:

      DISPLAY= emacs -q --daemon
      emacsclient --display "$DISPLAY" \
          --eval "(require 'org)" \
          --eval "(org-get-x-clipboard 'PRIMARY)"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]