1 1.1 mycroft #!/bin/sh - 2 1.1 mycroft # 3 1.10 jmcneill # $NetBSD: sleep_button,v 1.10 2011/10/17 23:27:41 jmcneill Exp $ 4 1.1 mycroft # 5 1.3 jmcneill # Generic script for sleep button events. 6 1.1 mycroft # 7 1.1 mycroft # Arguments passed by powerd(8): 8 1.1 mycroft # 9 1.1 mycroft # device event 10 1.1 mycroft 11 1.1 mycroft case "${2}" in 12 1.3 jmcneill pressed) 13 1.7 jruoho 14 1.8 plunky /etc/rc.d/bluetooth stop 15 1.3 jmcneill /etc/rc.d/ntpd stop 16 1.3 jmcneill /etc/rc.d/dhclient stop 17 1.3 jmcneill /etc/rc.d/network stop 18 1.4 jmcneill /etc/rc.d/wpa_supplicant stop 19 1.7 jruoho 20 1.9 jym if /sbin/sysctl -q hw.acpi.sleep.state; then 21 1.7 jruoho /sbin/sysctl -w hw.acpi.sleep.state=3 22 1.9 jym elif /sbin/sysctl -q machdep.xen.suspend; then 23 1.9 jym /sbin/sysctl -w machdep.xen.suspend=1 24 1.3 jmcneill else 25 1.4 jmcneill sleep 1 26 1.6 abs if /etc/rc.d/apmd onestatus >/dev/null ; then 27 1.4 jmcneill /usr/sbin/apm -z 28 1.4 jmcneill else 29 1.4 jmcneill /usr/sbin/apm -d -z 30 1.4 jmcneill fi 31 1.4 jmcneill # ... waking up 32 1.4 jmcneill sleep 1 33 1.3 jmcneill fi 34 1.7 jruoho 35 1.4 jmcneill /etc/rc.d/wpa_supplicant start 36 1.3 jmcneill /etc/rc.d/network start 37 1.3 jmcneill /etc/rc.d/dhclient start 38 1.3 jmcneill /etc/rc.d/ntpdate start 39 1.3 jmcneill /etc/rc.d/ntpd start 40 1.8 plunky /etc/rc.d/bluetooth start 41 1.3 jmcneill ;; 42 1.7 jruoho 43 1.3 jmcneill released) 44 1.10 jmcneill case "${1}" in 45 1.10 jmcneill vmt0) 46 1.10 jmcneill # Virtual machine is resuming, restart the network 47 1.10 jmcneill /etc/rc.d/dhcpcd restart 48 1.10 jmcneill ;; 49 1.10 jmcneill esac 50 1.3 jmcneill ;; 51 1.1 mycroft *) 52 1.3 jmcneill logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1 53 1.1 mycroft exit 1 54 1.1 mycroft ;; 55 1.1 mycroft esac 56