gnome-clocks alarms are not registered with waked unless it's manually started after a reboot
Describe your issue
What's the expected behaviour?
I'm running pmos with phosh on a pinephone. I have an alarm registered with gnome-clocks, which internally are registered with waked. If I reboot the phone, log in, but don't open the gnome-clocks program, alarms that I set in gnome-clocks previously should still fire, waking up the phone from sleep if necessary.
What's the current behaviour?
gnome-clocks' alarms are never re-registered with waked, but the rtc wake alarm has been reset by the reboot. The net result is that if the phone goes to sleep, the phone does not wake up at the alarm time so the alarm never fires.
How to reproduce your issue?
Set an alarm for T + N minutes. Suspend your device. Notice the device doesn't wake up and fire the alarm after N minutes. Manually wake up the device. Notice that there is also no missed alarm notification for the alarm.
What device are you using?
pine64-pinephone
On what postmarketOS version did you encounter the issue?
-
edge ( master
branch) -
v21.06
On what environment did you encounter the issue?
Phone environments
-
Phosh -
Plasma Mobile -
Sxmo
Other
-
No environment -
GNOME -
KDE Plasma -
Kodi -
MATE -
Shelli -
Sway -
Weston -
Xfce4 -
fbkeyboard -
i3wm
How did you get postmarketOS image?
-
from https://images.postmarketos.org -
I built it using pmbootstrap -
It was preinstalled on my device
What's the build date of the image? (in yyyy-mm-dd format)
It's been apk upgrade
d as of 2021-08-11
Additional information
I figured this could be fixed by either configuring gnome-clocks to be autostarted by phosh / whatever DE, or by having waked persist alarms across restarts. I pre-emptively filed seath1/waked#1 (closed) for the latter.
But thinking about it some more, even if waked does wake up the device in time for the alarm, gnome-clocks would not be running in order to fire the alarm anyway. And if gnome-clocks needs to be running anyway, then it would've already registered its alarms with waked, so perhaps waked doesn't need any changes. Is that correct?
If so, is there a way to have gnome-clocks be autostarted on login by phosh, preferably without showing any UI, ie just to run in the background as it does after being started manually and then closed? Adding a .desktop with Exec=/usr/bin/gnome-clocks
to ~/.config/autostart/
starts gnome-clocks, but with a UI.
How are other distros handling this?
Edit:
Having spent some time reading gnome-clocks and gtk code, it doesn't seem like there's any way to (1) start gnome-clocks and (2) have it register its alarms with waked and (3) leave it running to fire the alarms later and (4) not show the UI. The code to register the alarms with waked is tied to showing its UI, which would still be fine if there was a way to start it with the UI and then hide it, but there does not seem to be a way to do that either.
-
Creating a .desktop file that execs
/usr/bin/gnome-clocks
satisfies (1), (2), (3) but not (4). -
Creating a .desktop file that runs a shell script that runs
gapplication launch org.gnome.clocks; gapplication action org.gnome.clocks quit
satisfies (1), (2), (4) but not (3). Thequit
action causes the whole program to quit rather than just hiding its window. -
Creating a .desktop file that runs a shell script that runs
gapplication action org.gnome.clocks arnavions-non-existent-action
satisfies (1), (4) but not (2), (3). The program waits for an actual existing action before showing its window. -
There doesn't seem to be any "action" string that could be used with
gapplication action org.gnome.clocks ...
to destroy the main window but leave the application running. -
If there is some GTK / phosh / phoc / wlroots way to close an arbitrary window from a shell script without killing the application that created it, I can't find it.
I'm currently living with the first option, ie ~/.config/autostart/gnome-clocks.desktop
with the contents:
[Desktop Entry]
Type=Application
Name=Autostart gnome-clocks for alarms
Exec=/usr/bin/gnome-clocks
X-GNOME-Autostart-enabled=true
If auto-starting gnome-clocks is an acceptable fix for pmos, then that .desktop can be dropped in /etc/xdg/autostart
as part of the gnome-clocks package, minus the X-GNOME-Autostart-enabled=true
key which isn't needed in that case. It's also possible to not autostart gnome-clocks unless an alarm is defined, by having the .desktop file exec a script that first checks the output of gsettings get org.gnome.clocks alarms
.
Also:
How are other distros handling this?
It seems they aren't.
The best fix will probably be to convince upstream to add a --daemon
flag or --background
flag or some other way to start the program such that it register its alarms but doesn't show a UI. Presumably this is a problem not just for phones or phosh but even with GNOME on desktops.