const bluetooth = await Service.import("bluetooth") export function ConnectedList() { return Widget.Box({ class_name: "btdevices", setup: self => self.hook(bluetooth, self => { self.children = bluetooth.connected_devices .map(({ address, icon_name, name }) => Widget.EventBox({ child: Widget.Icon(icon_name + '-symbolic'), tooltip_text: name, on_primary_click: () => { bluetooth.getDevice(address).setConnection(false) }, })); self.visible = bluetooth.connected_devices.length > 0; }, 'notify::connected-devices'), }) } export default function Bluetooth() { return Widget.EventBox({ tooltip_text: bluetooth.bind('enabled').as(on => on ? 'Enabled' : 'Disabled'), child: Widget.Icon({ icon: bluetooth.bind('enabled').as(on => `bluetooth-${on ? 'active' : 'disabled'}-symbolic`), }) }) }