all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Andrew Cohen <acohen@ust.hk>
Cc: 63620@debbugs.gnu.org
Subject: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake
Date: Sun, 21 May 2023 10:12:51 +0200	[thread overview]
Message-ID: <87lehinlvg.fsf@gmx.de> (raw)
In-Reply-To: <87fs7qmw00.fsf@ust.hk> (Andrew Cohen's message of "Sun, 21 May 2023 07:19:27 +0800")

Andrew Cohen <acohen@ust.hk> 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.





  reply	other threads:[~2023-05-21  8:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-20 23:19 bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake Andrew Cohen
2023-05-21  8:12 ` Michael Albinus [this message]
2023-06-05 13:06   ` Andrew Cohen
2023-06-10 10:47     ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lehinlvg.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=63620@debbugs.gnu.org \
    --cc=acohen@ust.hk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.