emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Julien Cubizolles <j.cubizolles@free.fr>
To: emacs-orgmode@gnu.org
Subject: Re: org-clock idle time in pgtk Emacs
Date: Tue, 31 Jan 2023 17:24:37 +0100	[thread overview]
Message-ID: <87lelin03e.fsf@free.fr> (raw)
In-Reply-To: 87wnea15hy.fsf@localhost

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-clock.patch --]
[-- Type: text/x-diff, Size: 2641 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 219 bytes --]


> 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	other threads:[~2023-01-31 16:25 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 [this message]
2023-02-01 13:15     ` Ihor Radchenko
2023-02-01 15:45       ` Max Nikulin
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=87lelin03e.fsf@free.fr \
    --to=j.cubizolles@free.fr \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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