dotfiles/.config/scripts/wm/brightness.sh

26 lines
394 B
Bash
Executable File

#!/bin/sh
[ -z $IS_LAPTOP ] && exit
blpath=/sys/class/backlight/intel_backlight
max=$(cat $blpath/max_brightness)
current=$(cat $blpath/brightness)
if [ -z $1 ]
then
printf %.0f\\n $(echo "$current/$max * 100" | bc -l)
exit
elif (( $1 < 10 ))
then
perc=10
elif (( $1 > 100 ))
then
perc=100
else
perc=$1
fi
brightness="$(($max * $perc / 100))"
echo $brightness > $blpath/brightness