diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-18 14:57:11 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-18 14:57:11 +0200 |
| commit | b90bcb5ba7d7be8b80021b0332a646d016196743 (patch) | |
| tree | 3add080508f6fa0a261fe078fef52d33f4c39075 /desktop/island/StatusPill.qml | |
| parent | 1f6bd402b5d2ffef845129a327cae95113b23e55 (diff) | |
| download | quickshell-b90bcb5ba7d7be8b80021b0332a646d016196743.tar.gz quickshell-b90bcb5ba7d7be8b80021b0332a646d016196743.zip | |
island: headphones panel for Sony noise control
A headphones icon in the status pill, shown while Sony headphones are
connected, opens a panel in the capsule: battery, noise control tiles
(ANC, ambient, off), ambient level, focus on voice, the headphones' own
sink volume, power off and refresh.
Battery and volume need nothing new: BlueZ's Battery1 already reports the
charge, and volume is AVRCP through PipeWire, so the slider drives the
headphones' bluez_output node rather than the default sink. Only the mode
needs Sony's own protocol, which sonyctl speaks over RFCOMM with the
Python standard library. The headphones advertise the v2 MDR service on
channel 18 and answer an 8-byte init reply, which is the v2 shape.
What was measured on a WH-CH720N, and differs from what reading
Gadgetbridge alone suggested: the ambient subtype is 17, while 15 (what
Gadgetbridge sends to models without wind-noise reduction) is acked and
never answered; the set payload is 7 bytes, with no wind byte. Noise
cancelling has no strength, only on or off; a level sent with it is
ignored and the previous ambient level kept. Focus on voice reads back
as set. A connect right after the previous run closed fails with EBUSY,
so sonyctl retries it briefly.
Each call is about 2s, so the panel runs one at a time and sends the
ambient level only once the slider or wheel settles. The mode is re-read
on every open because the headphones' own button changes it too. Power
off was not exercised, to keep the headphones on during development.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/island/StatusPill.qml')
| -rw-r--r-- | desktop/island/StatusPill.qml | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/desktop/island/StatusPill.qml b/desktop/island/StatusPill.qml index 2202747..915807b 100644 --- a/desktop/island/StatusPill.qml +++ b/desktop/island/StatusPill.qml @@ -12,11 +12,13 @@ import Quickshell import Quickshell.Widgets import Quickshell.Services.SystemTray +import Quickshell.Bluetooth import QtQuick import ".." import "Logic.js" as Logic -// Volume icon, tray, layout flag. The volume icon opens its panel in this +// Headphones icon (while Sony headphones are connected), volume icon, tray, +// layout flag. The headphones and volume icons open their panels in this // capsule; the tray is a plain tray; the flag switches layout on scroll and // ignores clicks. Capsule { @@ -27,15 +29,22 @@ Capsule { required property QtObject window property string panel: "" + // ponytail: Sony headphones are recognised by their model prefix; sonyctl + // speaks only the v2 protocol, measured on a WH-CH720N. + readonly property var phones: (Bluetooth.devices?.values ?? []) + .find(d => d.connected && /^(WH|WF)-|^LinkBuds/.test(d.deviceName)) ?? null + signal openSound() + signal openHeadphones() + signal closePanel() signal openDrawer() // Emitted just before a tray menu opens; the menu cannot report its close. signal menuShown() - expanded: panel === "sound" + expanded: panel === "sound" || panel === "headphones" restWidth: restRow.implicitWidth + 24 panelWidth: 320 - panelHeight: soundPanel.implicitHeight + 28 + panelHeight: (panel === "headphones" ? phonesPanel.implicitHeight : soundPanel.implicitHeight) + 28 Row { @@ -47,6 +56,19 @@ Capsule { Behavior on opacity { NumberAnimation { duration: 120 } } IconImage { + visible: pill.phones !== null + anchors.verticalCenter: parent.verticalCenter + implicitSize: 18 + source: Quickshell.iconPath("audio-headphones", true) + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: pill.openHeadphones() + } + } + + IconImage { anchors.verticalCenter: parent.verticalCenter implicitSize: 18 source: Quickshell.iconPath(Logic.volumeIcon(pill.sound.volume, pill.sound.muted), true) @@ -122,4 +144,17 @@ Capsule { Behavior on opacity { NumberAnimation { duration: 160 } } onOpenDrawer: pill.openDrawer() } + + HeadphonesPanel { + id: phonesPanel + x: 14 + y: 14 + width: pill.panelWidth - 28 + device: pill.phones + open: pill.panel === "headphones" + onClose: pill.closePanel() + opacity: open ? 1 : 0 + visible: opacity > 0 + Behavior on opacity { NumberAnimation { duration: 160 } } + } } |
