Cross Reference: sleep_button
xref: /src/etc/powerd/scripts/sleep_button
  • Home
  • History
  • AnnotateAnnotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /src/etc/powerd/scripts/
sleep_button revision 1.4
11.1Smycroft#!/bin/sh -
21.1Smycroft#
31.4Sjmcneill#	$NetBSD: sleep_button,v 1.4 2008/05/21 13:06:10 jmcneill 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.3Sjmcneill	/etc/rc.d/ntpd stop
141.3Sjmcneill	/etc/rc.d/dhclient stop
151.3Sjmcneill	/etc/rc.d/network stop
161.4Sjmcneill	/etc/rc.d/wpa_supplicant stop
171.4Sjmcneill	if /sbin/sysctl machdep.sleep_state >/dev/null 2>&1; then
181.4Sjmcneill		/sbin/sysctl -w machdep.sleep_state=3
191.3Sjmcneill	else
201.4Sjmcneill		sleep 1
211.4Sjmcneill		if /etc/rc.d/apmd status >/dev/null ; then
221.4Sjmcneill			/usr/sbin/apm -z
231.4Sjmcneill		else
241.4Sjmcneill			/usr/sbin/apm -d -z
251.4Sjmcneill		fi
261.4Sjmcneill		# ... waking up
271.4Sjmcneill		sleep 1
281.3Sjmcneill	fi
291.4Sjmcneill	/etc/rc.d/wpa_supplicant start
301.3Sjmcneill	/etc/rc.d/network start
311.3Sjmcneill	/etc/rc.d/dhclient start
321.3Sjmcneill	/etc/rc.d/ntpdate start
331.3Sjmcneill	/etc/rc.d/ntpd start
341.3Sjmcneill	;;
351.3Sjmcneillreleased)
361.3Sjmcneill	# Note that we don't really need to handle a released event here,
371.3Sjmcneill	# so we can gracefully exit.
381.3Sjmcneill	;;
391.1Smycroft*)
401.3Sjmcneill	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
411.1Smycroft	exit 1
421.1Smycroft	;;
431.1Smycroftesac
44

Indexes created Sat Dec 20 01:09:25 GMT 2025