LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Laptop brightness on acer laptops. (http://www.linuxquestions.org/questions/linux-hardware-18/laptop-brightness-on-acer-laptops-542426/)

rohandhruva 04-01-2007 02:12 PM

Laptop brightness on acer laptops.
 
Hi,

Is there any way to control laptop brightness on acer laptops ? The hardware keys work, ofcourse, but is there some software way to do it ? So that gnome-power-manager can reduce brightness when AC adapter is removed, etc. Also, so that I can use the brightness applet introduced in gnome 2.18 to control the brightness :)

Up until now, Ubuntu, arch and any other distro for that matter, cannot control brightness on my Acer TravelMate 3260. Is there any solution ? Does libsmbios work for acer laptops ?

Rohan.

Lenard 04-02-2007 08:03 AM

Some sample files you may find useful to review and edit for your hardware specs, all are from my Acer5100 laptop;

A copy of /etc/acpi/actions/ati-powermode.sh;
Code:

#!/bin/sh

#
# Control script for ACPI lid state and AC adapter state
#
# Copyright (c) 2006, ATI Technologies Inc.  All rights reserved.
#
# Fedora Modifications By Michael Larabel <Michael AT Phoronix.com> on July 5, 2006

getXuser() {
        user=`finger| grep -m1 ":$displaynum " | awk '{print $1}'`
        if [ x"$user" = x"" ]; then
                user=`finger| grep -m1 ":$displaynum" | awk '{print $1}'`
        fi
        if [ x"$user" != x"" ]; then
                userhome=`getent passwd $user | cut -d: -f6`
                export XAUTHORITY=$userhome/.Xauthority
        else
                export XAUTHORITY=""
        fi
}


grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
 lid_closed=1
 echo "Lid Closed"
else
 lid_closed=0
 echo "Lid Open"
fi

grep -q off-line /proc/acpi/ac_adapter/*/state

if [ $? = 0 ]; then
  echo "On DC"
  on_dc=1
else
  echo "On AC"
  on_dc=0
fi



if [ ${lid_closed} -eq 1 -o ${on_dc} -eq 1 ]; then
    echo "Low power"
    for x in /tmp/.X11-unix/*; do
        displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
        getXuser;
        if [ x"$XAUTHORITY" != x"" ]; then
            export DISPLAY=":$displaynum"
            su $user -c "/usr/bin/aticonfig --set-powerstate=1 --effective=now"
        fi
    done
else
    echo "High power"
    for x in /tmp/.X11-unix/*; do
        displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
        getXuser;
        if [ x"$XAUTHORITY" != x"" ]; then
            export DISPLAY=":$displaynum"
            su $user -c "/usr/bin/aticonfig --set-powerstate=3 --effective=now"
        fi
    done
fi

A copy of /etc/acpi/events/ac-aticonfig;
Code:

# /etc/acpi/actions/ati-powermode.sh
# Called when the user connects ac power to us

event=ac_adapter
action=/etc/acpi/actions/ati-powermode.sh

And finally /etc/acpi/events/power.conf;
Code:

# ACPID config to power down machine if powerbutton is pressed, but only if
# no gnome-power-manager is running

event=button/power.*
action=/bin/ps awwux | /bin/grep gnome-power-manager | /bin/grep -qv grep || /sbin/shutdown -h now

Which does seem to suggest that gnome-power-manager may not be the best choice to have installed/enabled.

rohandhruva 04-02-2007 08:10 AM

My laptop does not have an ATI card. Your scripts are very useful. Thanks a lot :)

However, your scripts do not list any command to control screen brightness from software. It is possible, for eg, in HP, Dell, Asus notebooks.

Lenard 04-02-2007 09:43 AM

Sorry, I do not know of any software tools to manage the screen brightness/contrast. I find the the 'Fn'+bightness/contrast buttons to be just fine.

Yes, I realize that your laptop does not have an ATi graphics interface, but as you noted the scripts are useful. A little editing and renaming (???) should be all you need.

After a little looking your laptop may not support (a BIOS issue) the acpi AC/Battery, please check around in the /proc/acpi directory structure for support. you should have sub-directories like ac-adapter and battery with files, example;

$ ls /proc/acpi/battery/BAT1
alarm info state

$ ls /proc/acpi/ac_adapter/ACAD
state

Here is another little script you may find useful (again some editing may be needed to match your hardware configuration), I named it chkpower and keep in in my home/bin directory;

Code:

#!/bin/sh
BAT_DIR=/proc/acpi/battery/BAT1
FULL_BAT=`grep 'last full capacity' ${BAT_DIR}/info | awk '{ print $4 }'`
CUR_BAT=`grep 'remaining capacity' ${BAT_DIR}/state | awk '{ print $3 }'`
AVG=`expr $(expr ${CUR_BAT} \* 100) / ${FULL_BAT}`
MyName=`uname -n`

echo
echo The current status report of the power system on $MyName is:

if grep -q 'charged' /proc/acpi/battery/BAT1/state; then
        echo The AC adapter is attached and the battery is fully charged.
        echo
        else
                if grep -q discharging /proc/acpi/battery/BAT1/state; then
                echo On battery, $AVG % of the full charge is remaining. No AC power adapter attached.
                grep 'remaining capacity' /proc/acpi/battery/BAT1/state
                echo
                else
                echo The AC power adapter is attached, the battery is at $AVG % of full charge and is charging.
                echo
                fi
fi
exit 0

Also visit; http://freeunix.dyndns.org:8000/site2/acpitool.shtml

.

rohandhruva 04-02-2007 10:07 AM

Yes, Fn key combo is great, but being able to control it from software allows to write hooks like "reduce brightness to 50% when ac adapter is removed" and so on .. Just adds the professional touch, no real value :)

And, thank you - the chkpower script is great ! I am looking into acpitool now.

Lenard 04-02-2007 12:32 PM

You should have enough info now to create your own acpi script to control the brightness, the author at the acpitool site may be helpful with pointers.

I also have one last script for you, this one goes into the /etc/acpi/actions directory and is named battery.sh on my laptop, it shuts down the laptop when the battery level gets critical;

Code:

#!/bin/sh
if grep -q on-line /proc/acpi/ac_adapter/ACAD/state; then
  exit 0
fi

BAT_DIR=/proc/acpi/battery/BAT1
FULL_BAT=`grep 'last full capacity' ${BAT_DIR}/info | awk '{ print $4 }'`
CUR_BAT=`grep 'remaining capacity' ${BAT_DIR}/state | awk '{ print $3 }'`
AVG=`expr $(expr ${CUR_BAT} \* 100) / ${FULL_BAT}`

if [ "$AVG" -le "4" ]; then
  action=/sbin/shutdown -h now
fi

.

rohandhruva 04-02-2007 07:14 PM

Thanks a lot once again Lenard, the scripts are great !

blahblah 02-02-2010 06:10 AM

command utility to reduce brightness
 
Hi


I wanna write a c program which reduces the monitor brightness(monitor screen has to become dim).
So I want to know is there any command or api to dim the monitor.

Please dont suggest xgamma -gamma "value".
because it does not make the monitor dim. just it reduces RGB values.

And that API or command must work for lcd, CRT, Laptop monitors.

Thanks


All times are GMT -5. The time now is 02:04 PM.