summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/UPower.conf2
-rw-r--r--src/linux/up-backend.c16
2 files changed, 14 insertions, 4 deletions
diff --git a/etc/UPower.conf b/etc/UPower.conf
index 5e9ad31..ffae2b1 100644
--- a/etc/UPower.conf
+++ b/etc/UPower.conf
@@ -97,7 +97,7 @@ AllowRiskyCriticalPowerAction=false
# HybridSleep
# Suspend (AllowRiskyCriticalPowerAction should be true to use this option but risky)
#
-# If Suspend isn't available or AllowRiskyCriticalPowerAction=false, Poweroff will be used
+# If Suspend isn't available or AllowRiskyCriticalPowerAction=false, HybridSleep will be used
# If HybridSleep isn't available, Hibernate will be used
# If Hibernate isn't available, PowerOff will be used
CriticalPowerAction=HybridSleep
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index 1b55a65..4e31ab9 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -558,20 +558,30 @@ up_backend_get_critical_action (UpBackend *backend)
{ "Hibernate", "CanHibernate" },
{ "PowerOff", NULL },
};
+ g_autofree gchar *action = NULL;
+ gboolean can_risky = FALSE;
guint i = 1;
- char *action;
g_return_val_if_fail (backend->priv->logind_proxy != NULL, NULL);
- /* Find the configured action first */
+ can_risky = up_config_get_boolean (backend->priv->config,
+ "AllowRiskyCriticalPowerAction");
+
+ /* find the configured action first */
action = up_config_get_string (backend->priv->config, "CriticalPowerAction");
+
+ /* safeguard for the risky actions */
+ if (!can_risky && !g_strcmp0 (action, "Suspend")) {
+ g_free (action);
+ action = g_strdup_printf ("HybridSleep");
+ }
+
if (action != NULL) {
for (i = 0; i < G_N_ELEMENTS (actions); i++)
if (g_str_equal (actions[i].method, action))
break;
if (i >= G_N_ELEMENTS (actions))
i = 1;
- g_free (action);
}
for (; i < G_N_ELEMENTS (actions); i++) {