FollieHiyuki-dotfiles/home/.local/bin/brightness

49 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/bin/sh
2021-02-13 11:28:59 -05:00
_notify_brightness() {
if command -v mako >/dev/null
then
icon="$HOME/.config/mako/idea.png"
else
icon="$HOME/.config/dunst/idea.png"
fi
notify-send -h string:x-canonical-private-synchronous:brightness "Brightness: $1%" -h int:value:"$1" -i "${icon}"
}
2021-02-13 11:28:59 -05:00
case $1 in
up)
if command -v light >/dev/null
then
light -A 5 >/dev/null
brightness="$(light -G | cut -d '.' -f 1)"
_notify_brightness "$brightness"
elif command -v brightnessctl >/dev/null
then
brightnessctl set 5%+ >/dev/null
brightness="$(brightnessctl i | grep '%' | awk -F'(' '{print $2}' | awk -F'%' '{print $1}')"
_notify_brightness "$brightness"
else
brillo -l -A 5 >/dev/null
brightness="$(brillo -G | cut -d '.' -f 1)"
_notify_brightness "$brightness"
2021-02-13 11:28:59 -05:00
fi ;;
down)
if command -v light >/dev/null
then
light -U 5 >/dev/null
brightness="$(light -G | cut -d '.' -f 1)"
_notify_brightness "$brightness"
elif command -v brightnessctl >/dev/null
then
brightnessctl set 5%- >/dev/null
brightness="$(brightnessctl i | grep '%' | awk -F'(' '{print $2}' | awk -F'%' '{print $1}')"
_notify_brightness "$brightness"
else
brillo -l -U 5 >/dev/null
brightness="$(brillo -G | cut -d '.' -f 1)"
_notify_brightness "$brightness"
2021-02-13 11:28:59 -05:00
fi ;;
*)
;;
esac