1 1.1 mycroft #!/bin/sh - 2 1.1 mycroft # 3 1.5 jmcneill # $NetBSD: sleep_button,v 1.5 2008/06/06 23:13:58 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.5 jmcneill /etc/rc.d/btdevctl stop 14 1.5 jmcneill /etc/rc.d/btconfig 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.4 jmcneill if /sbin/sysctl machdep.sleep_state >/dev/null 2>&1; then 20 1.4 jmcneill /sbin/sysctl -w machdep.sleep_state=3 21 1.3 jmcneill else 22 1.4 jmcneill sleep 1 23 1.4 jmcneill if /etc/rc.d/apmd status >/dev/null ; then 24 1.4 jmcneill /usr/sbin/apm -z 25 1.4 jmcneill else 26 1.4 jmcneill /usr/sbin/apm -d -z 27 1.4 jmcneill fi 28 1.4 jmcneill # ... waking up 29 1.4 jmcneill sleep 1 30 1.3 jmcneill fi 31 1.4 jmcneill /etc/rc.d/wpa_supplicant start 32 1.3 jmcneill /etc/rc.d/network start 33 1.3 jmcneill /etc/rc.d/dhclient start 34 1.3 jmcneill /etc/rc.d/ntpdate start 35 1.3 jmcneill /etc/rc.d/ntpd start 36 1.5 jmcneill /etc/rc.d/btconfig start 37 1.5 jmcneill /etc/rc.d/btdevctl start 38 1.3 jmcneill ;; 39 1.3 jmcneill released) 40 1.3 jmcneill # Note that we don't really need to handle a released event here, 41 1.3 jmcneill # so we can gracefully exit. 42 1.3 jmcneill ;; 43 1.1 mycroft *) 44 1.3 jmcneill logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1 45 1.1 mycroft exit 1 46 1.1 mycroft ;; 47 1.1 mycroft esac 48