diff options
Diffstat (limited to 'src/gpm-manager.c')
-rw-r--r-- | src/gpm-manager.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/src/gpm-manager.c b/src/gpm-manager.c index 9b697b5..aeb5a31 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -33,11 +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 <gio/gunixfdlist.h> #include <gtk/gtk.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> @@ -103,10 +101,8 @@ struct GpmManagerPrivate NotifyNotification *notification_warning_low; NotifyNotification *notification_discharging; NotifyNotification *notification_fully_charged; -#ifdef WITH_SYSTEMD_INHIBIT gint32 systemd_inhibit; GDBusProxy *systemd_inhibit_proxy; -#endif }; typedef enum { @@ -908,8 +904,8 @@ gpm_manager_button_pressed_cb (GpmButton *button, const gchar *type, GpmManager gchar *message; egg_debug ("Button press event type=%s", type); - /* ConsoleKit says we are not on active console */ - if (!egg_console_kit_is_active (manager->priv->console)) { + /* ConsoleKit/systemd say we are not on active console */ + if (!LOGIND_RUNNING() && !egg_console_kit_is_active (manager->priv->console)) { egg_debug ("ignoring as not on active console"); return; } @@ -1847,9 +1843,8 @@ gpm_manager_control_resume_cb (GpmControl *control, GpmControlAction action, Gpm g_timeout_add_seconds (1, gpm_manager_reset_just_resumed_cb, manager); } -#ifdef WITH_SYSTEMD_INHIBIT /** - * gpm_main_system_inhibit: + * gpm_main_systemd_inhibit: * * Return a fd to the to the inhibitor, that we can close on exit. * @@ -1917,7 +1912,6 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) { egg_debug ("Inhibiting systemd sleep - success"); return r; } -#endif /** * gpm_manager_init: @@ -1929,20 +1923,17 @@ gpm_manager_init (GpmManager *manager) gboolean check_type_cpu; gint timeout; DBusGConnection *connection; - GDBusConnection *g_connection; + GDBusConnection *g_connection; GError *error = NULL; manager->priv = GPM_MANAGER_GET_PRIVATE (manager); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - g_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + g_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); -#ifdef WITH_SYSTEMD_INHIBIT - /* We want to inhibit the systemd suspend options, and take care of them ourselves */ - if (sd_booted() > 0) { - manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy); - } - -#endif + /* We want to inhibit the systemd suspend options, and take care of them ourselves */ + if (LOGIND_RUNNING()) { + manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy); + } /* init to unthrottled */ manager->priv->screensaver_ac_throttle_id = 0; @@ -2101,16 +2092,15 @@ gpm_manager_finalize (GObject *object) g_object_unref (manager->priv->client); g_object_unref (manager->priv->status_icon); -#ifdef WITH_SYSTEMD_INHIBIT - /* Let systemd take over again ... */ - if (manager->priv->systemd_inhibit > 0) { - close(manager->priv->systemd_inhibit); - } - if (manager->priv->systemd_inhibit_proxy != NULL) { - g_object_unref (manager->priv->systemd_inhibit_proxy); - } - //g_object_unref (manager->priv->systemd_inhibit); -#endif + if (LOGIND_RUNNING()) { + /* Let systemd take over again ... */ + if (manager->priv->systemd_inhibit > 0) { + close(manager->priv->systemd_inhibit); + } + if (manager->priv->systemd_inhibit_proxy != NULL) { + g_object_unref (manager->priv->systemd_inhibit_proxy); + } + } G_OBJECT_CLASS (gpm_manager_parent_class)->finalize (object); } |