gpm-brightness: add systemd-logind fallback #380
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.