From: Ihor Radchenko <yantar92@posteo.net>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-x11idle-exists-p with emacs --daemon
Date: Mon, 31 Oct 2022 02:50:31 +0000 [thread overview]
Message-ID: <877d0gn1u0.fsf@localhost> (raw)
In-Reply-To: <tjl53g$17cf$1@ciao.gmane.io>
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>
next prev parent reply other threads:[~2022-10-31 2:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 22:31 org-x11idle-exists-p with emacs --daemon Julien Cubizolles
2022-10-28 3:08 ` Max Nikulin
2022-10-28 4:29 ` Ihor Radchenko
2022-10-28 4:39 ` Max Nikulin
2022-10-28 5:19 ` Ihor Radchenko
2022-10-28 4:28 ` Ihor Radchenko
2022-10-28 21:48 ` Julien Cubizolles
2022-10-29 2:54 ` Ihor Radchenko
2022-10-29 12:33 ` Max Nikulin
2022-10-30 1:33 ` Ihor Radchenko
2022-10-30 6:20 ` Max Nikulin
2022-10-31 2:50 ` Ihor Radchenko [this message]
2022-10-31 2:53 ` Change default value of org-clock-x11-idle-program-name (was: org-x11idle-exists-p with emacs --daemon) Ihor Radchenko
2023-01-24 12:41 ` [PATCH] Change default value of org-clock-x11-idle-program-name Ihor Radchenko
2023-01-26 15:43 ` Max Nikulin
2023-01-27 10:20 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877d0gn1u0.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).