emacs-devel
[Top][All Lists]
Advanced

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

How to get DISPLAY of emacsclient?


From: Max Nikulin
Subject: How to get DISPLAY of emacsclient?
Date: Fri, 25 Nov 2022 22:17:54 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

Hi,

Is it possible to get display of an emacsclient process? I mean either --display option argument or the DISPLAY environment variable namely for the client.

Unfortunately the value of following expression is the DISPLAY environment of the server process

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

I admit, it should work in most cases, but it is not robust:

    DISPLAY= emacs --daemon --display :0

causes empty string returned by `getenv'. In general, emacsclient's display is not necessary the same as the server's one. If I have got it correctly, the value is passed from client to server and there is a local "display" variable in server.el hidden from evaluated expression.

The context of the question is the following. Org-capture allows to create notes in non-distracting way (by setting :immediate-finish t property of the capture template). The idea is to save text currently selected in some application (either PRIMARY or CLIPBOARD) using a global window manager shortcut invoking

     emacsclient --eval '(org-capture nil "x")'

There is a pitfall. Emacs daemon has no frame at startup, so selection is inaccessible:

     emacsclient --eval "(org-get-x-clipboard 'PRIMARY)"

returns nil (it is merely a convenient way to call `gui-get-selection'). A workaround is to call `server-select-display', but to do so it is necessary to know display. That is why I am asking how to obtain display of emacsclient.




reply via email to

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