sleep_button revision 1.9
11.1Smycroft#!/bin/sh - 21.1Smycroft# 31.9Sjym# $NetBSD: sleep_button,v 1.9 2011/09/17 14:44:18 jym Exp $ 41.1Smycroft# 51.3Sjmcneill# Generic script for sleep button events. 61.1Smycroft# 71.1Smycroft# Arguments passed by powerd(8): 81.1Smycroft# 91.1Smycroft# device event 101.1Smycroft 111.1Smycroftcase "${2}" in 121.3Sjmcneillpressed) 131.7Sjruoho 141.8Splunky /etc/rc.d/bluetooth stop 151.3Sjmcneill /etc/rc.d/ntpd stop 161.3Sjmcneill /etc/rc.d/dhclient stop 171.3Sjmcneill /etc/rc.d/network stop 181.4Sjmcneill /etc/rc.d/wpa_supplicant stop 191.7Sjruoho 201.9Sjym if /sbin/sysctl -q hw.acpi.sleep.state; then 211.7Sjruoho /sbin/sysctl -w hw.acpi.sleep.state=3 221.9Sjym elif /sbin/sysctl -q machdep.xen.suspend; then 231.9Sjym /sbin/sysctl -w machdep.xen.suspend=1 241.3Sjmcneill else 251.4Sjmcneill sleep 1 261.6Sabs if /etc/rc.d/apmd onestatus >/dev/null ; then 271.4Sjmcneill /usr/sbin/apm -z 281.4Sjmcneill else 291.4Sjmcneill /usr/sbin/apm -d -z 301.4Sjmcneill fi 311.4Sjmcneill # ... waking up 321.4Sjmcneill sleep 1 331.3Sjmcneill fi 341.7Sjruoho 351.4Sjmcneill /etc/rc.d/wpa_supplicant start 361.3Sjmcneill /etc/rc.d/network start 371.3Sjmcneill /etc/rc.d/dhclient start 381.3Sjmcneill /etc/rc.d/ntpdate start 391.3Sjmcneill /etc/rc.d/ntpd start 401.8Splunky /etc/rc.d/bluetooth start 411.3Sjmcneill ;; 421.7Sjruoho 431.3Sjmcneillreleased) 441.3Sjmcneill # Note that we don't really need to handle a released event here, 451.3Sjmcneill # so we can gracefully exit. 461.3Sjmcneill ;; 471.1Smycroft*) 481.3Sjmcneill logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1 491.1Smycroft exit 1 501.1Smycroft ;; 511.1Smycroftesac 52