mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

xbl (415B)


      1 #!/usr/bin/zsh
      2 
      3 # adjust backlight to percentage
      4 
      5 PERCENTAGE="$1"
      6 
      7 xbacklight -steps 1 -time 0 -set "$PERCENTAGE" 2>/dev/null
      8 if [ $? -eq 0 ]; then
      9   exit 0
     10 fi
     11 
     12 # do things differently
     13 ls /sys/devices/pci*/**/intel_backlight/brightness | while read l
     14 do
     15   MAX=$(cat ${l%brightness}max_brightness)
     16   VAL=$(($MAX * $PERCENTAGE / 100))
     17   VALN=$(printf '%.*f\n' 0 "$VAL")
     18   echo "$VALN" | sudo tee $l > /dev/null
     19 done
     20