Freedesktop Portals provide the org.freedesktop.portal.Inhibit portal (accessible with DBUS) that can monitor screensaver state. This will not handle a custom timeout, but rely on the system screensaver state
Another option is the org.freedesktop.ScreenSaver.GetSessionIdleTime DBUS API that is present on some desktop environment despite not being in the Freedesktop spec. (doesn't seem to be present in GNOME)
Enhancement Details
Freedesktop Portal
Freedesktop Portals provide the
org.freedesktop.portal.Inhibit
portal (accessible with DBUS) that can monitor screensaver state. This will not handle a custom timeout, but rely on the system screensaver statehttps://docs.flatpak.org/en/latest/portal-api-reference.html#gdbus-method-org-freedesktop-portal-Inhibit.CreateMonitor
Per Desktop Environment DBUS
GNOME's Mutter Wayland compositor provide a DBUS API to get IDLE time (
org.gnome.Mutter.IdleMonitor.GetIdletime
)It seems much easier to implement than the desktop portal, and doesn't rely on the screensaver, giving IDLE time.
To test :
Another option is the
org.freedesktop.ScreenSaver.GetSessionIdleTime
DBUS API that is present on some desktop environment despite not being in the Freedesktop spec. (doesn't seem to be present in GNOME)Wayland
idle_notifier
protocolhttps://wayland.app/protocols/ext-idle-notify-v1
It seems to cover the current feature, but sadly only KWin and Sway support it at the moment.
Additional Details
No response