8:26 AM

Small brightness tweak on laptop....


It was very hard trying all these days to fix the brightness controll on dell xps15.Finally got it corrected....The ACPI controlls the brightness in your laptop wich can be tweaked through a simple file in the folder

    /sys/class/backlight

The folder contains a number of subfolders like acpi_video0,intel_backlight etc. These folders contain a number of file like
brightness : which contains the present brightness value
max_brightness : the maximum possible brightness value

 use intel onboard graphics which controlls the brightness. All I need to do is to change the value of brightness file in intel_backlight.This can be done simply by echo command.

Here is a simple sript to perform the same.The up arrow key can be used to increase the brightness and down arrow key can be used to decrease the brightness.Make sure you run the script as root who has the right to write into the file.

===================================================


#!/bin/sh

folder="/sys/class/backlight/intel_backlight"

cd "$folder"

value=3000
max=4882
min=100

if (($EUID != 0))
then
    echo "You do not have required previlages to run the script!!!"
    exit 1
fi

while true
do
    read -n3 -s  key
    echo -n "$key" | grep "\[B"
    if [ "$?" -eq 0 ]
    then
        if (($value < 100))
        then
            value=100
            continue
        fi
        echo $value
        echo -n $value > brightness 
        value=$[$value-100]
    fi
    echo -n "$key" | grep "\[A" 
    if [ "$?" -eq 0 ]
    then
        if (($value > 4000))
        then
            continue
        fi
        echo $value
        echo -n $value > brightness 
        value=$[$value+100]
    fi
done

===================================================

0 comments: