Subject: Re: Thinkpad T42 Power Management
To: Curt Sampson <cjs@cynic.net>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: port-i386
Date: 11/17/2005 05:32:48
In message <Pine.NEB.4.63.0511171439340.8510@angelic.cynic.net>, Curt Sampson w
rites:
>So, I finally made my choice and went out and got a Thinkpad T42.
>It seems to be working fine so far, though I've not tried X11 yet.
>
>However, I'm not at all familiar with any kind of power management, and
>I'm wondering what I should be using on this machine. Do I just start
>apmd and powerd in rc.conf, and go with the manual pages from there?
>Does anybody have any handy scripts or anything like that?
>
Use apm only. Powerd requires ACPI, which (as far as I know) isn't
really useful yet on laptops, since you can't do suspend/resume.
As for scripts -- a lot depends on your usage pattern. My laptop
constantly moves to different networks, so I restart dhclient on resume.
That means I also have to restart ntpd -- it misbehaves if interfaces
or addresses change -- and bind. I have to run the latter, because
firefox and other long-running only read resolv.conf on firse use of
the DNS. Accordingly, I point resolv.conf at 127.0.0.1 and let DNS
adapt.
Here are some of my scripts:
/etc/apm/suspend:
!/bin/sh
logger -p local0.info -t apm "suspending"
/etc/rc.d/ntpd stop
sync
for i in $(ifconfig -l)
do
case $i in
lo[0-9]*|null[0-9]*)
;;
*)
ifconfig $i down
;;
esac
done
sync; sync
sleep 1
-----------------
/etc/apm/resume:
#!/bin/ksh
logger -p local0.info -t apm "resuming"
cd /
case `apm -d -a` in
0|2) sh /etc/apm/battery;;
1) sh /etc/apm/line;;
esac
sleep 2
ed /etc/resolv.conf <<'EOF'
g/nameserver.*# dhclient/d
w
q
EOF
route -q delete default
int=""
for i in $(ifconfig -l)
do
case "$i" in
lo0|null*) ;;
*)
int="$int $i"
for j in $(ifconfig $i | awk '$1 == "inet" { if ($2 == "
alias") print $3; else print $2}')
do
ifconfig $i delete $j
done
;;
esac
done
(
if [ -f /var/run/dhclient.pid ] && (kill -0 `</var/run/dhclient.pid ` )2
>/dev/null
then
logger -p local0.info -t dhclient dhclient
/etc/rc.d/dhclient restart
#logger -p local0.info -t rtsold rtsold -d "$int"
#rtsol -d "$int" >/dev/console 2>&1 &
else
logger -p local0.info -t dhclient dhclient bypassed
fi
) &
mixerctl -w outputs.master=255,255
--Steven M. Bellovin, http://www.cs.columbia.edu/~smb