unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: "T.V Raman" <raman@google.com>
Cc: emacs-devel@gnu.org
Subject: Re: Emacs: Responding To Brightness Changes
Date: Wed, 08 Jun 2022 10:09:20 +0200	[thread overview]
Message-ID: <878rq737bj.fsf@gmx.de> (raw)
In-Reply-To: p91tu8v6g53.fsf@google.com

"T.V Raman" <raman@google.com> writes:

Hi,

> Is there a way to react to display brightness changes from Emacs --
> perhaps using dbus signals?

At least there are D-Bus signals. Start a new Emacs and call "M-x dbus-monitor".
Confirm the :session bus.

If you change now the display brightness, you'll see (beside other
signals and method invocations) the signal

--8<---------------cut here---------------start------------->8---
signal time=1654672931.3694549 sender=:1.71 -> destination=nil serial=87 path=/org/gnome/SettingsDaemon/Power interface=org.freedesktop.DBus.Properties member=PropertiesChanged
(:string "org.gnome.SettingsDaemon.Power.Screen")
(:array
 (:dict-entry :string "Brightness"
	      (:variant :int32 35)))
(:array)
--8<---------------cut here---------------end--------------->8---

So I would register for the signal PropertiesChanged of interface
org.freedesktop.DBus.Properties at object path /org/gnome/SettingsDaemon/Power:

--8<---------------cut here---------------start------------->8---
(require 'dbus)
(dbus-register-signal :session "org.gnome.SettingsDaemon.Power"
 "/org/gnome/SettingsDaemon/Power" "org.freedesktop.DBus.Properties"
 "PropertiesChanged" (lambda (&rest args) (message "%s" args)))
--8<---------------cut here---------------end--------------->8---

If you now change the display brightness, you'll see messages in the
echo area like

--8<---------------cut here---------------start------------->8---
(org.gnome.SettingsDaemon.Power.Screen ((Brightness (35))) nil)
--8<---------------cut here---------------end--------------->8---

These events are the same as you have seen in the D-Bus monitor above.
Based on this, you can change the handler to whatever you like. Please
check for the property name "org.gnome.SettingsDaemon.Power.Screen",
because other property changes might be signalled as well.

> All my searches turn up doing this for the kbd backlight, or appear to
> need  some kind of Gnome Settings Panel ...

Yep, the Gnome Settings daemon is in turn. But you don't need to open a
panel; the D-Bus events arrive without that.

> Thanks,
>
> --Raman(I Search, I Find, I Misplace, I Research)

Best regards, Michael.



  reply	other threads:[~2022-06-08  8:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08  2:30 Emacs: Responding To Brightness Changes T.V Raman
2022-06-08  8:09 ` Michael Albinus [this message]
2022-06-08 14:00   ` T.V Raman
2022-06-08 14:36     ` Michael Albinus
2022-06-08 14:41       ` T.V Raman
2022-06-09  2:24     ` T.V Raman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=878rq737bj.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=emacs-devel@gnu.org \
    --cc=raman@google.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).