# ACPI and LCD backlighting

## bbarrera

Recently I had to disable APM and enable ACPI to support a new wireless card (drivers require ACPI and kernel PCMCIA). Since then my LCD panel backlighting is always on even when the computer is idle. Worse, closing and opening the panel requires a ctrl-alt-f1 and then a ctrl-alt-f7 to "wake up" the display. Finally, the KDE Control Panel power controls didn't work anymore.

Here is how I fixed the problems (instructions assume KDE & bash):

1. Enable DPMS in /etc/X11/XF86Config. By doing this, two things started working:

- Display Power Control settings in the KDE Control Center

- xset commands to control DPMS (used in my ACPI event handler)

/etc/X11/XF86Config

```

...

...

Section "Monitor"

    HorizSync   31-90

    Identifier  "Monitor1"

    ModelName   "1400X LAPTOP DISPLAY PANEL"

    VendorName  "DELL"

    VertRefresh  59-75

    UseModes    "Modes[0]"

    Option      "DPMS"

EndSection

...

...
```

The key line is "Option "DMPS" -- I noticed this line in a SuSE generated XF86Config file. Once I added that to my Gentoo XF86Config file the power management control in KDE started working.

2. Turn on display power management in KDE control panel.

KDE Control Center -> Power Control -> Display Power Control

check Enable box, disable standby, disable suspend, and set number of minutes in power off.

3 Emerge acpid, the ACPI event daemon. Add acpid to default runlevel using rc-update:

```
rc-update add acpid default
```

Then add some event handlers, here are mine:

/etc/acpi/default.sh

```
#!/bin/sh

# Default acpi script that takes an entry for all actions

set $*

group=${1/\/*/}

action=${1/*\//}

case "$group" in

        button)

                case "$action" in

                        power)  /sbin/init 0

                                ;;

                        lid)

                                lidstate="`cat /proc/acpi/button/lid/LID/state | awk '{print $2}'`"

                                case "$lidstate" in

                                        open)   /usr/X11R6/bin/xset -display :0.0 dpms force on

#                                               logger "LCD panel is $lidstate"

                                                ;;

                                        closed) /usr/X11R6/bin/xset -display :0.0 dpms force off

#                                               logger "LCD panel is $lidstate"

                                                ;;

                                esac

                                ;;

                        *)      logger "ACPI action $action is not defined"

                                ;;

                esac

                ;;

        *)

                logger "ACPI group $group / action $action is not defined"

                ;;

esac
```

4. Start acpid.

```
/etc/init.d/acpid start
```

5. Now you must allow the acpid daemon access to X server. Since the acpid is running as root after a reboot, we need to allow root access to the X server when we are logged in as a normal user. The xhost command provides basic security and I enabled access to X from any user logged into my machine (couldn't figure out how to just allow root user). For cut&paste portability across computers, I added line "xhost +`hostname`" to my .bash_profile:

```
# /etc/skel/.bash_profile:

# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/skel/.bash_profile,v 1.10 2002/11/18 19:39:22 azarah Exp $

xhost +`hostname`

#This file is sourced by bash when you log in interactively.

[ -f ~/.bashrc ] && . ~/.bashrc
```

6. Test by closing the lid. Peek under lid and it should immediately turn off backlighting. Now open lid and the screen should immediately come back.

Improvements welcome.

Enjoy!

----------

## artooman

for me, this only blanks the screen.  i followed all the steps with the exception of the KDE parts since i run gnome.  is this supposed to actually shut off the screen?  if so, can anyone else get this to work?

----------

## bbarrera

What happens when you run this command with your user account?

```
usr/X11R6/bin/xset -display :0.0 dpms force off
```

----------

## tizzy

 *Quote:*   

> What happens when you run this command with your user account? 
> 
> Code:	
> 
> usr/X11R6/bin/xset -display :0.0 dpms force off
> ...

 

I've got the same problem. If I have started the command, it blanks my screen, but didnt switch off the backlight. It's a Fujitsu PIIIM 1GHz and a RadeonM graphics card. Acpi is compiled into the kernel and there are no failure messages in any logfile. I would use APM, but I need acpi for my hardware.  :Sad: 

Alex

----------

## bbarrera

I've got a Dell Inspiron 4100 with Nvidia GeForce2 Go. The xset command didn't turn off backlighting until I added "option DPMS" to /etc/X11/XF86Config.

Check /var/log/XFree86.0.log -- mine has the following line confirming that DPMS is enabled.

```
(**) Option "dpms"

(**) NVIDIA(0): DPMS enabled
```

----------

## tizzy

Of course I have set the DPMS-Option in the XF86Config. In the logfile I can read dpms is enabled. I have reconfigured my kernel, too. The logfile says, XFree wants to have access to e2c. So I have compiled it in, but it doesnt help.

The backlight is switched of when I close the panel. Maybe it isnt switched of by acpi, but in a hard wired way. How can I find out if there is an acpi event? I cant find any entries in any logfiles. And if I find out there is an acpi event for closing the panel, how can I use this for switching off the backlight?

The described way from above doesnt seems to work for my hardware. But it have to work, because Mandrake does it very well. What a pity, I just deleted all config files.  :Sad: 

T.

----------

## bbarrera

Sorry I can't help with your hardware. Here are a few things to check. The acpid deamon writes to several files in /var/log -- use something like "cd /var/log; grep logger *" to find the log entries. The events and information are found under /proc/acpi directory.

----------

## Boris27

 *tizzy wrote:*   

> Of course I have set the DPMS-Option in the XF86Config. In the logfile I can read dpms is enabled. I have reconfigured my kernel, too. The logfile says, XFree wants to have access to e2c. So I have compiled it in, but it doesnt help.
> 
> The backlight is switched of when I close the panel. Maybe it isnt switched of by acpi, but in a hard wired way. How can I find out if there is an acpi event? I cant find any entries in any logfiles. And if I find out there is an acpi event for closing the panel, how can I use this for switching off the backlight?
> 
> The described way from above doesnt seems to work for my hardware. But it have to work, because Mandrake does it very well. What a pity, I just deleted all config files. 
> ...

 

If its a hardwired thing, look for a small hole where a pin on the lid pushes in a switch. On my HP XE3 laptop, its in the middle at the end of the screen, and pressing it with my fingernail turns off the backlight.

----------

## peshwengi

I believe my laptop has some magnets around the edge of the screen which trip a relay or something when it is closed.

----------

## Cosmosis

I'm having a little trouble with this...

the command "/usr/X11R6/bin/xset -display :0.0 dpms force off" kills my display, and this is good as it's exactly what I want but the events file isn't doing anything. When I close the lid the screen just stays on. I don't really understand why or whats going on but.. I don't know. I'm running Gentoo 1.4 and Gnome on my Dell Inspiron 1100...

any help would be appreciated..

-Tim

----------

## angagon

First simply monitor the ACPI events that are being generated with something along the lines of (you'll probably have to run this as root): 

```
tail -f /var/log/acpid
```

  Then either close and open the lid or push and release the button and watch for "button/lid" events being generated.  When you open and close the lid a close event will first be fired and then a lid open event will be fired.

Then you need to set ACPI to handle those events.  The simplest way to do that, IMO, is to add event definition files to /etc/acpi/events.  

For example:

```
#/etc/acpi/events/lid-opened

event=button/lid C136 00000080 00000008

action=/etc/acpi/actions/lid-opened.sh

```

and 

```
#/etc/acpi/events/lid-closed

event=button/lid C136 00000080 00000007

action=/etc/acpi/actions/lid-closed.sh

```

The action can be any command, so you could put the xset command there, but changing it requires restarting acpid, as near as I could figure.  Using a shell script allows you to modify what commands you want to be run on lid events at any time.  Then set up the scripts to run all the commands you want.

Oh, to restart acpid, so that it detects and uses the new event definition file a 

```
/etc/init.d/acpid restart
```

is in order.

----------

## sparks

Great thread bbarrera, those tips really helped me learn more about my newly acpi aware system!  However, I am having some of the same problems as the others.  My screen will go black, as it should, but the backlight still stays on (and consumes power).  How do we go about getting the backlight to shut off?  BTW I have a Dell D600 with bios A08 if that helps any.

----------

## Cosmosis

Hey...

I tried what you said but when I do "tail -f /var/log/acpid" and then open and close the lid it gives me nothing, not lid open\close events like it should. What am I doing wrong??

-tim

----------

## jana

Check out this forum for some really good help on acpi scripting!  Don't forget to customize the scripts for your own /proc directory structure...

 - j

----------

## angagon

If you aren't getting events for the close,open lid, and assuming acpid is running, did you build ACPI button support into the kernel or in modules.  If you build them as modules then

```
# modprobe button
```

as root and try it again.

----------

## ShallowCorporateRaider

I followed the steps outlined in the main post, and everything worked fine.  Here is my problem:

After I reboot, the screen will not longer shutoff when I close the lid.  If I do a 

```
cat /var/log/acpi
```

 then I see 

```
Xlib: No protocol specified

/usr/X11R6/bin/xset:  unable to open display ":0.0"
```

If I restart acpid, then everything works fine.  I have acpid running at the default runlevel currently.  It seems like it is not loading the xhost+hostname line from the profile.

Any ideas?

----------

## ShallowCorporateRaider

Small update -- 

My problem is still as I described it above, but the workaround is incorrect.  I stated above that if I simply restarted acpid, then it worked.  That is not correct.

In fact, I have to restart acpid with X running, and then the LID event works correctly.  Any ideas, folks?

----------

## babak

I really enjoy reading these bunch of informations,

Thanks alot guys.

I really appreciate if any body help me with my problem.

I have DELL inspiron 5100 and have a same problem, in other hand I can't find that mechanism you talked about for sensing closing lid.

In other words I have problem to gererate that event with out closing lid.

Would you please help me.

Thanks

----------

## fideli

 *bbarrera wrote:*   

> 5. Now you must allow the acpid daemon access to X server. Since the acpid is running as root after a reboot, we need to allow root access to the X server when we are logged in as a normal user. The xhost command provides basic security and I enabled access to X from any user logged into my machine (couldn't figure out how to just allow root user). For cut&paste portability across computers, I added line "xhost +`hostname`" to my .bash_profile:
> 
> ```
> # /etc/skel/.bash_profile:
> 
> ...

 

Does this change to /etc/skel/.bash_profile apply right away?  I added the line to all my .bash_profiles (skel, root, and user) and I'm not sure when it'll take place because the only time my ~/.bash_profile is run is when I open up a Konsole window, where it informs me that my `hostname` is a bad hostname.  I ran xset by myself and it sure turns the screen off, and the lidstate becomes open and closed accordingly (hehe, at this point I can test both states with the screen on from /proc/acpi/lid/LID0/state).  Can anyone clarify step 5 of the howto?  Thanks.

 *bbarrera also wrote:*   

> Enjoy!

 

I shall, in due time.

-\ fideli /-

----------

## SilveRo

 *fideli wrote:*   

>  *bbarrera wrote:*   5. Now you must allow the acpid daemon access to X server. Since the acpid is running as root after a reboot, we need to allow root access to the X server when we are logged in as a normal user. The xhost command provides basic security and I enabled access to X from any user logged into my machine (couldn't figure out how to just allow root user). For cut&paste portability across computers, I added line "xhost +`hostname`" to my .bash_profile:
> 
> ```
> # /etc/skel/.bash_profile:
> 
> ...

 

https://forums.gentoo.org/viewtopic.php?t=159453

=*

----------

## SilveRo

 *ShallowCorporateRaider wrote:*   

> Small update -- 
> 
> My problem is still as I described it above, but the workaround is incorrect.  I stated above that if I simply restarted acpid, then it worked.  That is not correct.
> 
> In fact, I have to restart acpid with X running, and then the LID event works correctly.  Any ideas, folks?

 

check out this thread:

https://forums.gentoo.org/viewtopic.php?t=159453

=*

----------

## moowei

allow me to ask a stupid question..

How to adjust the brightness level? This has been bothering me for a long time. I think my brightness level is always at 7/8.

Thanks A LOT!

----------

## SilveRo

 *moowei wrote:*   

> allow me to ask a stupid question..
> 
> How to adjust the brightness level? This has been bothering me for a long time. I think my brightness level is always at 7/8.
> 
> Thanks A LOT!

 

Sorry, I never addressed the matter because I can raise the brightness with the standard Fn key bindings, that work without any further configuration. I have a Dell Inspiron 8600.

Try searching these forums, or linux-laptop.org, or google, or start a thread describing your problem and your laptop model.

----------

## moowei

yea, I've seen many people say that this function is hard wired on their Fn keys, so there's not a problem. Anyways, I found it:

echo "brightness:7" > /proc/acpi/toshiba/lcd

(only for toshiba)

thanks!  :Very Happy: 

----------

## SilveRo

 *moowei wrote:*   

> yea, I've seen many people say that this function is hard wired on their Fn keys, so there's not a problem. Anyways, I found it:
> 
> echo "brightness:7" > /proc/acpi/toshiba/lcd
> 
> (only for toshiba)
> ...

 

NP =)

I'm glad you worked it out. Easy one, huh?

 :Razz: 

----------

## moowei

Hi

I have a "small problem" with my LCD backlight. It actually acts properly when closing the lid, but the problem is when the system is idled the screen will only turn to blank screen but the backlight is apparently on. I tried

 *Quote:*   

> usr/X11R6/bin/xset -display :0.0 dpms force off

 

and the backlight DOES turn off porperly, so I am guessing I just need to adjust the settings somewhere to make the backlight turn off by default. I am thinking of editing ACPI... but am not sure. Could any one help, please?

(the problem exists in both X and console)

Thanks a lot.

----------

## ADFoxDie

I was browsing around this forum cause I was having the same problem and I found this post.  I was having a similar problem getting my screen to turn off.  It turns out that the Radeon card series isn't supported in DPMS.  I found a solution elsewhere on SuSE's web site.

First:

```
emerge radeontool
```

Then edit /etc/acpi/default.sh and link the lid button state to radeontool

```

#!/bin/sh

# Default acpi script that takes an entry for all actions

set $*

group=${1/\/*/}

action=${1/*\//}

case "$group" in

   button)

      case "$action" in

         power)   /usr/local/sbin/hibernate

            ;;

         lid)

            lidstate="`cat /proc/acpi/button/lid/LID/state | awk '{print $2}'`"

            case "$lidstate" in

               open) /usr/bin/radeontool light on

#                  logger "LCD panel is $lidstate"

                  ;;

               closed) /usr/bin/radeontool light off

#                  logger "LCD panel is $lidstate"

                  ;;

            esac

            ;;

         *)   logger "ACPI action $action is not defined"

            ;;

      esac

      ;;

   *)

      logger "ACPI group $group / action $action is not defined"

      ;;

esac

```

Hope somebody finds this helpful  :Smile: 

----------

## snowbum

cool cool, ADFoxDie. I am able to turn of the backlight on my sony vaio with that tool. I have radeon 7500 16mb adapter. The thing is I have to turn it back on manually. I guess I can use this only when it reaches an ACPI state and then issue the on command when it comes out of that state. I'll do more research.

----------

## xro

It seems to me, that many people in this thread, have backlight problems with their Radeon powered LCD Screen.

So I just wanted to mention, that not-turning-off-the-backlight-when-blanking-the-screen is a well known bug of the Xfree Radeon Driver:

Link to Bugzilla:

http://bugs.xfree86.org/show_bug.cgi?id=26

There are also patches for Xfree or precompiled radeon_drv.o that solve this particular problem  :Smile: 

----------

## bfg

Thanxs XRO.

I gotta a laptop DELL this week and was having the same problem with the LID Open.

Then i found your solution and it works pretty well for me!

 :Very Happy: 

----------

## artooman

You guys all rock my world.  I have been trying to get my radeon-based LCD to turn off for over a year now (Dell D600), and I found this thread while looking for something completely different.  It now works!!!  radeontool did it for me!

Thanks!

----------

