From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uPdDEWGJ2mPjpwAAbAwnHQ (envelope-from ) for ; Wed, 01 Feb 2023 16:46:41 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id WOlIEWGJ2mOwfQEA9RJhRA (envelope-from ) for ; Wed, 01 Feb 2023 16:46:41 +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 22048ED67 for ; Wed, 1 Feb 2023 16:46:41 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNFJI-00045n-K2; Wed, 01 Feb 2023 10:46:08 -0500 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 1pNFJE-0003pc-M8 for emacs-orgmode@gnu.org; Wed, 01 Feb 2023 10:46:04 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNFIz-0002HK-6D for emacs-orgmode@gnu.org; Wed, 01 Feb 2023 10:45:51 -0500 Received: by mail-pl1-x62d.google.com with SMTP id b5so11592491plz.5 for ; Wed, 01 Feb 2023 07:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:cc:to:from:references :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=pIRdXUHqzvZWcnyNtY2G0B95X5cmvIwhYNl8NO10ZQY=; b=WdEbUs4/90ihm3H9EnoVSy5y8DVIeeDo4W+LW4soRrXR3eviGRezqW7vEuwxxGlgN8 a4lr6omSo7ciicgTjUUkN6VoS0VydKLRVY9bOCTH/FLfAwKFkeBLhB2tE7PeG25k4YBk 7rklNxMw8ytE99cjdUrTkXfFUXtORB2T6BjiLh0xFsTg+umMch9C03fUSSIB1Sp3dq/V gWtKwSADOEEpRKCe3kjjQssrmnk13GZYTz4EAmjqtanGXDrMZPlC25LHf30P1l7JnKx9 SNl8gqqZrfhzm65tVeWCBOjo6aPvngBlfepbJnhZmL9Z4ZA245JFUhW9WOSym3unjB3E uIgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:to:from:references :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pIRdXUHqzvZWcnyNtY2G0B95X5cmvIwhYNl8NO10ZQY=; b=5qwnBppEtekTa/y/2gQBiiWYErKJdEWAQe+mGvdc8RKIuCHhQFIu0fgTMcTTLC8K4H hQa+G+hLrr2cGBKaVokQFXwxuLqA8C3LumUgDoI39UqwxDlQw8I251DS7onW5MaHECvo ZUTronPtB0O+r6JsNoLxuKBb5Drsid4eCCREM/TRf5vKg5R2bbnScUKHLjJPXIvuVgBb whAB4kd3vVvpVVNHf6xj/NfwmDLEyB4DugKkODZ935B8lb/6J5cn66fNGkN7Zra5Ews2 GrmQt+5ujQmLi4uGGbyjiHEg3UuLR/mklP1NMluqOrgo+dFbIYP6zo1+DUWrRiwbtBgW 54ZQ== X-Gm-Message-State: AO0yUKXV2I5IMi+zRPEG2825E4LXHVAUV58QoMq9rEkJmaWgSjCWGvH3 xUSjlCgREZfs4z/6xsyVHZsyYt9c854= X-Google-Smtp-Source: AK7set92ywbTRmTSRnCq3gCO4WiY3l9g68Fk5+SOlfZQNdFWRZr8aqi/H+oCJYwqA9AWRzkcdo/kkQ== X-Received: by 2002:a17:902:a513:b0:196:6496:85fa with SMTP id s19-20020a170902a51300b00196649685famr2886414plq.26.1675266346630; Wed, 01 Feb 2023 07:45:46 -0800 (PST) Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id s9-20020a170902ea0900b0019311ec72e8sm11542566plg.253.2023.02.01.07.45.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Feb 2023 07:45:46 -0800 (PST) Message-ID: <29c1766c-89cb-6898-f11d-5886144dff27@gmail.com> Date: Wed, 1 Feb 2023 22:45:42 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: org-clock idle time in pgtk Emacs Content-Language: en-US References: <875ylvnxf9.fsf@free.fr> <87wnea15hy.fsf@localhost> <87lelin03e.fsf@free.fr> <87y1phjzmg.fsf@localhost> From: Max Nikulin To: emacs-orgmode@gnu.org Cc: Julien Cubizolles In-Reply-To: <87y1phjzmg.fsf@localhost> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=manikulin@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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, NICE_REPLY_A=-0.09, 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 ARC-Seal: i=1; s=key1; d=yhetil.org; t=1675266401; a=rsa-sha256; cv=none; b=LXanEbZG0EVEMJ/4uVC9f1pnRK96leoLEhaT+HJ6vz5JzkttL7z+auqyf6B9rw5rKmH3wM zldT3iTE4WiVQotVv1udjcSMByLmjO51VBuuIBn7K+WQp4Y8LQPPtiuySlcdz/DpcqyS3A YlZ47b1cz8NRbppbRGM2Jsuwx3fLahmG1Phq8ZIsBE21I4kH5uVi2aToE36z3pG3HAe058 SyxzLudAo8feZBBSDK26gnLhjbiIpE6ywshtP0cKpUA5xu4qQIIMpv6TVQu0i7WSnRptAR CRoOQLfd7l5i0ZL0dpBiAI3cCJgUHz+iqMIQNr42N85sL1koN7j2Cn5E149PIQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="WdEbUs4/"; 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=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1675266401; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=pIRdXUHqzvZWcnyNtY2G0B95X5cmvIwhYNl8NO10ZQY=; b=XWxPEp94g2m69KeWG14Nx1SxctrbmQ82AzDvN9jw167iYh04EFOclBlktnLgIfgIV5VdEE KIMmnEIczOoh/DbJ3AxOUGVbpWI2BEUxqOvp+sTDLSpHi5sg54vcPhQn4B161gPTb+4UYB pjOqOPGasepwk/J9yPExACfRwg8/OBBa+L9eMrahFDIOxCdxq7EDLi8YUmFYk2zargALt5 40FRr9WIT2jtJz3TEJe3+H5nFJi0kcKMoOzvoyHfSwzTl7w85Bz1UeeZ8aZLiAzMU76uv3 3mDX2lYlQ8xmEbA5+mNRc6KPObD3gur659u4BrPw7K65jTvewPzt4XvrjxE+tQ== Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="WdEbUs4/"; 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=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: 7.62 X-Spam-Score: 7.62 X-Migadu-Queue-Id: 22048ED67 X-TUID: 0M1ww0wRpPLa On 01/02/2023 20:15, Ihor Radchenko wrote: >> +(defcustom org-clock-pgtkidle-program-name >> + (if (executable-find "jc-idle-time") >> + "jc-idle-time") >> + "Name of the program which prints idle time in milliseconds. > > May I know where "jc-idle-time" is coming from? Is it a built-in command > on wayland? During discussion in the later thread Julien Cubizolles to emacs-orgmode. org-x11idle-exists-p with emacs --daemon. Fri, 28 Oct 2022 00:31:23 +0200. https://list.orgmode.org/871qqs6gqs.fsf@free.fr I noticed a suggestion to use a d-bus method, unfortunately it is Gnome-specific https://unix.stackexchange.com/questions/396911/how-can-i-tell-if-a-user-is-idle-in-wayland/ dbus-send --print-reply --dest=org.gnome.Mutter.IdleMonitor /org/gnome/Mutter/IdleMonitor/Core org.gnome.Mutter.IdleMonitor.GetIdletime Another interface likely may give not really reliable results: org.freedesktop.ScreenSaver GetSessionIdleTime https://lists.freedesktop.org/archives/xdg/2007-March/009187.html Stephan Kulow. screensaver dbus interfaces. Mon Mar 5 05:16:39 PST 2007 Unsure if some workaround like in xprintidle should be used on this way: https://github.com/g0hl1n/xprintidle/blob/master/xprintidle.c#L150 * Workaround: Check if if XServer is in a dpms state, check the * current timeout for this state and add this value to * the current idle time and return. */ >> +(defvar org-pgtkidle-exists-p >> + ;; Check that org-clock-pgtkidle-program-name exists. But don't do that on DOS/Windows, >> + ;; since the command definitely does NOT exist there, and invoking >> + ;; COMMAND.COM on MS-Windows is a bad idea -- it hangs. >> + (and (null (memq system-type '(windows-nt ms-dos))) >> + (eq 0 (call-process-shell-command >> + (format "command -v %s" org-clock-pgtkidle-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-pgtkidle-program-name)))) > > We may as well resolve this FIXME since we are at it. > Instead of the awkward combination of two `call-process-shell-command' > prompts, we can simply use `executable-find' + `call-process'. Is there a reasonable way to avoid code duplication? I agree that `executable-find' may be better since `org-clock-pgtkidle-program-name' might contain spaces or shell specials causing issues with current code.