From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake Date: Sun, 21 May 2023 10:12:51 +0200 Message-ID: <87lehinlvg.fsf@gmx.de> References: <87fs7qmw00.fsf@ust.hk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14589"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 63620@debbugs.gnu.org To: Andrew Cohen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 21 10:14:17 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q0eCm-0003aB-GE for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 May 2023 10:14:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q0eCa-0002OV-SS; Sun, 21 May 2023 04:14:04 -0400 Original-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 1q0eCY-0002OI-QG for bug-gnu-emacs@gnu.org; Sun, 21 May 2023 04:14:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q0eCY-0004eJ-8Z for bug-gnu-emacs@gnu.org; Sun, 21 May 2023 04:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q0eCX-00026N-Ps for bug-gnu-emacs@gnu.org; Sun, 21 May 2023 04:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 May 2023 08:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63620 X-GNU-PR-Package: emacs Original-Received: via spool by 63620-submit@debbugs.gnu.org id=B63620.16846567878009 (code B ref 63620); Sun, 21 May 2023 08:14:01 +0000 Original-Received: (at 63620) by debbugs.gnu.org; 21 May 2023 08:13:07 +0000 Original-Received: from localhost ([127.0.0.1]:59979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0eBf-000257-Fr for submit@debbugs.gnu.org; Sun, 21 May 2023 04:13:07 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:45797) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0eBc-00024b-De for 63620@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@gmx.de; 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 Original-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 In-Reply-To: <87fs7qmw00.fsf@ust.hk> (Andrew Cohen's message of "Sun, 21 May 2023 07:19:27 +0800") X-Provags-ID: V03:K1:Buy4P8/Uj6Nx/N1MGDFXNj+SF1rXqfG8PmfqSWqhpl5D23BQDr+ sRj4p7lPwaEfS9fz9D1OZ70C212XxuE+907Hwz1VdKLdiVlVcExEWGwd4YpaG7OAienSwCt NtWnEBZw1h2UZLCpxS2eE280gY9XIBnEltYI7YMzrEhlFvzzkhx6t6A+XWmg2KRv38zediZ yRCUfWrMClzEA/XJ5EuuA== 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+nWIjMSKP0d7Bae81JytYgMdWvth481P52t6FEMTzndF90CmpiFrED X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:262095 Archived-At: Andrew Cohen 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.