up-config: A config and warning message for Ignore as the CriticalPowerAction

Action "Ignore" is one of the CriticalPowerAction. It is a risky action
so AllowRiskyCriticalPowerAction should be set to true to enable it.
This commit is contained in:
Kate Hsuan 2024-05-23 16:04:31 +08:00
parent 00eb31a63c
commit d756a7d512
2 changed files with 6 additions and 5 deletions

View file

@ -96,6 +96,7 @@ AllowRiskyCriticalPowerAction=false
# Hibernate
# HybridSleep
# Suspend (AllowRiskyCriticalPowerAction should be true to use this option but risky)
# Ignore (AllowRiskyCriticalPowerAction should be true to use this option but risky)
#
# If Suspend isn't available or AllowRiskyCriticalPowerAction=false, HybridSleep will be used
# If HybridSleep isn't available, Hibernate will be used

View file

@ -123,18 +123,18 @@ up_config_init (UpConfig *config)
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 (!g_strcmp0 (critical_action, "Suspend") || !g_strcmp0 (critical_action, "Ignore")) {
if (allow_risky_critical_action) {
g_warning ("The \"Suspend\" CriticalPowerAction setting is considered risky:"
g_warning ("The \"%s\" 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.");
" support for risky settings.", critical_action);
} else {
g_warning ("The \"Suspend\" CriticalPowerAction setting is considered risky:"
g_warning ("The \"%s\" 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.");
" risky settings.", critical_action);
}
}
}