summaryrefslogtreecommitdiff
path: root/src/gpm-manager.c
diff options
context:
space:
mode:
authorFabio Erculiani <[email protected]>2013-07-04 23:39:48 +0200
committerFabio Erculiani <[email protected]>2013-07-05 12:49:59 +0200
commit352ad899ab041bce07f56a3bc4af0469844b4105 (patch)
treed6a71626515bea666b64b2ea1f885c5997578aa7 /src/gpm-manager.c
parentb36c93575f88bd5a045c36f3d8084608ae20879f (diff)
downloadmate-power-manager-352ad899ab041bce07f56a3bc4af0469844b4105.tar.bz2
mate-power-manager-352ad899ab041bce07f56a3bc4af0469844b4105.tar.xz
drop --with-systemdinhibit and move logind detection to runtime
There is no need to bind the user to either systemd-logind or upower at build time. People can switch between init systems or run logind without systemd.
Diffstat (limited to 'src/gpm-manager.c')
-rw-r--r--src/gpm-manager.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 9b697b5..c99bd09 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -33,9 +33,6 @@
#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>
@@ -103,10 +100,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 {
@@ -1847,9 +1842,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 +1911,6 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) {
egg_debug ("Inhibiting systemd sleep - success");
return r;
}
-#endif
/**
* gpm_manager_init:
@@ -1929,20 +1922,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;
@@ -2101,16 +2091,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);
}