diff options
author | Landry Breuil <landry@rhaalovely.net> | 2012-01-06 17:34:20 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2012-01-06 16:40:09 +0000 |
commit | 19790b99a2b8b0f1a784bfc8b10e7677020efdb8 (patch) | |
tree | 6d3883e3f163f6675f873411dbffc1b795f2ef8b | |
parent | 4f3150fb27ed575c06630d302345de22d0bdef07 (diff) |
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>
-rw-r--r-- | etc/UPower.conf | 6 | ||||
-rw-r--r-- | src/up-daemon.c | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/etc/UPower.conf b/etc/UPower.conf index c9da9cd..23f06f8 100644 --- a/etc/UPower.conf +++ b/etc/UPower.conf @@ -20,6 +20,12 @@ SleepTimeout=1000 # default=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. # # The Watts Up Pro contains a generic FTDI USB device without a specific diff --git a/src/up-daemon.c b/src/up-daemon.c index db02eae..6165fab 100644 --- a/src/up-daemon.c +++ b/src/up-daemon.c @@ -97,6 +97,7 @@ struct UpDaemonPrivate guint about_to_sleep_id; guint conf_sleep_timeout; gboolean conf_allow_hibernate_encrypted_swap; + gboolean conf_run_powersave_command; const gchar *sleep_kind; }; @@ -768,7 +769,8 @@ up_daemon_startup (UpDaemon *daemon) g_debug ("daemon now not coldplug"); /* 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: return ret; } @@ -940,7 +942,8 @@ up_daemon_device_changed_cb (UpDevice *device, UpDaemon *daemon) up_daemon_set_on_battery (daemon, ret); /* 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); if (ret != priv->on_low_battery) @@ -1089,6 +1092,7 @@ up_daemon_init (UpDaemon *daemon) daemon->priv->about_to_sleep_id = 0; daemon->priv->conf_sleep_timeout = 1000; daemon->priv->conf_allow_hibernate_encrypted_swap = FALSE; + daemon->priv->conf_run_powersave_command = TRUE; /* load some values from the config file */ file = g_key_file_new (); @@ -1105,6 +1109,8 @@ up_daemon_init (UpDaemon *daemon) g_key_file_get_integer (file, "UPower", "SleepTimeout", NULL); daemon->priv->conf_allow_hibernate_encrypted_swap = 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 { g_warning ("failed to load config file %s: %s", filename, error->message); g_error_free (error); |