#!/bin/sh

PROC_FILE=/proc/bt_sw
STORE_FILE=/etc/btstate

. "${PM_FUNCTIONS}"

suspend_bt()
{
    cat $PROC_FILE > $STORE_FILE
    STATE=`cat /proc/bt_sw`
    if [ $STATE = 1 ]; then
	echo 0 > $PROC_FILE
    fi
}

resume_bt()
{
    cat $STORE_FILE > $PROC_FILE
}

case "$1" in
    hibernate|suspend)
	suspend_bt
	;;
    thaw|resume) 
	resume_bt
	;;
    *)
	;;
esac
