1
0
Fork 0
dotfiles/files/bin/brightness-control

37 lines
859 B
Bash
Executable File

#!/usr/bin/env bash
# You can call this script like this:
# $ ./brightnessControl.sh up
# $ ./brightnessControl.sh down
# Script inspired by these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
function get_brightness {
brightnessctl -m | grep -o '[0-9]\+%' | head -c-2
}
function send_notification {
icon="notification-display-brightness"
echo $(get_brightness) >"$XDG_RUNTIME_DIR/wobpipe"
}
case $1 in
up)
# increase the backlight by 5%
brightnessctl set +5%
send_notification
;;
down)
if [[ $(get_brightness) -lt 5 ]]; then
# avoid 0% brightness
brightnessctl set 1%
else
# decrease the backlight by 5%
brightnessctl set 5%-
fi
send_notification
;;
esac