#!/bin/sh



request_power_state() {

requester=$1

state=$2

if [ $state == "keep_on" ]; then

 echo "$requester is preventing OM from sleeping."

 dbus-send --system --dest=org.openmoko.Power / org.openmoko.Power.Core.RequestResourceState string:cpu string:$requester string:on

elif [ $state == "may_off" ]; then

 echo "$requester is allowing OM to sleep."

 dbus-send --system --dest=org.openmoko.Power / org.openmoko.Power.Core.RemoveRequestedResourceState string:cpu string:$requester 

elif [ $state == "go_off" ]; then

 echo "$requester is forcing OM to sleep."

 dbus-send --system --dest=org.openmoko.Power / org.openmoko.Power.Core.RequestResourceState string:cpu string:$requester string:off

else

 echo "Unknown power state requested ('$name', '$state'). Pick 'keep_on', 'may_off', or 'go_off'."

fi

}

