1
0
Fork 0
dotfiles/home/dot_local/bin/executable_brightness-control

37 lines
859 B
Plaintext
Raw Normal View History

2021-04-10 20:37:16 +00:00
#!/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