Subject: Re: bind script to X->VT switch
To: George Michaelson <ggm@apnic.net>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-x11
Date: 02/02/2007 19:55:34
--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Fri, Feb 02, 2007 at 01:44:32PM -0500, George Michaelson wrote:
> I'd love to have a script, which does the moral equivalent of:

Attached is my powerd script. It should illustrate the point.

Joerg

--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=lid_switch

#!/bin/sh -
#
#	$NetBSD: lid_switch,v 1.4 2006/09/27 01:41:45 jnemeth Exp $
#
# Generic script for lid switch events.  We try to put the system to sleep.
#
# Arguments passed by powerd(8):
#
#	device event

case "${2}" in
pressed)
	curtty=`/usr/sbin/wsconscfg -g`
	/usr/sbin/wsconscfg -s 1
	sleep 1
	/sbin/sysctl -w machdep.sleep_state=3
	/usr/sbin/wsconscfg -s $curtty
	/sbin/ifconfig iwi0 | grep inet > /dev/null && /sbin/ifconfig iwi0 up
	exit 0
	;;
released)
	;;
*)
	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
	exit 1
esac

--envbJBWh7q8WU6mo--