Backlight control script for Intel GMA 500/3600

Simple backlight control script for Intel GMA 500/3600. Work under the superuser.

Code:
#!/bin/sh

intel_bl_setpci="pciconf -w"
intel_bl_getpci="pciconf -r"
INTEL_BL_DEVICE="pci0:0:2:0"
INTEL_BL_REGISTER="0xf4"
INTEL_BL_MAX_VALUE="255"
INTEL_BL_COMMAND="$1"
INTEL_BL_SET_VALUE="$2"

[ "`id -u`" -eq "0" ] || { echo "Only root can run `basename $0`." ; exit 1 ; }

intel_bl_use() {
    echo "Use: `basename $0` <+|-|=> <DEC_VALUE>"
    echo "Final max value can be no more ${INTEL_BL_MAX_VALUE}"
    exit 0
}

INTEL_BL_CUR_VALUE="`${intel_bl_getpci} ${INTEL_BL_DEVICE} ${INTEL_BL_REGISTER}`"
INTEL_BL_CUR_VALUE_DEC="`let 0x${INTEL_BL_CUR_VALUE}`"

if [ ! "$2" ] ; then
    echo "Current value is ${INTEL_BL_CUR_VALUE_DEC}"
    intel_bl_use
fi

if [ "$1" = "+" -o "$1" = "-" ] ; then
    INTEL_BL_EXP_VALUE="$((${INTEL_BL_CUR_VALUE_DEC} ${1} ${INTEL_BL_SET_VALUE}))"
elif [ "$1" = "=" ] ; then
    INTEL_BL_EXP_VALUE="${INTEL_BL_SET_VALUE}"
else
    intel_bl_use
fi

if [ "${INTEL_BL_EXP_VALUE}" -gt "${INTEL_BL_MAX_VALUE}" ] ; then
    echo "${INTEL_BL_EXP_VALUE} must not be greater than ${INTEL_BL_MAX_VALUE}" ; exit 1
elif [ "${INTEL_BL_EXP_VALUE}" -lt "0" ] ; then
    echo "${INTEL_BL_EXP_VALUE} must not be less than 0" ; exit 1
fi

echo "Set backlight: ${INTEL_BL_CUR_VALUE_DEC} -> ${INTEL_BL_EXP_VALUE}"
${intel_bl_setpci} ${INTEL_BL_DEVICE} ${INTEL_BL_REGISTER} 0x`printf "%x" ${INTEL_BL_EXP_VALUE}`

Без имени.png


Also: https://pastebin.com/z8B2r3TX

Enjoy.
 
Back
Top