[PATCH:xbacklight] Use double instead of int for value

Nils Schneider nils at nilsschneider.net
Mon Sep 28 06:20:30 PDT 2015


Modern displays allow for fine grained brightness settings. For example,
my laptop allows for 852 brightness steps. In some situations I find it
useful to set the brightness below 1 percent (the minimum possible when
using integers).

This patch makes xbacklight use a double instead so lower brightness
values like 0.12 are possible.

Signed-off-by: Nils Schneider <nils at nilsschneider.net>
---
 xbacklight.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/xbacklight.c b/xbacklight.c
index 21cca72..f4a8b12 100644
--- a/xbacklight.c
+++ b/xbacklight.c
@@ -120,7 +120,7 @@ main (int argc, char **argv)
 {
     char    *dpy_name = NULL;
     op_t    op = Get;
-    int	    value = 0;
+    double  value = 0;
     int	    i;
     int	    total_time = 200;	/* ms */
     int	    steps = 20;
@@ -150,39 +150,39 @@ main (int argc, char **argv)
 	{
 	    if (++i >= argc) missing_arg (argv[i-1]);
 	    op = Set;
-	    value = atoi (argv[i]);
+	    value = atof (argv[i]);
 	    continue;
 	}
 	if (argv[i][0] == '=' && isdigit (argv[i][1]))
 	{
 	    op = Set;
-	    value = atoi (argv[i] + 1);
+	    value = atof (argv[i] + 1);
 	    continue;
 	}
 	if (!strcmp (argv[i], "-inc") || !strcmp (argv[i], "+"))
 	{
 	    if (++i >= argc) missing_arg (argv[i-1]);
 	    op = Inc;
-	    value = atoi (argv[i]);
+	    value = atof (argv[i]);
 	    continue;
 	}
 	if (argv[i][0] == '+' && isdigit (argv[i][1]))
 	{
 	    op = Inc;
-	    value = atoi (argv[i] + 1);
+	    value = atof (argv[i] + 1);
 	    continue;
 	}
 	if (!strcmp (argv[i], "-dec") || !strcmp (argv[i], "-"))
 	{
 	    if (++i >= argc) missing_arg (argv[i-1]);
 	    op = Dec;
-	    value = atoi (argv[i]);
+	    value = atof (argv[i]);
 	    continue;
 	}
 	if (argv[i][0] == '-' && isdigit (argv[i][1]))
 	{
 	    op = Dec;
-	    value = atoi (argv[i] + 1);
+	    value = atof (argv[i] + 1);
 	    continue;
 	}
 	if (!strcmp (argv[i], "-get") || !strcmp (argv[i], "-g"))
-- 
2.5.3



More information about the xorg-devel mailing list