2024-02-06 16:39:03 -05:00
|
|
|
#!/bin/bash
|
2024-03-12 13:00:38 -04:00
|
|
|
# bright=`cat /sys/class/backlight/amdgpu_bl0/brightness` # for use without brightnessctl
|
|
|
|
|
bright=`brightnessctl g`
|
2024-01-15 14:11:14 -05:00
|
|
|
state=-1
|
2024-03-12 13:00:38 -04:00
|
|
|
# thresh=(0 1 3 5 9 15 27 48 84 147 255) # generated using floor(256^x-1)
|
|
|
|
|
# thresh=(0 26 51 77 102 128 153 179 204 230 255) # generated using floor(256*x-1)
|
|
|
|
|
thresh=(0 19 39 60 81 103 126 151 180 214 255) # generated using floor(64^x+192*x-1)
|
2024-01-15 14:11:14 -05:00
|
|
|
|
|
|
|
|
for i in ${!thresh[@]}; do
|
2024-02-06 16:39:03 -05:00
|
|
|
if [[ $bright -ge ${thresh[$i]} ]]
|
2024-01-15 14:11:14 -05:00
|
|
|
then
|
|
|
|
|
state=$i
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
new=$(($1 + $state))
|
2024-02-06 16:39:03 -05:00
|
|
|
|
|
|
|
|
if [[ $new -ge 0 ]] && [[ $new -le 10 ]]
|
2024-01-15 14:11:14 -05:00
|
|
|
then
|
2024-03-12 13:00:38 -04:00
|
|
|
# echo ${thresh[$new]} | tee /sys/class/backlight/amdgpu_bl0/brightness
|
|
|
|
|
brightnessctl s ${thresh[$new]}
|
2024-02-06 16:39:03 -05:00
|
|
|
if [[ $? -eq 0 ]] && [[ -f $(which dunstify) ]]
|
|
|
|
|
then
|
2024-03-11 22:32:32 -04:00
|
|
|
dunstify -a "changebrightness.sh" -u low -i weather-clear -h string:x-dunst-stack-tag:changebrightness -h string:hlcolor:#ffffff -h int:value:$(($new*10)) "Brightness: $new"
|
2024-02-06 16:39:03 -05:00
|
|
|
fi
|
2024-01-15 14:11:14 -05:00
|
|
|
fi
|
2024-02-06 16:39:03 -05:00
|
|
|
|