From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id eOnpIpnUXWM2oQAAbAwnHQ (envelope-from ) for ; Sun, 30 Oct 2022 02:34:17 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MPdCIpnUXWNl/QAAG6o9tA (envelope-from ) for ; Sun, 30 Oct 2022 02:34:17 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2DC4E2EAE0 for ; Sun, 30 Oct 2022 02:34:17 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooxC6-00007o-EO; Sat, 29 Oct 2022 21:32:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooxC3-00007I-Ue for emacs-orgmode@gnu.org; Sat, 29 Oct 2022 21:32:55 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooxC0-0005Bi-Nz for emacs-orgmode@gnu.org; Sat, 29 Oct 2022 21:32:55 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id EE7B5240101 for ; Sun, 30 Oct 2022 02:32:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667093568; bh=VOrsaUfAhPpwQJ3lcnkZrFVxvoeJqBEPTrBS7BZU+MM=; h=From:To:Cc:Subject:Date:From; b=gmjdJsokY72QKVXw/mESQmNjEWLOkl/dPqM20yiqbzELX/knsClxjfLD4d5XEREgP NPWeuhiFHh+PjLYLCvvY4vN/pUoZQCCRjcPKydsAgqbyvCEHGodZSLm+9JPOaDwx2h pLgDxEAOYZU/AXGnzlRlfljkfKWobl9sSVCpMxLDp5tZLxwVfU4iiNp8f243lI6EHl sg6czuOK1qPvhH5/ow3WNEXX6C3jdqmkr8PuncaHQO+zIHIGdgRYIXjdIDYoID9Ys7 sZFjqTt6j7UuvFCujQ/eklG1K6XaeAgXRnBYZatA4oZIjLxq+RFF9kAZ8xCYw1RN1G cAGpQpBhBLqRQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N0Jgf4mK5z9rxD; Sun, 30 Oct 2022 02:32:46 +0100 (CET) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: org-x11idle-exists-p with emacs --daemon In-Reply-To: References: <871qqs6gqs.fsf@free.fr> <87y1t0lgfo.fsf@localhost> Date: Sun, 30 Oct 2022 01:33:30 +0000 Message-ID: <87mt9egknp.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1667093657; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=jCy86GnkGj7Mkv/z02fF0HGq/AZPiKU8EFahRedLF1k=; b=bkjaXk3rWkah4tTovVo0acE8CuQ67lLur0GNAOQUG23QiwZET/sEyjMdJpWPMymoss2olq 8jRvq0lxyuh9Gj0X1SxRN9onk32y3XGcwC4H7j66rPPkN+Tw0o6VG1vAYgXyOppHHZOO0I HYsEnW3FvR4gLmvZ5ECUxsWdRMX11xtbozxyqTSK0Zer/qqZGdsTEwt7d6VPstymJ+3wwc ao763Pa267kPD6TNw8nn9R6ovpiPQbU+NqnLPptVu+/5FCtaBichLYGirzlW4FwB2vvzom K8g+eLhS0v+CL/QjSg85yI0tyP6PyoMytpi2WyL56nRu8dVl6XtDo50IGXqx8Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1667093657; a=rsa-sha256; cv=none; b=PXvlMFXn+HjY8pB8A6Ix62sS4EprCRYBrIA6s8G6CKixIvNkYd7EGuJpk1I/1jEyZJkjUA dCmmZTS0cG7Vz4pFwhimXCDZzTbwh3wmAvFfcA2OOj3HxpsIDR3MsaJUQPDtOkHJScXFi5 tJL3WPmoAv7Xt2H3FtVhgmk9zQ25hypda690ZedOm90MU8MThM8Iq5bUDkBqLxtUcl22r2 6AV8EcZpnojkg6rjHZw5QWBGFZB6qFoXIhNu+dFrJhaTAoT12WkEdMiYkEDeSEOpf8b7DN xJb07YH8jTq7edtG0yQ6xosQYJwJK/BgQu/w5gFI6Lb+rDwOu7bopNHhMbWDcQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=gmjdJsok; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -8.74 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=gmjdJsok; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 2DC4E2EAE0 X-Spam-Score: -8.74 X-Migadu-Scanner: scn0.migadu.com X-TUID: GLuOlDzjO22E Max Nikulin writes: > On 28/10/2022 11:28, Ihor Radchenko wrote: >> >> * lisp/org-clock.el (org-x11idle-exists-p): Do not check if load-time >> `window-system' is `x'. Instead, rely on the check in >> `org-user-idle-seconds'. > > I would say that even there it is not strictly correct to test > `window-system', perhaps `x-display-list' is a bit better since > particular frame may be a terminal one running in xterm, but user has x > frames. I am not sure here. Let us first establish the purpose of all this fiddling with idle program. `org-user-idle-seconds' is aiming to find the actual idle time of an Org user. Not just in Emacs, but also in other places. That's why the fallback `org-emacs-idle-seconds' is not the most accurate, and we are trying to use other, more accurate, means to determine idle time. `org-user-idle-seconds' uses system command to determine idle time, when possible. On Mac, such command is always available. On X11, Org defaults to https://git.sr.ht/~bzg/worg/tree/master/item/code/scripts/x11idle.c script that will fail to work from non-X frame, AFAIU. So, I do think the `window-system' is the right way to invoke x11idle at least. Terminal frames may not have access to X11 scope and thus will not be able to determine the real idle time. Not to mention that terminal Emacs may not be running on X and even successfully getting idle time will yield erroneous results. > In server.el I found > > (frame-parameter frame 'display) > > that might be even better and should work with daemon having a single > frame in xterm. I can not figure out if --display command line option > affects some variable of Emacs daemon. I do not understand. I just tried to check the value of `window-system' in terminal Emacs frame and in X11 Emacs frame running using the same Emacs daemon. The value in X11 frame is 'x and nil in terminal. So, `window-system' already accounts for current frame. > Another tricky case is multiple x connection to different displays. It > seems GTK3 have some limitations (pgtk build) and such rarely used > configuration will become completely obsolete. Multiple X connection means non-deterministic idle time. Each individual X server will have its own idle time. The current approach with running `org-x11-idle-seconds' in current frame is the most reasonable in such scenario, IMHO. >> diff --git a/lisp/org-clock.el b/lisp/org-clock.el >> index e98a34f0d..ca026c44f 100644 >> --- a/lisp/org-clock.el >> +++ b/lisp/org-clock.el >> @@ -1201,8 +1201,7 @@ (defun org-mac-idle-seconds () >> >> (defvar org-x11idle-exists-p >> ;; Check that x11idle exists >> - (and (eq window-system 'x) >> - (eq 0 (call-process-shell-command >> + (and (eq 0 (call-process-shell-command >> (format "command -v %s" org-clock-x11idle-program-name))) > > I joined to this discussion presuming (by some confusion) that such > variable should be lazily initialized on first call of > `org-user-idle-seconds'. I considered `window-system' test as a way to > distinguish GUI and text Emacs sessions. Actually such parameter is > dynamic. Remotely running Emacs may be disconnected from one X server > and connected to another session. > > Actually `window-system' check has another role: skip command > availability test on systems other than Linux. > > What is the result of "command -v" on Windows? Should it be executed > there at all (unconditionally at load time)? It will fail and the value of `org-x11idle-exists-p' will be nil. I do not see any problem here. > P.S. There are a number of X11 servers for Windows. I am unsure if Emacs > builds for Windows and X11 frames are supported. I am lost how to > properly test such cases in the code. We do not care. We check if idle program works by calling it. If it fails (due to command being not available or not supporting the X11 server), we fall back to safe approach using Emacs idle time. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at