X-Loop: help-debbugs@HIDDEN Subject: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake Resent-From: Andrew Cohen <acohen@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 20 May 2023 23:25:02 +0000 Resent-Message-ID: <handler.63620.B.168462508612787 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 63620 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 63620 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.168462508612787 (code B ref -1); Sat, 20 May 2023 23:25:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 May 2023 23:24:46 +0000 Received: from localhost ([127.0.0.1]:59603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1q0VwL-0003KA-Hn for submit <at> debbugs.gnu.org; Sat, 20 May 2023 19:24:45 -0400 Received: from lists.gnu.org ([209.51.188.17]:57678) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <acohen@HIDDEN>) id 1q0VwJ-0003K3-Ly for submit <at> debbugs.gnu.org; Sat, 20 May 2023 19:24:44 -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 <acohen@HIDDEN>) id 1q0VwJ-00017Z-Fb for bug-gnu-emacs@HIDDEN; Sat, 20 May 2023 19:24:43 -0400 Received: from mail-tycjpn01on2072a.outbound.protection.outlook.com ([2a01:111:f403:7010::72a] helo=JPN01-TYC-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <acohen@HIDDEN>) id 1q0VwG-00049d-TQ for bug-gnu-emacs@HIDDEN; Sat, 20 May 2023 19:24:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HX38iqiWiqFuKIloy5/IXWANRw7zbtlsUqqLCMtthXbI/uM/y+yPOsF5mglOQNzDDMPkYENV+6gePVflFK5mV4Ybh1prb2akOPtaSjX9veZgbKTGAsqGFCe5EUmI1Enl4ABlrx9F8Pavt8DUEIMa+VafJ3SPaUwF9wOCKBgcMR1MnlFWazcDH95CzkzH3hV3HbwGzR5y7m2Rq5SaRF4gZxqrJlVPu6TFO38XTbvqcezyYqnIkwhiUZFLSokClKCQH9IFFDsUKNQckLHo2m4tepICZotUHRj4c87mp+nuYqFH76lzVzT2rcuqJUBF4dT1/W1giTuqX8BT0HXwVpQweA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R/vMerENyhLB6MqkxKTPylMxzGx5V+YRFPXpXZosGoA=; b=adK6UwboLUaGVoeM8mYLft3RV0CiUZmHHHs697qqQg/UXyLH2VzBQ2X06nX23aU+UiDz3OeHCdd4UWjWkkVAVBFWCLElCcuMg4tQIaovkzKb6XPgX+BWZcdZish3DNkgkJE6kX5vfB4Yb5Tb9UY1iqapHVQy4qz46Hsci8o5yLkvxN8HOiSBEb+ZZ+OE7L+DG7SZVbBzf7/PuakjuxB80P4tHB3bt+IPLkek9NTvdrgBKcdokTDaOgbpjvLJKf/i5puuavxyFL7cpXPAl/uCBIpLhB71mvOkCLa9qegkJtmQkP+NHXiMK1GWWWQynAPx7sgig05XHRI1taYlw/AvCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ust.hk; dmarc=pass action=none header.from=ust.hk; dkim=pass header.d=ust.hk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ust.hk; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R/vMerENyhLB6MqkxKTPylMxzGx5V+YRFPXpXZosGoA=; b=bhYFJqm0V/5OOpDLJMAHbw+/4Z9+qsKRUI6hMbN34qsxSbnrUePlzsBMOxqRC1WwADcwiT9qjbq1Ulo1D1xSbNMvrtWuWSDcnjXOoiR+KCD0YEZMlMyrqnXBQtkNitpnpJqTEfBkeC9b0orA0iIlU7y1KNxfhpKDLnThI0WuA5NgMp3MeyZbyytflW7M56eeHz78yoKLe+fh7GwQXFdtIcnsJGmYMj8GNqQc6LRWfV8uP9zzN4ri4mHIRg4YUcIRr13nPk4Hcyw7CdCW/HIeVQMal/X0KGN9Z8CgQ8hv0i038EPPtyFbcKiG7JhOS5gGqbpICt49Sbtd7ewAaIWGEw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ust.hk; Received: from OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1bf::11) by TYWP286MB1959.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:164::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.27; Sat, 20 May 2023 23:19:32 +0000 Received: from OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM ([fe80::c1ac:edec:7164:36ec]) by OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM ([fe80::c1ac:edec:7164:36ec%7]) with mapi id 15.20.6411.025; Sat, 20 May 2023 23:19:31 +0000 From: Andrew Cohen <acohen@HIDDEN> Date: Sun, 21 May 2023 07:19:27 +0800 Message-ID: <87fs7qmw00.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: text/plain X-ClientProxiedBy: SGAP274CA0022.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::34) To OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1bf::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3P286MB1877:EE_|TYWP286MB1959:EE_ X-MS-Office365-Filtering-Correlation-Id: 787eba8d-a9b5-47ad-ac5c-08db5988aa95 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8cPUqa/znd24Sk+T/VAVRciHMy3tNClwNkgRdgt+o6HB8102+ldQWCfPlkZWo8/7AEmib7Tfq5hwDqOGETwU/VMGApPi4xz03/6Tkd+PMANuwd+Yq269v8FGQpgBxLW4iaoUl7Si+kgyszMbyvj/DiXZpcy8sOKqB3zIzkUr/h5alPtokcUu2LFaV+7oLu36H37+dCQEieBrNb/BXAjFdI4jVSMxu3W0yurajkbAEr3Q39FE5mU5DW7qOTfsBpMG+yyYHg2j8wzPyvP84jlL2SNA5ak71xa2k9zLEf/sfIemG4a2DwJE2yfxdbhybsslOOoQXIfWVB+mqvQjTbp2wZIVK1DOSm4CdueXPCfnrSm7yZhWSZaN1HkQ0/xVeMwEr15JhPWDeQiwHFyzSVgrnlUikiixhf8vukm09Pl8FebNy56uaHTBFQ+sw7PEAjk7WaIBkcB0sJJNmoBJkix54J3B+jUJADSijE6b3nxeD7aoFAC6/qYCtHi23bWULLDcYCJMdbVLuxabK9yoEOOml69AAWTCVLqPNLkFStkFy97gZFqkJ84VjFpYpzrreaEW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(376002)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(41320700001)(38100700002)(2616005)(6506007)(83380400001)(26005)(6512007)(186003)(8676002)(8936002)(36756003)(86362001)(316002)(786003)(41300700001)(5660300002)(6916009)(6486002)(6666004)(66476007)(66556008)(66946007)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9rq8D0krlsHKM1nDvg3Vuw0QJS5/XvyTFjK55TIcVBvl84zpT5otFlSV/Zfhhq/g9+GkL6Mh37eGS8b/PCEc+Mo8G8L34RsxOaiZACKJHskTFhy9ZSCTmH3HrGoSNQFG+/IbexkgGmv3YvM98LvYVyhhoSuxKiWFi2WaLNKufFyFHkVvvRl0J3fcKVb78VRAcHc2zRXErQxON5tD+LGkr41RIfqP0gyx8LkwFhgX4VNJh4tGWoYYn/ftheSHkx/1qj4tGTC10jnFmve6UgEVxs9K10mElkb/MMNlcz/wCs5cqlZgmCb+6oICtzEc8FcUU/PzBwDJ7cJLqbVx9tCQsWER6sTqAAIC/sGAIGK95wRPQc6AxgeduRZKZOp7X8y9lDAF10fY54Hc+juFQ9+RR8uhSdYMsR5s7UmRhXnTCH7m6mzKNPeHSqpDZvd2eP7TZVSd9oV6roBg+psGECv1hQ3/pwOvMxAktfZxBS0TYAafHp/QP4DssivcAKJjP4FL/aluB9kNlsaJ+jpGZu0gE6dAcA8XV9J0L95bUUFBP23TfBTgF8fDgxoI+BsGqWeiyJ6VVpzMfZ/cukE/jTKrK5uVJKX0Kw27cXDlVfw9qqvaZj0UpOkBicZc2kN9O4jn9paq04ClmclSgsE2ZHWG5Ta74wxuZRjfijUEjZOg9wrRYr04tgz+7KswWHOmRnKXjwFRrNcm1h5j28UnY0iRxENrNdLHQHTW2RehsKnU4/CunKo1JvjlJD8Xr2ms9O1dQ4qbSVfj7KgHxEQlYJDL5V1Eq+lIYmFzM1B6DUkGgvA49q5Xa5UV3XYNvNhXLqvEj6NJ7QjkALPWvTKzBNTwmUbw+c573qOcn2gEgFGufHc7krQoFF5eb7g7Tqjt0/deNOoVugxtcAcO0w0ih1HusRKTOk6MDXLiV0C5s3+ou/wK9/dypd8fYTj9Xq8tu181FjDBq9WAHPONnv1zhf6aioAzgMmKfooaglFk8lBa5pA+16ut3EuSZ+kGlp5OyVfotatlWTVWV+WQeaCoyZQ5TzuE+jkMorSwdlh5+ycu45z6dsgstCyV/NLVurvdMzacArz77gkc9hmU+rJbCRWwYS4xOXAzUIFGIofOct3PbflQ4VDUGprZPAvilictnf3XdxG9fcrnP9VNxdATq5g/KjYjUMtNL4Ixhygiki/crbQRJV6Eom6ESUbNFmZRQ0BjcY8Ikg5RFjyTIaeGkIi+q0IhH9Jp7dnP/KkVEhZRP73oHaWDnvTInSDcd8Guz1q3+ftjMmJuBuSQzjEulu6FyG78EzUF2F5qDrtYR3/MH707MUseTUOq0uVIuRRGdUPswtPMB61+SfxUOqWFTNIrugADl2QlBCe0zvWRuTeOY11MJeoSDdXtx0ZfUIkTjy5PQmpYjodhOf3SU1MT9oeq/NR5cOpsrdT7j5ZV07HKS1aAvFM02AV+E9Gq1sDoD9OXpYlbsTACEHgRAVetvKSx8LWP/DuQx3N6BeKQg0dOaUsEvYjbe2UlANbrwmhoQggPrKxT4mFuvlHeA5WRQK/nqEkDNs2KG3bXbBZNRQqeaqZPoN7aVIUUOGVk0qevInju X-OriginatorOrg: ust.hk X-MS-Exchange-CrossTenant-Network-Message-Id: 787eba8d-a9b5-47ad-ac5c-08db5988aa95 X-MS-Exchange-CrossTenant-AuthSource: OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2023 23:19:31.6972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: c917f3e2-9322-4926-9bb3-daca730413ca X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 41aUxSe+hIcG0QJpbO9vunWkZqHRm366anUzks4wbZgG8z2p2F5IZrbBZCy1Sy7n X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWP286MB1959 Received-SPF: pass client-ip=2a01:111:f403:7010::72a; envelope-from=acohen@HIDDEN; helo=JPN01-TYC-obe.outbound.protection.outlook.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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) I am playing around with various network things (mostly vpn related) and need Emacs to take certain actions when my laptop sleeps and wakes. This is easy to do using the existing dbus support (the relevant code is below, which runs hooks on sleeping and waking) The question is whether this is useful enough to add to Emacs, and if so the best place to put it. Not too long ago, Eric Abrahamsen added gnus-dbus.el which is similar, although for a single purpose: to close gnus server network connections on sleep. This has a single entry point for the user: set 'gnus-dbus-close-on-sleep to t to enable the feature. Options: 1. Do nothing (this isn't useful enough to change anything, and I can just keep using my own code). 2. Add a small package dbus-sleep.el. I would also remove gnus-dbus.el but leave the variable 'gnus-dbus-close-on-sleep and use it to control the installation of appropriate gnus functions to the new hooks. 3. 2. Add the new code to the existing dbus.el. I would also remove gnus-dbus.el but leave the variable 'gnus-dbus-close-on-sleep and use it to control the installation of appropriate functions to the new hooks. I mostly favor adding it to dbus.el. The argument against: dbus.el is focused on providing language bindings for the D-Bus API rather than a user-feature. The removal of gnus-dbus.el shouldn't cause any problem since I would maintain the same functionality enabled by the same variable, so no user-visible change. Advice? ;;; Code: (require 'dbus) (defcustom dbus-sleep-sleep-hook nil "Hook to run on sleep." :group 'dbus-sleep :type 'hook) (defcustom dbus-sleep-wake-hook nil "Hook to run on wake." :group 'dbus-sleep :type 'hook) (defvar dbus-sleep-registration-object nil "Object returned from `dbus-register-signal'. This is used to unregister the signal.") ;;;###autoload (defun dbus-sleep-enable () "Use `dbus-register-signal' to close servers on sleep." (interactive) ;; Don't enable if it's already enabled. (when (and (featurep 'dbusbind) (not dbus-sleep-registration-object)) (setq dbus-sleep-registration-object (dbus-register-signal :system "org.freedesktop.login1" "/org/freedesktop/login1" "org.freedesktop.login1.Manager" "PrepareForSleep" #'dbus-sleep-handler)))) (defun dbus-sleep-disable () "Unregister sleep signal." (interactive) (condition-case nil (dbus-unregister-object dbus-sleep-registration-object) (setq dbus-sleep-registration-object nil) (wrong-type-argument nil))) (defun dbus-sleep-handler (sleep-wake) "Handler to execute sleep and wake functions. SLEEP-WAKE is t on sleeping and nil on waking." (ignore-errors (if sleep-wake (run-hooks 'dbus-sleep-sleep-hook) (run-hooks 'dbus-sleep-wake-hook)))) -- Andrew Cohen
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Andrew Cohen <acohen@HIDDEN> Subject: bug#63620: Acknowledgement (30.0.50; [Feature Request] run hooks on sleep/wake) Message-ID: <handler.63620.B.168462508612787.ack <at> debbugs.gnu.org> References: <87fs7qmw00.fsf@HIDDEN> X-Gnu-PR-Message: ack 63620 X-Gnu-PR-Package: emacs Reply-To: 63620 <at> debbugs.gnu.org Date: Sat, 20 May 2023 23:25:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-gnu-emacs@HIDDEN If you wish to submit further information on this problem, please send it to 63620 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 63620: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63620 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake Resent-From: Michael Albinus <michael.albinus@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 21 May 2023 08:14:01 +0000 Resent-Message-ID: <handler.63620.B63620.16846567878009 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 63620 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Andrew Cohen <acohen@HIDDEN> Cc: 63620 <at> debbugs.gnu.org Received: via spool by 63620-submit <at> debbugs.gnu.org id=B63620.16846567878009 (code B ref 63620); Sun, 21 May 2023 08:14:01 +0000 Received: (at 63620) by debbugs.gnu.org; 21 May 2023 08:13:07 +0000 Received: from localhost ([127.0.0.1]:59979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1q0eBf-000257-Fr for submit <at> debbugs.gnu.org; Sun, 21 May 2023 04:13:07 -0400 Received: from mout.gmx.net ([212.227.17.21]:45797) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <michael.albinus@HIDDEN>) id 1q0eBc-00024b-De for 63620 <at> debbugs.gnu.org; Sun, 21 May 2023 04:13:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1684656773; i=michael.albinus@HIDDEN; bh=sBoByeaeOdJETzWswEUKQGHZzNKXH4sKwqNUk0PBHFY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=DABWri0CSl3H6MSOpOKlX6grpBu8DaE0eWyw3fRQ7ekOLDOy52vafZaR5YEXM6KDt 57s4nz4fT5tx8pf3cXix2OHFZV+cM60tFyIpPDsEmv4eNwIcCTGUaIEBlnkooBqV4Y nMkKxKTy6eysr84/SkInoD8dVT8wqZCB4KFTLbEf7PQZ4gZj/n1q8C+FUxoRcw+6jI +0fcXBTJXqVEYdlwSux1QeAGNtLXernTMsineZHxlIjuD9b5Z9kI3tIEU/vmNNkFsu BWdS/4+kn5KwW/JEL0iRpFvLzu6UAi6/AP61WsuG8ukght6VGUn9h/hKeMekuYKni6 v+V8++trUxccQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.39.13]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MdNY8-1qZhsz1wAq-00ZLFO; Sun, 21 May 2023 10:12:53 +0200 From: Michael Albinus <michael.albinus@HIDDEN> In-Reply-To: <87fs7qmw00.fsf@HIDDEN> (Andrew Cohen's message of "Sun, 21 May 2023 07:19:27 +0800") References: <87fs7qmw00.fsf@HIDDEN> Date: Sun, 21 May 2023 10:12:51 +0200 Message-ID: <87lehinlvg.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:Buy4P8/Uj6Nx/N1MGDFXNj+SF1rXqfG8PmfqSWqhpl5D23BQDr+ sRj4p7lPwaEfS9fz9D1OZ70C212XxuE+907Hwz1VdKLdiVlVcExEWGwd4YpaG7OAienSwCt NtWnEBZw1h2UZLCpxS2eE280gY9XIBnEltYI7YMzrEhlFvzzkhx6t6A+XWmg2KRv38zediZ yRCUfWrMClzEA/XJ5EuuA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ISS3QARFEqk=;Vroz3XJhCes5EROHDLuo/twjZZ1 htoqCf4dLb3x8Vsso0MDuUvNetUbwoH1Z4gUr3WTYOTQpw/Br9+1gsgNvaUZc4PhJCCe2OUmv 9zd+g9dLCSe3ceunoIyLe1uUZKRO+qrfD0B90wYyipMh8K3TOb5r/Xm9KLz/08hWwX+g1zU/2 ps8sKVU5gQxTxZE/nNLHjf+1KoQ4uYLkgAYtWsxMDMZnd+vs4uFUvxPA8JRh27OkAvBTG+DBf 8R+uDGgiQfkNDoBbGGp6baSpswBJ/oumaiJeS6asya5MRxpIIpWCI2SiYVh9t8pTOhH+mhSy/ Vr8k5Dys1fkmCfjpcSZDlx8IOPEis63YSnB36S6RLG6jKLdV3R1kEvVV8DoA3D2QkSXpCKCCm cHuNTVR6daj91UzjfnHm8dOIOn/kZdAG8P8oL4fdgScYvdUQMZ+P9Zv+z6OLK4lcA2LyZRHUR 7w2N3olcCovIHb2Ka4JjRugf5FlXIkbTt7sWezH2e17UqOVQyOJeMyEs3s7jnOCWo7pvBNxAq ajHNJhPmQEiSrHJ+4Rx7g07/sTA6o+Vq6dqSSwUrN27Unvyr6ikhJj22nwZFw+lMD800x9iIv BRGn56rBAoq64vzCi75Ei8cShWbzCypP1LsWeu/SfKw2U+I+oIV/X29QhUdTwJ4dSddmEYEwH Zq69Em2pFktQCMZdKVdlDSYh+GyStxDQ2zq12XSUzGfa6O1PNknoBn20uaBa7drZ56b2Ypfme pG43UhtqP3OJZfk8ai+nWIjMSKP0d7Bae81JytYgMdWvth481P52t6FEMTzndF90CmpiFrEDe roJHkBqmh6EBi0eHMrVSb0x28in3jU1XKWNvFxKY31EcyV1MbXpgDbrEQWlezIwXd1YZ/ptYu l/oudAN++Ngq8ItwHYny9m/RxUz/dHOQsMgh3n7hZtNHPebTXTcYtgxeu9fl6AFIue2+ePgBA BZiuhQ== X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Andrew Cohen <acohen@HIDDEN> writes: Hi Andrew, > 2. Add a small package dbus-sleep.el. I would also remove gnus-dbus.el > but leave the variable 'gnus-dbus-close-on-sleep and use it to control > the installation of appropriate gnus functions to the new hooks. > > 3. Add the new code to the existing dbus.el. I would also remove > gnus-dbus.el but leave the variable 'gnus-dbus-close-on-sleep and use it > to control the installation of appropriate functions to the new hooks. > > I mostly favor adding it to dbus.el. The argument against: dbus.el is > focused on providing language bindings for the D-Bus API rather than a > user-feature. The removal of gnus-dbus.el shouldn't cause any problem > since I would maintain the same functionality enabled by the same > variable, so no user-visible change. Using D-Bus is just an implementation detail. What you want are handlers, which are invoked when your laptop falls asleep or awakes. A general package could implement it using D-Bus if available, or using something else if there's no D-Bus. See battery.el, which uses the D-Bus service "org.freedesktop.UPower" only if possible. Your package might be called sleep.el or alike. Your code uses the D-Bus service "org.freedesktop.login1", which isn't part of the basic D-Bus spec. So it isn't suited for dbus.el anyway. > ;;;###autoload > (defun dbus-sleep-enable () > "Use `dbus-register-signal' to close servers on sleep." > (interactive) I would make it rather a global minor mode, that you can enable/disable it easily. > ;; Don't enable if it's already enabled. > (when (and (featurep 'dbusbind) (not dbus-sleep-registration-object)) Perhaps, you check also for the service "org.freedesktop.login1", like --8<---------------cut here---------------start------------->8--- (member "org.freedesktop.login1" (dbus-list-activatable-names :system)) --8<---------------cut here---------------end--------------->8--- This check might return nil for several reasons, like the system bus is not running, or you don't have permissions to speak to the system bus, or the service simply doesn't exist. Best regards, Michael.
X-Loop: help-debbugs@HIDDEN Subject: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake Resent-From: Andrew Cohen <acohen@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Mon, 05 Jun 2023 13:07:01 +0000 Resent-Message-ID: <handler.63620.B63620.168597041518077 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 63620 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Michael Albinus <michael.albinus@HIDDEN> Cc: 63620 <at> debbugs.gnu.org Received: via spool by 63620-submit <at> debbugs.gnu.org id=B63620.168597041518077 (code B ref 63620); Mon, 05 Jun 2023 13:07:01 +0000 Received: (at 63620) by debbugs.gnu.org; 5 Jun 2023 13:06:55 +0000 Received: from localhost ([127.0.0.1]:48430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1q69vC-0004hV-NU for submit <at> debbugs.gnu.org; Mon, 05 Jun 2023 09:06:55 -0400 Received: from mail-os0jpn01on2107.outbound.protection.outlook.com ([40.107.113.107]:5970 helo=JPN01-OS0-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <acohen@HIDDEN>) id 1q69v9-0004hC-78 for 63620 <at> debbugs.gnu.org; Mon, 05 Jun 2023 09:06:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U5sTqryY+cgAgzfq/wkJsVh5RpGOnR9YKIikdfr1b146xGfv2lqa+9wGuDdulCfI3nWO4/xSh+Soi/r5Ogc/QaP5yMKj7KTn4RL6M8nV4TSyAUNPkiasklTiUAttcM2uZYpU3aWUPNkFgFrP7FxfbTAnZm96s9CoGtdEL+MXJ0lrnCPmb7pQ+d4yhfl0OCRVgygP8aUoUOLmNOl8w6PjnufD8IA2iWA0kEZqRwmi+vSi2q8eNTe1TbBAl94pUjIQAr6L1hfvKQLGWTkEUh64sSGX8PH8KaG9OinedcQn09GEh5f94QDGhNmcIBaM9NW0btvfxYim8TgmI5L1KWZ1jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ByPxk3uByxTlt4F0+cZPCPMSKoW9mKYZPS+QUmqCSAw=; b=FCefDBiQ6sY5MnVKv1cVNubWLFIcDgORJrqFzy6vKS8UbGXgsEYFMqGnXFmTtV2xekch3eVj7lLiW3b/gMl6j8qXwFs8CdWI7rvKklP51HTeUC+v5UPcsgEZNEFra59Fc7+DJ/yMdhS102/HCfbAOQzBDTyG2Zny4Iy1o8tJ81hMFarP58yDQho9kJWjD/tN4nRMRt3QW/rDX8u5cV7J1+POdLQovUENhUcF/7KBsqlpPJd/b0S/rUKvEV82FHIi+lNhXGdNxLv5l3yc7n26M5ynzFNpoNZP0zkf7e+VUUJWU149nTBy3t/+7Vk2mlmyEcV6l0O+pKEJnk4JgCCmxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ust.hk; dmarc=pass action=none header.from=ust.hk; dkim=pass header.d=ust.hk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ust.hk; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ByPxk3uByxTlt4F0+cZPCPMSKoW9mKYZPS+QUmqCSAw=; b=eHt3BDSXxKibgihvXOebMtEFDNiknUD/GpUYUL9zn3F5ZgI7cZcLe/XKyioX5s265lLYmrfaB0SKG35SwxoBSVoKEE51+9Y4aAmYkgCRO5P1pR/Pz+hL/+3CpCcud94VerGWFX49vMhvf4cgToWfOphm5AVFK/f++K1XMVpcDYKRcpz8OtmHeAQxzZ1DUNcyIj3ytle9f+/JLTCbhyyT00eOgHwyB9mU+wkOYSXfTosH57xMR+xJxFW+Fqsqhnl57XgPpxXctKHt/rLmbIzZrFdHMl48EcaRk79SpoAzfUPPK+imsjT5NS40yB7yDse8W8pmXVN69qRP8cBetrHKqw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ust.hk; Received: from OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1bf::11) by TY1P286MB3257.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2e8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Mon, 5 Jun 2023 13:06:43 +0000 Received: from OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM ([fe80::873a:53e:955d:c20f]) by OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM ([fe80::873a:53e:955d:c20f%7]) with mapi id 15.20.6455.030; Mon, 5 Jun 2023 13:06:43 +0000 From: Andrew Cohen <acohen@HIDDEN> In-Reply-To: <87lehinlvg.fsf@HIDDEN> (Michael Albinus's message of "Sun, 21 May 2023 10:12:51 +0200") Organization: Hong Kong University of Science and Technology References: <87fs7qmw00.fsf@HIDDEN> <87lehinlvg.fsf@HIDDEN> Date: Mon, 05 Jun 2023 21:06:37 +0800 Message-ID: <87y1ky83du.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: multipart/mixed; boundary="=-=-=" X-ClientProxiedBy: KU1PR03CA0029.apcprd03.prod.outlook.com (2603:1096:802:19::17) To OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1bf::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3P286MB1877:EE_|TY1P286MB3257:EE_ X-MS-Office365-Filtering-Correlation-Id: e665078d-0cc3-41ff-06db-08db65c5b57f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oL0+oPEfyh+4wm2rGxJS63rWV7WTdiiG2zZ1SuiHrtpYDj+F5x/X6SnFGi5XrZq9du6cB0MP444EnESJNEVzOMp3adAdYFgtbzdtoMR3Dc3nyNgVFIXZQKltJCmDnTy8oRDLk9gc/4Gk1LF7HieeMkc0kvE5LMAZk9sIl+TIedeKWncbxywoSW2VloX96eIGUcVqII50TaTKhJCoVKlh8DH5OIMW7MISMMn/3oGBIV4gjuKbuOd79UM9IxD2vonB4aLrMDCEuKXcaKVZnHrvjaCmxOc85Kyy4hUvSPeWc2NJi5ZECT4xH4UOwIzlQBgda1GNcPMpHsrdm9tC9lrbJr6Oh+HBL4JJeBcsM9eqN3zDeENsv2dJDhRfdTER+o68AO+nLG8NSJNaSnliAFo4Z7NmAJfr0atcLSRl+TAKZ2pMmfjesMYOEO90WVdq/KqjHNf1YelelNeLntVMgcGuV+wwAU9nHGgVIs9COrKwDW0CM415HIl8gaF9v7GvKVLQpEGNcoFmlh3UHFn6OPIhgkuAgELkOnVYli+iVzFnZGwMvaCJ91ekgZj53KKZ23Sfd2qfO2WkFFHL1WMQd0Na9JsuzcOhb59VJb0CyqMOaBYsg7CvhXfAfhEYtV6xvHP1 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(366004)(396003)(136003)(346002)(376002)(451199021)(478600001)(2906002)(36756003)(6486002)(36916002)(6666004)(2616005)(83380400001)(41320700001)(186003)(6512007)(6506007)(26005)(86362001)(38100700002)(786003)(316002)(8676002)(8936002)(66946007)(6916009)(4326008)(66556008)(66476007)(5660300002)(41300700001)(547064002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zeaYcuFLqYQVcwDIiejP3lr+lw4rNl+KlQ2VLSRAzE5PHulGHzrzufHF1cRfIMPTxMg0jxwfOet+0+fULdSl/b1p/zMts5wAZkX1YMcOl/E4a6Ec93RT2jw/anWxkZJB5xcjjNHX3VmdDHBxhiw9fmAR+T3m0x1rCEzSxx1NLXmTOI7MoZCXLxsPCjVsQ0rtLtVsvdhPpADbuy/WFq1tNjKUwKrLLOoO9BtoZuAWCPhavCirfkSmS1rmDYL50tU6bP4eKJ+WMPKedbIMAzoXuUhWcb9iKM0ilXuBNMr6KZ3Vcv49KJ7FrNtPgGlve96RvjyePoilIV3tPYfPfkNIGitLRnhGJP6sGzf/deXkVIUg9VC1q2//ZHRh5LUxiBrUwlWPvihAPxd7c5z7/K6s3jjd27+3UiQNe9savBOj16T9Qfo/gxOu2q+5hMdao60L2dVa3VHBWWV4IH509494QiVc04tTPH6hqmleOCs8BTSYFdct14/jxKjK/WQCIWwaJ/Sun3mfGRdKcVDm9B1Vk0XpycScVaY+mLcRTnGTLnZyVWpzoNyMa7yk84IhChoY1Ak0+0pKI2eQ+I3qhN87jLBEspEeBnunikpxv/Hz6Khooq2qgVItFJltRibQH5OEqJFirAyYXZuu7yUhrxb1M2TUVvUJ7d6hg1qWHxHbdSoTYApY6G5mCwAwh7/1Yj9iQomMfrGbCrvJbE9UvicMzNb5foUpsd50QHIGaKtZRZRDBWeY5PdWoX1M7+Glf08XkLwVHrdkwYQBmQShBzdlBPo6FfS9s7qkehnQqEgfgKJo7aYwSWMkScaSfYOkuGCqdllyEqaVixIwmndM050qS1I5Dz6a7wvTcDg4zbyqxgKJxQ91iNsuWBI1YlUU1fYVXGp+gWnqOEFJi5VWZetrg0PZway6QG23VpMQcXz+LGqLhYSlkukenjWS4EFoMPKoD35Sv7ybha3tpkAW25oWjkWRwgfqy7l6iXQRsyrfpeLH0ejQdLHufterd1T3tcoQGTOJG8oBl3iy6VqFtTZ2UzxnIGYgmwSTDEVRKtR5xkARgKit2k5NoTdgJMtv7EtzVx9CALNtJ+GquwPp3d4vhAs5+9GVbtmKZO7yjZS7QUWgOJUIJo2Z46F75C1EuBpPoLOGYHpPIh4UQE9oBVaE3wc4rFRxtb7IhSUQx/iPhBPQo3BrivCxGHlYir6u0YbfSVtLge7WNGhUnxNQRqTm9Ec6NndaoW824bM8Aq19kn8i2s8l1jQ95tSWgxPJUOxvV20LT1ZtPf1zSwnOKgUXnGejdwnBM36Pa0wA0GZFoptp98fCDlP6uHurCLvXD71cBpLmJpKUVj7P+GpNj1enaJb7RwZYEtXrBMWIlHm6icVV2qhoO6JgShcY0WyM0xjQ1+aoMp2kk4Sn67WXu6kaDGEzKRYlhkcF9XIMXts77kZ0N/V6XoyxGPhV/w4A0ddWXL6NQo0fb+RIzK7MUrrFBIY5iUytLOSbMg0zwIqR2kk5rL/zSamAHOeM3xfsKLsqEJ/urYOvtSUbpOs4v2OOJ5U0OPPrXN00jab6NrrLiFGaLlacmrpesozNTat4WLUc X-OriginatorOrg: ust.hk X-MS-Exchange-CrossTenant-Network-Message-Id: e665078d-0cc3-41ff-06db-08db65c5b57f X-MS-Exchange-CrossTenant-AuthSource: OS3P286MB1877.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2023 13:06:43.3209 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: c917f3e2-9322-4926-9bb3-daca730413ca X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PmAbTWXcoPuAOKdVUL9d86ptUTrZjSmhmaoZ4w2mSq9AmRmEo7ba+pzFh5RYDMol X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1P286MB3257 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Dear Michael >>>>> "MA" == Michael Albinus <michael.albinus@HIDDEN> writes: [...] MA> Using D-Bus is just an implementation detail. What you want are MA> handlers, which are invoked when your laptop falls asleep or MA> awakes. Yes, of course you are right! MA> A general package could implement it using D-Bus if available, MA> or using something else if there's no D-Bus. See battery.el, MA> which uses the D-Bus service "org.freedesktop.UPower" only if MA> possible. Your package might be called sleep.el or alike. I am not familiar with other methods for detecting sleep/wake, so I just have dbus at the moment. But if anyone knows of something else (especially on windows) it can then be added. [...] MA> I would make it rather a global minor mode, that you can MA> enable/disable it easily. Yes, that is a better idea. [...] MA> Perhaps, you check also for the service MA> "org.freedesktop.login1", like MA> (member "org.freedesktop.login1" (dbus-list-activatable-names MA> :system)) OK, added. I've now put everything together and modified the gnus code to use the new sleep.el. But I remain unsure if I should remove gnus-dbus.el entirely (everything remains the same for the user: setting gnus-dbus-close-on-sleep to a non-nil value will enable the feature using the global minor mode rather than gnus-dbus). And is sleep.el something worth adding? --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=sleep.el Content-Transfer-Encoding: quoted-printable Content-Description: sleep.el ;;; sleep.el --- run hooks on sleep and wake -*- lexical-binding:t -*- ;; Copyright (C) 2023 Free Software Foundation, Inc. ;; Author: Andrew Cohen <> ;; Maintainer: emacs-devel@HIDDEN ;; Keywords: ;; This file is part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. ;;; Commentary: ;;; This global minor mode enables evaluating code when the device ;;; running Emacs enters or leaves the sleep state. Two hooks are ;;; used, sleep-sleep-hook and sleep-wake-hook, run when the system ;;; detects that it is going to sleep or waking up. Currently only a ;;; dbus interface to detect sleep state change is implemented. ;;; Code: (require 'dbus) (defgroup sleep nil "Run hooks on entering/leaving the sleep state." :group 'hardware) (defcustom sleep-sleep-hook nil "Hook to run on entering sleep." :group 'sleep :type 'hook) (defcustom sleep-wake-hook nil "Hook to run on leaving sleep." :group 'sleep :type 'hook) (defvar sleep-registration-object nil "Object returned from `dbus-register-signal'. This is used to unregister the signal.") (defun sleep-wake-enable () "Enable detection of sleep/wake state change. Run sleep-sleep-hook and sleep-wake-hook as appropriate." (unless sleep-registration-object (setq sleep-registration-object (dbus-register-signal :system "org.freedesktop.login1" "/org/freedesktop/login1" "org.freedesktop.login1.Manager" "PrepareForSleep" #'sleep-handler)))) (defun sleep-wake-disable () "Disable detection of sleep/wake state change." (condition-case nil (progn (dbus-unregister-object sleep-registration-object) (setq sleep-registration-object nil)) (wrong-type-argument nil))) (defun sleep-handler (sleep-wake) "Handler to execute sleep and wake functions. SLEEP-WAKE is t on sleeping and nil on waking." (ignore-errors (if sleep-wake (run-hooks 'sleep-sleep-hook) (run-hooks 'sleep-wake-hook)))) ;;;###autoload (define-minor-mode sleep-wake-mode "Toggle sleep/wake detection. When sleep-wake-mode is enabled, Emacs will execute the hooks `sleep-sleep-hook' and `sleep-wake-hook' when entering or leaving the sleep state. This is currently only available on systems that support dbus detection of sleep state change." :global t :group 'sleep (when (and (featurep 'dbusbind) (member "org.freedesktop.login1" (dbus-list-activatable-names :system))) (if sleep-wake-mode (sleep-wake-enable) (sleep-wake-disable)))) (provide 'sleep) ;;; sleep.el ends here --=-=-= Content-Type: text/plain -- Andrew Cohen --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake Resent-From: Michael Albinus <michael.albinus@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 10 Jun 2023 10:48:02 +0000 Resent-Message-ID: <handler.63620.B63620.168639404821329 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 63620 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Andrew Cohen <acohen@HIDDEN> Cc: 63620 <at> debbugs.gnu.org Received: via spool by 63620-submit <at> debbugs.gnu.org id=B63620.168639404821329 (code B ref 63620); Sat, 10 Jun 2023 10:48:02 +0000 Received: (at 63620) by debbugs.gnu.org; 10 Jun 2023 10:47:28 +0000 Received: from localhost ([127.0.0.1]:33336 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1q7w7z-0005Xw-Uu for submit <at> debbugs.gnu.org; Sat, 10 Jun 2023 06:47:28 -0400 Received: from mout.gmx.net ([212.227.17.22]:46829) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <michael.albinus@HIDDEN>) id 1q7w7w-0005Xd-Ef for 63620 <at> debbugs.gnu.org; Sat, 10 Jun 2023 06:47:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1686394032; x=1686998832; i=michael.albinus@HIDDEN; bh=58rZXdSF9YrXXbPRgCKavpXrmqBTXpsIVYaiHWeY1As=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=TIO7/BPGTyfNnnTegpwXFv6ndVLJov0Xj2lcdFdXp+pgwTlpNV2fk7eyG2EqgjucvGJZ23Q yv40rkLGMI1vPBxOZTcexNupqM8pfS0KkWtYUC2i3dWY26yvetd9kKnKD8TinlDCSGnP7NBlu hlTtUAUsIOOyBlEV6bJhJ+tmKKNcwHkrGa4L8Q7bn7GfeEZ9pENtIOcq0iuz9knznkfayjPch mGk+w+V8BhcS4n3rnAIIb+Z36r373MW3+Aqc3rGA4cawP+3B2rHGfw5PsvVTPDEZ0VykIzbdC 6j8euDxHqEgimSXuFyzbQmOpujAkVJ6DSn++xtEcib/gyXKGN2IQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.39.13]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mi2Jt-1pdXBR0L57-00e0sT; Sat, 10 Jun 2023 12:47:12 +0200 From: Michael Albinus <michael.albinus@HIDDEN> In-Reply-To: <87y1ky83du.fsf@HIDDEN> (Andrew Cohen's message of "Mon, 05 Jun 2023 21:06:37 +0800") References: <87fs7qmw00.fsf@HIDDEN> <87lehinlvg.fsf@HIDDEN> <87y1ky83du.fsf@HIDDEN> Date: Sat, 10 Jun 2023 12:47:10 +0200 Message-ID: <87legr1tn5.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:+7Vm+4Gyy1Z9PmskvjTk1LpsZ8UtHELNn1jmoKlnuVNpmdjWAlW sN8fWXRbP/fmna7hzSzNt5GV+9dWyd/nNPq42mhuiRyOqFDwtvKAiF2RI8Q+jtTcKqLnoZl pHp4oy+WHeYLJ1Mk/UPHsnFw/cptxikFAuu/KS/h4YBpwdRhJjDcbx9M3OgE+kDz32SuB81 Wg9J8+EjNZB1EVX0dB6Fw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:I0NciSjItbM=;IW2RUAF7wLLXOa1ne7Fq3UQZZ47 LGEDGWctDwbIgF0AtwET9HVIEf2OmaUzjbNdPWH0r3v+I3VkNh5lfSlM/QHkaxV+2hkDWmxGE 0ogR8eCrcXGQuR3Y/kL9K57SvevjBUbeyVlIM4WY8Ne6eq5hvuzGJKOtmFuS5DGE7iL6R+8yn BjeHrWgm4h6QawqLoUEdA1vV1vHtOkaJ128ElgVpJycR31LrtNmeCmZMs3hygT/vRuEOJiQmM au4QMVkymtObRv9zIU7mJrka6/LZlYcAVJAkLCXmFnc6TUvu7D8rpoAh05ilOjZXS8jDBT/6b fUkeOv/6h1TLbTqeFyWlkzKI+kqnXkxvym5Vvr19398LHTQscAkv/v1MZ/JFOFXwqR+IKXhlx YJfFAqiHDwr6SXMYuil+MuAGoPse7d6bnHGbJlh8EpIZnbuxCDdjXzwLTpmZDPDQBxIGwFq7X vjBtcdfgfixk55zeloPsUxTL9VDwdz9SnO7s8vDreezs22kt9zzcZ8hvOAG6pSVlWz8TZkZdy F3ol/au9fcrkqZE2b8BzlMoZrc+1VrL8AndS1IOdi6YOe9jtGgVrrt6XEASxc5eNUQNka/Vw+ ziY8kkqqALeOr+uReGH6dXCAoIfn657RQGGtFM+qlSurvv3bqwxFFDpD6oI7YTuga1yFkeDlg 4whweh1LBM5+IZqBER0EwZP7mKvUNTnoCIu8n6THCfGevRyRWjA3g7M+Dfk/psPqiYOrYxaOC rJmwEZy5DhYa/zMZ62r0mQrtfOA98iCAwX4arf5TmqO+mcPDe23QmdepNDihEii6K9tpu3ue1 NYPMDCu93EE8qOq4wEawTmM/YKI8ENcO5GLlwpRWiN3SGl/q+zZE9fiDuabJvF1s0Sh/aRQ/E 7IZqzyTJ4tLZFzFezevm5VbVKR3RVul+SYxFa3PatHZbtHizEAvnnNfEIIsmlU0KHhE6xtHxy El1QBQ== X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Andrew Cohen <acohen@HIDDEN> writes: > Dear Michael Hi Andrew, sorry for the delayed answer, I've been busy ... > I've now put everything together and modified the gnus code to use the > new sleep.el. But I remain unsure if I should remove gnus-dbus.el > entirely (everything remains the same for the user: setting > gnus-dbus-close-on-sleep to a non-nil value will enable the feature > using the global minor mode rather than gnus-dbus). And is sleep.el > something worth adding? It depends whether sleep.el will be added to vanilla Emacs, or as GNU ELPA package. It's not my decision, but I lobby for the former. In this case, it could be used in gnus-dbus.el. Just some few comments on the code > ;;; sleep.el --- run hooks on sleep and wake -*- lexical-binding:t -*- I would be more precise. You don't mean sleeping Emacs or another application, but you mean sleeping the machine on OS level. Say it so. > ;;; This global minor mode enables evaluating code when the device > ;;; running Emacs enters or leaves the sleep state. Two hooks are > ;;; used, sleep-sleep-hook and sleep-wake-hook, run when the system > ;;; detects that it is going to sleep or waking up. Currently only a > ;;; dbus interface to detect sleep state change is implemented. Please quote Lisp objects like `sleep-sleep-hook'. D-Bus is spelled out in commentaries as D-Bus. > (defgroup sleep nil > "Run hooks on entering/leaving the sleep state." > :group 'hardware) > > (defcustom sleep-sleep-hook nil > "Hook to run on entering sleep." > :group 'sleep > :type 'hook) > > (defcustom sleep-wake-hook nil > "Hook to run on leaving sleep." > :group 'sleep > :type 'hook) These are the user visible objects. Please be precise what is going to sleep. The machine or device. > Run sleep-sleep-hook and sleep-wake-hook as appropriate." Please quote sleep-sleep-hook. > (unless sleep-registration-object > (setq sleep-registration-object > (dbus-register-signal :system > "org.freedesktop.login1" > "/org/freedesktop/login1" > "org.freedesktop.login1.Manager" > "PrepareForSleep" > #'sleep-handler)))) I would also protect against D-Bus errors. Like (ignore-error dbus-error (unless sleep-registration-object (setq sleep-registration-object (dbus-register-signal :system "org.freedesktop.login1" "/org/freedesktop/login1" "org.freedesktop.login1.Manager" "PrepareForSleep" #'sleep-handler)))) > (condition-case nil > (progn > (dbus-unregister-object > sleep-registration-object) > (setq sleep-registration-object nil)) > (wrong-type-argument nil))) Aka (ignore-error (dbus-error wrong-type-argument) (dbus-unregister-object sleep-registration-object) (setq sleep-registration-object nil)) > When sleep-wake-mode is enabled, Emacs will execute the hooks Please quote sleep-wake-mode. > support dbus detection of sleep state change." D-Bus is spelled out ... Furthermore, it would be nice if you add - documentation in lispref node "(elisp) System Interface". I'm not sure whether it is good for a new subnode, or whether it shall be documented in "(elisp) System Environment". This documentation should also give a practical example for functions in sleep-sleep-hook and sleep-wake-hook. - adding the functionality to etc/NEWS - if possible, adding tests in test/lisp/sleep-tests.el Best regards, Michael.
Received: (at control) by debbugs.gnu.org; 11 Sep 2023 23:13:06 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 11 19:13:06 2023 Received: from localhost ([127.0.0.1]:55102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qfq5a-0002gd-5F for submit <at> debbugs.gnu.org; Mon, 11 Sep 2023 19:13:06 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:61725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1qfq5X-0002g6-NH for control <at> debbugs.gnu.org; Mon, 11 Sep 2023 19:13:05 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2b703a0453fso84809941fa.3 for <control <at> debbugs.gnu.org>; Mon, 11 Sep 2023 16:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694473973; x=1695078773; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=cBPhBj4NeS19p0Xs6Ig6rtKSkyA7LMkPIzZnSFngwWE=; b=rAvPbvzjIquvkRxsNaeyHwBMXaDo8z8gIsIjzBlgNLzZg9kz0TCyRo6wukU0r+vQCi GdHJva7fYePmMP9J5WVRZxvLMpgUlo0hMSmvLvl1z0UwgwNhKcuC7ENcE53VMGG4s54e 5fT1KA6ss6zAQd4cp2rKtY+rRs0xAEvXPz3qzKUwtcr6xAwVgc7gs2E51xMwIvaShOQb 34v0ynHth3QJrpYkMmGMY0V4+lnJec+8gjJNxZGMKVB3B+Q/Qw4Maw8+UW28+XtjyF+D 1VCl94HsHzkbzHTyFUx2aT8xeo+jNEQvcKyjbGRng/tgxwcGcE/cNIleT9h1DNHKvCG5 fE+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694473973; x=1695078773; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cBPhBj4NeS19p0Xs6Ig6rtKSkyA7LMkPIzZnSFngwWE=; b=D69BPbvOGC8ZeqrXtCkTnldPdnUKep7372vS6Ga+CQnFhzKoDJQ0eQuxjORQe2JrG5 RcEqd9UnYOBnHKdj0j77eH8ITs8k3gCPn5R4kVUXTiHmaJKCes6TYPYlTzMkAZmWFa8w BuwgPfoMGTxBZg7AcbpYrNpDieJ7L7pLUNdq0NRwNwTexcJoWCSq+uwL6v3VVlvMkVye Pg4zso26hwceoKL29RNxmNBFQQrElwzADJEebmClr1k9EwYMBI9vhz/69OPRyV2PymHR jD7jJ40CAO92ZBQqF9TIOAOCQ5ltfREDAENR4zavDUilKOA641VkVM/qsrjw+pKir0Gh aDew== X-Gm-Message-State: AOJu0YzWtvkanCHDNIUAAKQmleZHv8IotJzx6+jiowzwCVwpVJgQVsio 7NWKdjY07Wmt6mDuT4ekCjnTt/oSODZusQONkaDVuAln X-Google-Smtp-Source: AGHT+IG5P2xH7i8JlaEBghWQah7LttEtTJ9sqx3xoS59ruPNBhalXYC6pT3KxbMLj3oDKB32ryVJs3r0rYpM1fxZWKY= X-Received: by 2002:a2e:851a:0:b0:2bc:b815:d64d with SMTP id j26-20020a2e851a000000b002bcb815d64dmr10126013lji.30.1694473973289; Mon, 11 Sep 2023 16:12:53 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 11 Sep 2023 16:12:52 -0700 From: Stefan Kangas <stefankangas@HIDDEN> MIME-Version: 1.0 Date: Mon, 11 Sep 2023 16:12:52 -0700 Message-ID: <CADwFkmn6NifZ_e+hbuMuB+3Eyc2SZQ4bywhLu6e2e8Tzn3xS0A@HIDDEN> Subject: control message for bug #63620 To: control <at> debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) tags 63620 + patch quit
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.