Topic: xbacklight for laptop working properly in Statler
Hi all!
In order to set my screen backlight some people suggest to use xbacklight program. But for some reason it does not work on my laptop (netbook Samsung nc10).
So I've written a program using xrandr to do it properly.
#!/bin/bash
# xbacklight.sh
# Adjust screen backlight with xrandr for laptop‐internal (normally LVDS) displays.
PGM=`basename $0`
function usage {
echo "Usage: $PGM < + or - >"
echo "Ex: $PGM -"
exit 1
}
if [ $# != 1 ]; then
usage
fi
arg=$1
if [ $arg != "+" ]; then
if [ $arg != "-" ]; then
usage
fi
fi
# Get range of BACKLIGHT property
declare -i range_min=`xrandr --prop | grep BACKLIGHT | cut -f 3 | cut -d ' ' -f 3 | cut -c 2`
declare -i range_max=`xrandr --prop | grep BACKLIGHT | cut -f 3 | cut -d ' ' -f 3 | cut -c 4`
# Get current value of BACKLIGHT property
declare -i backlight_value=`xrandr --prop | grep BACKLIGHT | cut -f 2 | cut -d ' ' -f 2`
# Increase or decrease BACKLIGHT value
if [ $arg = "+" ]; then
(( backlight_value = backlight_value + 1 ))
if (( backlight_value > range_max )); then
backlight_value=$range_max
fi
else
(( backlight_value = backlight_value - 1 ))
if (( backlight_value < range_min )); then
backlight_value=$range_min
fi
fi
# Set new BACKLIGHT value
xrandr --output LVDS1 --set BACKLIGHT $backlight_value
You can put it in your $HOME/bin directory then define keybings for using it (edit your file rc.xml):
<!-- Keybindings for screen backlight -->
<keybind key="C-Up">
<action name="Execute">
<execute>xbacklight.sh +</execute>
</action>
</keybind>
<keybind key="C-Down">
<action name="Execute">
<execute>xbacklight.sh -</execute>
</action>
</keybind>
Last edited by djerom (2010-10-03 09:29:48)