Mkay, I'll try to break this down as simple as I can for you (no offense, just trying to clear the confusion.)
In my code
Code:
#!/system/bin/sh
if [ -e /sys/class/leds/button-backlight/max_brightness ]; then
if [ `cat /sys/class/leds/button-backlight/max_brightness` -eq 0 ]
then
echo 15 > sys/class/leds/button-backlight/max_brightness
else
echo 0 > sys/class/leds/button-backlight/max_brightness
fi
fi
We see the first line is
This is how it is determined to be a bash shell script.
in the next lines you'll see
Code:
if [ -e /sys/class/leds/button-backlight/max_brightness ]; then
if [ `cat /sys/class/leds/button-backlight/max_brightness` -eq 0 ]
The "
Code:
if [ -e /sys/class/leds/button-backlight/max_brightness ];
Line is stating " -e " (If file exists) "/sys/class/leds/button-backlight/max_brightness" (FILE)
";" (Close argument)
Code:
then
if [ `cat /sys/class/leds/button-backlight/max_brightness` -eq 0 ]
Means:
Then
if concatenate value = 0 within file max_brightness
Code:
echo 15 > sys/class/leds/button-backlight/max_brightness
Means: Relay 15 as input to file max_brightness
Means: If the Value currently IN the file "max_brightness" is not equivalent to the requested value of "0" then do the next operation...
Which is:
Code:
echo 0 > sys/class/leds/button-backlight/max_brightness
Means" Set the code to '0' since I determined that it was 15 due to 15, and - being the only values that I input, and the file did not have the cancatenate value of 0.
is just how Hash - Bourne is set up to close the arguments.
Hopefully that allows you to understand what's going on in that.
IF NOT>>>
The script loads file max_brightness from the path sys/class/leds/button-backlight
Then it looks for anything containing a value of 0 (if you were using multiple numbers like 15, and the page had something containing 150 this could cause errors; but this page doesn't, so we can use concatenate value if 0.)
So the script determines whether 0 is on that page, and if not it sets it to 0. however "else" if it IS, then it sets it to 15.
Then it closes the scripts argrument. Very simple coding, actually.