Thread: RTC wakeup KT4
View Single Post
Old 09-10-2019, 08:25 PM   #1
yparitcher
Connoisseur
yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.yparitcher ought to be getting tired of karma fortunes by now.
 
Posts: 52
Karma: 616590
Join Date: Feb 2019
Device: K4 KT4 PW4 PW5
RTC wakeup KT4

For anyone trying to wake up the KT4 using the rtc as an alarm to wake at given time here is a script to do so.
every model is a little different this is for a KT4 without SO if you have a different model it will need tweeking

Code:
#!/bin/sh

#####
# Copyright (c) 2019 Y Paritcher
#####

# runs when the system displays the screensaver
do_ScreenSaver()
{
	logger -t "wakescript[$$]" -p local4.info "I display screensaver"
}

# runs when the RTC wakes the system up
wake_up_rtc()
{
	logger -t "wakescript[$$]" -p local4.info "I wakeup alarm RTC"
}

# runs when the system wakes up
# this can be for many reasons (rtc, power button)
wake_up()
{
	logger -t "wakescript[$$]" -p local4.info "I wakeup alarm"
	POWERD_STATES=`lipc-get-prop -s com.lab126.powerd state`
	logger -t "wakescript[$$]" -p local4.info "I PowerD state: $POWERD_STATES"
	if [ "$POWERD_STATES" == "screenSaver" ] || [ "POWERD_STATES" == "suspended" ] ; then
	  wake_up_rtc
	fi
}

# runs when in the readyToSuspend state;
# sets the rtc to wake up 
# delta = amount of seconds to wake up in
ready_suspend()
{
	delta="120"
	lipc-set-prop -i com.lab126.powerd rtcWakeup $delta
	logger -t "wakescript[$$]" -p local4.info "I delta: $delta"
}

# main loop, waits for powerd events
lipc-wait-event -m com.lab126.powerd goingToScreenSaver,wakeupFromSuspend,readyToSuspend | while read event; do
	case "$event" in
		goingToScreenSaver*)
			do_ScreenSaver;;
		wakeupFromSuspend*)
			wake_up;;
		readyToSuspend*)
			ready_suspend;;
	esac
done;
the script is also attached

see https://github.com/yparitcher/kindle-zmanim for example usage
yparitcher is offline   Reply With Quote