Browse Source

Fixed inconsistent brightness

Fixed brightness script not inc/dec in increments of 5
pull/358/head
Ecys 2 years ago committed by GitHub
parent
commit
9a543cd81e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 30
      config/hypr/scripts/Brightness.sh

30
config/hypr/scripts/Brightness.sh

@ -7,12 +7,12 @@ notification_timeout=1000
# Get brightness # Get brightness
get_backlight() { get_backlight() {
echo $(brightnessctl -m | cut -d, -f4) brightnessctl -m | cut -d, -f4 | sed 's/%//'
} }
# Get icons # Get icons
get_icon() { get_icon() {
current=$(get_backlight | sed 's/%//') current=$(get_backlight)
if [ "$current" -le "20" ]; then if [ "$current" -le "20" ]; then
icon="$iDIR/brightness-20.png" icon="$iDIR/brightness-20.png"
elif [ "$current" -le "40" ]; then elif [ "$current" -le "40" ]; then
@ -33,7 +33,27 @@ notify_user() {
# Change brightness # Change brightness
change_backlight() { change_backlight() {
brightnessctl set "$1" -n && get_icon && notify_user local current_brightness
current_brightness=$(get_backlight)
# Calculate new brightness
if [[ "$1" == "+5%" ]]; then
new_brightness=$((current_brightness + 5))
elif [[ "$1" == "5%-" ]]; then
new_brightness=$((current_brightness - 5))
fi
# Ensure new brightness is within valid range
if (( new_brightness < 0 )); then
new_brightness=0
elif (( new_brightness > 100 )); then
new_brightness=100
fi
brightnessctl set "${new_brightness}%"
get_icon
current=$new_brightness
notify_user
} }
# Execute accordingly # Execute accordingly
@ -42,10 +62,10 @@ case "$1" in
get_backlight get_backlight
;; ;;
"--inc") "--inc")
change_backlight "+10%" change_backlight "+5%"
;; ;;
"--dec") "--dec")
change_backlight "10%-" change_backlight "5%-"
;; ;;
*) *)
get_backlight get_backlight

Loading…
Cancel
Save