Subject: Re: how to blank or turn off console
To: None <netbsd-help@netbsd.org>
From: Jukka Salmi <j+nbsd@2006.salmi.ch>
List: netbsd-help
Date: 04/29/2006 11:00:14
--98e8jtXdkpgskNou
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Jeremy C. Reed --> netbsd-help (2006-04-28 17:00:22 -0700):
> Does anyone have /etc/powerd/scripts/ examples for "lid_switch"?
I attached the `lid_switch' script I used on a ThinkPad X40. Actually
it's a link to all the other power switch scripts:
$ ls -li /etc/powerd/scripts
total 20
10665 -rwxr-xr-x 5 root wheel 1433 Jan 18 09:49 acadapter
10665 -rwxr-xr-x 5 root wheel 1433 Jan 18 09:49 lid_switch
10665 -rwxr-xr-x 5 root wheel 1433 Jan 18 09:49 power_button
10665 -rwxr-xr-x 5 root wheel 1433 Jan 18 09:49 reset_button
10665 -rwxr-xr-x 5 root wheel 1433 Jan 18 09:49 sleep_button
However, it doesn't do anything (except logging...) when closing the
lid. And since the X40 always enters ddb(4) when I close the lid (PR
kern/32539) I don't use ACPI at all anymore...
Cheers, Jukka
--
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~
--98e8jtXdkpgskNou
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=lid_switch
#!/bin/sh
#
# /etc/powerd/scripts/{acadapter,lid_switch,{power,reset,sleep}_button}
#
# Jukka Salmi, 2006-01-08
#
PROG="${0##*/}"
log() { logger -t 'acpi' "$*"; }
err() { log "ERROR: $*"; exit 1; }
running_X() { pgrep '^XFree86$' >/dev/null; }
log "invoked as \`$0${1+ $*}'${1+ ($#)}"
case "$PROG" in
power_button)
log 'power_button'
case "$2" in
pressed) log 'pressed'; /sbin/shutdown -p now ;;
released) log 'released' ;;
esac
;;
reset_button)
log 'reset_button'
case "$2" in
pressed) log 'pressed' ;;
released) log 'released' ;;
esac
;;
sleep_button)
log 'sleep_button'
case "$2" in
pressed) log 'pressed' ;;
released) log 'released' ;;
esac
;;
lid_switch)
log 'lid_switch'
case "$2" in
pressed)
log 'closed'
;;
released)
log 'opened'
# If running X, closing and reopening the lid leaves the
# display garbled. This can be fixed by switching to another
# VT and back to X.
running_X && { wsconscfg -s 1; sleep 1; wsconscfg -s 5; }
;;
esac
;;
acadapter)
log 'acadapter'
case "$2" in
pressed)
log 'connected'
sysctl -q -w machdep.est.frequency.target=1400
mount -u -o atime,devmtime -A -t ffs
#atactl wd0 setidle 0
;;
released)
log 'disconnected'
sysctl -q -w machdep.est.frequency.target=600
mount -u -o noatime,nodevmtime -A -t ffs
# wd0 goes into standby mode (?!#%@)
#atactl wd0 setidle 5
;;
esac
;;
*)
err "unknown power switch: $PROG"
;;
esac
exit 0
--98e8jtXdkpgskNou--