Description of problem: attempting to use the systemd-inhibitors via dbus yields no inhibition of sleep. The code doing this is below. Once called, we leave the proxy and fd open, and close them both in the "finalize" of the application. From the debug logs we see: TI:12:24:54 TH:0x142ced0 FI:gpm-manager.c FN:gpm_manager_systemd_inhibit,1862 - Inhibiting systemd sleep TI:12:24:54 TH:0x142ced0 FI:gpm-manager.c FN:gpm_manager_systemd_inhibit,1889 - Inhibiting systemd sleep - fd = 21537632 TI:12:24:54 TH:0x142ced0 FI:gpm-manager.c FN:gpm_manager_systemd_inhibit,1895 - Inhibiting systemd sleep - success Which indicates the call is suceeding and the fd is being returned. However, running systemd-inhibt --list shows no active inhibitors. Advice on how to get this integration to work with systemd is much appreciated. /* Return a fd to the to the inhibitor, that we can close on exit. */ //GDBusProxy *proxy; GError *error = NULL; gint32 r = -1; proxy == NULL; /* Should we define these elsewhere? */ const char* arg_what = "handle-power-key:handle-suspend-key:handle-lid-switch"; const char* arg_who = "mate-power-manager"; const char* arg_why = "Mate power manager handles these events"; const char* arg_mode = "block"; egg_debug ("Inhibiting systemd sleep"); proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", NULL, &error ); //append all our arguments if (proxy == NULL) { egg_error("Error connecting to dbus - %s", error->message); g_error_free (error); return -1; } r = g_dbus_proxy_call_sync (proxy, "Inhibit", g_variant_new( "(ssss)", arg_what, arg_who, arg_why, arg_mode ), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error ); egg_debug ("Inhibiting systemd sleep - fd = %i", r); if (r < 1) { egg_error ("Error in dbus - %s", error->message); g_error_free (error); return -EIO; } egg_debug ("Inhibiting systemd sleep - success"); return r;
Besides working out that r is a pointer to a variant, and my code now having the code to get this value out. Every time I recieve the fd from the variant, it is *always* 0. How can this issue be resolved and tracked down.