Monitor session unlock from sandboxed application

Hello,

can a sandboxed (flatpak) application somehow (e.g. D-Bus signal?) be notified when the Gnome shell session is unlocked, or, alternatively, when the system is resumed from suspend?

My app would need to do some work whenever the user returns to their system after a prolonged period of absence (e.g. next working day).

My application is autostarted via the background portal, so if the user shuts down and then boots their system normally, I end up in the standard startup vfunc of Gtk Application and can act upon it, but that doesn’t work if the user just suspends their system and resume it the next day.

Cheers,
Basti

Logind offers this, through the LockedHint property of sessions: an app can get the ID of the auto session to determine the ID of its session, and then connect to the standard PropertiesChanged signal of that session and look for changes of the LockedHint property.

There’s no portal around this, tho; the app needs an explicit --system-talk-name=org.freedesktop.login1 finish arg in its manifest.