summaryrefslogtreecommitdiff
path: root/src/linux/up-device-supply.c
diff options
context:
space:
mode:
authorSeth Forshee <seth.forshee@canonical.com>2013-08-13 10:51:48 -0500
committerMartin Pitt <martinpitt@gnome.org>2013-08-23 08:45:57 +0200
commiteaf86482a925e69e6e32973184164c6b8e5391d0 (patch)
treee33a24e3bd9583adff60806599d67afbf9f5d742 /src/linux/up-device-supply.c
parent03f67aabfe2a01ebfbcb424fa193c02be8f0906e (diff)
downloadupower-eaf86482a925e69e6e32973184164c6b8e5391d0.tar.gz
Add temperature property for batteries
Linux's power_supply class supports a temperature attribute, which is supported by many battery drivers. Add a new property to export this information and support this property in Linux. https://bugs.freedesktop.org/show_bug.cgi?id=68338 Signed-off-by: Seth Forshee <seth.forshee@canonical.com> Signed-off-by: Martin Pitt <martinpitt@gnome.org>
Diffstat (limited to 'src/linux/up-device-supply.c')
-rw-r--r--src/linux/up-device-supply.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 6a82721..68f3537 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -134,6 +134,7 @@ up_device_supply_reset_values (UpDeviceSupply *supply)
"time-to-empty", (gint64) 0,
"time-to-full", (gint64) 0,
"percentage", (gdouble) 0.0,
+ "temperature", (gdouble) 0.0,
"technology", UP_DEVICE_TECHNOLOGY_UNKNOWN,
NULL);
}
@@ -490,6 +491,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
gdouble voltage;
gint64 time_to_empty;
gint64 time_to_full;
+ gdouble temp;
gchar *manufacturer = NULL;
gchar *model_name = NULL;
gchar *serial_number = NULL;
@@ -785,6 +787,9 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
if (time_to_full > (20 * 60 * 60)) /* 20 hours for charging */
time_to_full = 0;
+ /* get temperature */
+ temp = sysfs_get_double(native_path, "temp") / 10.0;
+
/* check if the energy value has changed and, if that's the case,
* store the new values in the buffer. */
if (up_device_supply_push_new_energy (supply, energy))
@@ -811,6 +816,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
"voltage", voltage,
"time-to-empty", time_to_empty,
"time-to-full", time_to_full,
+ "temperature", temp,
NULL);
out: