diff options
-rw-r--r-- | xbacklight.c | 25 | ||||
-rw-r--r-- | xbacklight.man | 7 |
2 files changed, 27 insertions, 5 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); } } } diff --git a/xbacklight.man b/xbacklight.man index 0a998f6..b5a060c 100644 --- a/xbacklight.man +++ b/xbacklight.man @@ -44,8 +44,13 @@ Sets each backlight brightness to the specified level. Increases brightness by the specified amount. .IP "-dec \fIpercent\fP" Decreases brightness by the specified amount. -.IP --help +.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 faiding. Default is 20. .SH "SEE ALSO" Xrandr(3) .SH AUTHORS |