Files
dotfiles/bin/.bin/fade

23 lines
674 B
Bash
Executable File

#!/bin/bash
max_brightness=$(cat /sys/class/backlight/intel_backlight/max_brightness)
brightness=$(cat /sys/class/backlight/intel_backlight/brightness)
step=$((max_brightness / 12))
inc=2
low_delta=$((brightness - step))
high_delta=$((brightness + step))
if { [ "$1" = "down" ] && [ $low_delta -ge $step ]; } || { [ "$1" = "up" ] && [ $high_delta -le "$max_brightness" ]; }; then
for i in $(seq $step); do
case $1 in
'up')
brightnessctl s +$inc 1>/dev/null
;;
'down')
brightnessctl s $inc- 1>/dev/null
;;
esac
done
else
echo "Brightness too high or low"
fi