xref: /titanic_41/usr/src/cmd/hal/tools/sunos/hal-system-power-suspend-sunos.sh (revision d2ec54f7875f7e05edd56195adbeb593c947763f)
1#!/bin/sh
2#
3# hal-system-system-power-suspend-sunos.sh
4#
5# Licensed under the Academic Free License version 2.1
6#
7
8alarm_not_supported() {
9	echo org.freedesktop.Hal.Device.SystemPowerManagement.AlarmNotSupported >&2
10	echo Waking the system up is not supported >&2
11	exit 1
12}
13
14unsupported() {
15	echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
16	echo No suspend method found >&2
17	exit 1
18}
19
20read seconds_to_sleep
21if [ $seconds_to_sleep != "0" ] ; then
22	alarm_not_supported
23fi
24
25if [ -x "/usr/sbin/uadmin" ] ; then
26	/usr/sbin/uadmin 3 20
27	RET=$?
28else
29	unsupported
30fi
31
32#Refresh devices as a resume can do funny things
33for type in button battery ac_adapter
34do
35	devices=`hal-find-by-capability --capability $type`
36	for device in $devices
37	do
38		dbus-send --system --print-reply --dest=org.freedesktop.Hal \
39			  $device org.freedesktop.Hal.Device.Rescan
40	done
41done
42
43exit $RET
44