11.1Smycroft#!/bin/sh - 21.1Smycroft# 31.11Sroy# $NetBSD: sleep_button,v 1.11 2017/07/13 13:50:48 roy 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.9Sjym if /sbin/sysctl -q hw.acpi.sleep.state; then 141.7Sjruoho /sbin/sysctl -w hw.acpi.sleep.state=3 151.9Sjym elif /sbin/sysctl -q machdep.xen.suspend; then 161.9Sjym /sbin/sysctl -w machdep.xen.suspend=1 171.3Sjmcneill else 181.4Sjmcneill sleep 1 191.6Sabs if /etc/rc.d/apmd onestatus >/dev/null ; then 201.4Sjmcneill /usr/sbin/apm -z 211.4Sjmcneill else 221.4Sjmcneill /usr/sbin/apm -d -z 231.4Sjmcneill fi 241.4Sjmcneill # ... waking up 251.4Sjmcneill sleep 1 261.3Sjmcneill fi 271.3Sjmcneill ;; 281.7Sjruoho 291.3Sjmcneillreleased) 301.10Sjmcneill case "${1}" in 311.10Sjmcneill vmt0) 321.10Sjmcneill # Virtual machine is resuming, restart the network 331.10Sjmcneill /etc/rc.d/dhcpcd restart 341.10Sjmcneill ;; 351.10Sjmcneill esac 361.3Sjmcneill ;; 371.1Smycroft*) 381.3Sjmcneill logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1 391.1Smycroft exit 1 401.1Smycroft ;; 411.1Smycroftesac 42