summaryrefslogtreecommitdiff
path: root/src/up-daemon.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-10-11 16:05:16 +0200
committerBastien Nocera <hadess@hadess.net>2013-10-14 10:42:56 +0200
commit87709f709a724e139afad182b6bcbccc82ab66f4 (patch)
treea3954ce7a00a053baeb465d8c7ae43a00397636b /src/up-daemon.c
parent0da46209f39a6d14fc4a3f9e9be9d652c2b84d1b (diff)
downloadupower-87709f709a724e139afad182b6bcbccc82ab66f4.tar.gz
daemon: Add small hack for keyboards and mice
Imported from gnome-settings-daemon, itself from gnome-power-manager.
Diffstat (limited to 'src/up-daemon.c')
-rw-r--r--src/up-daemon.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/up-daemon.c b/src/up-daemon.c
index 10c836a..b1bfa61 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -447,13 +447,27 @@ up_daemon_set_warning_level (UpDaemon *daemon, UpDeviceLevel warning_level)
}
UpDeviceLevel
-up_daemon_compute_warning_level(UpDaemon *daemon,
- gboolean power_supply,
- gdouble percentage,
- gint64 time_to_empty)
+up_daemon_compute_warning_level (UpDaemon *daemon,
+ UpDeviceKind kind,
+ gboolean power_supply,
+ gdouble percentage,
+ gint64 time_to_empty)
{
gboolean use_percentage = TRUE;
+ /* Keyboard and mice usually have a coarser
+ * battery level, so this avoids falling directly
+ * into critical (or off) before any warnings */
+ if (kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD) {
+ if (percentage < 13.0f)
+ return UP_DEVICE_LEVEL_CRITICAL;
+ else if (percentage < 26.0f)
+ return UP_DEVICE_LEVEL_LOW;
+ else
+ return UP_DEVICE_LEVEL_NONE;
+ }
+
if (!power_supply || !daemon->priv->use_percentage_for_policy)
use_percentage = FALSE;