diff options
Diffstat (limited to '.local/bin/backlight')
-rwxr-xr-x | .local/bin/backlight | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/.local/bin/backlight b/.local/bin/backlight new file mode 100755 index 0000000..cf48dca --- /dev/null +++ b/.local/bin/backlight @@ -0,0 +1,20 @@ +#!/bin/bash + +[[ -n "$BACKLIGHT" ]] || BACKLIGHT=intel_backlight +fmax=/sys/class/backlight/$BACKLIGHT/max_brightness +fcur=/sys/class/backlight/$BACKLIGHT/brightness +read max < $fmax || exit $? +case $# in + 0) + read cur < $fcur + bc <<<"100*$cur/$max" | cut -d. -f1 + ;; + 1) + declare -i pct="$1" + bc <<<"$max*$pct/100" | cut -d. -f1 > $fcur + ;; + *) + echo "Usage: [BACKLIGHT=<device_id>] backlight [<percent>]" >&2 + exit 1 + ;; +esac |