pax_global_header00006660000000000000000000000064112570123250014510gustar00rootroot0000000000000052 comment=cbf474d6751dd32154163b8997519319655f0545 xbacklight-1.1.1/000075500000000000000000000000001125701232500136265ustar00rootroot00000000000000xbacklight-1.1.1/.gitignore000064400000000000000000000003621125701232500156170ustar00rootroot00000000000000.deps Makefile Makefile.in aclocal.m4 autom4te.cache compile config.guess config.h config.h.in config.log config.status config.sub configure depcomp install-sh missing stamp-h1 xbacklight xbacklight.1 *~ *.o ChangeLog xbacklight-*.tar.* tags xbacklight-1.1.1/COPYING000064400000000000000000000021511125701232500146600ustar00rootroot00000000000000Copyright © 2007 Keith Packard Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the copyright holders not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The copyright holders make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. xbacklight-1.1.1/Makefile.am000064400000000000000000000044571125701232500156740ustar00rootroot00000000000000# # Copyright 2005 Red Hat, Inc. # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of Red Hat not be used in # advertising or publicity pertaining to distribution of the software without # specific, written prior permission. Red Hat makes no # representations about the suitability of this software for any purpose. It # is provided "as is" without express or implied warranty. # # RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO # EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, # DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = xbacklight AM_CFLAGS = $(CWARNFLAGS) $(XRANDR_CFLAGS) xbacklight_LDADD = $(XRANDR_LIBS) xbacklight_SOURCES = \ xbacklight.c appman_PRE = \ xbacklight.man appmandir = $(APP_MAN_DIR) appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) EXTRA_DIST = $(appman_PRE) COPYING CLEANFILES = $(appman_DATA) SED = sed # Strings to replace in man pages XORGRELSTRING = @PACKAGE_STRING@ XORGMANNAME = X Version 11 MAN_SUBSTS = \ -e 's|__vendorversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \ -e 's|__xorgversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \ -e 's|__xservername__|Xorg|g' \ -e 's|__xconfigfile__|xorg.conf|g' \ -e 's|__projectroot__|$(prefix)|g' \ -e 's|__apploaddir__|$(appdefaultdir)|' \ -e 's|__appmansuffix__|$(APP_MAN_SUFFIX)|g' \ -e 's|__libmansuffix__|$(LIB_MAN_SUFFIX)|g' \ -e 's|__adminmansuffix__|$(ADMIN_MAN_SUFFIX)|g' \ -e 's|__miscmansuffix__|$(MISC_MAN_SUFFIX)|g' \ -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' SUFFIXES = .$(APP_MAN_SUFFIX) .man .man.$(APP_MAN_SUFFIX): sed $(MAN_SUBSTS) < $< > $@ EXTRA_DIST += ChangeLog MAINTAINERCLEANFILES=ChangeLog .PHONY: ChangeLog ChangeLog: $(CHANGELOG_CMD) dist-hook: ChangeLog xbacklight-1.1.1/README000064400000000000000000000015231125701232500145070ustar00rootroot00000000000000Xbacklight is used to adjust the backlight brightness where supported. It uses the RandR extension to find all outputs on the X server supporting backlight brightness control and changes them all in the same way. All questions regarding this software should be directed at the Xorg mailing list: http://lists.freedesktop.org/mailman/listinfo/xorg Please submit bug reports to the Xorg bugzilla: https://bugs.freedesktop.org/enter_bug.cgi?product=xorg The master development code repository can be found at: git://anongit.freedesktop.org/git/xorg/app/xbacklight http://cgit.freedesktop.org/xorg/app/xbacklight For patch submission instructions, see: http://www.x.org/wiki/Development/Documentation/SubmittingPatches For more information on the git code manager, see: http://wiki.x.org/wiki/GitPage xbacklight-1.1.1/autogen.sh000075500000000000000000000003041125701232500156240ustar00rootroot00000000000000#! /bin/sh srcdir=`dirname $0` test -z "$srcdir" && srcdir=. ORIGDIR=`pwd` cd $srcdir autoreconf -v --install || exit 1 cd $ORIGDIR || exit $? $srcdir/configure --enable-maintainer-mode "$@" xbacklight-1.1.1/configure.ac000064400000000000000000000034311125701232500161150ustar00rootroot00000000000000 dnl Copyright 2005 Red Hat, Inc. dnl dnl Permission to use, copy, modify, distribute, and sell this software and its dnl documentation for any purpose is hereby granted without fee, provided that dnl the above copyright notice appear in all copies and that both that dnl copyright notice and this permission notice appear in supporting dnl documentation, and that the name of Red Hat not be used in dnl advertising or publicity pertaining to distribution of the software without dnl specific, written prior permission. Red Hat makes no dnl representations about the suitability of this software for any purpose. It dnl is provided "as is" without express or implied warranty. dnl dnl RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO dnl EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR dnl PERFORMANCE OF THIS SOFTWARE. dnl dnl Process this file with autoconf to create configure. AC_PREREQ([2.57]) AC_INIT(xbacklight,[1.1.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xbacklight) AM_INIT_AUTOMAKE([dist-bzip2]) AM_MAINTAINER_MODE # Require xorg-macros: XORG_DEFAULT_OPTIONS m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.3 or later before running autoconf/autogen])]) XORG_MACROS_VERSION(1.3) AM_CONFIG_HEADER(config.h) AC_PROG_CC AC_PROG_INSTALL XORG_DEFAULT_OPTIONS # Checks for pkg-config packages PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2.0 xrender x11) AC_SUBST(XRANDR_CFLAGS) AC_SUBST(XRANDR_LIBS) AC_OUTPUT([Makefile]) xbacklight-1.1.1/xbacklight.c000064400000000000000000000156041125701232500161200ustar00rootroot00000000000000/* * Copyright © 2007 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting documentation, and * that the name of the copyright holders not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. The copyright holders make no representations * about the suitability of this software for any purpose. It is provided "as * is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include typedef enum { Get, Set, Inc, Dec } op_t; static char *program_name; static Atom backlight, backlight_new, backlight_legacy; static void usage (void) { fprintf(stderr, "usage: %s [options]\n", program_name); fprintf(stderr, " where options are:\n"); fprintf(stderr, " -display or -d \n"); fprintf(stderr, " -help\n"); fprintf(stderr, " -set or = \n"); fprintf(stderr, " -inc or + \n"); fprintf(stderr, " -dec or - \n"); fprintf(stderr, " -get\n"); fprintf(stderr, " -time \n"); fprintf(stderr, " -steps \n"); /*NOTREACHED*/ exit (1); } static long backlight_get (Display *dpy, RROutput output) { unsigned long nitems; unsigned long bytes_after; unsigned char *prop; Atom actual_type; int actual_format; long value; backlight = backlight_new; if (!backlight || XRRGetOutputProperty (dpy, output, backlight, 0, 4, False, False, None, &actual_type, &actual_format, &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 value = *((long *) prop); XFree (prop); return value; } static void backlight_set (Display *dpy, RROutput output, long value) { XRRChangeOutputProperty (dpy, output, backlight, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &value, 1); } int main (int argc, char **argv) { char *dpy_name = NULL; Display *dpy; int screen; int major, minor; op_t op = Get; int value = 0; int i; int total_time = 200; /* ms */ int steps = 20; program_name = argv[0]; for (i = 1; i < argc; i++) { if (!strcmp (argv[i], "-display") || !strcmp ("-d", argv[i])) { if (++i >= argc) usage(); dpy_name = argv[i]; continue; } if (!strcmp (argv[i], "-set") || !strcmp (argv[i], "=")) { if (++i >= argc) usage(); op = Set; value = atoi (argv[i]); continue; } if (argv[i][0] == '=' && isdigit (argv[i][1])) { op = Set; value = atoi (argv[i] + 1); continue; } if (!strcmp (argv[i], "-inc") || !strcmp (argv[i], "+")) { if (++i >= argc) usage(); op = Inc; value = atoi (argv[i]); continue; } if (argv[i][0] == '+' && isdigit (argv[i][1])) { op = Inc; value = atoi (argv[i] + 1); continue; } if (!strcmp (argv[i], "-dec") || !strcmp (argv[i], "-")) { if (++i >= argc) usage(); op = Dec; value = atoi (argv[i]); continue; } if (argv[i][0] == '-' && isdigit (argv[i][1])) { op = Dec; value = atoi (argv[i] + 1); continue; } if (!strcmp (argv[i], "-get") || !strcmp (argv[i], "-g")) { op = Get; continue; } if (!strcmp (argv[i], "-time")) { if (++i >= argc) usage(); total_time = atoi (argv[i]); continue; } if (!strcmp (argv[i], "-steps")) { if (++i >= argc) usage(); steps = atoi (argv[i]); continue; } if (!strcmp (argv[i], "-help") || !strcmp (argv[i], "-?")) { usage (); } usage (); } dpy = XOpenDisplay (dpy_name); if (!dpy) { fprintf (stderr, "Cannot open display \"%s\"\n", XDisplayName (dpy_name)); exit (1); } if (!XRRQueryVersion (dpy, &major, &minor)) { fprintf (stderr, "RandR extension missing\n"); exit (1); } if (major < 1 || (major == 1 && minor < 2)) { fprintf (stderr, "RandR version %d.%d too old\n", major, minor); exit (1); } 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); } for (screen = 0; screen < ScreenCount (dpy); screen++) { Window root = RootWindow (dpy, screen); XRRScreenResources *resources = XRRGetScreenResources (dpy, root); int o; if (!resources) continue; for (o = 0; o < resources->noutput; o++) { RROutput output = resources->outputs[o]; XRRPropertyInfo *info; double cur, new, step; double min, max; double set; cur = backlight_get (dpy, output); if (cur != -1) { info = XRRQueryOutputProperty (dpy, output, backlight); if (info) { if (info->range && info->num_values == 2) { min = info->values[0]; max = info->values[1]; if (op == Get) { printf ("%f\n", (cur - min) * 100 / (max - min)); } else { set = value * (max - min) / 100; switch (op) { case Set: new = min + set; break; case Inc: new = cur + set; break; case Dec: new = cur - set; break; default: XSync (dpy, False); return 1; } if (new > max) new = max; if (new < min) new = min; step = (new - cur) / steps; for (i = 0; i < steps && step != 0; i++) { if (i == steps - 1) cur = new; else cur += step; backlight_set (dpy, output, (long) cur); XFlush (dpy); usleep (total_time * 1000 / steps); } } } XFree (info); } } } XRRFreeScreenResources (resources); } XSync (dpy, False); return 0; } xbacklight-1.1.1/xbacklight.man000064400000000000000000000045041125701232500164460ustar00rootroot00000000000000.\" .\" Copyright © 2007 Keith Packard.\" .\" Permission to use, copy, modify, distribute, and sell this software and its .\" documentation for any purpose is hereby granted without fee, provided that .\" the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation, and that the name of Keith Packard not be used in .\" advertising or publicity pertaining to distribution of the software without .\" specific, written prior permission. Keith Packard makes no .\" representations about the suitability of this software for any purpose. It .\" is provided "as is" without express or implied warranty. .\" .\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, .\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO .\" EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR .\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, .\" DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER .\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR .\" PERFORMANCE OF THIS SOFTWARE. .\" .\" .TH XBACKLIGHT __appmansuffix__ __vendorversion__ .SH NAME xbacklight \- adjust backlight brightness using RandR extension .SH SYNOPSIS .B "xbacklight" [-help] [-display \fIdisplay\fP] [-get] [-set percent] [-inc percent] [-dec percent] .SH DESCRIPTION .I Xbacklight is used to adjust the backlight brightness where supported. It finds all outputs on the X server supporting backlight brightness control and changes them all in the same way. .IP -get Print out the current backlight brightness of each output with such a control. The brightness is represented as a percentage of the maximum brightness supported. .IP "-set \fIpercent\fP" Sets each backlight brightness to the specified level. .IP "-inc \fIpercent\fP" Increases brightness by the specified amount. .IP "-dec \fIpercent\fP" Decreases brightness by the specified amount. .IP -help Print out a summary of the usage and exit. .IP "-time \fImilliseconds\fP" Length of time to spend fading the backlight between old and new value. Default is 200. .IP "-steps \fInumber\fP" Number of steps to take while fading. Default is 20. .SH "SEE ALSO" Xrandr(3) .SH AUTHORS Keith Packard, Open Source Technology Center, Intel Corporation.