aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--brightnessctl.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 63cdcc4..b3986fb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
VERSION = 0.2
DESTDIR ?= /usr/local
-CFLAGS += -std=c99 -g -Wall -Wextra -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L
+CFLAGS += -std=c99 -g -Wall -Wextra -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -lm
MODE ?= 4711
all: brightnessctl
diff --git a/brightnessctl.c b/brightnessctl.c
index f169608..71321c4 100644
--- a/brightnessctl.c
+++ b/brightnessctl.c
@@ -10,6 +10,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
static char *path = "/sys/class";
static char *classes[] = { "backlight", "leds", NULL };
@@ -292,7 +293,7 @@ int print_device(struct device *dev) {
void apply_value(struct device *d, struct value *val) {
long new, mod = val->v_type == ABSOLUTE ?
- val->val : val->val / 100.0 * d->max_brightness;
+ val->val : ceil(val->val / 100.0 * d->max_brightness);
if (val->d_type == DIRECT) {
new = mod > d->max_brightness ? d->max_brightness : mod;
goto apply;