From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id oKP9LB/xKGV5NQAA9RJhRA:P1 (envelope-from ) for ; Fri, 13 Oct 2023 09:26:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id oKP9LB/xKGV5NQAA9RJhRA (envelope-from ) for ; Fri, 13 Oct 2023 09:26:23 +0200 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 6988B370A4 for ; Fri, 13 Oct 2023 09:26:23 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Cq9fGScP; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1697181983; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=JIJW5i+YNytrzZ4nJde9FJucDLPzYWVuyIKoZbAooUU=; b=fBcy2ubp7fuKay/Q8a8HyfmYWnSUyzydUIVHJ3QbLAJrQZxwqKjHCMd6QCDL9FlLNrc6jS OCO52XoJhKG/lKHkjQwIAZ/hQgx5bJ/S0ruuOFYKAlY48oT4i2NhM83mC0xnbrbVBVk7ph +BM7q11ogWm0I79KpA4BPyqvzqeiOHUAJl0hxagvud5BmTxnuHUSxGHJ4JLJAMuWcW/sUE xVf1EDDMx95TooNgjvVMcahwqg8xk6WVZ+Zob1BJxJ4lfdgBPBm89FrtJa9HRRgsi1hZgG Zb9DRlAy6LC3HnE4IOYk3u/ZJWE7ZIJ4aDZr6ng/r4y2PX1GPET5J34rsbIPsA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Cq9fGScP; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1697181983; a=rsa-sha256; cv=none; b=kiqYzkkhFwAblConr1CwfrSEHrJJTk4K7Jo7GRMtcRpzsQRoxc9wJQfW1eGIquyv30VL3j Ti8g+HBSbpO9AtQTgTTmxozErJycwEhOtfvkZR4Aa7KCqGupvTM+ftwOTvzeJwSVi75Nd7 wpii2RRKoKzVZvDnxOQ2BIgXDV7ApwqkGerGxBZGOyFz478XKsvITHiK7lsdlkUiFkRGfT 8UNtoX3R3wHVFGnUNnzmTB5GpfpsYCr2fIiDCNS+p8eQQj12kiieYiv5kEDE247nlEIfuD S0nVtNvNVG3IEEcxQWRPWS6N9vJi/HQdAYPd/Owa2N6FaRtsPt6pxHHmKq+uSQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrCY1-0007LF-4T; Fri, 13 Oct 2023 03:25:25 -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 1qrCXy-0007Ky-4v for emacs-orgmode@gnu.org; Fri, 13 Oct 2023 03:25:22 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrCXw-0008D3-C8 for emacs-orgmode@gnu.org; Fri, 13 Oct 2023 03:25:21 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1ca052ec63bso1600505ad.1 for ; Fri, 13 Oct 2023 00:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697181917; x=1697786717; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:user-agent:from:to:cc:subject:date:message-id:reply-to; bh=JIJW5i+YNytrzZ4nJde9FJucDLPzYWVuyIKoZbAooUU=; b=Cq9fGScPDhZ5BXuZ8mKKXYSSFsIxo0GtuyN7oTaN/p62HqAp6EFB/p0RCtV0uq380Q ZAZ/TzgTJqgMqIANmdHjJgkFvMNmdGFz37ZAI2s9LZD+rRDVFun69vva3GTEr9aKVwLG I5xP+hiYE2f7Y4hQPy80hvTFJPzif9StvttvY7SNAtnYQPdH+JUsomn7BFeZ+A3MCn/h xqsLc6IgasmMtFQpk2DkWeBq0akDsUgCctoNmEdkWhgwTBG3OTWMWIMkr41uznEmQqj4 o9SNyj1K0k1nqs4rw/z5LfRYPz4nBVddg2AxH8RaikBIHzrh/x/hydTTZPparB+fS9jr b3oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697181917; x=1697786717; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:user-agent:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JIJW5i+YNytrzZ4nJde9FJucDLPzYWVuyIKoZbAooUU=; b=Wyy7bYCGZYT7Hpdjcqcei1QDbgJGw+EvML/5p0U2Do5YZy3YWApfOQ1BtHPwwwpWYV hnhbs1qGGST91ulPxFvxLQZqmxUPzfwXMZOI/KKshTD2S0r/gE8Tcxh/YogAObKOXGCD T7syMAzoK1kIj9V44M5Vpfxk/8zhYHZYxPR9gSPF44yLLdGVEVKEsB1THmQ8YGhmQkYC LtcKyi0JmO7SRiV4dWHTcvi/wRIwW5l+xJ53Y8BvoyAlRxW9oMNnBTx6X8MYA5IjNuDs 7wS3QfKH7uWHkfyGFW7UymrP3K4VbFM9LhYVWU8BzAGhZriSi6rIHr5SdPMAdgy5ZBiz QMrA== X-Gm-Message-State: AOJu0YyWYB7vrv7wEke+VFSbyHBbso0huX07tiEwAGMyR3qXB9AwVLul H9L93AQhD4dTdJ6KHs910LUK1uO6zHE6hg== X-Google-Smtp-Source: AGHT+IFISDlixfoKRXJJykF6XFfTRAuH9PG3PZMLXounBs9CnGFTStlW9Kc4YZ6XMI2F3j1lZb9gmw== X-Received: by 2002:a17:903:248:b0:1c7:495c:87e0 with SMTP id j8-20020a170903024800b001c7495c87e0mr31427136plh.37.1697181917225; Fri, 13 Oct 2023 00:25:17 -0700 (PDT) Received: from laptop.lockywolf.net ([2001:470:24:315::102]) by smtp.gmail.com with ESMTPSA id j6-20020a170902da8600b001b9e86e05b7sm3195102plx.0.2023.10.13.00.25.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:25:16 -0700 (PDT) User-agent: mu4e 1.10.7; emacs 30.0.50 From: Vladimir Nikishkin To: emacs-orgmode@gnu.org Subject: [BUG] org-clock-auto-clockout does not actually use x11idle on X11 [9.6.8 (release_9.6.8-3-g21171d @ /usr/share/emacs/30.0.50/lisp/org/)] Date: Fri, 13 Oct 2023 15:02:32 +0800 Message-ID: <87ttqv6l2g.fsf@laptop.lockywolf.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=lockywolf@gmail.com; helo=mail-pl1-x62a.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -9.18 X-Spam-Score: -9.18 X-Migadu-Queue-Id: 6988B370A4 X-Migadu-Scanner: mx2.migadu.com X-TUID: H0lveuyyl40+ For some time I have been wondering why auto-clockout does not use x11idle on my machine. Today I finally got to studying this issue. Here is `org-clock-auto-clockout-insinuate' #+begin_src elisp (defun org-clock-auto-clockout-insinuate () "Set up hook for auto clocking out when Emacs is idle. See `org-clock-auto-clockout-timer'. This function is meant to be added to the user configuration." (require 'org-clock) (add-hook 'org-clock-in-hook #'org-clock-auto-clockout t)) #+end_src Okay, the only thing it does is it adds a hook. What does the hook do? #+begin_src elisp (defun org-clock-auto-clockout () "Clock out the currently clocked in task if Emacs is idle. See `org-clock-auto-clockout-timer' to set the idle time span. This is only effective when `org-clock-auto-clockout-insinuate' is present in the user configuration." (when (and (numberp org-clock-auto-clockout-timer) org-clock-current-task) (run-with-idle-timer org-clock-auto-clockout-timer nil #'org-clock-out))) #+end_src just runs auto clockout on an emacs idle timer, which does not care about X11 idleness either. It also runs only once, since the seconds argument is nil. #'org-clock-out does not use x11idle either. So, at least in Org 9.6.8, the Manual's claim that #+begin_quote (1) On computers using macOS, idleness is based on actual user idleness, not just Emacs=E2=80=99 idle time. For X11, you can install a ut= ility program =E2=80=98x11idle.c=E2=80=99, available in the =E2=80=98org-contrib/= =E2=80=99 repository, or install the xprintidle package and set it to the variable =E2=80=98org-clock-x11idle-program-name=E2=80=99 if you are running Debian,= to get the same general treatment of idleness. On other systems, idle time refers to Emacs idle time only. #+end_quote is false. I suggest rewriting that timer expression like this: #+begin_src elisp (run-with-timer 60 60 (lambda () (if (< org-clock-auto-clockout-timer (if org-x11idle-exis= ts-p (org-x11-idle-sec= onds) (current-idle-time)= ))) (org-clock-out) nil))) #+end_src or, even better: #+begin_src elisp (defun org-clock-auto-clockout-maybe () (if (< org-clock-auto-clockout-timer (if org-x11idle-exists-p (org-x11-idle-seconds) (current-idle-time))))) (defun org-clock-auto-clockout-insinuate () "Set up hook for auto clocking out when Emacs is idle. See `org-clock-auto-clockout-timer'. This function is meant to be added to the user configuration." (require 'org-clock) (add-hook 'org-clock-in-hook #'org-clock-auto-clockout-maybe t) (add-hook 'org-clock-out-hook (lambda () (cancel-function-timers 'org-clock-auto-clockout-maybe)))) #+end_src Emacs : GNU Emacs 30.0.50 (build 1, x86_64-slackware-linux-gnu, GTK+ Versi= on 3.24.31, cairo version 1.16.0) of 2023-09-22 Package: Org mode version 9.6.8 (release_9.6.8-3-g21171d @ /usr/share/emacs= /30.0.50/lisp/org/) --=20 Your sincerely, Vladimir Nikishkin (MiEr, lockywolf) (Laptop)