From bca81be7755d15e7369d764bfa94a7ca6c595c76 Mon Sep 17 00:00:00 2001 From: Topi Miettinen Date: Sun, 1 Feb 2015 08:49:02 +0200 Subject: [PATCH] backlight: let udev properties override clamping On my computer, the minimum brightness enforced by clamping in backlight is too bright. Let udev property ID_BACKLIGHT_CLAMP control whether the brightness is clamped or not. --- man/systemd-backlight@.service.xml | 9 ++++++++- src/backlight/backlight.c | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/man/systemd-backlight@.service.xml b/man/systemd-backlight@.service.xml index 453afbf1b..21c6437ef 100644 --- a/man/systemd-backlight@.service.xml +++ b/man/systemd-backlight@.service.xml @@ -58,7 +58,14 @@ is a service that restores the display backlight brightness at early boot and saves it at shutdown. On disk, the backlight brightness is stored in - /var/lib/systemd/backlight/. + /var/lib/systemd/backlight/. During + loading, if udev property + is not set to + false value, the brightness is clamped to a value of + at least 1 or 5% of maximum brightness, whichever is + greater. This restriction will be removed when the + kernel allows user space to reliably set a brightness + value which does not turn off the display. diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index 1271a6698..c79ad6520 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -373,6 +373,7 @@ int main(int argc, char *argv[]) { if (streq(argv[1], "load")) { _cleanup_free_ char *value = NULL; + const char *clamp; if (!shall_restore_state()) return EXIT_SUCCESS; @@ -390,7 +391,9 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - clamp_brightness(device, &value, max_brightness); + clamp = udev_device_get_property_value(device, "ID_BACKLIGHT_CLAMP"); + if (!clamp || parse_boolean(clamp) != 0) /* default to clamping */ + clamp_brightness(device, &value, max_brightness); r = udev_device_set_sysattr_value(device, "brightness", value); if (r < 0) { -- 2.30.2