From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id gHqoDDekjGLv1AAAbAwnHQ (envelope-from ) for ; Tue, 24 May 2022 11:24:07 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id yCVMDDekjGLFMwEAauVa8A (envelope-from ) for ; Tue, 24 May 2022 11:24:07 +0200 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 BE97E2A8D8 for ; Tue, 24 May 2022 11:24:06 +0200 (CEST) Received: from localhost ([::1]:38296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntQlp-0001QC-CC for larch@yhetil.org; Tue, 24 May 2022 05:24:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntPyL-0002Vd-8k for emacs-orgmode@gnu.org; Tue, 24 May 2022 04:33:00 -0400 Received: from ciao.gmane.io ([116.202.254.214]:50996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntPyJ-0004gz-Jj for emacs-orgmode@gnu.org; Tue, 24 May 2022 04:32:56 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1ntPyG-0002kU-NV for emacs-orgmode@gnu.org; Tue, 24 May 2022 10:32:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Julien Cubizolles Subject: org-clock idle time in pgtk Emacs Date: Tue, 24 May 2022 10:32:10 +0200 Message-ID: <875ylvnxf9.fsf@free.fr> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cancel-Lock: sha1:t8bASyFxoHycc9CUE0vhy8fI1hg= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653384246; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=l+1tvKLDyjar/PFnWCTFs/AF8wo9svN4gi6O3T7wAec=; b=ei+uz/gdeBOeVuOcjPZGOGJFCaJ81+EKn7Ru54ewdMvasdubT77hwtrpAuIrfVW6CKL3ig E+eofrcmJ2RHrbj57XCP+2KZ2PA+Rv4FBnP27okoi6ORWS2/QGG4NXsPjAUx/5HB8fCF7I rMuJHL59OiGKm1VE4csJtV380GVq2MG92yJ4tWyENlEMJbuLTCu+rPX7s5RYEvqbY4z1+X LdgVCWDdaAJmXhFA1cZLs2PDKvv8f+fik3MJc68mzs6DFEJGgWHm66oxlqlIX62bDFq7yx Wr7hO1h1Aa2SwTUEDH2o098W3J6vDfwodSWt6K9uI9J5QZKlqqCCoFViqXvZlw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653384246; a=rsa-sha256; cv=none; b=ZQxhS+DzDUbJzDf0L+SfUnZrZcXLRMNxVfK8fjONjq9Jpy0HWW/fDEJqegVsn4dEzJra7D yrla2laFgM7Utc3Car/M/WTcFUcug249tDqUvUVtgvjsM6pM1YE9w++owPon3ZK+mvEyjN jzNyG5k/oAASW2kdUWgv4YXZC81mxs1ftIEIlZjHRrD4OsQ9YThhPsnsEpGEumlY0l63jp GShEKQpfDkcFp94j/owD6F4cROYygVlcl6567dqEHZ3BPAPa1teuFV3/myID8Hc/sbW6UA Uwg2w8z1vFDrmvVIJn9t9kzcaee7V8EVth6LeDI5ooU6bGlqyoKvFuj6tvV13w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=free.fr (policy=none); 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" X-Migadu-Spam-Score: 1.85 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=free.fr (policy=none); 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" X-Migadu-Queue-Id: BE97E2A8D8 X-Spam-Score: 1.85 X-Migadu-Scanner: scn0.migadu.com X-TUID: 0ra3TDFJjknF 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