Thursday, June 12, 2008

Thinkpad T60p acpi script

This is the script I use on my T60p (2007-AD1) to get the most out of my battery life. With this script in place, I can get about 375-4hrs off of my battery.

/etc/acpi/actions/battery.sh

#!/bin/bash
state=`grep on-line /proc/acpi/ac_adapter/AC/state | wc -l`
if [ $state -gt 0 ]; then
hal-disable-polling --device /dev/scd0 --enable-polling
echo 0 > /proc/sys/vm/laptop_mode
echo 0 > /sys/devices/system/cpu/sched_mc_power_savings
hdparm -B 128 -s 0 /dev/sda
echo 499 > /proc/sys/vm/dirty_writeback_centisecs
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 0 > $i; done
ethtool -s eth0 wol g
echo 0 > /sys/module/snd_hda_intel/parameters/power_save
echo enable > /proc/acpi/ibm/bluetooth
echo max_performance > /sys/class/scsi_host/host0/link_power_management_
policy
else
hal-disable-polling --device /dev/scd0
echo 5 > /proc/sys/vm/laptop_mode
echo 1 > /sys/devices/system/cpu/sched_mc_power_savings
hdparm -B 1 -s 12 /dev/sda
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
killall beagled
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done
ethtool -s eth0 wol d
echo 1 > /sys/module/snd_hda_intel/parameters/power_save
echo disable > /proc/acpi/ibm/bluetooth
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
fi


And of course the config file in /etc/acpi/events/battery.conf

# Configuration to turn on DPMS again on video activity, needed for some
# laptops. Disabled by default, uncomment if your laptop display stays blank
# after you close and open the lid.

event=battery.*
action=/etc/acpi/actions/battery.sh


1 comment:

Gromba said...

Thanks for this :D