summaryrefslogtreecommitdiff
path: root/xbacklight.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@neko.keithp.com>2007-03-29 23:18:14 -0700
committerKeith Packard <keithp@neko.keithp.com>2007-03-29 23:18:14 -0700
commit3000145191a00d4c9b90efb221fadb9ce37380c0 (patch)
tree7bd1bdfb0697801f8379ae0cd2fb7a43e766a544 /xbacklight.c
parent38c2c45514d50b825a5c74abedc30cb2272064d7 (diff)
Add -time and -steps options to adjust fade
Diffstat (limited to 'xbacklight.c')
-rw-r--r--xbacklight.c25
1 files changed, 21 insertions, 4 deletions
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 <percentage> or + <percentage>\n");
fprintf(stderr, " -dec <percentage> or - <percentage>\n");
fprintf(stderr, " -get\n");
+ fprintf(stderr, " -time <fade time in milliseconds>\n");
+ fprintf(stderr, " -steps <number of steps in fade>\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);
}
}
}