SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-10-03 09:28:34

djerom
New Member
Registered: 2009-07-14
Posts: 7

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)

Offline

Help fund CrunchBang, donate to the project!

#2 2011-06-05 18:28:46

bastiano
#! CrunchBanger
From: Sweden
Registered: 2010-06-01
Posts: 106

Re: xbacklight for laptop working properly in Statler

Looks good. Could this be used in any laptop? For example mine is HP ProBook 4310s.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo