Selaa lähdekoodia

[i3] Fix backlight fade script

Colin Powell 3 vuotta sitten
vanhempi
commit
54a6b57726
2 muutettua tiedostoa jossa 25 lisäystä ja 19 poistoa
  1. 22 16
      bin/.bin/fade
  2. 3 3
      i3/.config/i3/config

+ 22 - 16
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

+ 3 - 3
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