emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs: Responding To Brightness Changes


From: Michael Albinus
Subject: Re: Emacs: Responding To Brightness Changes
Date: Wed, 08 Jun 2022 10:09:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

"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 via email to

[Prev in Thread] Current Thread [Next in Thread]