diff --git a/libupower-glib/up-device.c b/libupower-glib/up-device.c
index bf9f758..8b66bde 100644
--- a/libupower-glib/up-device.c
+++ b/libupower-glib/up-device.c
@@ -85,6 +85,7 @@ struct _UpDevicePrivate
gint64 time_to_empty; /* seconds */
gint64 time_to_full; /* seconds */
gdouble percentage; /* percent */
+ gdouble temperature; /* degrees C */
gboolean recall_notice;
gchar *recall_vendor;
gchar *recall_url;
@@ -117,6 +118,7 @@ enum {
PROP_TIME_TO_EMPTY,
PROP_TIME_TO_FULL,
PROP_PERCENTAGE,
+ PROP_TEMPERATURE,
PROP_RECALL_NOTICE,
PROP_RECALL_VENDOR,
PROP_RECALL_URL,
@@ -205,6 +207,8 @@ up_device_collect_props_cb (const char *key, const GValue *value, UpDevice *devi
device->priv->time_to_empty = g_value_get_int64 (value);
} else if (g_strcmp0 (key, "Percentage") == 0) {
device->priv->percentage = g_value_get_double (value);
+ } else if (g_strcmp0 (key, "Temperature") == 0) {
+ device->priv->temperature = g_value_get_double (value);
} else if (g_strcmp0 (key, "Technology") == 0) {
device->priv->technology = g_value_get_uint (value);
} else if (g_strcmp0 (key, "IsPresent") == 0) {
@@ -512,6 +516,8 @@ up_device_to_text (UpDevice *device)
device->priv->kind == UP_DEVICE_KIND_UPS)
g_string_append_printf (string, " percentage: %g%%\n", device->priv->percentage);
if (device->priv->kind == UP_DEVICE_KIND_BATTERY) {
+ if (device->priv->temperature > 0)
+ g_string_append_printf (string, " temperature: %g degrees C\n", device->priv->temperature);
if (device->priv->capacity > 0)
g_string_append_printf (string, " capacity: %g%%\n", device->priv->capacity);
}
@@ -827,6 +833,9 @@ up_device_set_property (GObject *object, guint prop_id, const GValue *value, GPa
case PROP_PERCENTAGE:
device->priv->percentage = g_value_get_double (value);
break;
+ case PROP_TEMPERATURE:
+ device->priv->temperature = g_value_get_double (value);
+ break;
case PROP_TECHNOLOGY:
device->priv->technology = g_value_get_uint (value);
break;
@@ -931,6 +940,9 @@ up_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
case PROP_PERCENTAGE:
g_value_set_double (value, device->priv->percentage);
break;
+ case PROP_TEMPERATURE:
+ g_value_set_double (value, device->priv->temperature);
+ break;
case PROP_RECALL_NOTICE:
g_value_set_boolean (value, device->priv->recall_notice);
break;
@@ -1297,6 +1309,18 @@ up_device_class_init (UpDeviceClass *klass)
g_param_spec_double ("percentage", NULL, NULL,
0.0, 100.f, 100.0,
G_PARAM_READWRITE));
+ /**
+ * UpDevice:temperature:
+ *
+ * The temperature of the device in degrees Celsius.
+ *
+ * Since: 0.9.22
+ **/
+ g_object_class_install_property (object_class,
+ PROP_TEMPERATURE,
+ g_param_spec_double ("temperature", NULL, NULL,
+ 0.0, G_MAXDOUBLE, 0.0,
+ G_PARAM_READWRITE));
/**
* UpDevice:recall-notice:
*
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:
diff --git a/src/org.freedesktop.UPower.Device.xml b/src/org.freedesktop.UPower.Device.xml
index 04ea4da..0be009c 100644
--- a/src/org.freedesktop.UPower.Device.xml
+++ b/src/org.freedesktop.UPower.Device.xml
@@ -544,6 +544,19 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2
+
+
+
+
+ The temperature of the device in degrees Celsius. This property is
+ only valid if the property
+ type
+ has the value "battery".
+
+
+
+
+
diff --git a/src/up-device.c b/src/up-device.c
index 12f32ff..9e9c332 100644
--- a/src/up-device.c
+++ b/src/up-device.c
@@ -77,6 +77,7 @@ struct UpDevicePrivate
gint64 time_to_empty; /* seconds */
gint64 time_to_full; /* seconds */
gdouble percentage; /* percent */
+ gdouble temperature; /* degrees C */
gboolean recall_notice;
gchar *recall_vendor;
gchar *recall_url;
@@ -110,6 +111,7 @@ enum {
PROP_TIME_TO_EMPTY,
PROP_TIME_TO_FULL,
PROP_PERCENTAGE,
+ PROP_TEMPERATURE,
PROP_TECHNOLOGY,
PROP_RECALL_NOTICE,
PROP_RECALL_VENDOR,
@@ -249,6 +251,9 @@ up_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
case PROP_PERCENTAGE:
g_value_set_double (value, device->priv->percentage);
break;
+ case PROP_TEMPERATURE:
+ g_value_set_double (value, device->priv->temperature);
+ break;
case PROP_TECHNOLOGY:
g_value_set_uint (value, device->priv->technology);
break;
@@ -352,6 +357,9 @@ up_device_set_property (GObject *object, guint prop_id, const GValue *value, GPa
case PROP_PERCENTAGE:
device->priv->percentage = g_value_get_double (value);
break;
+ case PROP_TEMPERATURE:
+ device->priv->temperature = g_value_get_double (value);
+ break;
case PROP_TECHNOLOGY:
device->priv->technology = g_value_get_uint (value);
break;
@@ -1169,6 +1177,14 @@ up_device_class_init (UpDeviceClass *klass)
g_param_spec_double ("percentage", NULL, NULL,
0.0, 100.f, 100.0,
G_PARAM_READWRITE));
+ /**
+ * UpDevice:temperature:
+ */
+ g_object_class_install_property (object_class,
+ PROP_TEMPERATURE,
+ g_param_spec_double ("temperature", NULL, NULL,
+ 0.0, G_MAXDOUBLE, 0.0,
+ G_PARAM_READWRITE));
/**
* UpDevice:recall-notice:
*/