[ltp] When/where/what for low power consumption?
Ulrich Kuehn
linux-thinkpad@linux-thinkpad.org
Wed, 16 Nov 2005 17:17:21 +0100
On Wed, 2005-11-16 at 16:59 +0100, Felix E. Klee wrote:
[...]
> Now, some questions remain:
>
> * What ACPI events indicate attachment/detachment to/from mains (I
> should be able to find that out myself)?
>
In the acpi event directory have a file containing
==========================
event=ac_adapter
action=/etc/acpi/actions/ac_adapter.sh
==========================
> * How do I find out whether the system is running on batteries on
> startup (probably using "/proc/acpi/ac_adapter/AC/state")?
>
Yes, I do exactly that. In the ACPI action script for the ac power
event:
===========================================
status=`awk '/^state: / { print $2 }' /proc/acpi/ac_adapter/AC/state`
case $status in
"on-line")
$log "AC adapter is on-line."
/sbin/laptop-mode.sh stop
echo "Setting HD spindown for AC mode."
/sbin/hdparm -S $ACAD_HD /dev/hda > /dev/null 2>&1
/sbin/hdparm -B $ACAD_PM /dev/hda > /dev/null 2>&1
#echo -n $ACAD_CPU:$ACAD_THR
> /proc/acpi/processor/CPU0/limit
exit 0
;;
"off-line")
$log "AC adapter is off-line."
sleep 2
$log $(acpi -b)
/sbin/laptop-mode.sh start
echo "Setting HD spindown for battery mode."
/sbin/hdparm -S $BATT_HD /dev/hda # > /dev/null 2>&1
/sbin/hdparm -B $BATT_PM /dev/hda > /dev/null 2>&1
#echo -n $BATT_CPU:$BATT_THR
> /proc/acpi/processor/CPU0/limit
exit 0
;;
esac
=============================
and this script I do actively call during boot, as the acpi event is
only reported on a change.
Ulrich