gnome-settings-daemon/gnome-settings-daemon-notify-idle-resumed.patch

108 lines
5.2 KiB
Diff
Raw Normal View History

Index: gnome-settings-daemon-41.0/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
===================================================================
--- gnome-settings-daemon-41.0.orig/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
+++ gnome-settings-daemon-41.0/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
@@ -41,6 +41,11 @@
<summary>Power button action</summary>
<description>The action to take when the system power button is pressed. This action is hard-coded (and the setting ignored) on virtual machines (power off) and tablets (suspend).</description>
</key>
+ <key name="notify-idle-resumed" type="b">
+ <default>true</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="power-saver-profile-on-low-battery" type="b">
<default>true</default>
<summary>Enable power-saver profile when battery is low</summary>
Index: gnome-settings-daemon-41.0/plugins/power/gsd-power-manager.c
===================================================================
--- gnome-settings-daemon-41.0.orig/plugins/power/gsd-power-manager.c
+++ gnome-settings-daemon-41.0/plugins/power/gsd-power-manager.c
@@ -164,6 +164,7 @@ struct _GsdPowerManager
NotifyNotification *notification_ups_discharging;
NotifyNotification *notification_low;
NotifyNotification *notification_sleep_warning;
+ NotifyNotification *notification_resumed;
GsdPowerActionType sleep_action_type;
GHashTable *devices_notified_ht; /* key = serial str, value = UpDeviceLevel */
gboolean battery_is_low; /* battery low, or UPS discharging */
@@ -205,6 +206,7 @@ struct _GsdPowerManager
gboolean inhibit_suspend_taken;
guint inhibit_lid_switch_timer_id;
gboolean is_virtual_machine;
+ GsdPowerActionType last_idle_power_action;
/* Idles */
GnomeIdleMonitor *idle_monitor;
@@ -1744,6 +1746,49 @@ is_session_active (GsdPowerManager *mana
}
static void
+show_resumed_notification (GsdPowerManager *manager)
+{
+ GError *error = NULL;
+ gboolean ret;
+
+ /* don't show when running under GDM */
+ if (g_getenv ("RUNNING_UNDER_GDM") != NULL) {
+ g_debug ("running under gdm, so no notification");
+ return;
+ }
+
+ ret = g_settings_get_boolean (manager->settings, "notify-idle-resumed");
+ if (!ret)
+ return;
+
+ /* close any existing notification of this class */
+ notify_close_if_showing (&manager->notification_resumed);
+
+ /* create a new notification */
+ create_notification (_("System resumed from sleep"),
+ _("The system automatically went to sleep because the system was idle."),
+ NULL, NOTIFICATION_PRIVACY_SYSTEM,
+ &manager->notification_resumed);
+ notify_notification_set_timeout (manager->notification_resumed,
+ GSD_POWER_MANAGER_NOTIFY_TIMEOUT_SHORT);
+ notify_notification_set_urgency (manager->notification_resumed,
+ NOTIFY_URGENCY_NORMAL);
+ /* TRANSLATORS: this is the notification application name */
+ notify_notification_set_app_name (manager->notification_resumed, _("Power"));
+ notify_notification_set_hint (manager->notification_resumed,
+ "transient", g_variant_new_boolean (TRUE));
+
+ /* try to show */
+ ret = notify_notification_show (manager->notification_resumed,
+ &error);
+ if (!ret) {
+ g_warning ("failed to show notification: %s", error->message);
+ g_error_free (error);
+ g_object_unref (manager->notification_resumed);
+ }
+}
+
+static void
idle_set_mode (GsdPowerManager *manager, GsdPowerIdleMode mode)
{
gboolean ret = FALSE;
@@ -1824,6 +1869,7 @@ idle_set_mode (GsdPowerManager *manager,
action_type = g_settings_get_enum (manager->settings,
"sleep-inactive-ac-type");
}
+ manager->last_idle_power_action = action_type;
do_power_action_type (manager, action_type);
/* turn on screen and restore user-selected brightness level */
@@ -2777,6 +2823,12 @@ handle_suspend_actions (GsdPowerManager
static void
handle_resume_actions (GsdPowerManager *manager)
{
+ if (manager->last_idle_power_action == GSD_POWER_ACTION_SUSPEND ||
+ manager->last_idle_power_action == GSD_POWER_ACTION_HIBERNATE)
+ show_resumed_notification (manager);
+
+ manager->last_idle_power_action = GSD_POWER_ACTION_NOTHING;
+
/* ensure we turn the panel back on after resume */
backlight_enable (manager);