linux: allow Suspend as CriticalPowerAction

When using UPower in a non-hybernate setup, the result of a
CriticalPowerAction would be PowerOff. Certain users prefer
Suspend instead, because this is the only way to recover
graceful from that state.
Suspend action will only used, when explicit configured.

Closes: #23
Closes: #59
Signed-off-by: Kate Hsuan <hpa@redhat.com>
This commit is contained in:
Alexander Couzens 2017-09-11 19:52:04 +02:00 committed by Kate Hsuan
parent 1146047df9
commit 18b4748435
2 changed files with 5 additions and 2 deletions

View file

@ -88,7 +88,9 @@ TimeAction=120
# PowerOff
# Hibernate
# HybridSleep
# Suspend
#
# If Suspend isn't available, HybridSleep will be used
# If HybridSleep isn't available, Hibernate will be used
# If Hibernate isn't available, PowerOff will be used
CriticalPowerAction=HybridSleep

View file

@ -553,11 +553,12 @@ up_backend_get_critical_action (UpBackend *backend)
const gchar *method;
const gchar *can_method;
} actions[] = {
{ "Suspend", "CanSuspend" },
{ "HybridSleep", "CanHybridSleep" },
{ "Hibernate", "CanHibernate" },
{ "PowerOff", NULL },
};
guint i = 0;
guint i = 1;
char *action;
g_return_val_if_fail (backend->priv->logind_proxy != NULL, NULL);
@ -569,7 +570,7 @@ up_backend_get_critical_action (UpBackend *backend)
if (g_str_equal (actions[i].method, action))
break;
if (i >= G_N_ELEMENTS (actions))
i = 0;
i = 1;
g_free (action);
}