From 120dc12ca1cbdb8108d8d7dc47379880536c8f64 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Wed, 4 Dec 2024 22:56:13 -0500 Subject: [PATCH] feat(ags bt): add device toggles --- .../ags/config/widgets/bluetooth/device.tsx | 90 ++++++++++++++++++- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/nixosModules/ags/config/widgets/bluetooth/device.tsx b/nixosModules/ags/config/widgets/bluetooth/device.tsx index 08579bf7..13836a3a 100644 --- a/nixosModules/ags/config/widgets/bluetooth/device.tsx +++ b/nixosModules/ags/config/widgets/bluetooth/device.tsx @@ -6,18 +6,103 @@ import AstalBluetooth from 'gi://AstalBluetooth'; import Separator from '../misc/separator'; +/* Types */ +interface DevToggleProps { + label: string + prop: keyof AstalBluetooth.Device + onToggle: (active: boolean) => void +} + @register() export default class DeviceWidget extends Widget.Revealer { readonly dev: AstalBluetooth.Device; constructor({ dev }: { dev: AstalBluetooth.Device }) { + const bluetooth = AstalBluetooth.get_default(); + + const DevToggle = ({ label, prop, onToggle }: DevToggleProps) => ( + + + ); + const rev = ( - - TODO: add buttons here + + + + { + if (active) { + dev.connect_device(); + } + else { + dev.disconnect_device(); + } + }} + /> + + + + { + dev.set_trusted(active); + }} + /> + + + + { + if (active) { + dev.pair(); + } + else { + bluetooth.adapter.remove_device(dev); + } + }} + /> + + + + { + dev.set_blocked(active); + }} + /> + + ) as Widget.Revealer; @@ -61,6 +146,7 @@ export default class DeviceWidget extends Widget.Revealer { {button} {rev} + ), });