1035e325cSNate Lawson#!/bin/sh 2035e325cSNate Lawson# 3035e325cSNate Lawson# Suspend the system using either ACPI or APM. 4035e325cSNate Lawson# For APM, "apm -z" will be issued. 5035e325cSNate Lawson# For ACPI, the configured suspend state will be looked up, checked to see 6035e325cSNate Lawson# if it is supported, and "acpiconf -s <state>" will be issued. 7035e325cSNate Lawson# 8035e325cSNate Lawson# Mark Santcroos <marks@ripe.net> 9035e325cSNate Lawson# 10035e325cSNate Lawson# $FreeBSD$ 11035e325cSNate Lawson 12035e325cSNate LawsonPATH=/sbin:/usr/sbin:/usr/bin:/bin 13035e325cSNate Lawson 14035e325cSNate LawsonACPI_SUSPEND_STATE=hw.acpi.suspend_state 15035e325cSNate LawsonACPI_SUPPORTED_STATES=hw.acpi.supported_sleep_state 16035e325cSNate LawsonAPM_SUSPEND_DELAY=machdep.apm_suspend_delay 17035e325cSNate Lawson 18035e325cSNate Lawson# Check for ACPI support 19035e325cSNate Lawsonif sysctl $ACPI_SUSPEND_STATE >/dev/null 2>&1; then 20035e325cSNate Lawson # Get configured suspend state 21c6c051e5SNate Lawson SUSPEND_STATE=`sysctl -n $ACPI_SUSPEND_STATE ` 22035e325cSNate Lawson 23035e325cSNate Lawson # Get list of supported suspend states 24c6c051e5SNate Lawson SUPPORTED_STATES=`sysctl -n $ACPI_SUPPORTED_STATES ` 25035e325cSNate Lawson 26035e325cSNate Lawson # Check if the configured suspend state is supported by the system 27c6c051e5SNate Lawson if echo $SUPPORTED_STATES | grep $SUSPEND_STATE >/dev/null; then 28035e325cSNate Lawson # execute ACPI style suspend command 29035e325cSNate Lawson exec acpiconf -s $SUSPEND_STATE 30035e325cSNate Lawson else 31c6c051e5SNate Lawson echo -n "Requested suspend state $SUSPEND_STATE " 32035e325cSNate Lawson echo -n "is not supported. " 33c6c051e5SNate Lawson echo "Supported states: $SUPPORTED_STATES" 34035e325cSNate Lawson fi 35035e325cSNate Lawson# Check for APM support 36035e325cSNate Lawsonelif sysctl $APM_SUSPEND_DELAY >/dev/null 2>&1; then 37035e325cSNate Lawson # Execute APM style suspend command 38035e325cSNate Lawson exec apm -z 39035e325cSNate Lawsonelse 40035e325cSNate Lawson echo "Error: no ACPI or APM suspend support found." 41035e325cSNate Lawsonfi 42035e325cSNate Lawson 43035e325cSNate Lawsonexit 1 44