diff options
-rwxr-xr-x | backlight | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/backlight b/backlight new file mode 100755 index 0000000..2d5e0e2 --- /dev/null +++ b/backlight @@ -0,0 +1,26 @@ +#!/bin/bash + +# Allows you to adjust display backlight from the command line. +# USAGE: backlight <brightness change> +# The brightness change can be positive (for brighter) or negative (for darker). +# NOTE: requires root privileges. + +brightness=`cat /sys/class/backlight/intel_backlight/brightness` +delta="$1" + +if [[ ! $delta =~ ^-?[0-9]+$ ]]; then + echo "Not a number!" + exit 1 +fi + +new_brightness=$((brightness + delta)) + + +if [[ new_brightness -gt 7500 ]]; then + new_brightness=7500 +elif [[ new_brightness -lt 0 ]]; then + new_brightness=0 +fi + +# echo $new_brightness +tee /sys/class/backlight/intel_backlight/brightness <<< "$new_brightness" |