From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oHPuG+zcGWT1SQEASxT56A (envelope-from ) for ; Tue, 21 Mar 2023 17:35:56 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id QE7iG+zcGWSGbAAA9RJhRA (envelope-from ) for ; Tue, 21 Mar 2023 17:35:56 +0100 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 3FE682FE77 for ; Tue, 21 Mar 2023 17:35:56 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Cm7H6rXW; dmarc=pass (policy=none) header.from=gmail.com; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679416556; 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:dkim-signature; bh=NzJCE2dncrj0TIc6JIWuQDGe4GhvD10ymj1OlmKxp0U=; b=fU6YhV02XgND3bt4B9min06C73j7WnBNoZuhS/E2dVaztCEf0Qg4Gujqg9kDgWxLNWpqpa XfMkBfolmJELttoqokP4Mp71BeZcQFSjQ2e/luxODUjS9D66JrcsDBXi0hW6p80M84TK35 K2Jj5VgcuoBl8HR0sm+FeuG46zSOQ8A14PTkkIWBLHWGouALSioWEVzN7xPEARZRt/YGGS SUls18ev1Qw1r8faGdu0a9eLx12h1GQfWsrIra2Ir4MJDlKzYoOcfWpaXaVZMiAl3idnOq q/faeYwsg/Pp5ylFyXr6tsBgC5/BFw1uCyDb3T+Bhs2t1O7B8o9/5ZQ3JjxPgw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Cm7H6rXW; dmarc=pass (policy=none) header.from=gmail.com; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679416556; a=rsa-sha256; cv=none; b=QfmTBbT3Hh73ts7tAUH8biupJi1fiTXYW5QadaZeJp+3HBsv1bOicgNZ3pa1DC5Mv8jAjU qpgW0FXhk6SsdAZjXGBHnXw+ZCM9feefd/En3kIiEiIKFD4FmCfuejBE1+ouFNbXCTCJDL 3rym2Vo3aYCoTY+mZeYedSMUSFz9+Y/u6cdfcICRDpTnmqLvABvLSDl4XL9jRt5gy6Y+AO P0jB0UPncB31Axd+koKfNS8Kucq7UIy7ldbK7X5gqrsZYkNHVNVE40LGowR5ai+tD2t3ik mpX8n7firzUMT4vn0M9HUNXkglt9H+a+1hf4ESMXpBQFNYhZmmB+9xr1VgBQkQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1peewn-0005pf-Vo; Tue, 21 Mar 2023 12:34:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1peewn-0005pX-5L for emacs-orgmode@gnu.org; Tue, 21 Mar 2023 12:34:53 -0400 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1peewl-0007Gg-HO for emacs-orgmode@gnu.org; Tue, 21 Mar 2023 12:34:52 -0400 Received: by mail-qt1-x835.google.com with SMTP id c10so7373008qtj.10 for ; Tue, 21 Mar 2023 09:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679416489; h=mime-version:message-id:date:subject:to:from:user-agent:from:to:cc :subject:date:message-id:reply-to; bh=NzJCE2dncrj0TIc6JIWuQDGe4GhvD10ymj1OlmKxp0U=; b=Cm7H6rXWwLFWOtWcj3nv960wnIJznXRg08fxKiEmAtIx4nCT6iOEbPC4MgeH6k2z+T +qtbhxIVTwkc+lN62bXmnx5FkJgmtmh2P51q1J56RiCE7kAdQPnDT6sdOfx9johuP8iJ Fzyf36nBSEBp3hgKxuAvjVcedmAH9uxPRCL33go7T+U49B3IwBzDQqxa5eqlidTse4a6 h46Wyenjv0C872w9eOW+PnFjnjzCFjpmSpMNIqUkON93E8jTyc+28vXsQiet2QiJDp/I U+LdyApyt74Nw+CmYnD4y2/WaNpCSAhVQHMjLlBWSDXee3G9/0xUplrxJL/3TFnNOLcQ EujQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679416489; h=mime-version:message-id:date:subject:to:from:user-agent :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NzJCE2dncrj0TIc6JIWuQDGe4GhvD10ymj1OlmKxp0U=; b=B1+XWdClF6YTyW5/Y4CtZ5llob3efJgJfI5/55RemMnKtz/hDYolnk+qUPKU8U+5Mo DpgsevRs9A65YESPd1bT2mKn0mEaGYA8YqFyvBfxyRTwaaob3Rzb/kd4dL+7+MzRD+Yx 0YS3JycCjDHtF92gAFHxKrcn47GZdcPUhYga7o3c0K2sNiaIFn+mJ/hP4TuoHBxQEIUe pMwZdZ471cGi7CBVJK92KO1HynGVbr5t1Ynxxb4Q7yazrkAzY3GaOYeJBTL3zdbDH1ww NF1Rihd1NRcSi1qR4158Lf2QBD1aV85fx2d5NQhszVItjwKB5wK5Gr84MHaMFqVzd3pL vdWQ== X-Gm-Message-State: AO0yUKVvpma+QdDUAZi3jhfzI7yB4B8zZqbRLRVe19oV/8X6cfxjhEOR tCAf2OawRc4JwmZx0T1cpULMDmav9KU/Lw== X-Google-Smtp-Source: AK7set95vzkKdB7G/H95H+ZpwVxI839smTsjxKrmowk0ThEN0vG6kmqUsud9C03aBzSowrlw79fzPQ== X-Received: by 2002:a05:622a:1a17:b0:3e3:7ed0:d6df with SMTP id f23-20020a05622a1a1700b003e37ed0d6dfmr6012273qtb.6.1679416489284; Tue, 21 Mar 2023 09:34:49 -0700 (PDT) Received: from entropy ([2601:241:8c80:25a0::1cfd]) by smtp.gmail.com with ESMTPSA id i22-20020a05620a249600b0074411b03972sm8555689qkn.51.2023.03.21.09.34.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 09:34:48 -0700 (PDT) User-agent: mu4e 1.8.13; emacs 28.2 From: Nathaniel Nicandro To: emacs-orgmode Subject: [PATCH] org-user-idle-seconds: Add support for logind Date: Tue, 21 Mar 2023 10:39:52 -0500 Message-ID: <87a606njvc.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=nathanielnicandro@gmail.com; helo=mail-qt1-x835.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: X-Migadu-Queue-Id: 3FE682FE77 X-Spam-Score: -7.49 X-Migadu-Spam-Score: -7.49 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: 7bCNg3VPVW5Q --=-=-= Content-Type: text/plain Hello, I would like to submit a patch that adds support for logind to `org-user-idle-seconds`. This patch has been working for me for a long while now and I thought it time for me to submit it. I've contributed to Emacs in the past so my paperwork should be on file. Let me know if any changes should be made. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=logind-user-idle-seconds.patch Content-Description: org-user-idle-seconds: Add support for logind seconds lisp/org-clock.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index f869b0b..9d34a72 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -51,6 +51,9 @@ (declare-function org-table-goto-line "org-table" (n)) (declare-function org-dynamic-block-define "org" (type func)) (declare-function w32-notification-notify "w32fns.c" (&rest params)) (declare-function w32-notification-close "w32fns.c" (&rest params)) +(declare-function dbus-list-activatable-names "dbus" (&optional bus)) +(declare-function dbus-call-method "dbus" (bus service path interface method &rest args)) +(declare-function dbus-get-property "dbus" (bus service path interface property)) (defvar org-frame-title-format-backup nil) (defvar org-state) @@ -1214,6 +1217,25 @@ (defun org-x11-idle-seconds () "Return the current X11 idle time in seconds." (/ (string-to-number (shell-command-to-string org-clock-x11idle-program-name)) 1000)) +(defvar org-logind-dbus-session-path + (when (and (boundp 'dbus-runtime-version) + (require 'dbus nil t) + (member "org.freedesktop.login1" (dbus-list-activatable-names))) + (dbus-call-method + :system "org.freedesktop.login1" + "/org/freedesktop/login1" + "org.freedesktop.login1.Manager" + "GetSessionByPID" (emacs-pid)))) + +(defun org-logind-user-idle-seconds () + "Return the number of idle seconds for the user according to logind." + (- (float-time) + (/ (dbus-get-property + :system "org.freedesktop.login1" + org-logind-dbus-session-path + "org.freedesktop.login1.Session" "IdleSinceHint") + 1e6))) + (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 +1244,13 @@ (defun org-user-idle-seconds () (org-mac-idle-seconds)) ((and (eq window-system 'x) org-x11idle-exists-p) (org-x11-idle-seconds)) + ((and + org-logind-dbus-session-path + (dbus-get-property + :system "org.freedesktop.login1" + org-logind-dbus-session-path + "org.freedesktop.login1.Session" "IdleHint")) + (org-logind-user-idle-seconds)) (t (org-emacs-idle-seconds)))) -- 2.39.1 --=-=-= Content-Type: text/plain -- Nathaniel --=-=-=--