Skip to content

Instantly share code, notes, and snippets.

@TaylanTatli
Created December 29, 2016 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TaylanTatli/7e2d7a71df17afa45456e6694a68722f to your computer and use it in GitHub Desktop.
Save TaylanTatli/7e2d7a71df17afa45456e6694a68722f to your computer and use it in GitHub Desktop.
#!/bin/sh
# I have brightness bug with sony vaio, so I have to set my
# brightness manually.
# To run this script without root
# edit your /etc/sudoers file with visudo
# and add this line:
# username ALL=(ALL) NOPASSWD: /usr/bin/tee /sys/class/backlight/nv_backlight/brightness
# change username with your username
# brightness + : brightness up
# brightness - : brightness down
# bind this script to XF86MonBrightnessUp and XF86MonBrightnessDown
read=$(cat /sys/class/backlight/nv_backlight/brightness)
max=$(cat /sys/class/backlight/nv_backlight/max_brightness)
path='/sys/class/backlight/nv_backlight/brightness'
if test "$read" -ge 0 && test "$read" -le 100; then
case $1 in
+)
newlevel=$(($read + 5))
if test "$newlevel" -ge 0 && test "$newlevel" -le 100; then
echo "$newlevel" | sudo tee "$path"
notify-send "Brightness: $newlevel / $max"
else
echo "Max level reached"
notify-send "Brightness: Max level"
fi
;;
-)
newlevel=$(($read - 5))
if test "$newlevel" -ge 0 && test "$newlevel" -le 100; then
echo $newlevel | sudo tee $path
notify-send "Brightness: $newlevel / $max"
else
echo "Min level reached"
notify-send "Brightness: Min level"
fi
;;
*)
echo "put + or - as argument"
;;
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment