1117557Snjl#!/bin/sh
2117557Snjl#
3117557Snjl# Suspend the system using either ACPI or APM.
4117557Snjl# For APM, "apm -z" will be issued.
5117557Snjl# For ACPI, the configured suspend state will be looked up, checked to see
6117557Snjl# if it is supported, and "acpiconf -s <state>" will be issued.
7117557Snjl#
8117557Snjl# Mark Santcroos <marks@ripe.net>
9117557Snjl#
10117557Snjl# $FreeBSD$
11117557Snjl
12117557SnjlPATH=/sbin:/usr/sbin:/usr/bin:/bin
13117557Snjl
14117557SnjlACPI_SUSPEND_STATE=hw.acpi.suspend_state
15117557SnjlACPI_SUPPORTED_STATES=hw.acpi.supported_sleep_state
16117557SnjlAPM_SUSPEND_DELAY=machdep.apm_suspend_delay
17117557Snjl
18117557Snjl# Check for ACPI support
19117557Snjlif sysctl $ACPI_SUSPEND_STATE >/dev/null 2>&1; then
20117557Snjl	# Get configured suspend state
21118020Snjl	SUSPEND_STATE=`sysctl -n $ACPI_SUSPEND_STATE `
22117557Snjl
23117557Snjl	# Get list of supported suspend states
24118020Snjl	SUPPORTED_STATES=`sysctl -n $ACPI_SUPPORTED_STATES `
25117557Snjl
26117557Snjl	# Check if the configured suspend state is supported by the system
27118020Snjl	if echo $SUPPORTED_STATES | grep $SUSPEND_STATE >/dev/null; then
28117557Snjl		# execute ACPI style suspend command
29117557Snjl		exec acpiconf -s $SUSPEND_STATE
30117557Snjl	else
31118020Snjl		echo -n "Requested suspend state $SUSPEND_STATE "
32117557Snjl		echo -n "is not supported.  "
33118020Snjl		echo    "Supported states: $SUPPORTED_STATES"
34117557Snjl	fi
35117557Snjl# Check for APM support
36117557Snjlelif sysctl $APM_SUSPEND_DELAY >/dev/null 2>&1; then
37117557Snjl	# Execute APM style suspend command
38117557Snjl	exec apm -z
39117557Snjlelse
40117557Snjl	echo "Error: no ACPI or APM suspend support found."
41117557Snjlfi
42117557Snjl
43117557Snjlexit 1
44