From 54a6b57726e160efb8e5434676831d3a6baa14b9 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 13 Jan 2022 09:47:39 -0500 Subject: [PATCH] [i3] Fix backlight fade script --- bin/.bin/fade | 38 ++++++++++++++++++++++---------------- i3/.config/i3/config | 6 +++--- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/bin/.bin/fade b/bin/.bin/fade index 7dd7673..c0e570a 100755 --- a/bin/.bin/fade +++ b/bin/.bin/fade @@ -1,18 +1,24 @@ -#!/bin/sh +#!/bin/bash hostname=`hostname` -count=200 -if [[ $hostname = 'titan' ]] -then - count=50 -fi +max_brightness=`cat /sys/class/backlight/intel_backlight/max_brightness` +brightness=`cat /sys/class/backlight/intel_backlight/brightness` +step=$(( max_brightness / 6 )) +inc=2 +low_delta=$(( brightness - step )) +high_delta=$(( brightness + step )) -for i in $(seq $count); do - case $1 in - 'up') - brightnessctl s +3 - ;; - 'down') - brightnessctl s 3- - ;; - esac -done +if ( [ $1 = 'down' ] && [ $low_delta -gt 0 ] ) || ( [ $1 = 'up' ] && [ $high_delta -lt $max_brightness ] ) +then + for i in $(seq $step); do + case $1 in + 'up') + brightnessctl s +$inc 1> /dev/null + ;; + 'down') + brightnessctl s $inc- 1> /dev/null + ;; + esac + done +else + echo 'Brightness too high. Use `off` parameter to turn backlight off' +fi diff --git a/i3/.config/i3/config b/i3/.config/i3/config index bd9c169..8193cc8 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -260,8 +260,8 @@ set $casts ~/videos/casts # Sreen brightness controls bindsym F5 exec ~/.bin/fade down bindsym F6 exec ~/.bin/fade up -bindsym XF86MonBrightnessUp exec ~/.bin/fade up -bindsym XF86MonBrightnessDown exec ~/.bin/fade down +#bindsym XF86MonBrightnessUp exec ~/.bin/fade up +#bindsym XF86MonBrightnessDown exec ~/.bin/fade down #bindsym XF86MonBrightnessUp exec ~/.config/i3/bright.sh -u # increase 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 # 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 syncthing -no-qute exec xrdb --merge ~/.Xresoureces