This change modifies the brightness backend so that it uses the logind API as a fallback with a higher preference than the external binary helper. In other words, we will try to adjust brightness by:
Changing the Backlight or BACKLIGHT property on the XRandR output
Making a D-Bus SetBrightness call to the logind session
Calling the external helper with pkexec
This change is roughly inspired by a similar adjustment to gnome-settings-daemon, although in their case they prefer the D-Bus approach over XRR; this seems overly blunt to me but perhaps makes sense in the context of future Wayland support.
Unfortunately, there's no corresponding GetBrightness call available, nor is there any way to enumerate backlight devices through D-Bus. We add libgudev as a dependency so that we can look up current backlights and brightness values as needed. In theory, a future revision to this code could eliminate the get-brightness and get-max-brightness options to the external helper, as they are Linux-dependent anyway (they use Linux sysfs paths), preferring the same in-process udev lookups we use here.
We gate this feature entirely behind a --with-udev configure flag so users who don't have a sufficient libgudev version won't be stuck. As the required version has landed in Debian stable, we may be able to make it a hard requirement on Linux in the not-too-distant future.
I've also included a small bugfix to the OSD window class. It seems that when a compositor is switched out from under the daemon while it has an OSD window open, the callback to close the window after a given time will cause a segfault.
systemd 243 added support for an additional mechanism for managing backlight brightness in the form of a D-Bus call to the current logind session. The feature allows any user to manipulate backlights and LEDs without superuser privileges.
This change modifies the brightness backend so that it uses the logind API as a fallback with a higher preference than the external binary helper. In other words, we will try to adjust brightness by:
Backlight
orBACKLIGHT
property on the XRandR outputSetBrightness
call to the logind sessionThis change is roughly inspired by a similar adjustment to gnome-settings-daemon, although in their case they prefer the D-Bus approach over XRR; this seems overly blunt to me but perhaps makes sense in the context of future Wayland support.
Unfortunately, there's no corresponding
GetBrightness
call available, nor is there any way to enumerate backlight devices through D-Bus. We add libgudev as a dependency so that we can look up current backlights and brightness values as needed. In theory, a future revision to this code could eliminate the get-brightness and get-max-brightness options to the external helper, as they are Linux-dependent anyway (they use Linux sysfs paths), preferring the same in-process udev lookups we use here.We gate this feature entirely behind a
--with-udev
configure flag so users who don't have a sufficient libgudev version won't be stuck. As the required version has landed in Debian stable, we may be able to make it a hard requirement on Linux in the not-too-distant future.I've also included a small bugfix to the OSD window class. It seems that when a compositor is switched out from under the daemon while it has an OSD window open, the callback to close the window after a given time will cause a segfault.