polybar: brightness
This commit is contained in:
parent
fdc9d394a1
commit
9a1966900f
2 changed files with 65 additions and 1 deletions
54
polybar/backlight.sh
Normal file
54
polybar/backlight.sh
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/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
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
inotifywait -q -m -e close_write /sys/class/backlight/intel_backlight/brightness |
|
||||||
|
echo "$(getIcon) $brightness_percent%"
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -63,6 +63,17 @@ exec = /home/mg/dotfiles/polybar/popup-calendar.sh
|
||||||
interval = 5
|
interval = 5
|
||||||
click-left = /home/mg/dotfiles/polybar/popup-calendar.sh --popup &
|
click-left = /home/mg/dotfiles/polybar/popup-calendar.sh --popup &
|
||||||
|
|
||||||
|
[module/backlight]
|
||||||
|
type = custom/script
|
||||||
|
exec=/home/mg/dotfiles/polybar/backlight.sh
|
||||||
|
tail=true
|
||||||
|
interval=0
|
||||||
|
scroll-up = /home/mg/dotfiles/polybar/backlight.sh increase
|
||||||
|
scroll-down = /home/mg/dotfiles/polybar/backlight.sh decrease
|
||||||
|
format-background = ${color.shade5}
|
||||||
|
format-foreground = ${color.modulefg}
|
||||||
|
format-padding = 1
|
||||||
|
|
||||||
[module/xwindow]
|
[module/xwindow]
|
||||||
type = internal/xwindow
|
type = internal/xwindow
|
||||||
label = %title:0:30:...%
|
label = %title:0:30:...%
|
||||||
|
@ -179,7 +190,6 @@ format-disconnected =
|
||||||
;label-disconnected = %ifname% disconnected
|
;label-disconnected = %ifname% disconnected
|
||||||
;label-disconnected-foreground = ${colors.foreground-alt}
|
;label-disconnected-foreground = ${colors.foreground-alt}
|
||||||
|
|
||||||
|
|
||||||
[module/date]
|
[module/date]
|
||||||
type = internal/date
|
type = internal/date
|
||||||
interval = 5
|
interval = 5
|
||||||
|
|
Loading…
Reference in a new issue