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 +KDHIfuaG2QluAAASxT56A (envelope-from ) for ; Thu, 23 Mar 2023 01:19:07 +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 2ISVIfuaG2RC2AAA9RJhRA (envelope-from ) for ; Thu, 23 Mar 2023 01:19:07 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by aspmx1.migadu.com (Postfix) with ESMTP id A892627BD7 for ; Thu, 23 Mar 2023 01:19:06 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pf6OY-0004aV-1y; Wed, 22 Mar 2023 17:53:22 -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 1pf6OV-0004a7-I5 for emacs-orgmode@gnu.org; Wed, 22 Mar 2023 17:53:19 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pf6OJ-0003xx-RS; Wed, 22 Mar 2023 17:53:17 -0400 Received: by mail-qt1-x834.google.com with SMTP id a5so2929477qto.6; Wed, 22 Mar 2023 14:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679521955; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=duwpQv+Lp0u0//441SIBi24JRiL25KHA3Eo4TcAiDuE=; b=F0S3DtvWqYw+hclyfY/dt+hmzoEfo8YGKbSZNehjaFGaODSkZPS9qck6juic4+qYSc EI+Q8qQFYJhJs5CryjT1Il2CI7+udb+RdCfuvtNxZYnoVA+tImwLlQDnLnwo5ThMK2wQ aZD3J6Xzftfg4UQynxWIhJPOSbi3cKzM/JP9QekdeoT7oOyI78PNPHP6mPUo95017nPs cwYzXOZbeXiwkRADFHc3NuuftUPhiHtmVYrfUBZVnjhtzSQ+51rq0xoLLR+8VNS466m4 1r8k4s72+s+wjFjaDyZi5xZPiNxYpzJ1vpfQ/PQukQocdYl1sKx6uwuaydi5kt5L1DGm FgvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679521955; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=duwpQv+Lp0u0//441SIBi24JRiL25KHA3Eo4TcAiDuE=; b=JpheG8sp3pXmlBrhV8b9S5hMKgz9yzxFyOWfIoJh6sK49OhDZrqEZ7g185ZnqeRRLu 7BBWNf3kCa4dVW4Ytn+707VnmXxEoqSmbrkAg+4c4FZx0qNj+84lB4JjCKXCYgiNa79V 6CPBgHx2AoixOssHh7g/ljXKIQNfL3UF/cfm9Jahe6SNXAgalyQHp9/B3F+Qnw7kO6QP /Dy66VPjX44SXsmZrvBmIzQ1fsaM4I4veg2XxbCOpCWY2l6nOdw/KrBVQkyOLoK9bZkG UdiQQNKgSQYcilGlpFKuolPm2omJYJCOgVFdmZnfhcQqbaKtpabGRQjCGh5GlaRb/6kQ IXjw== X-Gm-Message-State: AO0yUKX+XUaPmXH5lC/Xg9TYFeOsv7OjBvdTDpVUzWA6uF3vFwepnQww z2sAGyutrUszC7G13NZXHEkb3HM0t6Y5cOBM X-Google-Smtp-Source: AK7set9V2dn9DwM2AgprxBf/8uPa2hmxGkt/7KrPpgZffu3/yJvlKagv9EOzs263JvOzp8XS/cK8jg== X-Received: by 2002:ac8:5f84:0:b0:3e3:8e1a:c30b with SMTP id j4-20020ac85f84000000b003e38e1ac30bmr5080412qta.1.1679520056287; Wed, 22 Mar 2023 14:20:56 -0700 (PDT) Received: from entropy ([2601:241:8c80:25a0::1cfd]) by smtp.gmail.com with ESMTPSA id q62-20020a374341000000b0074589d41342sm12183105qka.17.2023.03.22.14.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 14:20:55 -0700 (PDT) References: <87a606njvc.fsf@gmail.com> <87h6udnfga.fsf@localhost> User-agent: mu4e 1.8.13; emacs 28.2 From: Nathaniel Nicandro To: Ihor Radchenko Cc: Nathaniel Nicandro , Bastien , emacs-orgmode Subject: Re: [PATCH] org-user-idle-seconds: Add support for logind Date: Wed, 22 Mar 2023 16:15:59 -0500 In-reply-to: <87h6udnfga.fsf@localhost> Message-ID: <875yaso53d.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=nathanielnicandro@gmail.com; helo=mail-qt1-x834.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: 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 ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679530746; a=rsa-sha256; cv=none; b=W9OciBqw5hgETaYNBM153uCFYD0IG9Z3HikidmVAAOY2SLzbgjNmfTF4PRHBkJoE/pkOLW ItM+H22iuvonz7BQ4lR20FufLBr9h5Io3nSkpOWJOumsJOX+sJ9pPFUXfIArcddp+I1FgM vS0BV3MMQ3r9kpoOKh9hJdt5x/om1QA/U5YEguZKHrpFj4914xhylt7KiNiqNsgf6TL5OK yaXyQ7o74qT7U+F1IOmuLuwSsK33iyTHnHDB0pVBJDHCZN2193lF4AfQNyhlwm5rygApIA hdtQgfl3ELytiogRawRmO8U1ZwNVqsA28cZlSBiH5gWsw6YGdojViBhxc8HR4w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=F0S3DtvW; 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=1679530746; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=duwpQv+Lp0u0//441SIBi24JRiL25KHA3Eo4TcAiDuE=; b=LbpAnWMZrp4wifmYon8kSZ/aQV2VZei3N0d3E+Pw4yToGoADkau4DPDzLMMFA68ghKlofl 9mGmztCyg0SKkHUx4NpzPkNI69WRKw6JJqPLynlgdIjT+jHyGGytL6RBAqdxxtyvjOqtfb nb3v3ghSVokb3QuCGjnYfowaycYz/B3iIyriOznTK44p4FW4v6/87caCagIzuXoIGAH65z LvIZAOEF3cwKm2GwV2ghWngxfhbtdRIXlV7FG6kkB9W8XH7ahLA3LbYS6lU++3JPVh86YH /tHi6cyeCafzrgjKfahfseuMnO2KB3HhRJQEqpCN9PdsPV5yyPjlyo1u3jOfog== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=F0S3DtvW; 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" X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -4.88 X-Spam-Score: -4.88 X-Migadu-Queue-Id: A892627BD7 X-TUID: 56zVclwkmIzH --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Nathaniel Nicandro writes: > >> 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. > > Thanks! > > Though I do not see any commits associated with Nathaniel Nicandro or > your email in Emacs git repo. > Bastien, may you check FSF records? > >> Let me know if any changes should be made. >> >> lisp/org-clock.el | 29 +++++++++++++++++++++++++++++ >> 1 file changed, 29 insertions(+) > > Please provide the commit message. See > https://orgmode.org/worg/org-contribute.html#commit-messages Done in the attached updated patch. > >> +(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)))) > > Please provide a docstring for the new variable. > > Also, this new feature is worth documenting in ORG-NEWS. Done. > > Otherwise, the patch looks good. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-org-clock.el-Add-support-for-logind.patch Content-Description: Add support for logind v2 >From 1cc887d1378839c3322c93ebb5a524499b8d3073 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Wed, 22 Mar 2023 14:54:57 -0500 Subject: [PATCH] lisp/org-clock.el: Add support for logind * lisp/org-timer.el (org-logind-dbus-session-path): New variable. (org-logind-user-idle-seconds): New function. (org-user-idle-seconds): Use them. --- etc/ORG-NEWS | 7 +++++++ lisp/org-clock.el | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 87ecd77..ef3a2ab 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -87,6 +87,13 @@ a date range in the agenda. It inherits from the default face in order to remain backward-compatible. ** New features +*** Add support for ~logind~ idle time in ~org-user-idle-seconds~ + +When Emacs is built with =dbus= support and +the =org.freedesktop.login1= interface is available, fallback to +checking the =IdleSinceHint= property when +determining =org-user-idle-seconds= as the penultimate step. + *** ~org-metaup~ and ~org-metadown~ now act on headings in region When region is active and starts at a heading, ~org-metaup~ and diff --git a/lisp/org-clock.el b/lisp/org-clock.el index f869b0b..323efa4 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,26 @@ (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))) + "D-Bus session path for the elogind interface.") + +(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 +1245,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 --=-=-=--