aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDavid Runge <david.runge@frqrec.com>2014-02-25 23:57:40 +0100
committerDavid Runge <david.runge@frqrec.com>2014-02-25 23:57:40 +0100
commit28e418c8e73e35b46bb7428b007866a360e34629 (patch)
tree60b60c330ca2195ad341ea05018991fde640f3c7 /bin
parent68dc18fe54b88ca146419a083f2c765c8668d35a (diff)
downloaddotfiles-28e418c8e73e35b46bb7428b007866a360e34629.tar.gz
dotfiles-28e418c8e73e35b46bb7428b007866a360e34629.tar.bz2
dotfiles-28e418c8e73e35b46bb7428b007866a360e34629.tar.xz
dotfiles-28e418c8e73e35b46bb7428b007866a360e34629.zip
Rewrite of script to be called from acpi handler (listening to brightness up/down keys)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/set_backlight46
1 files changed, 45 insertions, 1 deletions
diff --git a/bin/set_backlight b/bin/set_backlight
index 00a6d8f..c110321 100755
--- a/bin/set_backlight
+++ b/bin/set_backlight
@@ -7,6 +7,50 @@
if [[ $EUID -ne 0 ]];then
echo "This must be run as root."
else
+ # get current and maximum brightness, set maximum steps allowed
+ brightness_current=$(cat /sys/class/backlight/intel_backlight/brightness)
+ brightness_max=$(cat /sys/class/backlight/intel_backlight/max_brightness)
+ brightness_max=$(($brightness_max-1000))
+ brightness_steps=20
+ brightness_steps_width=$(($brightness_max/$brightness_steps))
+ brightness_new=0
+ # if first parameter to this script is a number
+ re='^[0-9]+$'
+ if [[ $1 =~ $re ]]; then
+ echo "Direct step called"
+ if [[ $1 -gt brightness_steps && $1 -ne 0 ]];then
+ brightness_new=$(($1*brightness_steps_width))
+ fi
+ elif [[ $1 == "up" || $1 == "down" ]];then
+ brightness_calc=$(($brightness_current / $brightness_steps_width))
+ case $1 in
+ "up" )
+ brightness_calc=$((($brightness_calc+1) * $brightness_steps_width))
+ echo "brightness_calc: $brightness_calc"
+ echo "brightness_max: $brightness_max"
+ if [[ $brightness_max -gt $brightness_calc ]];then
+ echo "true"
+ brightness_new=$brightness_calc
+ else
+ echo "false"
+ brightness_new=$brightness_current
+ fi
+ ;;
+ "down" )
+ brightness_calc=$((($brightness_calc-1) * $brightness_steps_width))
+ echo "brightness_calc: $brightness_calc"
+ if [[ $brightness_calc -gt 0 ]];then
+ brightness_new=$brightness_calc
+ else
+ brightness_new=$brightness_current
+ fi
+ ;;
+ esac
+ echo "Step called with: $1"
+ fi
+ echo $brightness_current
+ echo $brightness_new
# set to 234 (around 4th step)
- echo 234 > /sys/class/backlight/intel_backlight/brightness
+ #echo 234 > /sys/class/backlight/intel_backlight/brightness
+ echo $brightness_new > /sys/class/backlight/intel_backlight/brightness
fi