PINE64
gnome-clocks waking the phone via a waking daemon (POC) - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120)
+--- Forum: PinePhone Software (https://forum.pine64.org/forumdisplay.php?fid=121)
+--- Thread: gnome-clocks waking the phone via a waking daemon (POC) (/showthread.php?tid=13246)



gnome-clocks waking the phone via a waking daemon (POC) - seath - 02-27-2021

Hi,
I've heard that gnome is working on letting gnome-clocks wake up the phone but didn't find anything in that regard.

So i experimented a little bit myself and got it to work with a little dirty hack. I don't really know a lot about the gnome ecosystem, vala, dbus, flatpack etc. so it really is a messĀ  Big Grin but kinda working.

I first tried to write directly to /sys/class/rtc/rtc0/wakealarm from gnome-clocks when an alarm is changed but it outright refused to. Even with chmod-ing that file. I don't really know why but my guess it's b/c of some flatpack specific stuff.

So i wrote a small external program "waked" which let's other programs register alarms via dbus to wake up the system. It's just a little experiment and still relies on /sys/class/rtc/rtc0/wakealarm being chmodded but better then nothing. Running waked as root didn't work because then the dbus sessions didn't play nicely.

Then i slapped some spaghetti to gnome-clocks to register it's alarms in waked. Really messy, just a poc.

You can find the result here: https://gitlab.com/seath1
waked needs sdbus-cpp to build

What do you think, could that be a step in the right direction? I'm a bit surprised I couldn't find something existing to schedule rtc wakeups other than systemd timers which afaik doesn't let users add their own timers.


RE: gnome-clocks waking the phone via a waking daemon (POC) - marcih - 02-27-2021

Cool stuff, thanks for sharing. Have you seen the proof-of-concept alarm app by Kai Luke that also saves the wake time into rtc?

(02-27-2021, 09:49 AM)seath Wrote: I've heard that gnome is working on letting gnome-clocks wake up the phone but didn't find anything in that regard.

Here's the relevant bug report if you wanna submit your patches.


RE: gnome-clocks waking the phone via a waking daemon (POC) - seath - 02-28-2021

Yes I saw the his app albeit just after I tried this approach.

Looks like he is using the systemd timer approach. Seems like hes escalating privileges with a helper utility.
In contrast I guess using a daemon could have the benefit of letting multiple programs schedule wake-ups in an unified manner.
For example the alarms from the clock and events from the calendar etc. maybe even build a system for permissions, which apps are allowed to wake up the phone in the long run.

For now I changed it to run as a service via systemd and use the system bus in dbus. I added PKGBUILDs to the repo to ease up the installation if someone wants to try.
The service needs to be started/enabled via

Code:
systemctl enable waked
# then reboot or
systemctl start waked
But be warned it's very janky.
1. That gnome-clocks version doesn't remove registered wake-ups when you delete or deactivate an alarm
2. waked atm only reschedules the next wake-up if called from outside. (Which that gnome-clocks version does minutely if running and at least one active alarm present when an alarm fires or gets changed otherwise)
3. waked forgets all registered alarm on reboot or if the service gets restarted one way or another
4. don't know if it plays nicely if systemd timers (or other stuff managing rtc wake-ups) are present.

Edit1: updated gnome-clocks-waked