Skip to content

Instantly share code, notes, and snippets.

@kdarkhan
Last active May 3, 2016 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdarkhan/8b7a5f2dbbab7c7347301536af1ae521 to your computer and use it in GitHub Desktop.
Save kdarkhan/8b7a5f2dbbab7c7347301536af1ae521 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
if [ "$EUID" -ne 0 ]
then echo "The script should be run under root"
exit
fi
path=/sys/class/backlight/intel_backlight/
read -r currentBrightness < "$path"/actual_brightness
read -r maxBrightness < "$path"/max_brightness
step="$(( maxBrightness / 17 ))"
if [ "$1" = "up" ]; then
echo "Increasing brightness"
let "newBrightness = currentBrightness + step"
else
echo "Decresing brightness $1"
let "newBrightness = currentBrightness - step"
fi
if [ "$newBrightness" -gt "$maxBrightness" ]; then
newBrightness=$maxBrightness
elif [ "$newBrightness" -lt 0 ]; then
newBrightness=0
fi
echo "New brightness is $newBrightness"
# tee /sys/class/backlight/intel_backlight/brightness <<< $newBrightness
echo $newBrightness > /sys/class/backlight/intel_backlight/brightness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment