summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-10-17 11:55:47 +0200
committerBastien Nocera <hadess@hadess.net>2013-10-17 17:41:39 +0200
commitb9218005c034f977c2964b2efc662035e216f784 (patch)
treeda1612774a68dc311d93c2663816bc04a436dc2c
parent88e384e32627d0ba1239883b65442f4952ffb47e (diff)
downloadgnome-settings-daemon-b9218005c034f977c2964b2efc662035e216f784.tar.gz
power: Stop the alert sound before taking action
As it's UPower taking action, make sure that we stop the alert sound before the action is taken. We might wake up to the sound otherwise.
-rw-r--r--plugins/power/gsd-power-manager.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index d1446597..6fa66fa0 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -76,11 +76,10 @@
#define SYSTEMD_DBUS_PATH "/org/freedesktop/login1"
#define SYSTEMD_DBUS_INTERFACE "org.freedesktop.login1.Manager"
-/* Time between notifying the user about a critical action and executing it.
- * This can be changed with the GSD_ACTION_DELAY constant. */
-#ifndef GSD_ACTION_DELAY
+/* Time between notifying the user about a critical action and the action itself in UPower. */
#define GSD_ACTION_DELAY 20
-#endif /* !GSD_ACTION_DELAY */
+/* And the time before we stop the warning sound */
+#define GSD_STOP_SOUND_DELAY GSD_ACTION_DELAY - 2
static const gchar introspection_xml[] =
"<node>"
@@ -385,7 +384,7 @@ manager_critical_action_get (GsdPowerManager *manager)
}
static gboolean
-manager_critical_action_do_cb (GsdPowerManager *manager)
+manager_critical_action_stop_sound_cb (GsdPowerManager *manager)
{
/* stop playing the alert as it's too late to do anything now */
play_loop_stop (&manager->priv->critical_alert_timeout_id);
@@ -722,8 +721,8 @@ engine_charge_action (GsdPowerManager *manager, UpDevice *device)
}
/* wait 20 seconds for user-panic */
- timer_id = g_timeout_add_seconds (GSD_ACTION_DELAY,
- (GSourceFunc) manager_critical_action_do_cb,
+ timer_id = g_timeout_add_seconds (GSD_STOP_SOUND_DELAY,
+ (GSourceFunc) manager_critical_action_stop_sound_cb,
manager);
g_source_set_name_by_id (timer_id, "[GsdPowerManager] battery critical-action");
@@ -747,8 +746,8 @@ engine_charge_action (GsdPowerManager *manager, UpDevice *device)
}
/* wait 20 seconds for user-panic */
- timer_id = g_timeout_add_seconds (GSD_ACTION_DELAY,
- (GSourceFunc) manager_critical_action_do_cb,
+ timer_id = g_timeout_add_seconds (GSD_STOP_SOUND_DELAY,
+ (GSourceFunc) manager_critical_action_stop_sound_cb,
manager);
g_source_set_name_by_id (timer_id, "[GsdPowerManager] ups critical-action");
}