Skip to content

Inhibit suspend from GtkApplication

In a radio player application, I want to prevent the system from suspending while a radio is playing.

For that I use gtk_application_inhibit. It works well on GNOME, but on XFCE I get this GTK warning:

(goodvibes:12772): Gtk-WARNING **: 10:23:57.000: Calling org.xfce.Session.Manager.Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method “Inhibit”

Interestingly, there was an issue opened in GTK in order to support the XFCE session manager, a long time ago, and support was merged back in June 2016:

After this commit, gtk_application_inhibit () attempts to call the D-Bus method org.xfce.SessionManager /org/xfce/SessionManager org.xfce.Session.Manager.Inhibit(). However this method does not exist!

So I was wondering if it's a known issue, or am I missing something?

If there's no method org.xfce.Session.Manager.Inhibit, then what is the right way for an application to inhibit suspend on XFCE?

Is it through the D-Bus service org.freedesktop.PowerManagement /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.Inhibit()? Or org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Inhibit() on the system bus? Or something else?

Thanks!