From 06659df98ec17e31491ae60b58abaf5f1af57604 Mon Sep 17 00:00:00 2001 From: Joshua Yuen Date: Sat, 12 Sep 2026 23:22:34 -0400 Subject: [PATCH] Restyle Bluetooth device rows to match wifi menu --- modules/home/ags/app/style.scss | 36 +------ modules/home/ags/app/widget/Bluetooth.tsx | 109 ++++++++++++---------- 2 files changed, 59 insertions(+), 86 deletions(-) diff --git a/modules/home/ags/app/style.scss b/modules/home/ags/app/style.scss index f722483..001a050 100644 --- a/modules/home/ags/app/style.scss +++ b/modules/home/ags/app/style.scss @@ -389,30 +389,6 @@ scale { background: $hover-overlay; } } - - switch { - background: $base03; - border-radius: 999px; - min-width: 34px; - min-height: 16px; - margin: 1px 0; - - slider { - background: $base05; - border-radius: 999px; - min-width: 12px; - min-height: 12px; - margin: 2px; - } - } - - switch:checked { - background: $primary-bg; - - slider { - background: $primary-fg; - } - } } .wifi-status, @@ -442,15 +418,9 @@ scale { } } -.device-item { - padding: 5px 7px; - border-radius: 6px; +.device-row { margin: 1px 0; - icon { - font-size: 16px; - } - .device-name { margin: 0 6px; } @@ -466,10 +436,6 @@ scale { opacity: 0.7; margin-right: 2px; } - - &:hover { - background: $hover-overlay; - } } // media player card diff --git a/modules/home/ags/app/widget/Bluetooth.tsx b/modules/home/ags/app/widget/Bluetooth.tsx index edecac8..4d1c2b2 100644 --- a/modules/home/ags/app/widget/Bluetooth.tsx +++ b/modules/home/ags/app/widget/Bluetooth.tsx @@ -48,64 +48,71 @@ const pillLabel = Variable.derive( ) // ported from AlfheimOS: icon, name, battery, busy icon while connecting, -// switch reflecting the bluez connected state +// whole row toggles the bluez connected state function DeviceItem(device: AstalBluetooth.Device) { const battery = bind(device, "battery_percentage") const connecting = bind(device, "connecting") + const connected = Variable.derive( + [bind(device, "connected"), connecting], + (c, busy) => c && !busy, + ) // bluez reports br-connection-busy when attempts pile up, so debounce let lastAttempt = 0 + + function toggle() { + if (connecting.get()) return + // skip retries within the debounce window + const now = Date.now() + if (now - lastAttempt < 1500) return + lastAttempt = now + const state = !device.connected + // bluez rejects connects while the controller is busy scanning + if (state) setDiscovery(false) + // vala async: begin with a callback, finish() throws + const done = (_source: AstalBluetooth.Device, res: Gio.AsyncResult) => { + try { + if (state) device.connect_device_finish(res) + else device.disconnect_device_finish(res) + } catch (e) { + console.error(e) + } + } + if (state) device.connect_device(done) + else device.disconnect_device(done) + } + return ( - - -