#!/bin/sh

PROC_FILE=/proc/wlan_sw
STORE_FILE=/etc/wifistate

. "${PM_FUNCTIONS}"

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

resume_wifi()
{
    cat $STORE_FILE > $PROC_FILE
}

case "$1" in
    hibernate|suspend)
	suspend_wifi
	;;
    thaw|resume) 
	resume_wifi
	;;
    *)
	;;
esac
