Looks like I can do it all in mortscript.
Code:
# Turn off your device at 12:05am every morning to counteract a gAlarm bug where device turns on at midnight
and refuses to reenter standby.
# Thanks to prscott from xda devs for scheduling script example: http://forum.xda-developers.com/showthread.php?p=1925725#post1925725
# Additional thanks to RoryB and CLHatch for helping me with mortscript time: http://forum.xda-developers.com/showpost.php?p=7414028&postcount=3494
# getting time, date and weekday information
GetTime(hour,min,sec,day,month,year)
date = TimeStamp()
year = (FormatTime("Y"))
nextyear = (FormatTime("Y") + 1)
month = (FormatTime("m"))
nextmonth = (FormatTime("m") + 1)
day = (FormatTime("d"))
weekday = (FormatTime( "w" ))
hour = (FormatTime("H"))
nexthour = (hour + 1)
tomorrow = FormatTime("d", TimeStamp()+86400)
nextday = (FormatTime( "d" ) + 1)
# kill old notification(s) to prevent overlap
RemoveNotifications( "\Storage Card\gamidnightfix.mscr" )
# If on phone - wait 5 minutes to start again
CallActive = RegRead( "HKLM", "System\State\Phone", "Active Call Count" )
If (CallActive > 0)
RunAt( ( TimeStamp() + 60*5 ), "\Storage Card\gamidnightfix.mscr" )
Call ExitNow
EndIf
# add tomorrow's 12:05 am notification and poweroff
# set new notify
If (tomorrow = 01)
If (month = 12)
RunAt( nextyear, 01, 01, 00, 05, "\Storage Card\gamidnightfix.mscr")
Else
RunAt( year, nextmonth, 01, 00, 05, "\Storage Card\gamidnightfix.mscr")
EndIf
Else
RunAt( year, month, nextday, 00, 05, "\Storage Card\gamidnightfix.mscr")
EndIf
# go into standby
poweroff
# exit routine
exit
Never scripted before, and I borrowed most of the code, so I'm betting this example won't work. I'll update it once I find the right scripting.
Bookmarks