diff options
author | Elan Ruusamäe <[email protected]> | 2013-02-19 00:39:49 +0200 |
---|---|---|
committer | Elan Ruusamäe <[email protected]> | 2013-02-19 00:39:49 +0200 |
commit | 49336aa33623fb20a495ecd329a2504511a0c112 (patch) | |
tree | 2612fa788eb983c055cb2aaee17750f5f6c9accd /src | |
parent | 982c86b51d022fb4fa9310daaeb5c77e070328de (diff) | |
download | mate-power-manager-49336aa33623fb20a495ecd329a2504511a0c112.tar.bz2 mate-power-manager-49336aa33623fb20a495ecd329a2504511a0c112.tar.xz |
allow compiling with systemd, but have systemd booted optional
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/gpm-manager.c | 22 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index b5e7369..fcbca7d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -192,6 +192,7 @@ mate_power_manager_LDADD = \ $(LIBNOTIFY_LIBS) \ $(GPM_EXTRA_LIBS) \ $(UPOWER_LIBS) \ + $(SYSTEMD_INHIBIT_LIBS) \ -lm mate_power_manager_CFLAGS = \ diff --git a/src/gpm-manager.c b/src/gpm-manager.c index 3d501b4..9b697b5 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -33,6 +33,9 @@ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif /* HAVE_UNISTD_H */ +#ifdef WITH_SYSTEMD_INHIBIT +#include <systemd/sd-daemon.h> +#endif /* WITH_SYSTEMD_INHIBIT */ #include <glib/gi18n.h> #include <gtk/gtk.h> @@ -1847,17 +1850,19 @@ gpm_manager_control_resume_cb (GpmControl *control, GpmControlAction action, Gpm #ifdef WITH_SYSTEMD_INHIBIT /** * gpm_main_system_inhibit: + * + * Return a fd to the to the inhibitor, that we can close on exit. + * + * Return value: fd, -1 on error **/ static gint32 gpm_manager_systemd_inhibit (GDBusProxy *proxy) { - /* Return a fd to the to the inhibitor, that we can close on exit. */ - //GDBusProxy *proxy; GError *error = NULL; gint32 r = -1; gint32 fd = -1; GVariant *res; GUnixFDList *fd_list = NULL; - //proxy == NULL; + /* Should we define these elsewhere? */ const char* arg_what = "handle-power-key:handle-suspend-key:handle-lid-switch"; const char* arg_who = g_get_user_name (); @@ -1892,7 +1897,7 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) { &fd_list, NULL, &error - ); + ); if (error == NULL && res != NULL) { g_variant_get(res, "(h)", &r); egg_debug ("Inhibiting systemd sleep res = %i", r); @@ -1907,8 +1912,8 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) { } else if (error != NULL || res == NULL) { egg_error ("Error in dbus - %s", error->message); g_error_free (error); - return -EIO; - } + return -EIO; + } egg_debug ("Inhibiting systemd sleep - success"); return r; } @@ -1933,7 +1938,10 @@ gpm_manager_init (GpmManager *manager) #ifdef WITH_SYSTEMD_INHIBIT /* We want to inhibit the systemd suspend options, and take care of them ourselves */ - manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy); + if (sd_booted() > 0) { + manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy); + } + #endif /* init to unthrottled */ |