[i3] Fix backlight fade script

This commit is contained in:
2022-01-13 09:47:39 -05:00
parent 544088a7fe
commit 54a6b57726
2 changed files with 25 additions and 19 deletions

View File

@ -1,18 +1,24 @@
#!/bin/sh #!/bin/bash
hostname=`hostname` hostname=`hostname`
count=200 max_brightness=`cat /sys/class/backlight/intel_backlight/max_brightness`
if [[ $hostname = 'titan' ]] brightness=`cat /sys/class/backlight/intel_backlight/brightness`
then step=$(( max_brightness / 6 ))
count=50 inc=2
fi low_delta=$(( brightness - step ))
high_delta=$(( brightness + step ))
for i in $(seq $count); do if ( [ $1 = 'down' ] && [ $low_delta -gt 0 ] ) || ( [ $1 = 'up' ] && [ $high_delta -lt $max_brightness ] )
case $1 in then
'up') for i in $(seq $step); do
brightnessctl s +3 case $1 in
;; 'up')
'down') brightnessctl s +$inc 1> /dev/null
brightnessctl s 3- ;;
;; 'down')
esac brightnessctl s $inc- 1> /dev/null
done ;;
esac
done
else
echo 'Brightness too high. Use `off` parameter to turn backlight off'
fi

View File

@ -260,8 +260,8 @@ set $casts ~/videos/casts
# Sreen brightness controls # Sreen brightness controls
bindsym F5 exec ~/.bin/fade down bindsym F5 exec ~/.bin/fade down
bindsym F6 exec ~/.bin/fade up bindsym F6 exec ~/.bin/fade up
bindsym XF86MonBrightnessUp exec ~/.bin/fade up #bindsym XF86MonBrightnessUp exec ~/.bin/fade up
bindsym XF86MonBrightnessDown exec ~/.bin/fade down #bindsym XF86MonBrightnessDown exec ~/.bin/fade down
#bindsym XF86MonBrightnessUp exec ~/.config/i3/bright.sh -u # increase screen brightness #bindsym XF86MonBrightnessUp exec ~/.config/i3/bright.sh -u # increase screen brightness
#bindsym XF86MonBrightnessDown exec ~/.config/i3/bright.sh -d # decrease screen brightness #bindsym XF86MonBrightnessDown exec ~/.config/i3/bright.sh -d # decrease screen brightness
@ -330,7 +330,7 @@ exec --no-startup-id nm-applet
exec --no-startup-id copyq exec --no-startup-id copyq
# RELOAD # RELOAD
exec --no-startup-id picom --config ~/.config/compton/compton.conf #exec --no-startup-id picom --config ~/.config/compton/compton.conf
exec --no-startup-id dunst exec --no-startup-id dunst
exec --no-startup-id syncthing -no-qute exec --no-startup-id syncthing -no-qute
exec xrdb --merge ~/.Xresoureces exec xrdb --merge ~/.Xresoureces