Timo Aaltonen pushed to branch upstream-unstable at X Strike Force / app / xbacklight
Commits:
-
4080fb78
by Alan Coopersmith at 2013-11-25T22:37:45-08:00
-
b2a08484
by Alan Coopersmith at 2013-11-25T22:41:12-08:00
-
af78be65
by Alan Coopersmith at 2014-06-02T22:09:32-07:00
-
7db4876c
by Alan Coopersmith at 2014-06-02T22:09:32-07:00
-
f6277d4b
by Nils Schneider at 2015-10-26T13:35:29+01:00
-
25f26120
by Nils Schneider at 2015-11-05T14:55:56+01:00
-
f74c4af2
by Peter Hutterer at 2017-01-26T10:13:53+10:00
-
d4ba6640
by Emil Velikov at 2017-01-26T10:13:53+10:00
-
67f8af19
by Mihail Konev at 2017-01-26T14:00:20+10:00
-
8709d1ef
by Alan Coopersmith at 2018-03-09T17:35:30-08:00
-
12274b4d
by Alan Coopersmith at 2018-11-16T21:09:45-08:00
-
31d4c5d6
by Alan Coopersmith at 2018-11-21T16:58:46-08:00
-
ce6001ab
by Roman Donchenko at 2019-06-09T13:05:47-07:00
-
92de87f3
by Roberto Ricci at 2019-06-09T13:07:16-07:00
-
5172321f
by Alan Coopersmith at 2019-06-09T13:23:06-07:00
-
76de9d7a
by Alan Coopersmith at 2019-07-14T11:25:03-07:00
6 changed files:
Changes:
... | ... | @@ -41,3 +41,5 @@ ChangeLog: |
41 | 41 | $(CHANGELOG_CMD)
|
42 | 42 | |
43 | 43 | dist-hook: ChangeLog INSTALL
|
44 | + |
|
45 | +EXTRA_DIST = README.md |
1 | -Xbacklight is used to adjust the backlight brightness where supported.
|
|
1 | +Xbacklight is used to adjust the backlight brightness where supported.
|
|
2 | 2 | It uses the RandR extension to find all outputs on the X server
|
3 | 3 | supporting backlight brightness control and changes them all in the
|
4 | 4 | same way.
|
... | ... | @@ -6,23 +6,15 @@ same way. |
6 | 6 | All questions regarding this software should be directed at the
|
7 | 7 | Xorg mailing list:
|
8 | 8 | |
9 | - http://lists.freedesktop.org/mailman/listinfo/xorg
|
|
10 | - |
|
11 | -Please submit bug reports to the Xorg bugzilla:
|
|
12 | - |
|
13 | - https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
|
|
9 | + https://lists.x.org/mailman/listinfo/xorg
|
|
14 | 10 | |
15 | 11 | The master development code repository can be found at:
|
16 | 12 | |
17 | - git://anongit.freedesktop.org/git/xorg/app/xbacklight
|
|
13 | + https://gitlab.freedesktop.org/xorg/app/xbacklight
|
|
18 | 14 | |
19 | - http://cgit.freedesktop.org/xorg/app/xbacklight
|
|
15 | +Please submit bug reports and requests to merge patches there.
|
|
20 | 16 | |
21 | 17 | For patch submission instructions, see:
|
22 | 18 | |
23 | - http://www.x.org/wiki/Development/Documentation/SubmittingPatches
|
|
24 | - |
|
25 | -For more information on the git code manager, see:
|
|
26 | - |
|
27 | - http://wiki.x.org/wiki/GitPage
|
|
19 | + https://www.x.org/wiki/Development/Documentation/SubmittingPatches
|
|
28 | 20 |
1 | 1 | #! /bin/sh
|
2 | 2 | |
3 | -srcdir=`dirname $0`
|
|
3 | +srcdir=`dirname "$0"`
|
|
4 | 4 | test -z "$srcdir" && srcdir=.
|
5 | 5 | |
6 | 6 | ORIGDIR=`pwd`
|
7 | -cd $srcdir
|
|
7 | +cd "$srcdir"
|
|
8 | 8 | |
9 | 9 | autoreconf -v --install || exit 1
|
10 | -cd $ORIGDIR || exit $?
|
|
10 | +cd "$ORIGDIR" || exit $?
|
|
11 | 11 | |
12 | -$srcdir/configure --enable-maintainer-mode "$@"
|
|
12 | +git config --local --get format.subjectPrefix >/dev/null 2>&1 ||
|
|
13 | + git config --local format.subjectPrefix "PATCH app/xbacklight"
|
|
13 | 14 | |
15 | +if test -z "$NOCONFIGURE"; then
|
|
16 | + exec "$srcdir"/configure "$@"
|
|
17 | +fi |
... | ... | @@ -23,15 +23,14 @@ dnl Process this file with autoconf to create configure. |
23 | 23 | |
24 | 24 | # Initialize Autoconf
|
25 | 25 | AC_PREREQ([2.60])
|
26 | -AC_INIT([xbacklight], [1.2.1],
|
|
27 | - [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
|
26 | +AC_INIT([xbacklight], [1.2.3],
|
|
27 | + [https://gitlab.freedesktop.org/xorg/app/xbacklight/issues],
|
|
28 | 28 | [xbacklight])
|
29 | 29 | AC_CONFIG_SRCDIR([Makefile.am])
|
30 | 30 | AC_CONFIG_HEADERS([config.h])
|
31 | 31 | |
32 | 32 | # Initialize Automake
|
33 | 33 | AM_INIT_AUTOMAKE([foreign dist-bzip2])
|
34 | -AM_MAINTAINER_MODE
|
|
35 | 34 | |
36 | 35 | # Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
|
37 | 36 | m4_ifndef([XORG_MACROS_VERSION],
|
... | ... | @@ -46,6 +46,8 @@ Increases brightness by the specified amount. |
46 | 46 | Decreases brightness by the specified amount.
|
47 | 47 | .IP \-help
|
48 | 48 | Print out a summary of the usage and exit.
|
49 | +.IP \-version
|
|
50 | +Print out the program version and exit.
|
|
49 | 51 | .IP "\-time \fImilliseconds\fP"
|
50 | 52 | Length of time to spend fading the backlight between old and new value.
|
51 | 53 | Default is 200.
|
... | ... | @@ -19,8 +19,14 @@ |
19 | 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
20 | 20 | * OF THIS SOFTWARE.
|
21 | 21 | */
|
22 | + |
|
23 | +#ifdef HAVE_CONFIG_H
|
|
24 | +# include "config.h"
|
|
25 | +#endif
|
|
26 | + |
|
22 | 27 | #include <stdio.h>
|
23 | 28 | #include <stdlib.h>
|
29 | +#include <errno.h>
|
|
24 | 30 | |
25 | 31 | #include <xcb/xcb.h>
|
26 | 32 | #include <xcb/xcb_util.h>
|
... | ... | @@ -38,19 +44,41 @@ static char *program_name; |
38 | 44 | static xcb_atom_t backlight, backlight_new, backlight_legacy;
|
39 | 45 | |
40 | 46 | static void
|
41 | -usage (void)
|
|
47 | +usage (int exitcode)
|
|
42 | 48 | {
|
43 | 49 | fprintf(stderr, "usage: %s [options]\n%s", program_name,
|
44 | 50 | " where options are:\n"
|
45 | 51 | " -display <display> or -d <display>\n"
|
46 | 52 | " -help\n"
|
53 | + " -version\n"
|
|
47 | 54 | " -set <percentage> or = <percentage>\n"
|
48 | 55 | " -inc <percentage> or + <percentage>\n"
|
49 | 56 | " -dec <percentage> or - <percentage>\n"
|
50 | 57 | " -get\n"
|
51 | 58 | " -time <fade time in milliseconds>\n"
|
52 | 59 | " -steps <number of steps in fade>\n");
|
53 | - exit (1);
|
|
60 | + exit (exitcode);
|
|
61 | +}
|
|
62 | + |
|
63 | +static double
|
|
64 | +atof_or_die (char *str)
|
|
65 | +{
|
|
66 | + double retval;
|
|
67 | + char *endptr = NULL;
|
|
68 | + errno = 0;
|
|
69 | + retval = strtod(str, &endptr);
|
|
70 | + if ((errno != 0) || (endptr == str)) {
|
|
71 | + fprintf(stderr, "%s: invalid argument '%s'\n", program_name, str);
|
|
72 | + usage(1);
|
|
73 | + }
|
|
74 | + return retval;
|
|
75 | +}
|
|
76 | + |
|
77 | +static void
|
|
78 | +missing_arg (const char *option)
|
|
79 | +{
|
|
80 | + fprintf(stderr, "%s: %s requires an argument\n", program_name, option);
|
|
81 | + usage(1);
|
|
54 | 82 | }
|
55 | 83 | |
56 | 84 | static long
|
... | ... | @@ -107,7 +135,7 @@ main (int argc, char **argv) |
107 | 135 | {
|
108 | 136 | char *dpy_name = NULL;
|
109 | 137 | op_t op = Get;
|
110 | - int value = 0;
|
|
138 | + double value = 0;
|
|
111 | 139 | int i;
|
112 | 140 | int total_time = 200; /* ms */
|
113 | 141 | int steps = 20;
|
... | ... | @@ -129,47 +157,47 @@ main (int argc, char **argv) |
129 | 157 | {
|
130 | 158 | if (!strcmp (argv[i], "-display") || !strcmp ("-d", argv[i]))
|
131 | 159 | {
|
132 | - if (++i >= argc) usage();
|
|
160 | + if (++i >= argc) missing_arg (argv[i-1]);
|
|
133 | 161 | dpy_name = argv[i];
|
134 | 162 | continue;
|
135 | 163 | }
|
136 | 164 | if (!strcmp (argv[i], "-set") || !strcmp (argv[i], "="))
|
137 | 165 | {
|
138 | - if (++i >= argc) usage();
|
|
166 | + if (++i >= argc) missing_arg (argv[i-1]);
|
|
139 | 167 | op = Set;
|
140 | - value = atoi (argv[i]);
|
|
168 | + value = atof_or_die (argv[i]);
|
|
141 | 169 | continue;
|
142 | 170 | }
|
143 | 171 | if (argv[i][0] == '=' && isdigit (argv[i][1]))
|
144 | 172 | {
|
145 | 173 | op = Set;
|
146 | - value = atoi (argv[i] + 1);
|
|
174 | + value = atof_or_die (argv[i] + 1);
|
|
147 | 175 | continue;
|
148 | 176 | }
|
149 | 177 | if (!strcmp (argv[i], "-inc") || !strcmp (argv[i], "+"))
|
150 | 178 | {
|
151 | - if (++i >= argc) usage();
|
|
179 | + if (++i >= argc) missing_arg (argv[i-1]);
|
|
152 | 180 | op = Inc;
|
153 | - value = atoi (argv[i]);
|
|
181 | + value = atof_or_die (argv[i]);
|
|
154 | 182 | continue;
|
155 | 183 | }
|
156 | 184 | if (argv[i][0] == '+' && isdigit (argv[i][1]))
|
157 | 185 | {
|
158 | 186 | op = Inc;
|
159 | - value = atoi (argv[i] + 1);
|
|
187 | + value = atof_or_die (argv[i] + 1);
|
|
160 | 188 | continue;
|
161 | 189 | }
|
162 | 190 | if (!strcmp (argv[i], "-dec") || !strcmp (argv[i], "-"))
|
163 | 191 | {
|
164 | - if (++i >= argc) usage();
|
|
192 | + if (++i >= argc) missing_arg (argv[i-1]);
|
|
165 | 193 | op = Dec;
|
166 | - value = atoi (argv[i]);
|
|
194 | + value = atof_or_die (argv[i]);
|
|
167 | 195 | continue;
|
168 | 196 | }
|
169 | 197 | if (argv[i][0] == '-' && isdigit (argv[i][1]))
|
170 | 198 | {
|
171 | 199 | op = Dec;
|
172 | - value = atoi (argv[i] + 1);
|
|
200 | + value = atof_or_die (argv[i] + 1);
|
|
173 | 201 | continue;
|
174 | 202 | }
|
175 | 203 | if (!strcmp (argv[i], "-get") || !strcmp (argv[i], "-g"))
|
... | ... | @@ -179,21 +207,28 @@ main (int argc, char **argv) |
179 | 207 | }
|
180 | 208 | if (!strcmp (argv[i], "-time"))
|
181 | 209 | {
|
182 | - if (++i >= argc) usage();
|
|
210 | + if (++i >= argc) missing_arg (argv[i-1]);
|
|
183 | 211 | total_time = atoi (argv[i]);
|
184 | 212 | continue;
|
185 | 213 | }
|
186 | 214 | if (!strcmp (argv[i], "-steps"))
|
187 | 215 | {
|
188 | - if (++i >= argc) usage();
|
|
216 | + if (++i >= argc) missing_arg (argv[i-1]);
|
|
189 | 217 | steps = atoi (argv[i]);
|
190 | 218 | continue;
|
191 | 219 | }
|
192 | 220 | if (!strcmp (argv[i], "-help") || !strcmp (argv[i], "-?"))
|
193 | 221 | {
|
194 | - usage ();
|
|
222 | + usage (0);
|
|
223 | + }
|
|
224 | + if (!strcmp (argv[i], "-version"))
|
|
225 | + {
|
|
226 | + puts (PACKAGE_STRING);
|
|
227 | + exit (0);
|
|
195 | 228 | }
|
196 | - usage ();
|
|
229 | + fprintf(stderr, "%s: unrecognized argument '%s'\n",
|
|
230 | + program_name, argv[i]);
|
|
231 | + usage (1);
|
|
197 | 232 | }
|
198 | 233 | conn = xcb_connect (dpy_name, NULL);
|
199 | 234 | ver_cookie = xcb_randr_query_version (conn, 1, 2);
|
... | ... | @@ -245,18 +280,18 @@ main (int argc, char **argv) |
245 | 280 | xcb_window_t root = screen->root;
|
246 | 281 | xcb_randr_output_t *outputs;
|
247 | 282 | |
248 | - xcb_randr_get_screen_resources_cookie_t resources_cookie;
|
|
249 | - xcb_randr_get_screen_resources_reply_t *resources_reply;
|
|
283 | + xcb_randr_get_screen_resources_current_cookie_t resources_cookie;
|
|
284 | + xcb_randr_get_screen_resources_current_reply_t *resources_reply;
|
|
250 | 285 | |
251 | - resources_cookie = xcb_randr_get_screen_resources (conn, root);
|
|
252 | - resources_reply = xcb_randr_get_screen_resources_reply (conn, resources_cookie, &error);
|
|
286 | + resources_cookie = xcb_randr_get_screen_resources_current (conn, root);
|
|
287 | + resources_reply = xcb_randr_get_screen_resources_current_reply (conn, resources_cookie, &error);
|
|
253 | 288 | if (error != NULL || resources_reply == NULL) {
|
254 | 289 | int ec = error ? error->error_code : -1;
|
255 | 290 | fprintf (stderr, "RANDR Get Screen Resources returned error %d\n", ec);
|
256 | 291 | continue;
|
257 | 292 | }
|
258 | 293 | |
259 | - outputs = xcb_randr_get_screen_resources_outputs (resources_reply);
|
|
294 | + outputs = xcb_randr_get_screen_resources_current_outputs (resources_reply);
|
|
260 | 295 | for (int o = 0; o < resources_reply->num_outputs; o++)
|
261 | 296 | {
|
262 | 297 | xcb_randr_output_t output = outputs[o];
|
... | ... | @@ -308,7 +343,7 @@ main (int argc, char **argv) |
308 | 343 | cur = new;
|
309 | 344 | else
|
310 | 345 | cur += step;
|
311 | - backlight_set (conn, output, (long) cur);
|
|
346 | + backlight_set (conn, output, (long) (cur + 0.5));
|
|
312 | 347 | xcb_flush (conn);
|
313 | 348 | usleep (total_time * 1000 / steps);
|
314 | 349 | }
|