diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-29 20:47:06 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-29 20:47:06 +1000 |
| commit | 0d5389a6873fc69080a3f452ca22c57b0c9cb199 (patch) | |
| tree | 1a770ad6e37b5372436ef00b779bff8bc67743de /services | |
| parent | feat: bar system tray (diff) | |
| download | caelestia-shell-0d5389a6873fc69080a3f452ca22c57b0c9cb199.tar.gz caelestia-shell-0d5389a6873fc69080a3f452ca22c57b0c9cb199.tar.bz2 caelestia-shell-0d5389a6873fc69080a3f452ca22c57b0c9cb199.zip | |
bluetooth: fix devices
Also add animation for bar bluetooth devices
Diffstat (limited to 'services')
| -rw-r--r-- | services/Bluetooth.qml | 29 |
1 files changed, 16 insertions, 13 deletions
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<Device> devices: [] + property list<Device> devices: [] readonly property list<Device> 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); } } } |