User Tools

Site Tools


howto:automaticbrightness

Automatic LCD brightness control

EEE is able to automatically adjust the LCD brightness depending on whether you are working on AC power or battery.

Instructions

1. In the console type

kwrite /home/user/.screen_brightness.sh

2. Put the following text in the file

  #!/bin/sh
 
  PWR_STATE=`cat /proc/acpi/ac_adapter/AC0/state | awk '{print $2}'`
 
  if [ "$PWR_STATE" == "off-line" ] ; then
        echo 5 > /proc/acpi/asus/brn
  else
        echo 15 > /proc/acpi/asus/brn
  fi

The 5 and 15 can be set to anything you like. 0 is dimmest and 15 is brightest.

3. Save the file, exit and make it executable with

chmod +x /home/user/.screen_brightness.sh

4. Next, type

sudo kwrite /etc/acpi/hotkey.sh

5. You should see something like that on the end of the file

  #Fn+F4
  0000002x)
          #echo "Brightness Up" > /dev/pts/0
          ;;
esac

6. Insert

  # Power cord in or out
  00000050 | 00000051 )
          sudo -u user /home/user/.screen_brightness.sh
          ;;

between ;; and esac, so the end of the file should look like

  #Fn+F4
  0000002x)
          #echo "Brightness Up" > /dev/pts/0
          ;;
  # Power cord in or out
  00000050 | 00000051 )
          sudo -u user /home/user/.screen_brightness.sh
          ;;
esac

7. Save the file, exit the editor and restart the system.

Now the brightness should change automatically when you plug/unplug the AC power, but will not change depending on the power status when you boot. To change that, first follow the instructions on how to make a script run at startup.

Then call .screen_brightness.sh from your startup script. For Easy Mode, type

kwrite /home/user/.icewm/startup

and put the following text in it

  #!/bin/sh
 
  if [ -x /home/user/.screen_brightness.sh ]; then
        /home/user/.screen_brightness.sh
  fi

then make it executable with

chmod +x /home/user/.icewm/startup

and your Eee will automatically set its brightness at boot time

Relative brightness change

The upper script changes the brightness to a fixed value but it is also possible to do a relative change, for example: change the brightness 5 steps down when you start working on battery (and vice versa). Putting the following line in your /etc/acpi/hotkey.sh will do this.

  # AC power
  00000050)
          BRN=`cat /proc/acpi/asus/brn`
          if [ $(($BRN+5)) -gt 15 ]; then
              echo 15 > /proc/acpi/asus/brn
          else
              echo $(($BRN+5)) > /proc/acpi/asus/brn
          fi
          ;;
  # battery power
  00000051)
          BRN=`cat /proc/acpi/asus/brn`
          if [ $(($BRN-5)) -lt 0 ]; then
              echo 0 > /proc/acpi/asus/brn
          else
              echo $(($BRN-5)) > /proc/acpi/asus/brn
          fi
          ;;

Remember previous brightness

Most computers will automatically change your screen brightness to the brightness you had previously in a given mode.

Putting the following code in your /etc/acpi/hotkey.sh

	# Power cord in
	00000050)
		echo `cat /proc/acpi/asus/brn` > /home/user/.screenbright_bat
		echo `cat /home/user/.screenbright_ac` > /proc/acpi/asus/brn
		;;
	# Power cord out
        00000051 )
		echo `cat /proc/acpi/asus/brn` > /home/user/.screenbright_ac
		echo `cat /home/user/.screenbright_bat` > /proc/acpi/asus/brn
		;;

Will enable your Eee PC to do the same rio sosh code rio rio sosh bouygues

howto/automaticbrightness.txt · Last modified: 2012/01/28 10:32 by hello