To adjust my backlight I'm using the command:
sudo bash -c "echo $backlight_value > /sys/class/backlight/apple_backlight/brightness;"
Now I want to setup a keybinding for the command above via shell script with openbox to adjust the backlight in my PC. To setup the keybinding I searched for the config file which is used by openbox:
$ ps ax | grep openbox
1194 ? Sl 0:02 openbox --config-file /home/ubuntu/.config/openbox/lubuntu-rc.xml --sm-save-file /home/ubuntu/.cache/openbox/sessions/1478226066-1194-624962777.obs --sm-no-load
1958 pts/0 S+ 0:00 grep --color=auto openbox
Next I edited the config file lubuntu-rc.xml and it works (I tested it):
<!-- My Keybindings -->
<keybind key="0xC0">
<action name="Execute">
<execute>lxterminal</execute>
</action>
</keybind>
Now I want to execute my custom shell script below. But in my shell script there are two commands (line 2 and 5) which needs addional permissions. How can I run them as root?
#!/bin/bash
curr=`cat /sys/class/backlight/apple_backlight/brightness`
if [ $curr -gt 0 ]; then
curr=$((curr - 1));
echo $curr > /sys/class/backlight/apple_backlight/brightness;
fi
I also changed privileges but the error is still there (permission denied):
ls -l /sys/class/backlight/apple_backlight/
total 0
-rwxrwxr-x 1 ubuntu ubuntu 4096 Nov 4 00:41 brightness
I tested only the script without binding and it works:
bash /home/ubuntu/Documents/CustomScripts/brightnessDown.sh