[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: org-x11idle-exists-p with emacs --daemon
From: |
Ihor Radchenko |
Subject: |
Re: org-x11idle-exists-p with emacs --daemon |
Date: |
Mon, 31 Oct 2022 02:50:31 +0000 |
Max Nikulin <manikulin@gmail.com> writes:
> Ihor, what I do not like in your patch is that an external process is
> unconditionally executed during load time. Earlier there was a (failed)
> attempt to limit it to X11.
>
> - Unsure if Windows builds of Emacs may connect to X servers.
> - MacOS does not use x11idle, it calls ioreg and perl instead.
We can test `sytem-type' to be in '(gnu gnu/linux gnu/kfreebsd).
> In above cases, there might be a point to execute x11idle if a user is
> running remote Emacs session on a Windows or a MacOS machine (e.g.
> through ssh) from local X server. Unsure if somebody has ever tried it.
> The reason to try x11idle should be a test if current frame is
> associated with X.
This is a trade-off. If we want to consider individual frames running on
remote X server, `org-user-idle-seconds' will need to check the command
availability on every call. That is - we will try to run shell command
every 60 seconds (`org-resolve-clocks-if-idle''s default timer). I'd say
that it is not a good idea considering how rare such situation is.
> A side note. I am aware that the following comment existed before your
> commit.
>> (and (eq 0 (call-process-shell-command
>> (format "command -v %s" org-clock-x11idle-program-name)))
>> ;; Check that x11idle can retrieve the idle time
>> ;; FIXME: Why "..-shell-command" rather than just `call-process'?
>> (eq 0 (call-process-shell-command org-clock-x11idle-program-name))))
>
> `call-process' can not be used here because "command" is a shell
> built-in, not a real executable. I have another question. Why
> `locate-file' is not used instead?
>
> (locate-file command exec-path exec-suffixes 1))
>
> https://emacs.stackexchange.com/questions/332/how-can-i-find-the-path-to-an-executable-with-emacs-lisp
Not idea. Maybe even `executable-find'?
> On 30/10/2022 08:33, Ihor Radchenko wrote:
>> Max Nikulin writes:
>>
>>> In server.el I found
>>>
>>> (frame-parameter frame 'display)
> ..
>>
>> I do not understand.
>
> echo "$DISPLAY"
> :0
> emacs -Q --daemon
> emacsclient -nw
>
> window-system
> nil
> (frame-parameter nil 'display)
> ":0"
> (call-process "xterm")
>
> So formally a tty frame has access to X11 server.
Can we reliably distinguish between X and Wayland this way?
> My summary:
> - To be really flexible (e.g. to support Wayland)
> `org-user-idle-seconds' should have an extension point allowing to
> specify elisp function.
Could you prepare a patch?
> - x11idle availability should be checked when X connection is detected,
> not at startup time and perhaps `locate-file' is better than "command"
> shell built-in.
Again, patches welcome.
It will be a marginal improvement.
> - (frame-parameter nil 'display) might be more accurate in addition to
> `window-system' check.
Do you mean (or ..)?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>