(defvar reveal_bluetooth false) (defpoll bluetooth_active :initial true :interval "5s" 'scripts/bar/bt-status') (defwidget bluetooth [] (revealer-on-hover :revealvar reveal_bluetooth :revealvar-name "reveal_bluetooth" (button :onclick 'blueman-manager' :class {bluetooth_active ? "active" : ""} "") (bluetooth_children :array btDeviceArray))) (defpoll btDeviceArray :initial "${[{ "name": "dummy", "connected": "no", "icon": " ", "address": "00:00:00:00:00:00" }]}" :interval "5s" 'scripts/bar/bt-devices') (defwidget bluetooth_children [array] (box :class "reveal_children" :orientation "h" :space-evenly true :halign "start" (for device in array (button :onclick {(device.connected == "yes") ? 'bluetoothctl disconnect "${device.address}"' : 'bluetoothctl connect "${device.address}"'} :class {(device.connected == "yes") ? "active" : ""} "${device.icon}"))))