diff --git a/dbus/org.freedesktop.UPower.Device.xml b/dbus/org.freedesktop.UPower.Device.xml index cd11841..d96cd4b 100644 --- a/dbus/org.freedesktop.UPower.Device.xml +++ b/dbus/org.freedesktop.UPower.Device.xml @@ -828,6 +828,27 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2 + + + + + +

When a start charge threshold is set the battery won't get charged until the charge drops under this threshold.

+
+
+
+
+ + + + + +

The end charge threshold stops the battery from getting charged after the set threshold

+
+
+
+
+ diff --git a/libupower-glib/up-device.c b/libupower-glib/up-device.c index 9438b63..53d6e27 100644 --- a/libupower-glib/up-device.c +++ b/libupower-glib/up-device.c @@ -90,6 +90,8 @@ enum { PROP_BATTERY_LEVEL, PROP_ICON_NAME, PROP_CHARGE_CYCLES, + PROP_CHARGE_START_THRESHOLD, + PROP_CHARGE_END_THRESHOLD, PROP_LAST }; @@ -386,6 +388,10 @@ up_device_to_text (UpDevice *device) if (kind == UP_DEVICE_KIND_BATTERY) { if (up_exported_device_get_technology (priv->proxy_device) != UP_DEVICE_TECHNOLOGY_UNKNOWN) g_string_append_printf (string, " technology: %s\n", up_device_technology_to_string (up_exported_device_get_technology (priv->proxy_device))); + if (up_exported_device_get_charge_start_threshold (priv->proxy_device) > 0) + g_string_append_printf (string, " charge-start-threshold: %d%%\n", up_exported_device_get_charge_start_threshold (priv->proxy_device)); + if (up_exported_device_get_charge_end_threshold (priv->proxy_device) > 0) + g_string_append_printf (string, " charge-end-threshold: %d%%\n", up_exported_device_get_charge_end_threshold (priv->proxy_device)); } if (kind == UP_DEVICE_KIND_LINE_POWER) g_string_append_printf (string, " online: %s\n", up_device_bool_to_string (up_exported_device_get_online (priv->proxy_device))); @@ -692,6 +698,12 @@ up_device_set_property (GObject *object, guint prop_id, const GValue *value, GPa case PROP_CHARGE_CYCLES: up_exported_device_set_charge_cycles (device->priv->proxy_device, g_value_get_int (value)); break; + case PROP_CHARGE_START_THRESHOLD: + up_exported_device_set_charge_start_threshold (device->priv->proxy_device, g_value_get_double (value)); + break; + case PROP_CHARGE_END_THRESHOLD: + up_exported_device_set_charge_end_threshold (device->priv->proxy_device, g_value_get_double (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -809,6 +821,12 @@ up_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe case PROP_CHARGE_CYCLES: g_value_set_int (value, up_exported_device_get_charge_cycles (device->priv->proxy_device)); break; + case PROP_CHARGE_START_THRESHOLD: + g_value_set_uint (value, up_exported_device_get_charge_start_threshold (device->priv->proxy_device)); + break; + case PROP_CHARGE_END_THRESHOLD: + g_value_set_uint (value, up_exported_device_get_charge_end_threshold (device->priv->proxy_device)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1225,6 +1243,32 @@ up_device_class_init (UpDeviceClass *klass) g_param_spec_int ("charge-cycles", NULL, NULL, -1, G_MAXINT, -1, G_PARAM_READWRITE)); + + /** + * UpDevice:charge-start-threshold: + * + * The charge start threshold of a battery. + * + * Since: 1.90.5 + **/ + g_object_class_install_property (object_class, + PROP_CHARGE_START_THRESHOLD, + g_param_spec_uint ("charge-start-threshold", + NULL, NULL, + 0, 100, 0, G_PARAM_READWRITE)); + + /** + * UpDevice:charge-end-threshold: + * + * The charge end threshold of a battery. + * + * Since: 1.90.5 + **/ + g_object_class_install_property (object_class, + PROP_CHARGE_END_THRESHOLD, + g_param_spec_uint ("charge-end-threshold", + NULL, NULL, + 0, 100, 100, G_PARAM_READWRITE)); } static void