File gnome-power-manager-notify-idle-sleep.patch of Package gnome-power-manager

diff --git a/data/org.gnome.power-manager.gschema.migrate b/data/org.gnome.power-manager.gschema.migrate
index 4365245..4209855 100644
--- a/data/org.gnome.power-manager.gschema.migrate
+++ b/data/org.gnome.power-manager.gschema.migrate
@@ -20,6 +20,7 @@ notify-fully-charged = /apps/gnome-power-manager/notify/fully_charged
 notify-sleep-failed = /apps/gnome-power-manager/notify/sleep_failed
 notify-sleep-failed-uri = /apps/gnome-power-manager/notify/sleep_failed_uri
 notify-low-power-system = /apps/gnome-power-manager/notify/low_power
+notify-idle-sleep = /apps/gnome-power-manager/notify/idle_sleep
 info-history-graph-points = /apps/gnome-power-manager/statistics/show_events
 info-history-graph-smooth = /apps/gnome-power-manager/statistics/smooth_data
 info-history-type = /apps/gnome-power-manager/statistics/graph_type
diff --git a/data/org.gnome.power-manager.gschema.xml.in b/data/org.gnome.power-manager.gschema.xml.in
index 8611416..e4cebba 100644
--- a/data/org.gnome.power-manager.gschema.xml.in
+++ b/data/org.gnome.power-manager.gschema.xml.in
@@ -142,6 +142,11 @@
       <_summary>Notify on a low power</_summary>
       <_description>If a notification message should be displayed when battery in a device attached to the computer is getting low.</_description>
     </key>
+    <key name="notify-idle-sleep" type="b">
+      <default>false</default>
+      <_summary>If an information message should be displayed when returning from idle sleep.</_summary>
+      <_description>If an information message should be displayed when returning from idle sleep.</_description>
+    </key>
     <key name="info-history-graph-points" type="b">
       <default>true</default>
       <_summary>Whether we should show the history data points</_summary>
diff --git a/src/gpm-common.h b/src/gpm-common.h
index dabda1a..ab5e1b8 100644
--- a/src/gpm-common.h
+++ b/src/gpm-common.h
@@ -95,6 +95,7 @@ G_BEGIN_DECLS
 #define GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI		"notify-sleep-failed-uri"
 #define GPM_SETTINGS_NOTIFY_LOW_POWER_SYSTEM		"notify-low-power-system"
 #define GPM_SETTINGS_NOTIFY_LOW_POWER_DEVICE		"notify-low-power-device"
+#define GPM_SETTINGS_NOTIFY_IDLE_SLEEP			"notify-idle-sleep"
 
 /* thresholds */
 #define GPM_SETTINGS_PERCENTAGE_LOW			"percentage-low"
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 9bb0591..3572c13 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -114,6 +114,7 @@ struct GpmManagerPrivate
 	GDBusConnection		*bus_connection;
 	guint 			 bus_owner_id;
 	guint			 bus_object_id;
+	gboolean		 idle_sleep;
 };
 
 typedef enum {
@@ -788,6 +789,31 @@ gpm_manager_perform_policy (GpmManager  *manager, const gchar *policy_key, const
 }
 
 /**
+ * gpm_manager_notify_idle_sleep:
+ * @manager: This class instance
+ *
+ * Called when we're back from suspend and the reason for suspend was a
+ * auto sleep due to system inactivity
+ **/
+static void
+gpm_manager_notify_idle_sleep (GpmManager *manager)
+{
+	gboolean show_idle_sleep;
+
+	/* only show this if specified in gsettings */
+	show_idle_sleep = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_IDLE_SLEEP);
+
+	/* only emit if in gsettings */
+	if (show_idle_sleep)
+		gpm_manager_notify (manager, &manager->priv->notification_general,
+				    _("System resumed from sleep"),
+				    _("The system automatically went to sleep because the system was idle."),
+				    GPM_MANAGER_NOTIFY_TIMEOUT_SHORT,
+				    GTK_STOCK_DIALOG_INFO,
+				    NOTIFY_URGENCY_NORMAL);
+}
+
+/**
  * gpm_manager_idle_do_sleep:
  * @manager: This class instance
  *
@@ -811,6 +837,7 @@ gpm_manager_idle_do_sleep (GpmManager *manager)
 
 	} else if (policy == GPM_ACTION_POLICY_SUSPEND) {
 		g_debug ("suspending, reason: System idle");
+		manager->priv->idle_sleep = TRUE;
 		ret = gpm_control_suspend (manager->priv->control, &error);
 		if (!ret) {
 			g_warning ("cannot suspend (error: %s), so trying hibernate", error->message);
@@ -820,11 +847,13 @@ gpm_manager_idle_do_sleep (GpmManager *manager)
 			if (!ret) {
 				g_warning ("cannot suspend or hibernate: %s", error->message);
 				g_error_free (error);
+				manager->priv->idle_sleep = FALSE;
 			}
 		}
 
 	} else if (policy == GPM_ACTION_POLICY_HIBERNATE) {
 		g_debug ("hibernating, reason: System idle");
+		manager->priv->idle_sleep = TRUE;
 		ret = gpm_control_hibernate (manager->priv->control, &error);
 		if (!ret) {
 			g_warning ("cannot hibernate (error: %s), so trying suspend", error->message);
@@ -834,6 +863,7 @@ gpm_manager_idle_do_sleep (GpmManager *manager)
 			if (!ret) {
 				g_warning ("cannot suspend or hibernate: %s", error->message);
 				g_error_free (error);
+				manager->priv->idle_sleep = FALSE;
 			}
 		}
 	}
@@ -2003,6 +2033,12 @@ gpm_manager_reset_just_resumed_cb (gpointer user_data)
 		gpm_manager_notify_close (manager, manager->priv->notification_fully_charged);
 
 	manager->priv->just_resumed = FALSE;
+
+	if (manager->priv->idle_sleep) {
+		gpm_manager_notify_idle_sleep (manager);
+		manager->priv->idle_sleep = FALSE;
+	}
+
 	return FALSE;
 }
 
@@ -2266,6 +2302,8 @@ gpm_manager_init (GpmManager *manager)
 	/* init to not just_resumed */
 	manager->priv->just_resumed = FALSE;
 
+	manager->priv->idle_sleep = FALSE;
+
 	/* don't apply policy when not active, so listen to ConsoleKit */
 	manager->priv->console = egg_console_kit_new ();
 
openSUSE Build Service is sponsored by