Skip to content

Instantly share code, notes, and snippets.

@atimermann
Created August 31, 2015 13:34
Show Gist options
  • Save atimermann/34f4e52b4a4db64e80a5 to your computer and use it in GitHub Desktop.
Save atimermann/34f4e52b4a4db64e80a5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# /usr/local/bin/brightness
# wrapper script to change brightness values
# make script executable
# constants - edit as required
UPPER=4882
LOWER=1
INCREMENT=100
DECREMENT=100
# current value
CURRENT=`cat /sys/class/backlight/intel_backlight/brightness`
NEW=$CURRENT
#if [ $CURRENT -eq 0 ]; then
# CURRENT=1;
#fi
case $1 in
up)
if [ $(($CURRENTi+$INCREMENT)) -le $UPPER ]; then
NEW=$(($CURRENT+$INCREMENT))
fi
;;
down)
if [ $(($CURRENT - $DECREMENT)) -ge $LOWER ]; then
NEW=$(($CURRENT - $DECREMENT))
fi
;;
*)
;;
esac
# set the new brightness value
echo $NEW > /sys/class/backlight/intel_backlight/brightness
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment