mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 04:20:04 +01:00
up-config: The warning message for the risky CriticalPowerAction
The warning message will be shown when CriticalPowerAction is "Suspend". One iwarning message is for enabling the risky CriticalPowerAction and the other is to show the potential risk when AllowRiskyCriticalPowerAction is true.
This commit is contained in:
parent
18b4748435
commit
8cb9fb0231
2 changed files with 31 additions and 3 deletions
|
|
@ -81,6 +81,13 @@ TimeLow=1200
|
|||
TimeCritical=300
|
||||
TimeAction=120
|
||||
|
||||
# Enable the risky CriticalPowerAction-Suspend
|
||||
# This option is not recommended, but it is here for users who
|
||||
# want to enable the riscky CriticalPowerAction, such as "Suspend"
|
||||
# to fulfil their needs.
|
||||
# Default is false
|
||||
AllowRiskyCriticalPowerAction=false
|
||||
|
||||
# The action to take when "TimeAction" or "PercentageAction" above has been
|
||||
# reached for the batteries (UPS or laptop batteries) supplying the computer
|
||||
#
|
||||
|
|
@ -88,9 +95,9 @@ TimeAction=120
|
|||
# PowerOff
|
||||
# Hibernate
|
||||
# HybridSleep
|
||||
# Suspend
|
||||
# Suspend (AllowRiskyCriticalPowerAction should be true to use this option but risky)
|
||||
#
|
||||
# If Suspend isn't available, HybridSleep will be used
|
||||
# If Suspend isn't available or AllowRiskyCriticalPowerAction=false, Poweroff will be used
|
||||
# If HybridSleep isn't available, Hibernate will be used
|
||||
# If Hibernate isn't available, PowerOff will be used
|
||||
CriticalPowerAction=HybridSleep
|
||||
|
|
|
|||
|
|
@ -94,9 +94,11 @@ up_config_class_init (UpConfigClass *klass)
|
|||
static void
|
||||
up_config_init (UpConfig *config)
|
||||
{
|
||||
gboolean ret;
|
||||
gboolean allow_risky_critical_action = FALSE;
|
||||
g_autofree gchar *critical_action = NULL;
|
||||
GError *error = NULL;
|
||||
gchar *filename;
|
||||
gboolean ret;
|
||||
|
||||
config->priv = up_config_get_instance_private (config);
|
||||
config->priv->keyfile = g_key_file_new ();
|
||||
|
|
@ -117,6 +119,25 @@ up_config_init (UpConfig *config)
|
|||
g_error_free (error);
|
||||
}
|
||||
|
||||
/* Warn for any dangerous configurations */
|
||||
critical_action = up_config_get_string (config, "CriticalPowerAction");
|
||||
allow_risky_critical_action = up_config_get_boolean (config, "AllowRiskyCriticalPowerAction");
|
||||
|
||||
if (!g_strcmp0 (critical_action, "Suspend")) {
|
||||
if (allow_risky_critical_action) {
|
||||
g_warning ("The \"Suspend\" CriticalPowerAction setting is considered risky:"
|
||||
" abrupt power loss due to battery exhaustion may lead to data"
|
||||
" corruption. Use AllowRiskyCriticalPowerAction=false to disable"
|
||||
" support for risky settings.");
|
||||
} else {
|
||||
g_warning ("The \"Suspend\" CriticalPowerAction setting is considered risky:"
|
||||
" abrupt power loss due to battery exhaustion may lead to data"
|
||||
" corruption. The system will perform \"HybridSleep\" instead."
|
||||
" Use AllowRiskyCriticalPowerAction=true to enable support for"
|
||||
" risky settings.");
|
||||
}
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue