emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Julien Cubizolles <j.cubizolles@free.fr>
To: emacs-orgmode@gnu.org
Subject: org-clock idle time in pgtk Emacs
Date: Tue, 24 May 2022 10:32:10 +0200	[thread overview]
Message-ID: <875ylvnxf9.fsf@free.fr> (raw)

org-clock checks for the 'x window-system in order to use the program
set up by org-clock-x11idle-program-name. Recent Emacs versions use the
'pgtk instead of 'x and as such will default to using
org-emacs-idle-seconds in org-user-idle-seconds.

The following patch provides a crude workaround.

I'm using a python program (included below) to report idletime in
wayland, using the idle-time module. It can be used for
org-clock-x11idle-program-name.

--8<---------------cut here---------------start------------->8---
modified   lisp/org-clock.el
@@ -1196,7 +1196,7 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
 
 (defvar org-x11idle-exists-p
   ;; Check that x11idle exists
-  (and (eq window-system 'x)
+  (and (or (eq window-system 'pgtk) (eq window-system 'x))
        (eq 0 (call-process-shell-command
               (format "command -v %s" org-clock-x11idle-program-name)))
        ;; Check that x11idle can retrieve the idle time
@@ -1213,7 +1213,7 @@ This routine returns a floating point number."
   (cond
    ((eq system-type 'darwin)
     (org-mac-idle-seconds))
-   ((and (eq window-system 'x) org-x11idle-exists-p)
+   ((and (or (eq window-system 'x) (eq window-system 'pgtk)) org-x11idle-exists-p)
     (org-x11-idle-seconds))
    (t
     (org-emacs-idle-seconds))))
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env python3

from idle_time import IdleMonitor

monitor = IdleMonitor.get_monitor()
print(f"{1000*monitor.get_idle_time():.0f}")
--8<---------------cut here---------------end--------------->8---




-- 
Julien Cubizolles



             reply	other threads:[~2022-05-24  9:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24  8:32 Julien Cubizolles [this message]
2022-05-24 10:27 ` org-clock idle time in pgtk Emacs 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
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=875ylvnxf9.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).