chiark / gitweb /
backlight: let udev properties override clamping
authorTopi Miettinen <toiwoton@gmail.com>
Sun, 1 Feb 2015 06:49:02 +0000 (08:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 2 Feb 2015 16:18:40 +0000 (17:18 +0100)
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
src/backlight/backlight.c

index 453afbf1b415ec4985da80e0a44d8931b08caf90..21c6437efab4d277a800cd6dea607c5703ffaeb0 100644 (file)
                 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
-                <filename>/var/lib/systemd/backlight/</filename>.</para>
+                <filename>/var/lib/systemd/backlight/</filename>. During
+                loading, if udev property
+                <option>ID_BACKLIGHT_CLAMP</option> 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.</para>
         </refsect1>
 
         <refsect1>
index 1271a66983392c8dc1a692eb0b6f83f4f47c46f9..c79ad6520c9f8668f0992c51d7506790f23e8726 100644 (file)
@@ -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) {