1 1.1 mycroft #!/bin/sh - 2 1.1 mycroft # 3 1.11 roy # $NetBSD: sleep_button,v 1.11 2017/07/13 13:50:48 roy 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.9 jym if /sbin/sysctl -q hw.acpi.sleep.state; then 14 1.7 jruoho /sbin/sysctl -w hw.acpi.sleep.state=3 15 1.9 jym elif /sbin/sysctl -q machdep.xen.suspend; then 16 1.9 jym /sbin/sysctl -w machdep.xen.suspend=1 17 1.3 jmcneill else 18 1.4 jmcneill sleep 1 19 1.6 abs if /etc/rc.d/apmd onestatus >/dev/null ; then 20 1.4 jmcneill /usr/sbin/apm -z 21 1.4 jmcneill else 22 1.4 jmcneill /usr/sbin/apm -d -z 23 1.4 jmcneill fi 24 1.4 jmcneill # ... waking up 25 1.4 jmcneill sleep 1 26 1.3 jmcneill fi 27 1.3 jmcneill ;; 28 1.7 jruoho 29 1.3 jmcneill released) 30 1.10 jmcneill case "${1}" in 31 1.10 jmcneill vmt0) 32 1.10 jmcneill # Virtual machine is resuming, restart the network 33 1.10 jmcneill /etc/rc.d/dhcpcd restart 34 1.10 jmcneill ;; 35 1.10 jmcneill esac 36 1.3 jmcneill ;; 37 1.1 mycroft *) 38 1.3 jmcneill logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1 39 1.1 mycroft exit 1 40 1.1 mycroft ;; 41 1.1 mycroft esac 42