-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bob Igo wrote:
| What do I need to do in order to put the device to sleep and have it
| wake up at a pre-determined time?

I thought others might be interested in the answer.  It turns out that
putting values into
/sys/class/rtc/rtc0/alarm/[pending|wakeup_enabled|since_epoch] does the
trick.  Here's a little shell script I whipped together, called
set_wakeup.sh, to set a wakeup time and suspend the device.  It's been
working great for me.  Enjoy!

#!/bin/sh

# Copyright 2008 Robert ("Bob") Igo of StormLogic, LLC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


#
# wakeup.sh sets a wakeup time for the device, taking as input the
# number of seconds past the epoch.
#
WAKE_TIME=$(($1 + 0)) # the wakeup time in seconds past the epoch
HIBERNATE=$2 # if "suspend" then suspend after setting the wakeup time

# test input
NOW=`date +%s`
# no wakeup time can be before this date
if [ "$WAKE_TIME" -le "$NOW" ]; then
~    echo "ERROR: Wakeup time is in the past."
~    echo "WAKE_TIME: $WAKE_TIME"
~    echo "NOW: $NOW"
~    echo
~    echo "USAGE: $0 SECONDS_PAST_EPOCH [suspend]"
~    echo "e.g. $0 1206997272 1"
~    exit
fi

# print status output
NOW=`date +%s`
DIFFERENCE=$(($WAKE_TIME - $NOW))
echo "I was asked to wake up at $WAKE_TIME seconds past epoch"
echo "which is $DIFFERENCE seconds from now."
echo

# set the wakeup time
ALARM_FILE=/sys/class/rtc/rtc0/alarm/since_epoch
echo "  Setting wakeup time for $WAKE_TIME..."
echo $WAKE_TIME  > $ALARM_FILE
echo 1 > /sys/class/rtc/rtc0/alarm/pending
echo 1 > /sys/class/rtc/rtc0/alarm/wakeup_enabled
echo "  DONE"

# print status output
NOW=`date +%s`
DIFFERENCE=$(($WAKE_TIME - $NOW))
echo
echo "If you hibernate the device NOW, it should wake up in"
echo "$DIFFERENCE seconds."

# hibernate if the user asked us to
if [ "$1" -eq "suspend" ]; then
~    apm --suspend
fi

- --
Bob Igo
StormLogic
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH8VN+65uO8u5kvxoRAsGuAJ9IOlZmX7teOV/S3tt8xFwom+d0qgCdEtY1
Zr+aDnkTzjvv3BXJUjTpH+Q=
=zZbk
-----END PGP SIGNATURE-----

_______________________________________________
Angstrom-distro-users mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/angstrom-distro-users

Reply via email to