mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-05 09:58:06 +02:00
export battery-is-present as some batteries in laptops and UPSs can be removed
This commit is contained in:
parent
a1f9c05280
commit
1f41f03776
2 changed files with 25 additions and 0 deletions
|
|
@ -63,6 +63,7 @@ struct DevkitPowerSourcePrivate
|
|||
DevkitPowerType type;
|
||||
|
||||
gboolean line_power_online;
|
||||
gboolean battery_is_present;
|
||||
gboolean battery_is_rechargeable;
|
||||
DevkitPowerState battery_state;
|
||||
DevkitPowerTechnology battery_technology;
|
||||
|
|
@ -95,6 +96,7 @@ enum
|
|||
PROP_TYPE,
|
||||
PROP_LINE_POWER_ONLINE,
|
||||
PROP_BATTERY_CAPACITY,
|
||||
PROP_BATTERY_IS_PRESENT,
|
||||
PROP_BATTERY_IS_RECHARGEABLE,
|
||||
PROP_BATTERY_STATE,
|
||||
PROP_BATTERY_ENERGY,
|
||||
|
|
@ -156,6 +158,10 @@ get_property (GObject *object,
|
|||
case PROP_LINE_POWER_ONLINE:
|
||||
g_value_set_boolean (value, source->priv->line_power_online);
|
||||
break;
|
||||
|
||||
case PROP_BATTERY_IS_PRESENT:
|
||||
g_value_set_boolean (value, source->priv->battery_is_present);
|
||||
break;
|
||||
case PROP_BATTERY_IS_RECHARGEABLE:
|
||||
g_value_set_boolean (value, source->priv->battery_is_rechargeable);
|
||||
break;
|
||||
|
|
@ -260,6 +266,10 @@ devkit_power_source_class_init (DevkitPowerSourceClass *klass)
|
|||
object_class,
|
||||
PROP_BATTERY_ENERGY,
|
||||
g_param_spec_double ("battery-energy", NULL, NULL, 0, G_MAXDOUBLE, 0, G_PARAM_READABLE));
|
||||
g_object_class_install_property (
|
||||
object_class,
|
||||
PROP_BATTERY_IS_PRESENT,
|
||||
g_param_spec_boolean ("battery-is-present", NULL, NULL, FALSE, G_PARAM_READABLE));
|
||||
g_object_class_install_property (
|
||||
object_class,
|
||||
PROP_BATTERY_IS_RECHARGEABLE,
|
||||
|
|
@ -510,6 +520,9 @@ update_battery (DevkitPowerSource *source)
|
|||
* This is just a very quick hack for now.
|
||||
*/
|
||||
|
||||
/* are we present? */
|
||||
source->priv->battery_is_present = sysfs_get_bool (source->priv->native_path, "present");
|
||||
|
||||
status = g_strstrip (sysfs_get_string (source->priv->native_path, "status"));
|
||||
is_charging = strcasecmp (status, "charging") == 0;
|
||||
is_discharging = strcasecmp (status, "discharging") == 0;
|
||||
|
|
|
|||
|
|
@ -202,6 +202,18 @@
|
|||
</doc:para></doc:description></doc:doc>
|
||||
</property>
|
||||
|
||||
<property name="battery-is-present" type="b" access="read">
|
||||
<doc:doc><doc:description><doc:para>
|
||||
If the power source is present in the bay.
|
||||
This field is required as some batteries are hot-removable, for example
|
||||
expensive UPS and most laptop batteries.
|
||||
</doc:para><doc:para>
|
||||
This property is only valid if the property
|
||||
<doc:ref type="property" to="Source:type">type</doc:ref>
|
||||
has the value "battery".
|
||||
</doc:para></doc:description></doc:doc>
|
||||
</property>
|
||||
|
||||
<property name="battery-state" type="s" access="read">
|
||||
<doc:doc><doc:description><doc:para>
|
||||
The battery power state.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue