Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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 ?
Distribution: RHEL/CentOS/SL 5 i386 and x86_64 pata for IDE in use
Posts: 4,790
Rep:
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.
Distribution: RHEL/CentOS/SL 5 i386 and x86_64 pata for IDE in use
Posts: 4,790
Rep:
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
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.
Distribution: RHEL/CentOS/SL 5 i386 and x86_64 pata for IDE in use
Posts: 4,790
Rep:
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.