summaryrefslogtreecommitdiff
path: root/src/gpm-manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpm-manager.c')
-rw-r--r--src/gpm-manager.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 6f403a9..6ca9dea 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>
@@ -104,10 +102,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 {
@@ -780,8 +776,8 @@ gpm_manager_idle_do_sleep (GpmManager *manager)
static void
gpm_manager_idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmManager *manager)
{
- /* 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;
}
@@ -909,8 +905,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;
}
@@ -1009,8 +1005,8 @@ gpm_manager_client_changed_cb (UpClient *client, GpmManager *manager)
/* save in local cache */
manager->priv->on_battery = on_battery;
- /* 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;
}
@@ -1848,9 +1844,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.
*
@@ -1918,7 +1913,6 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) {
egg_debug ("Inhibiting systemd sleep - success");
return r;
}
-#endif
/**
* gpm_manager_init:
@@ -1930,20 +1924,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);
-
-#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);
- }
+ g_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
-#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;
@@ -2104,16 +2095,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);
}