summaryrefslogtreecommitdiff
path: root/usr.bin/backlight
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2020-10-06 08:05:19 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2020-10-06 08:05:19 +0000
commit4d1308f49b1d6896f4b864bf3346ead5ff7ee0d0 (patch)
tree9953e7b6e880d8b10f155920fbed32e3dd2b0321 /usr.bin/backlight
parent194d5628721f6a306aa94f7e33be909f1ab16b49 (diff)
downloadsrc-test-4d1308f49b1d6896f4b864bf3346ead5ff7ee0d0.tar.gz
src-test-4d1308f49b1d6896f4b864bf3346ead5ff7ee0d0.zip
backlight: accept '%' in the brightness input value
Improve friendlyness of the command line by accepting the percent brightness in both format: with or without a trailing '%' Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D26692
Notes
Notes: svn path=/head/; revision=366471
Diffstat (limited to 'usr.bin/backlight')
-rw-r--r--usr.bin/backlight/backlight.83
-rw-r--r--usr.bin/backlight/backlight.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/backlight/backlight.8 b/usr.bin/backlight/backlight.8
index 1fcbd5854ee63..e734da59a5675 100644
--- a/usr.bin/backlight/backlight.8
+++ b/usr.bin/backlight/backlight.8
@@ -22,7 +22,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 02, 2020
+.Dd October 06, 2020
.Dt BACKLIGHT 8
.Os
.Sh NAME
@@ -63,6 +63,7 @@ When querying the brightness level only print the value.
Query information about the backlight (name, type).
.It Ar value
Set the brightness level to this value, must be between 0 and 100.
+A trailing '%' is valid.
.It Ar incr | +
.Op Ar value
Decrement the backlight level.
diff --git a/usr.bin/backlight/backlight.c b/usr.bin/backlight/backlight.c
index 2fafd79475254..a68876861adfa 100644
--- a/usr.bin/backlight/backlight.c
+++ b/usr.bin/backlight/backlight.c
@@ -144,6 +144,9 @@ main(int argc, char *argv[])
action = BACKLIGHT_SET_BRIGHTNESS;
if (argc == 1) {
+ /* ignore a trailing % for user friendlyness */
+ if (argv[0][strlen(argv[0]) - 1] == '%')
+ argv[0][strlen(argv[0]) - 1] = '\0';
percent = strtonum(argv[0], 0, 100, &percent_error);
if (percent_error)
errx(1, "Cannot parse brightness level %s: %s",