mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-24 07:30:05 +01:00
Add boolean RunPowersaveCommand to UPower.conf
Defaulting to true, it controls whether we want the powersave commands to be run when running on battery/plugging ac. Signed-off-by: Richard Hughes <richard@hughsie.com>
This commit is contained in:
parent
4f3150fb27
commit
19790b99a2
2 changed files with 14 additions and 2 deletions
|
|
@ -20,6 +20,12 @@ SleepTimeout=1000
|
||||||
# default=true
|
# default=true
|
||||||
AllowHibernateEncryptedSwap=true
|
AllowHibernateEncryptedSwap=true
|
||||||
|
|
||||||
|
# This controls whether we want the powersave commands to be run when running
|
||||||
|
# on battery or plugging AC.
|
||||||
|
#
|
||||||
|
# default=true
|
||||||
|
RunPowersaveCommand=true
|
||||||
|
|
||||||
# Enable the Watts Up Pro device.
|
# Enable the Watts Up Pro device.
|
||||||
#
|
#
|
||||||
# The Watts Up Pro contains a generic FTDI USB device without a specific
|
# The Watts Up Pro contains a generic FTDI USB device without a specific
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ struct UpDaemonPrivate
|
||||||
guint about_to_sleep_id;
|
guint about_to_sleep_id;
|
||||||
guint conf_sleep_timeout;
|
guint conf_sleep_timeout;
|
||||||
gboolean conf_allow_hibernate_encrypted_swap;
|
gboolean conf_allow_hibernate_encrypted_swap;
|
||||||
|
gboolean conf_run_powersave_command;
|
||||||
const gchar *sleep_kind;
|
const gchar *sleep_kind;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -768,7 +769,8 @@ up_daemon_startup (UpDaemon *daemon)
|
||||||
g_debug ("daemon now not coldplug");
|
g_debug ("daemon now not coldplug");
|
||||||
|
|
||||||
/* set power policy */
|
/* set power policy */
|
||||||
up_daemon_set_powersave (daemon, priv->on_battery);
|
if (priv->conf_run_powersave_command)
|
||||||
|
up_daemon_set_powersave (daemon, priv->on_battery);
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -940,7 +942,8 @@ up_daemon_device_changed_cb (UpDevice *device, UpDaemon *daemon)
|
||||||
up_daemon_set_on_battery (daemon, ret);
|
up_daemon_set_on_battery (daemon, ret);
|
||||||
|
|
||||||
/* set power policy */
|
/* set power policy */
|
||||||
up_daemon_set_powersave (daemon, ret);
|
if (priv->conf_run_powersave_command)
|
||||||
|
up_daemon_set_powersave (daemon, ret);
|
||||||
}
|
}
|
||||||
ret = up_daemon_get_on_low_battery_local (daemon);
|
ret = up_daemon_get_on_low_battery_local (daemon);
|
||||||
if (ret != priv->on_low_battery)
|
if (ret != priv->on_low_battery)
|
||||||
|
|
@ -1089,6 +1092,7 @@ up_daemon_init (UpDaemon *daemon)
|
||||||
daemon->priv->about_to_sleep_id = 0;
|
daemon->priv->about_to_sleep_id = 0;
|
||||||
daemon->priv->conf_sleep_timeout = 1000;
|
daemon->priv->conf_sleep_timeout = 1000;
|
||||||
daemon->priv->conf_allow_hibernate_encrypted_swap = FALSE;
|
daemon->priv->conf_allow_hibernate_encrypted_swap = FALSE;
|
||||||
|
daemon->priv->conf_run_powersave_command = TRUE;
|
||||||
|
|
||||||
/* load some values from the config file */
|
/* load some values from the config file */
|
||||||
file = g_key_file_new ();
|
file = g_key_file_new ();
|
||||||
|
|
@ -1105,6 +1109,8 @@ up_daemon_init (UpDaemon *daemon)
|
||||||
g_key_file_get_integer (file, "UPower", "SleepTimeout", NULL);
|
g_key_file_get_integer (file, "UPower", "SleepTimeout", NULL);
|
||||||
daemon->priv->conf_allow_hibernate_encrypted_swap =
|
daemon->priv->conf_allow_hibernate_encrypted_swap =
|
||||||
g_key_file_get_boolean (file, "UPower", "AllowHibernateEncryptedSwap", NULL);
|
g_key_file_get_boolean (file, "UPower", "AllowHibernateEncryptedSwap", NULL);
|
||||||
|
daemon->priv->conf_run_powersave_command =
|
||||||
|
g_key_file_get_boolean (file, "UPower", "RunPowersaveCommand", NULL);
|
||||||
} else {
|
} else {
|
||||||
g_warning ("failed to load config file %s: %s", filename, error->message);
|
g_warning ("failed to load config file %s: %s", filename, error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue