Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpm-brightness: add systemd-logind fallback #380

Closed
wants to merge 1 commit into from

Conversation

impl
Copy link

@impl impl commented Jul 22, 2022

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:

  1. Changing the Backlight or BACKLIGHT property on the XRandR output
  2. Making a D-Bus SetBrightness call to the logind session
  3. 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:

1. Changing the Backlight or BACKLIGHT property on the XRandR output
2. Making a D-Bus SetBrightness call to the logind session
3. 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.
@impl impl force-pushed the backlight-logind-fallback branch from df44c8c to 18a3235 Compare July 22, 2022 05:23
@lukefromdc
Copy link
Member

Do we have a tester with a non-systemd distro(e.g Devuan, BSD) on a laptop to test this for function. I don't have one set up myself

@raveit65
Copy link
Member

@impl
How can this be tested?

@impl impl closed this Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants