Bug 876396 - systemd-inhibit integration issue with mate-power-manager
Summary: systemd-inhibit integration issue with mate-power-manager
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 18
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Dan Mashal
URL:
Whiteboard:
Depends On: 869998
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-11-14 02:05 UTC by William Brown
Modified: 2012-12-15 23:04 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2012-11-20 23:10:07 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description William Brown 2012-11-14 02:05:09 UTC
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;

Comment 1 William Brown 2012-11-19 22:45:10 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.