emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: org-clock idle time in pgtk Emacs


From: Julien Cubizolles
Subject: Re: org-clock idle time in pgtk Emacs
Date: Tue, 31 Jan 2023 17:24:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Ihor Radchenko <yantar92@gmail.com> writes:

>
> As Tim pointed out, we cannot guarantee that things working on 'x build
> will also work on 'pgtk. Instead of abusing settings for 'x window
> system, can you please introduce a new function org-pgtk-idle-seconds
> using a new variable org-clock-pgtkidle-program-name, similar to
> org-x11-idle-seconds, and then update org-user-idle-seconds?

Sorry for the delay, here is a patch to that effect.

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index ceb1fc833..81be37448 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -453,6 +453,15 @@ https://orgmode.org/worg/code/scripts/x11idle.c";
   :package-version '(Org . "9.7")
   :type 'string)
 
+(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.
+Case of a pgtk Emacs instance."
+  :group 'org-clock
+  :package-version '(Org . "9.7")
+  :type 'string)
+
 (defcustom org-clock-goto-before-context 2
   "Number of lines of context to display before currently clocked-in entry.
 This applies when using `org-clock-goto'."
@@ -1199,6 +1208,17 @@ If `only-dangling-p' is non-nil, only ask to resolve 
dangling
   "Return the current Mac idle time in seconds."
   (string-to-number (shell-command-to-string "ioreg -c IOHIDSystem | perl -ane 
'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle; last}'")))
 
+(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))))
+
 (defvar org-x11idle-exists-p
   ;; Check that x11idle exists.  But don't do that on DOS/Windows,
   ;; since the command definitely does NOT exist there, and invoking
@@ -1214,6 +1234,10 @@ If `only-dangling-p' is non-nil, only ask to resolve 
dangling
   "Return the current X11 idle time in seconds."
   (/ (string-to-number (shell-command-to-string 
org-clock-x11idle-program-name)) 1000))
 
+(defun org-pgtk-idle-seconds ()
+  "Return the current X11 idle time in seconds."
+  (/ (string-to-number (shell-command-to-string 
org-clock-pgtkidle-program-name)) 1000))
+
 (defun org-user-idle-seconds ()
   "Return the number of seconds the user has been idle for.
 This routine returns a floating point number."
@@ -1222,6 +1246,8 @@ This routine returns a floating point number."
     (org-mac-idle-seconds))
    ((and (eq window-system 'x) org-x11idle-exists-p)
     (org-x11-idle-seconds))
+   ((and (eq window-system 'pgtk) org-pgtkidle-exists-p)
+    (org-pgtk-idle-seconds))
    (t
     (org-emacs-idle-seconds))))
 
> Please, make sure that the pgtk option works on Wayland as well (or not,
> but we will then need to wait until someone tests the patch on Wayland).

It's working in Wayland, with a pgtk build.

-- 
Julien Cubizolles

reply via email to

[Prev in Thread] Current Thread [Next in Thread]