You are not logged in.

#1 2009-06-27 11:03:19

makimaki
Member
From: Ireland
Registered: 2009-04-02
Posts: 109

Bash script workaround for intel backlight problems

Hi all,

I have LXDE with kernel 2.6.30, xf86-video-intel-newest (2.8 rc) on my Samsung NC10, and like many people I have been unable to change the backlight settings in X with kms turned on.

I have tried the various solutions on the forum and none of them work for me, so here are two little bash scripts that use the setpci command to change the backlight.

Note 1: I have a little file .backlight in my home dir that I store the backlight setting because I don't know how to read the value back from the pci address. So if you use this script you need to do this first:

echo FF > ~/.backlight

Note 2: These scripts also requre bc from extra to do the hex conversion & maths.

 sudo pacman -Sy bc

It's only 240 K in size, but if you are trying to keep the number of installed packages low, then you won't like this tongue
Here is the package details from pacman:

Name           : bc
Version        : 1.06-5
URL            : None
Licenses       : GPL  
Groups         : None
Provides       : None
Depends On     : readline  
Optional Deps  : None
Required By    : None
Conflicts With : bc-readline  
Replaces       : bc-readline  
Installed Size : 240.00 K
Packager       : Allan McRae <allan@archlinux.org>
Architecture   : i686
Build Date     : Sat 02 Aug 2008 14:18:04 IST
Install Date   : Thu 25 Jun 2009 16:06:53 IST
Install Reason : Explicitly installed
Install Script : No
Description    : An arbitrary precision calculator language

bc /usr/
bc /usr/bin/
bc /usr/bin/bc
bc /usr/bin/dc
bc /usr/share/
bc /usr/share/info/
bc /usr/share/info/bc.info
bc /usr/share/info/dc.info
bc /usr/share/man/
bc /usr/share/man/man1/
bc /usr/share/man/man1/bc.1.gz
bc /usr/share/man/man1/dc.1.gz

You also need to know the address of you graphics card:

 lspci | grep Display

For me this returns:

00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)

This is needed for this command in the scripts:

 sudo setpci -s 00:02.1 F4.B=$var3

Note the 00:02.1 is the address for my laptop screen, 00:02.0 is the address for the vga out controller for me.

Increase backlight:

#!/bin/bash
var1=`cat ~/.backlight`
var2=`echo "16 i $var1 F + p"|dc`
if (( ( "$var2" \>  "-1") && ( "$var2" \< "256" ) ));
then
    var3=`echo "10 i 16 o $var2 p"|dc`
    echo $var3 > ~/.backlight
    sudo setpci -s 00:02.1 F4.B=$var3
fi

Decrease backlight:

#!/bin/bash
var1=`cat ~/.backlight`
var2=`echo "16 i $var1 F - p"|dc`
if (( ( "$var2" \>  "-1") && ( "$var2" \< "256" ) ));
then
    var3=`echo "10 i 16 o $var2 p"|dc`
    echo $var3 > ~/.backlight
    sudo setpci -s 00:02.1 F4.B=$var3
fi

Obviously someone else can write a much smarter/better set of scripts than me, but I hope is can be of use for someone! smile

Edit:Here are my openbox bindings for the scripts:

  <keybind key="XF86MonBrightnessUp">
      <action name="Execute">
        <command>~/bin/blightu.sh</command>
      </action>
    </keybind>
    <keybind key="XF86MonBrightnessDown">
      <action name="Execute">
        <command>~/bin/blightd.sh</command>
      </action>
    </keybind>

Last edited by makimaki (2009-07-11 14:26:08)


====* -- Joke
    O
    \|/ --- Me
    / \             Whooooosh

Offline

#2 2009-09-29 14:43:26

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: Bash script workaround for intel backlight problems

makimaki, it is dc or bc in your script?. This should be bc , correct this.

Last edited by kgas (2009-09-29 15:05:56)

Offline

#3 2009-09-29 16:22:36

makimaki
Member
From: Ireland
Registered: 2009-04-02
Posts: 109

Re: Bash script workaround for intel backlight problems

kgas wrote:

makimaki, it is dc or bc in your script?. This should be bc , correct this.

No, it uses dc to do the calculation, which is included in the bc package. I chose dc for its reverse polish notation, as I found that easier to use.


====* -- Joke
    O
    \|/ --- Me
    / \             Whooooosh

Offline

#4 2009-10-01 01:39:39

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: Bash script workaround for intel backlight problems

Thanks, for me using dc gives stack empty error may be due to language setting.

Offline

#5 2009-10-01 04:21:31

moose jaw
Member
From: Milwaukee
Registered: 2007-08-20
Posts: 95

Re: Bash script workaround for intel backlight problems

FYI: The new xf86-video-intel (2.9) has just been released:
http://article.gmane.org/gmane.comp.fre … xorg/40733

According to the release announcement, the new driver fixes the backlight issue with KMS:

* Add support for BACKLIGHT property when using kernel modesetting
  (KMS). This allows backlight adjustment with programs such as
  "xbacklight -set <percentage>" or "xrandr --set BACKLIGHT <value>".

Offline

#6 2009-10-11 19:45:41

Barghest
Member
From: Hanau/Germany
Registered: 2008-01-03
Posts: 563

Re: Bash script workaround for intel backlight problems

Thanks for the information,

I built the latest driver from AUR and xbacklight works again.

Offline

#7 2009-10-11 20:38:14

makimaki
Member
From: Ireland
Registered: 2009-04-02
Posts: 109

Re: Bash script workaround for intel backlight problems

I've been using xf86-video-intel-newest from AUR for a while, so I hadn't noticed xbacklight works again! I upgraded to the latest firmware though, and like someone in the nc10 thread my brightness fn keys don't work nicely with xbacklight (still fine with the hack-around I use).


====* -- Joke
    O
    \|/ --- Me
    / \             Whooooosh

Offline

#8 2009-11-01 14:14:28

john_schaf
Member
From: France
Registered: 2007-02-24
Posts: 103

Re: Bash script workaround for intel backlight problems

With latest upgrade (xf86-video-intel 2.9.1 went to extra), still no xbacklight support with KMS enabled :

$ xbacklight
No outputs have backlight property

(here on samsung nc10)

Offline

#9 2009-11-01 15:16:24

Aedit
Member
Registered: 2009-10-29
Posts: 138

Re: Bash script workaround for intel backlight problems

See my backlight script and function key instructions here:
http://wiki.archlinux.org/index.php/Samsung_N140

Offline

#10 2009-11-01 17:57:31

john_schaf
Member
From: France
Registered: 2007-02-24
Posts: 103

Re: Bash script workaround for intel backlight problems

I don't want to use setpci. I prefer to disable KMS.

I just thought that v2.9 of the intel driver fixed this issue.

Offline

#11 2009-12-31 13:53:17

john_schaf
Member
From: France
Registered: 2007-02-24
Posts: 103

Re: Bash script workaround for intel backlight problems

2.6.32 is out, with KMS enabled by default.
I would like to know if people still need this workaround script to set the backlight, or if everything works well with xbacklight ?

For me, xbacklight is still not working at all, even with the driver from testing.

Offline

#12 2009-12-31 13:54:11

john_schaf
Member
From: France
Registered: 2007-02-24
Posts: 103

Re: Bash script workaround for intel backlight problems

2.6.32 is out, with KMS enabled by default.
I would like to know if people still need this workaround script to set the backlight, or if everything works well with xbacklight ?

For me, xbacklight is still not working at all, even with the driver from testing.

[oups, double posted !]

Last edited by john_schaf (2009-12-31 13:55:07)

Offline

#13 2009-12-31 14:27:30

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: Bash script workaround for intel backlight problems

with KMS enabled in kernel 2.6.32, backlight is working fine by default (Lenovo N500/N100 laptops)

Offline

#14 2010-01-22 05:36:32

bdjnk
Member
Registered: 2009-08-24
Posts: 78

Re: Bash script workaround for intel backlight problems

Aedit wrote:

See my backlight script and function key instructions here:
http://wiki.archlinux.org/index.php/Samsung_N140

Thanks Aedit, this works beautifully.

Offline

#15 2011-03-31 13:33:36

hongy19
Member
From: China
Registered: 2005-04-08
Posts: 77
Website

Re: Bash script workaround for intel backlight problems

does anyone know the difference between setpci method and xbacklight method?

in my laptop HP 2540p, the xbacklight method works, but setpci doesn't work.
From my understanding, the setpci method se the register directly and should work at every laptop.
But I don't undestand why it doesn't work at my laptop.

Offline

Board footer

Powered by FluxBB