Wednesday, July 03, 2013

Quick and short script for changing brightness manually (Lenovo G430 and Slackware Linux)

As I described in my first post, after installing Slackware 14.0 32-bit on a USB flash drive, the fn keys stopped working for controlling brightness.
Earlier I always had to append "acpi_backlight=vendor acpi_osi=Linux" in LILO to make brightness keys work but this time it didn't do the trick. So I quickly had to write a script for brightness control using sysfs. There is a directory for each different class of device in /sys/class/.

Just sharing the quick and short script I wrote -

#Script for changing the screen brightness manually
#!/bin/bash
cd /sys/class/backlight/intel_backlight/

function usage_and_exit()
{
        echo "***Usage: $0 <Brightness_level> {choose Brightness_level from: 1, 2, 3, 4, 5, 6, min and max}***"
        exit
}
if [ ! -n "$1" ]
then
        echo "***Missing Brightness Level, See Usage***"
        usage_and_exit
else
        case $1 in

        1)      echo 500000 > brightness
                exit
                ;;
        2)      echo 1000000 > brightness
                exit
                ;;
        3)      echo 1500000 > brightness
                exit
                ;;
        4)      echo 2000000 > brightness
                exit
                ;;
        5)      echo 2500000 > brightness
                exit
                ;;
        6)      echo 3000000 > brightness
                exit
                ;;
        "min")  echo 250000 > brightness
                exit
                ;;
        "max")  echo 3316785 > brightness
                exit
                ;;
        *)      echo "*Y U NO ENTER CORRECT LEVEL*"
                usage_and_exit
                ;;
        esac
fi

No comments:

Post a Comment