A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg01589.html below:

How to get DISPLAY of emacsclient?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] 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.





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4