dotfiles/.config/i3/brightness.sh

31 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# brightness.sh: this script exists because, on my ThinkPad X1 Yoga, as the
# screen brightness _value_ increases/decreases linearly, actual brightness
# does NOT increase/decrease linearly, so I had to make a hack that would
# inc/dec the value accordingly
current_brightness="$(xbacklight -get | cut -f1 -d'.')" # convert float->int
level=2 # default level
if [ "$current_brightness" -lt "1" ]; then # brightness < 1
level=0.2
elif [ "$current_brightness" -lt "5" ]; then # brightness < 5
level=0.8
elif [ "$current_brightness" -lt "11" ]; then # brightness < 11
level=1.5
elif [ "$current_brightness" -lt "21" ]; then # brightness < 21
level=3
elif [ "$current_brightness" -lt "51" ]; then # brightness < 51
level=6
else # brightness >= 50
level=10
fi
if [ "$1" == "inc" ]; then
xbacklight -inc "$level"
elif [ "$1" == "dec" ]; then
xbacklight -dec "$level"
fi