From fb9a726ba0bd891a55bd319d83d5a64d5d223905 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 11 Sep 2025 09:48:13 +0200 Subject: [PATCH] bluetooth dialog: sort names before mac addresses --- .../bluetoothDevices/BluetoothDialog.qml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.config/quickshell/ii/modules/sidebarRight/bluetoothDevices/BluetoothDialog.qml b/.config/quickshell/ii/modules/sidebarRight/bluetoothDevices/BluetoothDialog.qml index b9ddcaa3a..f51053697 100644 --- a/.config/quickshell/ii/modules/sidebarRight/bluetoothDevices/BluetoothDialog.qml +++ b/.config/quickshell/ii/modules/sidebarRight/bluetoothDevices/BluetoothDialog.qml @@ -43,7 +43,20 @@ WindowDialog { animateAppearance: false model: ScriptModel { - values: [...Bluetooth.devices.values].sort((a, b) => (b.connected - a.connected) || (b.paired - a.paired)) + values: [...Bluetooth.devices.values].sort((a, b) => { + // Connected -> paired -> others + let conn = (b.connected - a.connected) || (b.paired - a.paired); + if (conn !== 0) return conn; + + // Ones with meaningful names before MAC addresses + const macRegex = /^([0-9A-Fa-f]{2}-){5}[0-9A-Fa-f]{2}$/; + const aIsMac = macRegex.test(a.name); + const bIsMac = macRegex.test(b.name); + if (aIsMac !== bIsMac) return aIsMac ? 1 : -1; + + // Alphabetical by name + return a.name.localeCompare(b.name); + }) } delegate: BluetoothDeviceItem { required property BluetoothDevice modelData