From a245f46914493ec5b9de28d10aba0957745d7f71 Mon Sep 17 00:00:00 2001 From: Anjandev Momi Date: Thu, 9 Jul 2020 03:07:17 -0700 Subject: [PATCH] screenlock: enable rtc wakeup source Please apply to the crust feature branch. The rtc wakeup clock is useful cause it allows users to script programs. If I put my phone into deep sleep, none of the scripts I put in my cronjob will run. For example, if I have an alarm script: https://git.sr.ht/~anjan/sxmo-userscripts/tree/master/alarm.sh It is supposed to run at 7:00 am but since I put my phone in deep sleep before going to sleep, the script doesnt play sound to wake me up. Enabling the rtc wakeup clock enables using programs like rtcwake as a wrapper around your cronjobs to wake up the phone at a time and excecute the command you put in cron. For info on how to use rtcwake, see: https://wiki.postmarketos.org/wiki/Nokia_N900_(nokia-n900)#Setting_the_hardware_alarm_clock Not sure if we should patch busybox cron to use rtcwake automatically or whether we should trust the user to use rtcwake properly and document it. However, I am certain that the rtc wakeup source should be enabled for this usecase. Signed-off-by: Miles Alan --- programs/sxmo_screenlock.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/programs/sxmo_screenlock.c b/programs/sxmo_screenlock.c index 04cbd3e..290aa90 100644 --- a/programs/sxmo_screenlock.c +++ b/programs/sxmo_screenlock.c @@ -203,6 +203,13 @@ configuresuspendsettingsandwakeupsources() "enabled" ); + // Enable rtc wakeup source + fprintf(stderr, "Enable rtc wakeup source\n"); + writefile( + "/sys/devices/platform/soc/1f00000.rtc/power/wakeup", + "enabled" + ); + // Temporary hack to disable USB driver that doesn't suspend fprintf(stderr, "Disabling buggy USB driver\n"); writefile(