File gnome-power-manager-notify-idle-sleep.patch of Package gnome-power-manager
Index: src/gpm-manager.c
===================================================================
--- src/gpm-manager.c.orig
+++ src/gpm-manager.c
@@ -637,6 +637,26 @@ gpm_manager_get_low_battery (GpmManager
}
/**
+ * 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
+notify_idle_sleep (GpmManager *manager)
+{
+ gboolean show_idle_sleep;
+
+ /* only show this if specified in gconf */
+ show_idle_sleep = gconf_client_get_bool (manager->priv->conf, GPM_CONF_NOTIFY_IDLE_SLEEP, NULL);
+
+ /* only emit if in GConf */
+ if (show_idle_sleep)
+ gpm_notify_idle_sleep (manager->priv->notify);
+}
+
+/**
* idle_do_sleep:
* @manager: This class instance
*
@@ -679,6 +699,11 @@ idle_do_sleep (GpmManager *manager)
egg_warning ("cannot suspend or hibernate: %s", error->message);
g_error_free (error);
}
+ } else {
+ /* we're back from suspend without an error, tell the
+ * user that we've actually suspended due to system
+ * idleness */
+ notify_idle_sleep (manager);
}
} else if (strcmp (action, ACTION_HIBERNATE) == 0) {
@@ -693,6 +718,11 @@ idle_do_sleep (GpmManager *manager)
egg_warning ("cannot suspend or hibernate: %s", error->message);
g_error_free (error);
}
+ } else {
+ /* we're back from hibernate without an error, tell the
+ * user that we've actually suspended due to system
+ * idleness */
+ notify_idle_sleep (manager);
}
}
g_free (action);
Index: src/gpm-notify.c
===================================================================
--- src/gpm-notify.c.orig
+++ src/gpm-notify.c
@@ -347,6 +347,37 @@ gpm_notify_low_capacity (GpmNotify *noti
}
/**
+ * gpm_notify_idle_sleep:
+ **/
+gboolean
+gpm_notify_idle_sleep (GpmNotify *notify)
+{
+ const gchar *msg;
+ const gchar *title;
+
+ title = _("System resumed from sleep");
+ msg = _("The system automatically went to sleep because the system "
+ "was idle.");
+
+ gpm_notify_create (notify, title, msg, 2,
+ GTK_STOCK_DIALOG_WARNING,
+ GPM_NOTIFY_URGENCY_CRITICAL);
+
+ /* add extra stuff */
+#ifdef HAVE_LIBNOTIFY
+ notify->priv->do_not_show_gconf = GPM_CONF_NOTIFY_IDLE_SLEEP;
+ notify_notification_add_action (notify->priv->libnotify,
+ "dont-show-again",
+ _("Do not show me this again"),
+ (NotifyActionCallback) notify_general_clicked_cb,
+ notify, NULL);
+#endif
+
+ gpm_notify_show (notify);
+ return TRUE;
+}
+
+/**
* gpm_notify_inhibit_lid:
**/
gboolean
Index: src/gpm-notify.h
===================================================================
--- src/gpm-notify.h.orig
+++ src/gpm-notify.h
@@ -79,6 +79,7 @@ gboolean gpm_notify_perhaps_recall (Gpm
const gchar *website);
gboolean gpm_notify_low_capacity (GpmNotify *notify,
guint capacity);
+gboolean gpm_notify_idle_sleep (GpmNotify *notify);
gboolean gpm_notify_inhibit_lid (GpmNotify *notify);
gboolean gpm_notify_fully_charged_primary (GpmNotify *notify);
gboolean gpm_notify_discharging_primary (GpmNotify *notify);
Index: data/gnome-power-manager.schemas.in
===================================================================
--- data/gnome-power-manager.schemas.in.orig
+++ data/gnome-power-manager.schemas.in
@@ -657,6 +657,18 @@
</schema>
<schema>
+ <key>/schemas/apps/gnome-power-manager/notify/idle_sleep</key>
+ <applyto>/apps/gnome-power-manager/notify/idle_sleep</applyto>
+ <owner>gnome-power-manager</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>If an information message should be displayed when returning from idle sleep.</short>
+ <long>If an information message should be displayed when returning from idle sleep.</long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/gnome-power-manager/statistics/show_axis_labels</key>
<applyto>/apps/gnome-power-manager/statistics/show_axis_labels</applyto>
<owner>gnome-power-manager</owner>
Index: src/gpm-common.h
===================================================================
--- src/gpm-common.h.orig
+++ src/gpm-common.h
@@ -127,6 +127,7 @@ G_BEGIN_DECLS
#define GPM_CONF_NOTIFY_LOW_POWER GPM_CONF_DIR "/notify/low_power"
#define GPM_CONF_NOTIFY_ESTIMATED_DATA GPM_CONF_DIR "/notify/estimated_data"
#define GPM_CONF_NOTIFY_INHIBIT_LID GPM_CONF_DIR "/notify/inhibit_lid"
+#define GPM_CONF_NOTIFY_IDLE_SLEEP GPM_CONF_DIR "/notify/idle_sleep"
/* statistics */
#define GPM_CONF_STATS_SHOW_AXIS_LABELS GPM_CONF_DIR "/statistics/show_axis_labels"