summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2014-08-25 17:04:55 +0200
committerBastien Nocera <hadess@hadess.net>2014-09-02 21:56:38 +0200
commit657331063761bad6e7c608585a30ea18c6fdcf71 (patch)
tree07af00cb9ce2fa64cddfa21465811348a547aff5
parent07fa35c42b4ddab4bdc4ae0172aefac0258fe71e (diff)
downloadupower-657331063761bad6e7c608585a30ea18c6fdcf71.tar.gz
linux: Respect the CriticalPowerAction config option
It was documented, but the configuration was never actually read. https://bugs.freedesktop.org/show_bug.cgi?id=82925
-rw-r--r--src/linux/up-backend.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index 9f4d033..f588e74 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -371,11 +371,23 @@ up_backend_get_critical_action (UpBackend *backend)
{ "Hibernate", "CanHibernate" },
{ "PowerOff", NULL },
};
- guint i;
+ guint i = 0;
+ char *action;
g_return_val_if_fail (backend->priv->logind_proxy != NULL, NULL);
- for (i = 0; i < G_N_ELEMENTS (actions); i++) {
+ /* Find the configured action first */
+ action = up_config_get_string (backend->priv->config, "CriticalPowerAction");
+ 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 = 0;
+ g_free (action);
+ }
+
+ for (; i < G_N_ELEMENTS (actions); i++) {
GVariant *result;
if (actions[i].can_method) {