Home | History | Annotate | Line # | Download | only in scripts
      1 #!/bin/sh -
      2 #
      3 #	$NetBSD: sleep_button,v 1.10 2011/10/17 23:27:41 jmcneill Exp $
      4 #
      5 # Generic script for sleep button events.
      6 #
      7 # Arguments passed by powerd(8):
      8 #
      9 #	device event
     10 
     11 case "${2}" in
     12 pressed)
     13 	if /sbin/sysctl -q hw.acpi.sleep.state; then
     14 		/sbin/sysctl -w hw.acpi.sleep.state=3
     15 	elif /sbin/sysctl -q machdep.xen.suspend; then
     16 		/sbin/sysctl -w machdep.xen.suspend=1
     17 	else
     18 		sleep 1
     19 		if /etc/rc.d/apmd onestatus >/dev/null ; then
     20 			/usr/sbin/apm -z
     21 		else
     22 			/usr/sbin/apm -d -z
     23 		fi
     24 		# ... waking up
     25 		sleep 1
     26 	fi
     27 	;;
     28 
     29 released)
     30 	case "${1}" in
     31 	vmt0)
     32 		# Virtual machine is resuming, restart the network
     33 		/etc/rc.d/dhcpcd restart
     34 		;;
     35 	esac
     36 	;;
     37 *)
     38 	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
     39 	exit 1
     40 	;;
     41 esac
     42