[PATCH:xbacklight] Add a -mul option, which changes brightness by a multiplier.
Jake Schmidt
thejakeschmidt at gmail.com
Wed Dec 28 23:36:28 UTC 2016
On my laptop (a Lenovo ThinkPad X1 Carbon, 4th generation), the physical
screen brightness seems to be a logarithmic function of the xbacklight
number. This means adding/subtracting a constant has a much larger effect
on a dim screen than a bright screen. Multiplying the brightness by, say,
1.5/0.66 gives more desirable behavior (approximately constant brightness
changes throughout the range).
Signed-off-by: Jake Schmidt <thejakeschmidt at gmail.com>
---
xbacklight.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/xbacklight.c b/xbacklight.c
index 278043f..deba73f 100644
--- a/xbacklight.c
+++ b/xbacklight.c
@@ -36,7 +36,7 @@
#include <string.h>
#include <unistd.h>
-typedef enum { Get, Set, Inc, Dec } op_t;
+typedef enum { Get, Set, Inc, Dec, Mul } op_t;
static char *program_name;
@@ -53,6 +53,7 @@ usage (int exitcode)
" -set <percentage> or = <percentage>\n"
" -inc <percentage> or + <percentage>\n"
" -dec <percentage> or - <percentage>\n"
+ " -mul <multiplier> or * <multiplier>\n"
" -get\n"
" -time <fade time in milliseconds>\n"
" -steps <number of steps in fade>\n");
@@ -185,6 +186,19 @@ main (int argc, char **argv)
value = atof (argv[i] + 1);
continue;
}
+ if (!strcmp (argv[i], "-mul") || !strcmp (argv[i], "*"))
+ {
+ if (++i >= argc) missing_arg (argv[i-1]);
+ op = Mul;
+ value = atof (argv[i]);
+ continue;
+ }
+ if (argv[i][0] == '*' && isdigit (argv[i][1]))
+ {
+ op = Mul;
+ value = atof (argv[i] + 1);
+ continue;
+ }
if (!strcmp (argv[i], "-get") || !strcmp (argv[i], "-g"))
{
op = Get;
@@ -315,6 +329,16 @@ main (int argc, char **argv)
case Dec:
new = cur - set;
break;
+ case Mul:
+ set = cur * value - cur;
+ if (value > 1 && set < 1.0) {
+ set = 1.0;
+ }
+ if (value < 1 && set > -1.0) {
+ set = -1.0;
+ }
+ new = cur + set;
+ break;
default:
xcb_aux_sync (conn);
return 1;
--
2.9.3
More information about the xorg-devel
mailing list