diff options
author | Aylur <[email protected]> | 2025-01-28 11:41:33 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2025-01-28 11:41:33 +0100 |
commit | a23ef6a6c0bd9da6c68f8bc5e6d8e1efd9210e09 (patch) | |
tree | 1acc45b813a844440d494e05de8dcf34085ab9d8 /lib/bluetooth/bluetooth.vala | |
parent | d0de56e715cc1982d2eb0097b687c61133a0ff75 (diff) | |
parent | 5418f29bf1c8e3c2ce53add5d0a54b1cd003c13f (diff) |
Merge pull request #141 from ojaskavathe/main
feat: add battery_percentage to bluetooth devices
Diffstat (limited to 'lib/bluetooth/bluetooth.vala')
-rw-r--r-- | lib/bluetooth/bluetooth.vala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/bluetooth/bluetooth.vala b/lib/bluetooth/bluetooth.vala index 6eb6b76..02005c3 100644 --- a/lib/bluetooth/bluetooth.vala +++ b/lib/bluetooth/bluetooth.vala @@ -138,6 +138,9 @@ public class AstalBluetooth.Bluetooth : Object { [CCode (cname="astal_bluetooth_iadapter_proxy_get_type")] extern static GLib.Type get_iadapter_proxy_type(); + [CCode (cname="astal_bluetooth_ibattery_proxy_get_type")] + extern static GLib.Type get_ibattery_proxy_type(); + private Type manager_proxy_get_type(DBusObjectManagerClient _, string object_path, string? interface_name) { if (interface_name == null) return typeof(DBusObjectProxy); @@ -147,6 +150,8 @@ public class AstalBluetooth.Bluetooth : Object { return get_idevice_proxy_type(); case "org.bluez.Adapter1": return get_iadapter_proxy_type(); + case "org.bluez.Battery1": + return get_ibattery_proxy_type(); default: return typeof(DBusProxy); } @@ -161,6 +166,15 @@ public class AstalBluetooth.Bluetooth : Object { sync(); } + if (iface is IBattery) { + var battery = new Battery((IBattery)iface); + var device = _devices.lookup(iface.g_object_path); + if (device != null) { + device.set_battery(battery); + } + sync(); + } + if (iface is IAdapter) { var adapter = new Adapter((IAdapter)iface); _adapters.set(adapter.object_path, adapter); |