unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs: Responding To Brightness Changes
@ 2022-06-08  2:30 T.V Raman
  2022-06-08  8:09 ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: T.V Raman @ 2022-06-08  2:30 UTC (permalink / raw)
  To: emacs-devel

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

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


So not directly emacs-related --- but having this functionality might
be useful.
-- 

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1  🦮

-- 

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1  🦮



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs: Responding To Brightness Changes
  2022-06-08  2:30 Emacs: Responding To Brightness Changes T.V Raman
@ 2022-06-08  8:09 ` Michael Albinus
  2022-06-08 14:00   ` T.V Raman
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2022-06-08  8:09 UTC (permalink / raw)
  To: T.V Raman; +Cc: emacs-devel

"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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs: Responding To Brightness Changes
  2022-06-08  8:09 ` Michael Albinus
@ 2022-06-08 14:00   ` T.V Raman
  2022-06-08 14:36     ` Michael Albinus
  2022-06-09  2:24     ` T.V Raman
  0 siblings, 2 replies; 6+ messages in thread
From: T.V Raman @ 2022-06-08 14:00 UTC (permalink / raw)
  To: michael.albinus; +Cc: emacs-devel

Correct -- but the signal from SettingsDaemon shows up only if you're
already running some kind of Gnome Settings Panel, something that I
avoid by running StumpWM as  a Window Manager.

Is there a way to get that daemon running without dragging all of
Gnome along?
-- 

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1  🦮

--

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1  🦮



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs: Responding To Brightness Changes
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2022-06-08 14:36 UTC (permalink / raw)
  To: T.V Raman; +Cc: emacs-devel

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

Hi,

> Correct -- but the signal from SettingsDaemon shows up only if you're
> already running some kind of Gnome Settings Panel, something that I
> avoid by running StumpWM as  a Window Manager.
>
> Is there a way to get that daemon running without dragging all of
> Gnome along?

No idea, I have Gnome running by default.

Inspecting D-Bus objects, the signal is sent by the background process
/usr/libexec/gsd-power, which is started by systemd:

--8<---------------cut here---------------start------------->8---
albinus     2137       1  0 10:37 ?        00:00:00 /usr/lib/systemd/systemd --user
albinus     2605    2137  0 10:37 ?        00:00:00 /usr/libexec/gsd-power
--8<---------------cut here---------------end--------------->8---

Perhaps you can play around this.

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

Best regards, Michael.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs: Responding To Brightness Changes
  2022-06-08 14:36     ` Michael Albinus
@ 2022-06-08 14:41       ` T.V Raman
  0 siblings, 0 replies; 6+ messages in thread
From: T.V Raman @ 2022-06-08 14:41 UTC (permalink / raw)
  To: michael.albinus; +Cc: raman, emacs-devel

yes.

An easy way of figuring out if the signal is available is to use gdbus
introspect --session --dest
and then use bash completion to see what is available.

Michael Albinus writes:
 > "T.V Raman" <raman@google.com> writes:
 > 
 > Hi,
 > 
 > > Correct -- but the signal from SettingsDaemon shows up only if you're
 > > already running some kind of Gnome Settings Panel, something that I
 > > avoid by running StumpWM as  a Window Manager.
 > >
 > > Is there a way to get that daemon running without dragging all of
 > > Gnome along?
 > 
 > No idea, I have Gnome running by default.
 > 
 > Inspecting D-Bus objects, the signal is sent by the background process
 > /usr/libexec/gsd-power, which is started by systemd:
 > 
 > --8<---------------cut here---------------start------------->8---
 > albinus     2137       1  0 10:37 ?        00:00:00 /usr/lib/systemd/systemd --user
 > albinus     2605    2137  0 10:37 ?        00:00:00 /usr/libexec/gsd-power
 > --8<---------------cut here---------------end--------------->8---
 > 
 > Perhaps you can play around this.
 > 
 > > Thanks,
 > >
 > > --Raman(I Search, I Find, I Misplace, I Research)
 > 
 > Best regards, Michael.

-- 

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1  🦮

--

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1  🦮



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs: Responding To Brightness Changes
  2022-06-08 14:00   ` T.V Raman
  2022-06-08 14:36     ` Michael Albinus
@ 2022-06-09  2:24     ` T.V Raman
  1 sibling, 0 replies; 6+ messages in thread
From: T.V Raman @ 2022-06-09  2:24 UTC (permalink / raw)
  To: michael.albinus; +Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 408 bytes --]

Following up to myself and closing this out:

Figuring out how to coax the appropriate settings-daemon to run when not
using Gnome was a lot harder than writing a few lines of elisp that used
an idle-timer to check the state of the display -- to check the display
state I used shll-cmmand light -- 
-- 

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
7©4 Id: kg:/m/0285kf1  •0Ü8



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-09  2:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08  2:30 Emacs: Responding To Brightness Changes T.V Raman
2022-06-08  8:09 ` Michael Albinus
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

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).