From 5512e161157d6ac8a8d8a27fc99d596c6686b1da Mon Sep 17 00:00:00 2001 From: Matthias Hopf Date: Wed, 19 Aug 2009 14:38:31 +0200 Subject: Use "Backlight" RandR property, fall back to legacy "BACKLIGHT". --- xbacklight.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/xbacklight.c b/xbacklight.c index 6eb3327..9b68ce8 100644 --- a/xbacklight.c +++ b/xbacklight.c @@ -33,7 +33,7 @@ typedef enum { Get, Set, Inc, Dec } op_t; static char *program_name; -static Atom backlight; +static Atom backlight, backlight_new, backlight_legacy; static void usage (void) @@ -62,11 +62,21 @@ backlight_get (Display *dpy, RROutput output) int actual_format; long value; - if (XRRGetOutputProperty (dpy, output, backlight, + backlight = backlight_new; + if (!backlight || + XRRGetOutputProperty (dpy, output, backlight, 0, 4, False, False, None, &actual_type, &actual_format, - &nitems, &bytes_after, &prop) != Success) - return -1; + &nitems, &bytes_after, &prop) != Success) { + backlight = backlight_legacy; + if (!backlight || + XRRGetOutputProperty (dpy, output, backlight, + 0, 4, False, False, None, + &actual_type, &actual_format, + &nitems, &bytes_after, &prop) != Success) + return -1; + } + if (actual_type != XA_INTEGER || nitems != 1 || actual_format != 32) value = -1; else @@ -184,8 +194,10 @@ main (int argc, char **argv) fprintf (stderr, "RandR version %d.%d too old\n", major, minor); exit (1); } - backlight = XInternAtom (dpy, "BACKLIGHT", True); - if (backlight == None) + + backlight_new = XInternAtom (dpy, "Backlight", True); + backlight_legacy = XInternAtom (dpy, "BACKLIGHT", True); + if (backlight_new == None && backlight_legacy == None) { fprintf (stderr, "No outputs have backlight property\n"); exit (1); -- cgit v1.2.3