From 358044bdfd357916bad9ae9298fd89b54291a7a6 Mon Sep 17 00:00:00 2001 From: Ojas Kavathe Date: Wed, 27 Nov 2024 04:18:52 +0530 Subject: feat: add battery_percent to bluetooth devices --- lib/bluetooth/battery.vala | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/bluetooth/battery.vala (limited to 'lib/bluetooth/battery.vala') diff --git a/lib/bluetooth/battery.vala b/lib/bluetooth/battery.vala new file mode 100644 index 0000000..a828994 --- /dev/null +++ b/lib/bluetooth/battery.vala @@ -0,0 +1,33 @@ +/** + * Object representing a [[https://github.com/bluez/bluez/blob/master/doc/org.bluez.Battery.rst|battery]]. + */ +public class AstalBluetooth.Battery : Object { + private IBattery proxy; + + internal ObjectPath object_path { owned get; private set; } + + internal Battery(IBattery proxy) { + this.proxy = proxy; + this.object_path = (ObjectPath)proxy.g_object_path; + proxy.g_properties_changed.connect((props) => { + var map = (HashTable)props; + foreach (var key in map.get_keys()) { + var prop = kebab_case(key); + if (get_class().find_property(prop) != null) { + notify_property(prop); + } + } + }); + } + + /** + * The percentage of battery left as an unsigned 8-bit integer. + */ + public uint percentage { get { return proxy.percentage; } } + + /** + * Describes where the battery information comes from. + */ + public string source { owned get { return proxy.source; } } + +} -- cgit v1.2.3 From 5418f29bf1c8e3c2ce53add5d0a54b1cd003c13f Mon Sep 17 00:00:00 2001 From: Ojas Kavathe Date: Fri, 24 Jan 2025 09:01:07 +0530 Subject: fix(bluetooth): battery between 0-1 --- lib/bluetooth/battery.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/bluetooth/battery.vala') diff --git a/lib/bluetooth/battery.vala b/lib/bluetooth/battery.vala index a828994..9fdd70d 100644 --- a/lib/bluetooth/battery.vala +++ b/lib/bluetooth/battery.vala @@ -1,7 +1,7 @@ /** * Object representing a [[https://github.com/bluez/bluez/blob/master/doc/org.bluez.Battery.rst|battery]]. */ -public class AstalBluetooth.Battery : Object { +internal class AstalBluetooth.Battery : Object { private IBattery proxy; internal ObjectPath object_path { owned get; private set; } -- cgit v1.2.3