commit d7e12e55b0bce62ac3499953d3cbcd13e8ca20d1
parent cc1e3d0b494763ae4647ad6bbfd8a1d6c1537db9
Author: Oliver Lowe <oliver.lowe@audinate.com>
Date: Sat, 5 Apr 2025 15:36:55 +1100
backlight: add for Linux
Diffstat:
3 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/README b/README
@@ -4,6 +4,7 @@ To install, run install.sh.
The following commands are provided:
+- backlight - set backlight brightness
- bbsnip - create a snippet on BitBucket
- hits - count web traffic
- hlsget - download the contents of a HLS playlist
diff --git a/bin/backlight b/bin/backlight
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+dir=/sys/class/backlight/intel_backlight
+if ! test -e $dir
+then
+ echo $dir does not exist 1>&2
+ exit 1
+fi
+
+pct="0.$1"
+if test $1 -eq 100
+then
+ pct=1
+fi
+
+max=`cat $dir/max_brightness`
+echo $pct $max | awk '{
+ x = $1 * $2
+ print int(x)
+}' > $dir/brightness
diff --git a/man/backlight.1 b/man/backlight.1
@@ -0,0 +1,24 @@
+.Dd
+.Dt BACKLIGHT 1
+.Sh NAME
+.Nm backlight
+.Nd set backlight brightness
+.Sh SYNOPSIS
+.Nm
+.Ar percent
+.Sh DESCRIPTION
+.Nm
+sets the backlight device brightness to the given percentage of the maximum.
+.Sh EXAMPLE
+Set maximum brightness,
+then go back down to 50% brightness:
+.Bd -literal -offset Ds
+backlight 100
+backlight 50
+.Ed
+.Sh FILES
+.Pa /sys/class/backlight
+.Sh EXIT STATUS
+.Ex
+.Sh SEE ALSO
+.Xr sysfs 5