dotfiles/termscripts/brightness-software.sh

20 lines
444 B
Bash
Raw Normal View History

2019-07-11 16:09:05 +02:00
#!/bin/sh
[ -z "$1" ] && exit 1
if [ "$1" = "-dec" ]; then
operator="-"
elif [ "$1" = "-inc" ]; then
operator="+"
fi
[ -z "$2" ] && exit 1
[ "$1" != "-set" ] && result="$(echo "$BRIGHTNESS $operator $2" | bc -l)" \
|| result="$2"
[ "$(echo "$result > 1.0" | bc -l)" -eq 1 ] && result="1.0"
[ "$(echo "$result < 0.0" | bc -l)" -eq 1 ] && result="0.0"
xrandr --output LVDS1 --brightness "$result" && export BRIGHTNESS="$result"