dotfiles/polybar/backlight.sh

55 lines
1.3 KiB
Bash
Raw Normal View History

2021-06-29 13:53:10 +02:00
#!/bin/sh
# This polybar script show the current brightness level and allows you to increase or decrease it by scrolling up or down with the mouse wheel
#
# Make sure you have inotify-tools (and brightnessctl obv) installed otherwise inotifywait won't work
# You need to install a font from nerdfonts.com in order to see glyphs correctly. You can replace them with what you prefer
# https://raw.githubusercontent.com/FedericoAntoniazzi/dotfiles/master/.config/polybar/backlight.sh
brightness_level=$(brightnessctl g)
brightness_max=$(brightnessctl m)
brightness_percent=$(( $brightness_level * 100 / $brightness_max ))
getIcon() {
if [ "$brightness_percent" -ge 90 ]; then
icon=""
elif [ "$brightness_percent" -ge 75 ]; then
icon=""
elif [ "$brightness_percent" -ge 50 ]; then
icon=""
elif [ "$brightness_percent" -ge 40 ]; then
icon=""
elif [ "$brightness_percent" -ge 25 ]; then
icon=""
elif [ "$brightness_percent" -ge 10 ]; then
icon=""
else
icon=""
fi
echo "$icon"
}
increase(){
brightnessctl s +2% > /dev/null
return
}
decrease(){
brightnessctl s 2%- > /dev/null
return
}
case "$1" in
"increase")
increase
exit
;;
"decrease")
decrease
exit
;;
*)
2021-06-29 16:43:12 +02:00
brightnessctl g |
2021-06-29 13:53:10 +02:00
echo "$(getIcon) $brightness_percent%"
;;
esac