I am trying to run a script that changes the backlight, but requires root priviliges using a keyboard shortcut. Since I dont want to type in my password everytime I change the brightness, I want to add an exception in my sudoers file for that script. However none of my attempts have been succesfull. Please note that I did not write this script myself, and thus dont completely understand it (for the most parts, I do though).
-I created an alias in my .bashrc file for the script:
alias backlight='sudo ./.config/Scripts/backlight.sh'
-I removed the sudo commands from the script:
#!/bin/bash # base dir for backlight class basedir="/sys/class/backlight/" # get the backlight handler handler=$basedir$(ls $basedir)"/" # get current brightness old_brightness=$(cat $handler"brightness") # get max brightness max_brightness=$(cat $handler"max_brightness") # get current brightness % old_brightness_p=$(( 100 * $old_brightness / $max_brightness )) # calculate new brightness % new_brightness_p=$(($old_brightness_p $1)) # calculate new brightness value new_brightness=$(( $max_brightness * $new_brightness_p / 100 )) # set the new brightness value (sudo) chmod 666 $handler"brightness" echo $new_brightness > $handler"brightness"
-These are the lines i was experimenting with by adding them to the end of the sudoers file:
ALL ALL=(ALL) NOPASSWD: /home/sepseel/.conf/Scripts/$ #ALL ALL=(ALL) NOPASSWD: /bin/chmod
-My system is currently running ubuntu 16.04, with te i3wm so I have this in my i3 config file for the shurtcut:
bindsym XF86MonBrightnessUp exec "sudo ./home/sepseel/.config/Scripts/backlight.sh +10" bindsym XF86MonBrightnessDown exec "sudo ./home/sepseel/.config/Scripts/backlight.sh -10"
Thanks in advance.