diff options
Diffstat (limited to 'desktop/modules/bluetooth/BluetoothModule.qml')
| -rw-r--r-- | desktop/modules/bluetooth/BluetoothModule.qml | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/desktop/modules/bluetooth/BluetoothModule.qml b/desktop/modules/bluetooth/BluetoothModule.qml new file mode 100644 index 0000000..84ac9a4 --- /dev/null +++ b/desktop/modules/bluetooth/BluetoothModule.qml @@ -0,0 +1,55 @@ +// Copyright (C) 2026 Danilo M. <danix@danix.xyz> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +import Quickshell +import Quickshell.Bluetooth +import Quickshell.Io +import QtQuick +import "../.." + +// Always active: the BlueZ backend pushes and there is no poll to gate. +// Referencing Bluetooth here instantiates it at shell start. +Module { + id: mod + + name: "bluetooth" + label: "Bluetooth" + alwaysActive: true + + readonly property var adapter: Bluetooth.defaultAdapter + readonly property var devices: Bluetooth.devices ? Bluetooth.devices.values : [] + readonly property var connectedDevices: devices.filter(d => d.connected) + readonly property var pairedDevices: devices.filter(d => d.paired && !d.connected) + readonly property var availableDevices: devices.filter(d => !d.paired) + + readonly property bool anyConnected: connectedDevices.length > 0 + + // Null for the first ~2s, then filled. Safe navigation everywhere. + icon: mod.adapter && mod.adapter.enabled ? "\uf293" : "\uf05e" + + function notify(title, body) { + notifyProc.command = ["notify-send", "--app-name=bluetooth", + "--urgency=critical", "--icon=error", title, body]; + notifyProc.running = false; + notifyProc.running = true; + } + + property Process notifyProc: Process {} + + tileContent: Component { BluetoothTile { bt: mod } } + + page: Component { + Page { + title: "Bluetooth" + BluetoothPage { width: parent.width; bt: mod } + } + } +} |
