i3conf/bin/brightness.sh
2019-03-23 22:25:08 +01:00

20 lines
728 B
Bash
Executable file

#!/bin/sh
if [ $1 = '-d' ]; then
current=$(xrandr --verbose | grep -m 1 -i brightness | awk -F' ' '{ print $2 }')
new=$(echo "$current - 0.1" | bc -l)
xrandr --output eDP-1 --brightness 0$new
percent=$(echo "$new * 100" | bc -l)
notify-send "Brightness lowered to ${percent}%"
elif [ $1 = '-u' ]; then
current=$(xrandr --verbose | grep -m 1 -i brightness | awk -F' ' '{ print $2 }')
new=$(echo "$current + 0.1" | bc -l)
xrandr --output eDP-1 --brightness 0$new
percent=$(echo "$new * 100" | bc -l)
notify-send "Brightness raised to ${percent}%"
elif [ $1 = '-m' ]; then
xrandr --output eDP-1 --brightness 1
notify-send "Brightness reset to 100%"
else
xrandr --output eDP-1 --brightness $1
fi