From 3000145191a00d4c9b90efb221fadb9ce37380c0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 29 Mar 2007 23:18:14 -0700 Subject: Add -time and -steps options to adjust fade --- xbacklight.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'xbacklight.c') diff --git a/xbacklight.c b/xbacklight.c index df99905..9090cb5 100644 --- a/xbacklight.c +++ b/xbacklight.c @@ -21,6 +21,8 @@ usage (void) 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); } @@ -65,6 +67,8 @@ main (int argc, char **argv) op_t op = Get; int value = 0; int i; + int total_time = 200; /* ms */ + int steps = 20; program_name = argv[0]; @@ -120,10 +124,23 @@ main (int argc, char **argv) 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) @@ -190,16 +207,16 @@ main (int argc, char **argv) } if (new > max) new = max; if (new < min) new = min; - step = (new - cur) / 50; - for (i = 0; i < 50; i++) + step = (new - cur) / steps; + for (i = 0; i < steps && step != 0; i++) { - if (i == 49) + if (i == steps - 1) cur = new; else cur += step; backlight_set (dpy, output, (long) cur); XFlush (dpy); - usleep (10 * 1000); + usleep (total_time * 1000 / steps); } } } -- cgit v1.2.3