From 8784a015c2287a84eec226a32a9c11bfc95e8033 Mon Sep 17 00:00:00 2001 From: Soramane <61896496+soramanew@users.noreply.github.com> Date: Wed, 16 Jul 2025 23:49:45 +1000 Subject: bluetooth: use qs bluetooth --- services/Bluetooth.qml | 104 ------------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 services/Bluetooth.qml (limited to 'services') diff --git a/services/Bluetooth.qml b/services/Bluetooth.qml deleted file mode 100644 index 0769095..0000000 --- a/services/Bluetooth.qml +++ /dev/null @@ -1,104 +0,0 @@ -pragma Singleton - -import Quickshell -import Quickshell.Io -import QtQuick - -Singleton { - id: root - - property bool powered - property bool discovering - readonly property list devices: [] - - Process { - running: true - command: ["bluetoothctl"] - stdout: SplitParser { - onRead: { - getInfo.running = true; - getDevices.running = true; - } - } - } - - Process { - id: getInfo - - running: true - command: ["bluetoothctl", "show"] - environment: ({ - LANG: "C", - LC_ALL: "C" - }) - stdout: StdioCollector { - onStreamFinished: { - root.powered = text.includes("Powered: yes"); - root.discovering = text.includes("Discovering: yes"); - } - } - } - - Process { - id: getDevices - - running: true - command: ["fish", "-c", ` - for a in (bluetoothctl devices) - if string match -q 'Device *' $a - bluetoothctl info $addr (string split ' ' $a)[2] - echo - end - end`] - environment: ({ - LANG: "C", - LC_ALL: "C" - }) - stdout: StdioCollector { - onStreamFinished: { - const devices = text.trim().split("\n\n").map(d => ({ - name: d.match(/Name: (.*)/)[1], - alias: d.match(/Alias: (.*)/)[1], - address: d.match(/Device ([0-9A-Z:]{17})/)[1], - icon: d.match(/Icon: (.*)/)[1], - connected: d.includes("Connected: yes"), - paired: d.includes("Paired: yes"), - trusted: d.includes("Trusted: yes") - })); - const rDevices = root.devices; - - const destroyed = rDevices.filter(rd => !devices.find(d => d.address === rd.address)); - for (const device of destroyed) - rDevices.splice(rDevices.indexOf(device), 1).forEach(d => d.destroy()); - - for (const device of devices) { - const match = rDevices.find(d => d.address === device.address); - if (match) { - match.lastIpcObject = device; - } else { - rDevices.push(deviceComp.createObject(root, { - lastIpcObject: device - })); - } - } - } - } - } - - component Device: QtObject { - required property var lastIpcObject - readonly property string name: lastIpcObject.name - readonly property string alias: lastIpcObject.alias - readonly property string address: lastIpcObject.address - readonly property string icon: lastIpcObject.icon - readonly property bool connected: lastIpcObject.connected - readonly property bool paired: lastIpcObject.paired - readonly property bool trusted: lastIpcObject.trusted - } - - Component { - id: deviceComp - - Device {} - } -} -- cgit v1.2.3-freya