From 0d5389a6873fc69080a3f452ca22c57b0c9cb199 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Tue, 29 Apr 2025 20:47:06 +1000 Subject: bluetooth: fix devices Also add animation for bar bluetooth devices --- services/Bluetooth.qml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'services') diff --git a/services/Bluetooth.qml b/services/Bluetooth.qml index d749879..bff44bd 100644 --- a/services/Bluetooth.qml +++ b/services/Bluetooth.qml @@ -9,14 +9,17 @@ Singleton { property bool powered property bool discovering - readonly property list devices: [] + property list devices: [] readonly property list connected: devices.filter(d => d.connected) Process { running: true command: ["bluetoothctl"] stdout: SplitParser { - onRead: getInfo.running = true + onRead: { + getInfo.running = true; + getDevices.running = true; + } } } @@ -35,19 +38,19 @@ Singleton { Process { id: getDevices running: true - command: ["fish", "-c", `for a in (bluetoothctl devices | cut -d ' ' -f 2); bluetoothctl info $a | jq -R 'reduce (inputs / ":") as [$key, $value] ({}; .[$key | ltrimstr("\t")] = ($value | ltrimstr(" ")))' | jq -c --arg addr $a '.Address = $addr'; end`] + command: ["fish", "-c", `for a in (bluetoothctl devices | cut -d ' ' -f 2); bluetoothctl info $a | jq -R 'reduce (inputs / ":") as [$key, $value] ({}; .[$key | ltrimstr("\t")] = ($value | ltrimstr(" ")))' | jq -c --arg addr $a '.Address = $addr'; end | jq -sc`] stdout: SplitParser { onRead: data => { - const d = JSON.parse(data); - root.devices.push(deviceComp.createObject(root, { - name: d.Name, - alias: d.Alias, - address: d.Address, - icon: d.Icon, - connected: d.Connected === "yes", - paired: d.Paired === "yes", - trusted: d.Trusted === "yes" - })); + const devices = JSON.parse(data); + root.devices = devices.map(d => deviceComp.createObject(root, { + name: d.Name, + alias: d.Alias, + address: d.Address, + icon: d.Icon, + connected: d.Connected === "yes", + paired: d.Paired === "yes", + trusted: d.Trusted === "yes" + })).filter(d => d); } } } -- cgit v1.2.3-freya