2023-12-05 08:40:32 +01:00
Index: gnome-settings-daemon-45.0/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
2019-10-09 12:41:42 +02:00
===================================================================
2023-12-05 08:40:32 +01:00
--- gnome-settings-daemon-45.0.orig/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
+++ gnome-settings-daemon-45.0/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
2021-12-21 18:36:42 +01:00
@@ -41,6 +41,11 @@
2018-04-13 08:43:11 +02:00
<summary>Power button action</summary>
2023-12-05 08:40:32 +01:00
<description>The action to take when the system power button is pressed. Virtual machines only honor the 'nothing' action, and will shutdown otherwise. Tablets always suspend, ignoring all the other action options.</description>
2013-01-21 17:38:42 +01:00
</key>
+ <key name="notify-idle-resumed" type="b">
+ <default>true</default>
2019-11-26 10:26:17 +01:00
+ <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>
2013-01-21 17:38:42 +01:00
+ </key>
2021-12-21 18:36:42 +01:00
<key name="power-saver-profile-on-low-battery" type="b">
<default>true</default>
<summary>Enable power-saver profile when battery is low</summary>
2023-12-05 08:40:32 +01:00
Index: gnome-settings-daemon-45.0/plugins/power/gsd-power-manager.c
2019-10-09 12:41:42 +02:00
===================================================================
2023-12-05 08:40:32 +01:00
--- gnome-settings-daemon-45.0.orig/plugins/power/gsd-power-manager.c
+++ gnome-settings-daemon-45.0/plugins/power/gsd-power-manager.c
@@ -165,6 +165,7 @@ struct _GsdPowerManager
2014-05-28 13:59:19 +02:00
NotifyNotification *notification_ups_discharging;
2013-01-21 17:38:42 +01:00
NotifyNotification *notification_low;
2013-03-13 23:54:12 +01:00
NotifyNotification *notification_sleep_warning;
2023-12-05 08:40:32 +01:00
+ NotifyNotification *notification_resumed;
2013-03-13 23:54:12 +01:00
GsdPowerActionType sleep_action_type;
2021-07-13 09:26:55 +02:00
GHashTable *devices_notified_ht; /* key = serial str, value = UpDeviceLevel */
2021-12-21 18:36:42 +01:00
gboolean battery_is_low; /* battery low, or UPS discharging */
2023-12-05 08:40:32 +01:00
@@ -206,6 +207,7 @@ struct _GsdPowerManager
2019-10-04 17:46:22 +02:00
gboolean inhibit_suspend_taken;
2013-03-13 23:54:12 +01:00
guint inhibit_lid_switch_timer_id;
2013-01-21 17:38:42 +01:00
gboolean is_virtual_machine;
2023-12-05 08:40:32 +01:00
+ GsdPowerActionType last_idle_power_action;
2013-01-21 17:38:42 +01:00
2013-03-13 23:54:12 +01:00
/* Idles */
GnomeIdleMonitor *idle_monitor;
2023-12-05 08:40:32 +01:00
@@ -1730,6 +1732,49 @@ is_session_active (GsdPowerManager *mana
2013-01-21 17:38:42 +01:00
}
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;
+ }
+
2019-10-04 17:46:22 +02:00
+ ret = g_settings_get_boolean (manager->settings, "notify-idle-resumed");
2013-01-21 17:38:42 +01:00
+ if (!ret)
+ return;
+
+ /* close any existing notification of this class */
2019-10-04 17:46:22 +02:00
+ notify_close_if_showing (&manager->notification_resumed);
2013-01-21 17:38:42 +01:00
+
+ /* create a new notification */
+ create_notification (_("System resumed from sleep"),
+ _("The system automatically went to sleep because the system was idle."),
2019-10-09 12:41:42 +02:00
+ NULL, NOTIFICATION_PRIVACY_SYSTEM,
2019-10-04 17:46:22 +02:00
+ &manager->notification_resumed);
+ notify_notification_set_timeout (manager->notification_resumed,
2013-01-21 17:38:42 +01:00
+ GSD_POWER_MANAGER_NOTIFY_TIMEOUT_SHORT);
2019-10-04 17:46:22 +02:00
+ notify_notification_set_urgency (manager->notification_resumed,
2013-01-21 17:38:42 +01:00
+ NOTIFY_URGENCY_NORMAL);
+ /* TRANSLATORS: this is the notification application name */
2019-10-04 17:46:22 +02:00
+ notify_notification_set_app_name (manager->notification_resumed, _("Power"));
+ notify_notification_set_hint (manager->notification_resumed,
2013-01-21 17:38:42 +01:00
+ "transient", g_variant_new_boolean (TRUE));
+
+ /* try to show */
2019-10-04 17:46:22 +02:00
+ ret = notify_notification_show (manager->notification_resumed,
2013-01-21 17:38:42 +01:00
+ &error);
+ if (!ret) {
+ g_warning ("failed to show notification: %s", error->message);
+ g_error_free (error);
2019-10-04 17:46:22 +02:00
+ g_object_unref (manager->notification_resumed);
2013-01-21 17:38:42 +01:00
+ }
+}
+
+static void
idle_set_mode (GsdPowerManager *manager, GsdPowerIdleMode mode)
{
gboolean ret = FALSE;
2023-12-05 08:40:32 +01:00
@@ -1810,6 +1855,7 @@ idle_set_mode (GsdPowerManager *manager,
2019-10-04 17:46:22 +02:00
action_type = g_settings_get_enum (manager->settings,
2013-01-21 17:38:42 +01:00
"sleep-inactive-ac-type");
}
2023-12-05 08:40:32 +01:00
+ manager->last_idle_power_action = action_type;
2013-01-21 17:38:42 +01:00
do_power_action_type (manager, action_type);
/* turn on screen and restore user-selected brightness level */
2023-12-05 08:40:32 +01:00
@@ -2784,6 +2830,11 @@ handle_suspend_actions (GsdPowerManager
2014-05-28 13:59:19 +02:00
static void
handle_resume_actions (GsdPowerManager *manager)
{
2023-12-05 08:40:32 +01:00
+ if (manager->last_idle_power_action == GSD_POWER_ACTION_SUSPEND ||
2019-10-04 17:46:22 +02:00
+ manager->last_idle_power_action == GSD_POWER_ACTION_HIBERNATE)
2013-01-21 17:38:42 +01:00
+ show_resumed_notification (manager);
+
2019-10-04 17:46:22 +02:00
+ manager->last_idle_power_action = GSD_POWER_ACTION_NOTHING;
2013-01-21 17:38:42 +01:00
/* ensure we turn the panel back on after resume */
2013-03-13 23:54:12 +01:00
backlight_enable (manager);