Index: gnome-power-manager-2.24.1/src/gpm-conf.c
===================================================================
--- gnome-power-manager-2.24.1.orig/src/gpm-conf.c
+++ gnome-power-manager-2.24.1/src/gpm-conf.c
@@ -402,6 +402,16 @@ gpm_conf_init (GpmConf *conf)
 				 GS_CONF_DIR,
 				 gconf_key_changed_cb,
 				 conf, NULL, NULL);
+
+	/* watch gnome-session key */
+	gconf_client_add_dir (conf->priv->gconf_client,
+			      GPM_SESSION_DIR,
+			      GCONF_CLIENT_PRELOAD_NONE,
+			      NULL);
+	gconf_client_notify_add (conf->priv->gconf_client,
+				 GPM_SESSION_IDLE_DELAY,
+				 gconf_key_changed_cb,
+				 conf, NULL, NULL);
 }
 
 /**
Index: gnome-power-manager-2.24.1/src/gpm-conf.h
===================================================================
--- gnome-power-manager-2.24.1.orig/src/gpm-conf.h
+++ gnome-power-manager-2.24.1/src/gpm-conf.h
@@ -164,6 +164,8 @@ G_BEGIN_DECLS
 #define GS_CONF_DIR				"/apps/gnome-screensaver"
 #define GS_PREF_LOCK_ENABLED			GS_CONF_DIR "/lock_enabled"
 #define GS_PREF_IDLE_DELAY			GS_CONF_DIR "/idle_delay"
+#define GPM_SESSION_DIR                         "/desktop/gnome/session"
+#define GPM_SESSION_IDLE_DELAY                  GPM_SESSION_DIR "/idle_delay"
 
 typedef struct GpmConfPrivate GpmConfPrivate;
 
Index: gnome-power-manager-2.24.1/src/gpm-idle.c
===================================================================
--- gnome-power-manager-2.24.1.orig/src/gpm-idle.c
+++ gnome-power-manager-2.24.1/src/gpm-idle.c
@@ -35,11 +35,12 @@
 #endif /* HAVE_UNISTD_H */
 
 #include <glib.h>
+#include <dbus/dbus-glib.h>
 
 #include "gpm-idle.h"
+#include "gpm-conf.h"
 #include "gpm-load.h"
 #include "egg-debug.h"
-#include "gpm-screensaver.h"
 
 #define GPM_IDLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_IDLE, GpmIdlePrivate))
 
@@ -50,17 +51,37 @@
    while considered "at idle" */
 #define IDLE_LIMIT	5
 
+#define GPM_SESSION_MANAGER_SERVICE			"org.gnome.SessionManager"
+#define GPM_SESSION_MANAGER_PATH			"/org/gnome/SessionManager"
+#define GPM_SESSION_MANAGER_INTERFACE			"org.gnome.SessionManager"
+#define GPM_SESSION_MANAGER_PRESENCE_PATH		"/org/gnome/SessionManager/Presence"
+#define GPM_SESSION_MANAGER_PRESENCE_INTERFACE		"org.gnome.SessionManager.Presence"
+#define GPM_SESSION_MANAGER_CLIENT_PRIVATE_INTERFACE	"org.gnome.SessionManager.ClientPrivate"
+#define GPM_DBUS_PROPERTIES_INTERFACE			"org.freedesktop.DBus.Properties"
+
+typedef enum {
+	GPM_SESSION_STATUS_ENUM_AVAILABLE = 0,
+	GPM_SESSION_STATUS_ENUM_INVISIBLE,
+	GPM_SESSION_STATUS_ENUM_BUSY,
+	GPM_SESSION_STATUS_ENUM_IDLE,
+	GPM_SESSION_STATUS_ENUM_UNKNOWN
+} GpmSessionStatusEnum;
+
 struct GpmIdlePrivate
 {
 	GpmLoad		*load;
-	GpmScreensaver	*screensaver;
 	GpmIdleMode	 mode;
+	DBusGProxy      *proxy;
+	DBusGProxy	*proxy_presence;
+	DBusGProxy	*proxy_prop;
+        GpmConf         *conf;
 
 	guint		 system_timeout;	/* in seconds */
 	guint		 system_timer_id;
 	guint		 system_idle_timer_id;
 
 	gboolean	 check_type_cpu;
+        gboolean         is_idle_old;
 
 	gboolean	 init;
 	long unsigned	 old_idle;
@@ -220,6 +241,40 @@ add_system_timer (GpmIdle *idle)
 	}
 }
 
+static gboolean
+gpm_idle_is_idle (GpmIdle *idle)
+{
+	gboolean ret;
+	gboolean is_idle = FALSE;
+	GError *error = NULL;
+	GValue *value;
+
+	/* no gnome-session */
+	if (idle->priv->proxy_prop == NULL) {
+		egg_warning ("no gnome-session");
+		goto out;
+	}
+
+	value = g_new0(GValue, 1);
+	/* find out if this change altered the inhibited state */
+	ret = dbus_g_proxy_call (idle->priv->proxy_prop, "Get", &error,
+				 G_TYPE_STRING, GPM_SESSION_MANAGER_PRESENCE_INTERFACE,
+				 G_TYPE_STRING, "status",
+				 G_TYPE_INVALID,
+				 G_TYPE_VALUE, value,
+				 G_TYPE_INVALID);
+	if (!ret) {
+		egg_warning ("failed to get idle status: %s", error->message);
+		g_error_free (error);
+		is_idle = FALSE;
+		goto out;
+	}
+	is_idle = (g_value_get_uint (value) == GPM_SESSION_STATUS_ENUM_IDLE);
+	g_free (value);
+out:
+	return is_idle;
+}
+
 /**
  * gpm_idle_set_check_cpu:
  * @idle: This class instance
@@ -291,6 +346,17 @@ gpm_idle_set_system_timeout (GpmIdle	*id
 	}
 }
 
+guint
+gpm_idle_get_delay (GpmIdle *idle)
+{
+        guint idle_delay;
+
+	gpm_conf_get_uint (idle->priv->conf, GPM_SESSION_IDLE_DELAY,
+			   &idle_delay);
+
+        return idle_delay;
+}
+
 /**
  * session_idle_changed_cb:
  * @is_idle: If the session is idle
@@ -299,11 +365,14 @@ gpm_idle_set_system_timeout (GpmIdle	*id
  * The SessionIdleChanged callback from gnome-screensaver.
  **/
 static void
-session_idle_changed_cb (GpmScreensaver *screensaver,
-			 gboolean	 is_idle,
+session_idle_changed_cb (DBusGProxy     *proxy,
+			 guint          status,
 			 GpmIdle	*idle)
 {
 	GpmIdleMode mode;
+        gboolean is_idle;
+
+        is_idle = (status == GPM_SESSION_STATUS_ENUM_IDLE);
 
 	egg_debug ("Received GS session idle changed: %d", is_idle);
 
@@ -323,6 +392,7 @@ session_idle_changed_cb (GpmScreensaver
  *
  * The SessionIdleChanged callback from gnome-screensaver.
  **/
+/*
 static void
 powersave_idle_changed_cb (GpmScreensaver *screensaver,
 			  gboolean	 is_idle,
@@ -340,6 +410,7 @@ powersave_idle_changed_cb (GpmScreensave
 
 	gpm_idle_set_mode (idle, mode);
 }
+*/
 
 /**
  * gpm_idle_finalize:
@@ -358,7 +429,10 @@ gpm_idle_finalize (GObject *object)
 	g_return_if_fail (idle->priv != NULL);
 
 	g_object_unref (idle->priv->load);
-	g_object_unref (idle->priv->screensaver);
+        g_object_unref (idle->priv->conf);
+        g_object_unref (idle->priv->proxy);
+        g_object_unref (idle->priv->proxy_presence);
+        g_object_unref (idle->priv->proxy_prop);
 	gpm_idle_remove_all_timers (idle);
 
 	G_OBJECT_CLASS (gpm_idle_parent_class)->finalize (object);
@@ -400,15 +474,49 @@ gpm_idle_class_init (GpmIdleClass *klass
 static void
 gpm_idle_init (GpmIdle *idle)
 {
+	DBusGConnection *connection;
+        GError *error = NULL;
+
 	idle->priv = GPM_IDLE_GET_PRIVATE (idle);
 
 	idle->priv->system_timeout = G_MAXUINT;
 	idle->priv->load = gpm_load_new ();
-	idle->priv->screensaver = gpm_screensaver_new ();
-	g_signal_connect (idle->priv->screensaver, "session-idle-changed",
-			  G_CALLBACK (session_idle_changed_cb), idle);
-	g_signal_connect (idle->priv->screensaver, "powersave-idle-changed",
-			  G_CALLBACK (powersave_idle_changed_cb), idle);
+        idle->priv->conf = gpm_conf_new ();
+
+	connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+	idle->priv->proxy = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
+							     GPM_SESSION_MANAGER_PATH,
+							     GPM_SESSION_MANAGER_INTERFACE, &error);
+	if (idle->priv->proxy == NULL) {
+		egg_warning ("DBUS error: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	idle->priv->proxy_presence = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
+								      GPM_SESSION_MANAGER_PRESENCE_PATH,
+								      GPM_SESSION_MANAGER_PRESENCE_INTERFACE, &error);
+	if (idle->priv->proxy_presence == NULL) {
+		egg_warning ("DBUS error: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	idle->priv->proxy_prop = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
+								  GPM_SESSION_MANAGER_PRESENCE_PATH,
+								  GPM_DBUS_PROPERTIES_INTERFACE, &error);
+	if (idle->priv->proxy_prop == NULL) {
+		egg_warning ("DBUS error: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	/* get StatusChanged */
+	dbus_g_proxy_add_signal (idle->priv->proxy_presence, "StatusChanged", G_TYPE_UINT, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (idle->priv->proxy_presence, "StatusChanged", G_CALLBACK (session_idle_changed_cb), idle, NULL);
+
+        idle->priv->is_idle_old = gpm_idle_is_idle (idle);
 }
 
 /**
Index: gnome-power-manager-2.24.1/src/gpm-idle.h
===================================================================
--- gnome-power-manager-2.24.1.orig/src/gpm-idle.h
+++ gnome-power-manager-2.24.1/src/gpm-idle.h
@@ -68,6 +68,8 @@ void		 gpm_idle_set_system_timeout		(Gpm
 							 guint		 timeout);
 void		 gpm_idle_reset				(GpmIdle	*idle);
 
+guint            gpm_idle_get_delay                     (GpmIdle        *idle);
+
 G_END_DECLS
 
 #endif /* __GPM_IDLE_H */
Index: gnome-power-manager-2.24.1/src/gpm-prefs-core.c
===================================================================
--- gnome-power-manager-2.24.1.orig/src/gpm-prefs-core.c
+++ gnome-power-manager-2.24.1/src/gpm-prefs-core.c
@@ -42,7 +42,7 @@
 #include "gpm-prefs-core.h"
 #include "egg-debug.h"
 #include "gpm-stock-icons.h"
-#include "gpm-screensaver.h"
+#include "gpm-idle.h"
 #include "gpm-prefs-server.h"
 
 #ifdef HAVE_GCONF_DEFAULTS
@@ -68,7 +68,7 @@ struct GpmPrefsPrivate
 	gboolean		 can_suspend;
 	gboolean		 can_hibernate;
 	GpmConf			*conf;
-	GpmScreensaver		*screensaver;
+        GpmIdle                 *idle;
 #ifdef HAVE_GCONF_DEFAULTS
 	PolKitGnomeAction	*default_action;
 #endif
@@ -312,7 +312,7 @@ gpm_prefs_sleep_slider_changed_cb (GtkRa
 		/* We take away the g-s idle time as the slider represents
 		 * global time but we only do our timeout from when g-s
 		 * declares the session idle */
-		gs_idle_time = gpm_screensaver_get_delay (prefs->priv->screensaver);
+		gs_idle_time = gpm_idle_get_delay (prefs->priv->idle);
 		value -= gs_idle_time;
 
 		/* policy is in seconds, slider is in minutes */
@@ -354,7 +354,7 @@ gpm_prefs_setup_sleep_slider (GpmPrefs
 	} else {
 		/* policy is in seconds, slider is in minutes */
 		value /= 60;
-		gs_idle_time = gpm_screensaver_get_delay (prefs->priv->screensaver);
+		gs_idle_time = gpm_idle_get_delay (prefs->priv->idle);
 		value += gs_idle_time;
 	}
 
@@ -749,14 +749,12 @@ set_idle_hscale_stops (GpmPrefs    *pref
 }
 
 /**
- * gs_delay_changed_cb:
- * @key: The conf key
- * @prefs: This prefs class instance
+ * gs_set_delay:
+ * @delay: The idle delay
  **/
 static void
-gs_delay_changed_cb (GpmScreensaver *screensaver,
-		     gint	     delay,
-		     GpmPrefs	    *prefs)
+gs_set_delay (GpmPrefs	    *prefs,
+	      guint	     delay)
 {
 	/* update the start and stop points on the hscales */
 	set_idle_hscale_stops (prefs, "hscale_battery_computer", delay);
@@ -796,7 +794,12 @@ conf_key_changed_cb (GpmConf     *conf,
 	} else if (strcmp (key, GPM_CONF_LOWPOWER_BATT) == 0) {
 		gpm_conf_get_bool (prefs->priv->conf, GPM_CONF_LOWPOWER_BATT, &enabled);
 		egg_debug ("need to enable checkbox");
-	}
+	} else if (strcmp (key, GPM_SESSION_IDLE_DELAY) == 0) {
+                guint idle_delay;
+                gpm_conf_get_uint (prefs->priv->conf, GPM_SESSION_IDLE_DELAY, &idle_delay);
+                gs_set_delay (prefs, idle_delay);
+		egg_debug ("idle_delay changed");
+        }
 }
 
 /** setup the notification page */
@@ -914,7 +917,7 @@ prefs_setup_ac (GpmPrefs *prefs)
 	gpm_prefs_setup_checkbox (prefs, "checkbutton_ac_display_dim",
 				  GPM_CONF_BACKLIGHT_IDLE_DIM_AC);
 
-	delay = gpm_screensaver_get_delay (prefs->priv->screensaver);
+	delay = gpm_idle_get_delay (prefs->priv->idle);
 	set_idle_hscale_stops (prefs, "hscale_ac_computer", delay);
 	set_idle_hscale_stops (prefs, "hscale_ac_display", delay);
 
@@ -983,7 +986,7 @@ prefs_setup_battery (GpmPrefs *prefs)
 		gtk_widget_hide_all (widget);
 	}
 
-	delay = gpm_screensaver_get_delay (prefs->priv->screensaver);
+	delay = gpm_idle_get_delay (prefs->priv->idle);
 	set_idle_hscale_stops (prefs, "hscale_battery_computer", delay);
 	set_idle_hscale_stops (prefs, "hscale_battery_display", delay);
 
@@ -1059,7 +1062,7 @@ prefs_setup_ups (GpmPrefs *prefs)
 				      ups_low_actions);
 	gpm_prefs_setup_sleep_slider (prefs, "hscale_ups_computer",
 				      GPM_CONF_TIMEOUT_SLEEP_COMPUTER_BATT);
-	delay = gpm_screensaver_get_delay (prefs->priv->screensaver);
+	delay = gpm_idle_get_delay (prefs->priv->idle);
 	set_idle_hscale_stops (prefs, "hscale_ups_computer", delay);
 }
 
@@ -1202,9 +1205,7 @@ gpm_prefs_init (GpmPrefs *prefs)
 
 	prefs->priv = GPM_PREFS_GET_PRIVATE (prefs);
 
-	prefs->priv->screensaver = gpm_screensaver_new ();
-	g_signal_connect (prefs->priv->screensaver, "gs-delay-changed",
-			  G_CALLBACK (gs_delay_changed_cb), prefs);
+	prefs->priv->idle = gpm_idle_new ();
 
 	prefs->priv->conf = gpm_conf_new ();
 	g_signal_connect (prefs->priv->conf, "value-changed",
@@ -1284,8 +1285,8 @@ gpm_prefs_finalize (GObject *object)
 	prefs->priv = GPM_PREFS_GET_PRIVATE (prefs);
 
 	g_object_unref (prefs->priv->conf);
-	if (prefs->priv->screensaver) {
-		g_object_unref (prefs->priv->screensaver);
+	if (prefs->priv->idle) {
+		g_object_unref (prefs->priv->idle);
 	}
 
 	G_OBJECT_CLASS (gpm_prefs_parent_class)->finalize (object);
