emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Cc: Julien Cubizolles <j.cubizolles@free.fr>
Subject: Re: org-clock idle time in pgtk Emacs
Date: Wed, 1 Feb 2023 22:45:42 +0700	[thread overview]
Message-ID: <29c1766c-89cb-6898-f11d-5886144dff27@gmail.com> (raw)
In-Reply-To: <87y1phjzmg.fsf@localhost>

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. 

I noticed a suggestion to use a d-bus method, unfortunately it is 

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

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:
  * 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.

  reply	other threads:[~2023-02-01 15:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24  8:32 org-clock idle time in pgtk Emacs Julien Cubizolles
2022-05-24 10:27 ` Tim Cross
2022-05-25  6:38 ` Ihor Radchenko
2023-01-31 16:24   ` Julien Cubizolles
2023-02-01 13:15     ` Ihor Radchenko
2023-02-01 15:45       ` Max Nikulin [this message]
2023-02-02  9:17         ` Ihor Radchenko
2023-02-03  5:55       ` Julien Cubizolles
2023-02-03 12:17         ` Ihor Radchenko
2023-02-03 15:07           ` Max Nikulin
2023-02-04 11:04             ` 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:

  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=29c1766c-89cb-6898-f11d-5886144dff27@gmail.com \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=j.cubizolles@free.fr \


* 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


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).