Created
May 4, 2011 19:11
-
-
Save laurynas/955814 to your computer and use it in GitHub Desktop.
Schedule ACPI wakeup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Schedule ACPI wakeup | |
# | |
# Author: Laurynas Butkus (laurynas.butkus at gmail.com) | |
# | |
# Some info on ACPI wakeup: | |
# http://smackerelofopinion.blogspot.com/2009/08/acpi-wake-alarm-bugs.html | |
# | |
#SLEEP_SECS=19*60*60 | |
#SECS=$((`cat /sys/class/rtc/rtc0/since_epoch`+$SLEEP_SECS)) | |
SECS=$((`date --date '00:00 tomorrow' +'%s'`)) | |
MIN_SLEEP_SECS=$((30*60)) | |
REMAIN=$(($SECS-`date +'%s'`)) | |
# check if will sleep minimum sleep time | |
if [ $REMAIN -le $MIN_SLEEP_SECS ]; then | |
echo "Wakeup time too close. Adjusting sleep time." | |
SECS=$((`date +'%s'` + $MIN_SLEEP_SECS)) | |
fi | |
REMAIN_M=$((($SECS-`date +'%s'`)/60)) | |
#echo $SECS | |
echo "Will sleep for $REMAIN_M minutes" | |
echo 0 > /sys/class/rtc/rtc0/wakealarm | |
echo $SECS > /sys/class/rtc/rtc0/wakealarm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment