2003-07-14 17:31:34 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Suspend the system using either ACPI or APM.
|
|
|
|
# For APM, "apm -z" will be issued.
|
|
|
|
# For ACPI, the configured suspend state will be looked up, checked to see
|
|
|
|
# if it is supported, and "acpiconf -s <state>" will be issued.
|
|
|
|
#
|
|
|
|
# Mark Santcroos <marks@ripe.net>
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
|
|
|
|
PATH=/sbin:/usr/sbin:/usr/bin:/bin
|
|
|
|
|
|
|
|
ACPI_SUSPEND_STATE=hw.acpi.suspend_state
|
|
|
|
ACPI_SUPPORTED_STATES=hw.acpi.supported_sleep_state
|
|
|
|
APM_SUSPEND_DELAY=machdep.apm_suspend_delay
|
|
|
|
|
|
|
|
# Check for ACPI support
|
|
|
|
if sysctl $ACPI_SUSPEND_STATE >/dev/null 2>&1; then
|
|
|
|
# Get configured suspend state
|
2003-07-25 18:11:15 +01:00
|
|
|
SUSPEND_STATE=`sysctl -n $ACPI_SUSPEND_STATE `
|
2003-07-14 17:31:34 +01:00
|
|
|
|
|
|
|
# Get list of supported suspend states
|
2003-07-25 18:11:15 +01:00
|
|
|
SUPPORTED_STATES=`sysctl -n $ACPI_SUPPORTED_STATES `
|
2003-07-14 17:31:34 +01:00
|
|
|
|
|
|
|
# Check if the configured suspend state is supported by the system
|
2003-07-25 18:11:15 +01:00
|
|
|
if echo $SUPPORTED_STATES | grep $SUSPEND_STATE >/dev/null; then
|
2003-07-14 17:31:34 +01:00
|
|
|
# execute ACPI style suspend command
|
|
|
|
exec acpiconf -s $SUSPEND_STATE
|
|
|
|
else
|
2003-07-25 18:11:15 +01:00
|
|
|
echo -n "Requested suspend state $SUSPEND_STATE "
|
2003-07-14 17:31:34 +01:00
|
|
|
echo -n "is not supported. "
|
2003-07-25 18:11:15 +01:00
|
|
|
echo "Supported states: $SUPPORTED_STATES"
|
2003-07-14 17:31:34 +01:00
|
|
|
fi
|
|
|
|
# Check for APM support
|
|
|
|
elif sysctl $APM_SUSPEND_DELAY >/dev/null 2>&1; then
|
|
|
|
# Execute APM style suspend command
|
|
|
|
exec apm -z
|
|
|
|
else
|
|
|
|
echo "Error: no ACPI or APM suspend support found."
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 1
|