diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-20 11:45:08 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-20 11:45:08 +0200 |
| commit | 59c4a841b7107f6b21bcd1c8f120c8caf1bd2d7c (patch) | |
| tree | 868891e386c2e7597a3364aaed8c752c7a245469 /desktop/modules/bluetooth/BluetoothRow.qml | |
| parent | eba0c13ad2f50964b6f88950366cb659c0d8b055 (diff) | |
| download | quickshell-59c4a841b7107f6b21bcd1c8f120c8caf1bd2d7c.tar.gz quickshell-59c4a841b7107f6b21bcd1c8f120c8caf1bd2d7c.zip | |
feat(desktop): read gamepad battery from power_supply
BluetoothRow only read BluetoothDevice.battery, which is BlueZ's
org.bluez.Battery1. A gamepad never publishes that interface: a Sony pad
exposes its charge as a kernel power_supply instead, so the percentage never
appeared.
Read every power_supply whose name ends in a MAC on a 30s timer while
anything is connected, keyed by address. BlueZ still wins when it has a
value.
Diffstat (limited to 'desktop/modules/bluetooth/BluetoothRow.qml')
| -rw-r--r-- | desktop/modules/bluetooth/BluetoothRow.qml | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/desktop/modules/bluetooth/BluetoothRow.qml b/desktop/modules/bluetooth/BluetoothRow.qml index a7aecd0..297dc02 100644 --- a/desktop/modules/bluetooth/BluetoothRow.qml +++ b/desktop/modules/bluetooth/BluetoothRow.qml @@ -20,6 +20,14 @@ Rectangle { required property var bt required property var device + // BlueZ's org.bluez.Battery1 pushes a live value when the device reports + // one. A gamepad does not, so fall back to the module's power_supply map. + // Null means neither source knows, and the field stays hidden. + readonly property var battPct: { + if (row.device.batteryAvailable) return Math.round((row.device.battery ?? 0) * 100); + return row.bt.batteryFor(row.device.address); + } + implicitHeight: col.implicitHeight + 16 radius: 8 color: device.connected ? Qt.alpha(Theme.accent, 0.10) : Qt.alpha(Theme.surface, 0.35) @@ -49,8 +57,8 @@ Rectangle { Text { anchors.verticalCenter: parent.verticalCenter - visible: row.device.batteryAvailable ?? false - text: Math.round((row.device.battery ?? 0) * 100) + "%" + visible: row.battPct !== null + text: row.battPct + "%" font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 } color: Theme.overlay } |
