Difference between revisions of "Automatically reduce brightness"

From ThinkWiki
Jump to: navigation, search
(Versionbump to 0.2, new kernel interface for brightness in 2.6.22)
Line 3: Line 3:
  
 
== Prerequisites ==
 
== Prerequisites ==
A recent kernel with the [[ibm-acpi]] driver (You should have a directory called {{path|/sys/class/backlight/ibm/}}).
+
A recent kernel with the [[ibm-acpi]] driver (You should have a directory called {{path|/sys/class/backlight/ibm/}} or {{path|/sys/class/backlight/thinkpad_screen/}}).
  
 
== Installation ==
 
== Installation ==
# Download the [http://pberndt.com/Programme/Linux/brightd/_download/brightd.tar.bz2 brightness control daemon]
+
# Download the [http://www.pberndt.com/Programme/Linux/brightd/_download/brightd-0.2.tar.bz2 brightness control daemon]
 
# Unpack it and chdir into the {{path|brightd}} directory
 
# Unpack it and chdir into the {{path|brightd}} directory
 
# Call {{cmduser|make}}
 
# Call {{cmduser|make}}
Line 16: Line 16:
  
 
== Example installation for Gentoo linux and XFCE4 ==
 
== Example installation for Gentoo linux and XFCE4 ==
  $ wget -o /dev/null -O brightd-0.1.tar.bz2 "http://www.pberndt.com/Programme/Linux/brightd/_download/brightd-0.1.tar.bz2?ct=raw&sub=att"
+
  $ wget -o /dev/null -O brightd-0.1.tar.bz2 "http://www.pberndt.com/Programme/Linux/brightd/_download/brightd-0.2.tar.bz2?ct=raw&sub=att"
 
  $ tar xjf brightd-0.1.tar.bz2
 
  $ tar xjf brightd-0.1.tar.bz2
 
  $ cd brightd-0.1/
 
  $ cd brightd-0.1/
Line 32: Line 32:
 
         ebegin "Setting permissions on /sys"
 
         ebegin "Setting permissions on /sys"
 
   
 
   
         chmod g+w /sys/class/backlight/ibm/brightness
+
         chmod g+w /sys/class/backlight/*/brightness
         chgrp wheel /sys/class/backlight/ibm/brightness
+
         chgrp wheel /sys/class/backlight/*/brightness
 
   
 
   
 
         eend $?
 
         eend $?

Revision as of 21:43, 26 April 2007

The idea

When watching someone working with an iBook I noticed that the brightness automatically faded to the lowest level after a few seconds of inactivity. I think that this is a simple way to save power. I wrote a c-daemon which uses the XScreenSaver extension to check whether the user is active. If he is not, it lowers the brightness to a specific level. When he is active again, the brightness is reset to the previous level.

Prerequisites

A recent kernel with the ibm-acpi driver (You should have a directory called /sys/class/backlight/ibm/ or /sys/class/backlight/thinkpad_screen/).

Installation

  1. Download the brightness control daemon
  2. Unpack it and chdir into the brightd directory
  3. Call $ make
  4. Move the brightd executable into a directory like /usr/local/bin
  5. Put $ brightd -d into your ~/.Xsession (or another distro-specific startup script)
  6. Change the permissions of /sys/class/backlight/ibm/brightness so that your user can write to that file

See the README for more detailled instructions and command line parameters.

Example installation for Gentoo linux and XFCE4

$ wget -o /dev/null -O brightd-0.1.tar.bz2 "http://www.pberndt.com/Programme/Linux/brightd/_download/brightd-0.2.tar.bz2?ct=raw&sub=att"
$ tar xjf brightd-0.1.tar.bz2
$ cd brightd-0.1/
$ make
gcc -lX11 -lXss -o brightd brightd.c
$ cp brightd /usr/local/bin/
$ cd /etc/xdg/xfce4
$ vi xinitrc
73Gi
/usr/local/bin/brightd -s 5 -w 2 -d
<escape>:x 
$ cd /etc/init.d/
$ cat > permissions
start() {
        ebegin "Setting permissions on /sys"

        chmod g+w /sys/class/backlight/*/brightness
        chgrp wheel /sys/class/backlight/*/brightness

        eend $?
}
$ chmod a+x permissions
$ rc-update add permissions boot
$ ./permissions start

Done. Restart X to see it working.

Example installation for Debian Sid

brightd isn't yet in the official Debian archives (an ITP was filled), but you can get precompiled binaries for unstable from Zhenech's page.

$ wget http://debian.die-welt.net/pool/main/brightd/brightd_0.1-1_i386.deb

# dpkg -i brightd_0.1-1_i386.deb

Done. Relogin into your X session and brightd will be started. You can change this and other settings by editing /etc/default/brightd.

NOTE!
Changing permissions is not needed, because the binary is installed suid-root.

Possible problems

brightd does not fade, screensaver deactivated

On my Debian Sid box, brightd can run for hours and just do nothing. This happens because it thinks the screensaver is deactivated and screen shouldn't be faded (useful while watching videos). But in fact the screensaver isn't deactivated. To solve this problem, just execute the following command before starting bright:

$ xset s default

brightd says it is fading, but does not

On my Z61m /sys/class/backlight/ibm/brightness is 0 after the laptop boots up. As long it is 0, brightd does nothing, because it thinks, brightness is already as low as possible, so I need to initialize the brightness-level before using brightd:

# echo 7>/sys/class/backlight/ibm/brightness