aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/backlight
diff options
context:
space:
mode:
authorDavid Schlachter <fbsd-bugzilla@schlachter.ca>2021-03-03 07:57:35 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2021-03-03 07:57:35 +0000
commit3b005d51bd0fe4d8d19fb2df4d470b6e8baebf16 (patch)
treed52a85bb1bb01383a62f6c37fe291383be0559dd /usr.bin/backlight
parent5842073a9b7471831e0da48d29dd984d575f4e9e (diff)
downloadsrc-3b005d51bd0fe4d8d19fb2df4d470b6e8baebf16.tar.gz
src-3b005d51bd0fe4d8d19fb2df4d470b6e8baebf16.zip
Diffstat (limited to 'usr.bin/backlight')
-rw-r--r--usr.bin/backlight/backlight.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/backlight/backlight.c b/usr.bin/backlight/backlight.c
index 1dae0cfe5c62..9cf7a0912e95 100644
--- a/usr.bin/backlight/backlight.c
+++ b/usr.bin/backlight/backlight.c
@@ -98,7 +98,7 @@ main(int argc, char *argv[])
BACKLIGHTGETSTATUS,
BACKLIGHTUPDATESTATUS,
BACKLIGHTGETINFO};
- long percent = 0;
+ long percent = -1;
const char *percent_error;
uint32_t i;
bool setname;
@@ -188,15 +188,20 @@ main(int argc, char *argv[])
}
break;
case BACKLIGHT_SET_BRIGHTNESS:
+ if (percent == -1)
+ usage();
props.brightness = percent;
if (ioctl(fd, BACKLIGHTUPDATESTATUS, &props) == -1)
errx(1, "Cannot update the backlight device");
break;
case BACKLIGHT_INCR:
case BACKLIGHT_DECR:
+ if (percent == 0)
+ /* Avoid any ioctl if we don't have anything to do */
+ break;
if (ioctl(fd, BACKLIGHTGETSTATUS, &props) == -1)
errx(1, "Cannot query the backlight device");
- percent = percent == 0 ? 10 : percent;
+ percent = percent == -1 ? 10 : percent;
percent = action == BACKLIGHT_INCR ? percent : -percent;
props.brightness += percent;
if ((int)props.brightness < 0)