Created
December 29, 2016 11:39
-
-
Save TaylanTatli/7e2d7a71df17afa45456e6694a68722f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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