automatic wireless powersave

Jesse Guardiani jesse at wingnet.net
Thu Jun 19 15:12:16 PDT 2003


Jesse Guardiani wrote:

> Jesse Guardiani wrote:
> 
> Check this out.
> 
> I threw a quick little script together that
> does this pretty well. See attached.

Ah. Apparently application/x-shellscript isn't
a support MIME type on this list (or between
GMANE and this list).

See below for shell script:

----------------------------------------------------

#!/bin/sh
#
# Copyright (c) 2003  Jesse D. Guardiani
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.


# sample run command file for APM POWERSTATECHANGE Event

WI_INTERFACE="wi0"

# If we are on mains power...
if [ `apm -a` -eq 1 ]; then
        logger -p user.notice "rc.powerstatechange: Running on Mains..."

        # attempt to turn OFF powersave mode
        ifconfig $WI_INTERFACE -powersave

        if [ $? -eq 0 ]; then
                logger -p user.notice "rc.powerstatechange: powersave OFF for interface $WI_INTERFACE!"
        else
                logger -p user.notice "rc.powerstatechange: WARNING!! 'ifconfig $WI_INTERFACE -powersave' FAILED!"
        fi
else
        logger -p user.notice "Running on Battery..."

        # attempt to turn ON powersave mode
        ifconfig $WI_INTERFACE powersave

        if [ $? -eq 0 ]; then
                logger -p user.notice "rc.powerstatechange: powersave ON for interface $WI_INTERFACE!"
        else
                logger -p user.notice "rc.powerstatechange: WARNING!! 'ifconfig $WI_INTERFACE powersave' FAILED!"
        fi      
fi

exit 0

-- 
Jesse Guardiani, Systems Administrator
WingNET Internet Services,
P.O. Box 2605 // Cleveland, TN 37320-2605
423-559-LINK (v)  423-559-5145 (f)
http://www.wingnet.net




More information about the freebsd-mobile mailing list