summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Schneider <nils@nilsschneider.net>2015-09-28 15:20:30 +0200
committerHans de Goede <hdegoede@redhat.com>2015-10-26 13:35:29 +0100
commitf6277d4bf39de12c43a5dfb6db0de8e137ea7071 (patch)
tree05622bcc42dd22a34ef852f7fc394640210de590
parent7db4876cdeaa5d25cb857bead7153ef503e993d6 (diff)
Use double instead of int for value
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@nilsschneider.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--xbacklight.c14
1 files 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"))