1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
// 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.Services.Pipewire
import QtQuick
import "../.."
Column {
id: page
required property var service
signal back
spacing: 16
// A device's human name, most readable first.
function devLabel(n) {
if (!n) return "—";
return n.description || n.nickname || n.name || ("node " + n.id);
}
// The state glyph for a level row, the same shapes the OSD uses: a
// microphone for the input, a speaker whose fill follows the level for the
// output, red when muted.
function stateIcon(audio, input) {
if (input) return audio?.muted ? "\uf131" : "\uf130";
if (!audio || audio.muted || audio.volume <= 0) return "\uf026";
return audio.volume < 0.5 ? "\uf027" : "\uf028";
}
// Output and input. Each shows the current device, a slider for it, and an
// in-place device list that sets the default. The list expands within the
// page rather than opening a popup: a QtQuick.Controls popup is a separate
// window and does not position reliably on this layer surface.
Repeater {
model: [
{ label: "Output", node: page.service.sink, devices: page.service.outputs,
setDefault: n => Pipewire.preferredDefaultAudioSink = n },
{ label: "Input", node: page.service.source, devices: page.service.inputs,
setDefault: n => Pipewire.preferredDefaultAudioSource = n },
]
Column {
id: section
required property var modelData
readonly property var audio: modelData.node?.audio ?? null
property bool expanded: false
width: page.width
spacing: 6
Item {
width: parent.width
implicitHeight: name.implicitHeight
Text {
id: name
anchors.left: parent.left
text: modelData.label
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 1; bold: true }
color: Theme.text
}
// State glyph and level, clickable to mute/unmute.
Row {
id: levelRow
anchors { right: parent.right; verticalCenter: parent.verticalCenter }
spacing: 6
Text {
anchors.verticalCenter: parent.verticalCenter
text: page.stateIcon(audio, modelData.label === "Input")
font { family: Theme.fontFamily; pixelSize: Theme.fontSize }
color: audio?.muted ? Theme.red : Theme.accent
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: !audio ? "—" : audio.muted ? "muted" : Math.round(audio.volume * 100) + "%"
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 1 }
color: audio?.muted ? Theme.red : Theme.subtext
}
}
MouseArea {
anchors.fill: levelRow
enabled: audio !== null
cursorShape: Qt.PointingHandCursor
onClicked: if (audio) audio.muted = !audio.muted
}
}
// The current device; click to open the device list.
Item {
width: parent.width
implicitHeight: devRow.implicitHeight
Row {
id: devRow
width: parent.width
spacing: 6
Text {
width: parent.width - chevron.implicitWidth - parent.spacing
elide: Text.ElideRight
text: page.devLabel(modelData.node)
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
color: Theme.text
}
Text {
id: chevron
text: section.expanded ? "\uf077" : "\uf078"
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
color: Theme.overlay
}
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: section.expanded = !section.expanded
}
}
// The devices, expanded in place. The current one is highlighted;
// clicking a row makes it the default and folds the list away.
Column {
width: parent.width
spacing: 2
visible: section.expanded
Repeater {
model: section.modelData.devices
Rectangle {
required property var modelData
readonly property bool current: section.modelData.node === modelData
width: section.width
implicitHeight: devText.implicitHeight + 8
radius: 6
color: devArea.containsMouse ? Qt.alpha(Theme.accent, 0.18)
: current ? Qt.alpha(Theme.accent, 0.10) : "transparent"
Text {
id: devText
anchors {
left: parent.left; right: parent.right
verticalCenter: parent.verticalCenter
leftMargin: 8; rightMargin: 8
}
elide: Text.ElideRight
text: page.devLabel(modelData)
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3; bold: current }
color: current ? Theme.accent : Theme.text
}
MouseArea {
id: devArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
section.modelData.setDefault(modelData);
section.expanded = false;
}
}
}
}
}
// The meter. The hit area is taller than the 8px bar so it is easy
// to grab; preventStealing stops the page's Flickable taking the
// press, and the wheel is accepted here so the page does not scroll
// instead. Click sets, drag scrubs, wheel steps, wheel-up unmutes
// (the same thing the volume keybind does).
Item {
id: meter
width: parent.width
height: 20
readonly property real level: Math.min(audio?.volume ?? 0, 1)
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: 8
radius: 4
color: Theme.surface
Rectangle {
height: parent.height
radius: parent.radius
width: parent.width * meter.level
color: audio?.muted ? Theme.red : Theme.accent
opacity: audio?.muted ? 0.5 : 1
}
}
MouseArea {
anchors.fill: parent
enabled: audio !== null
preventStealing: true
cursorShape: Qt.PointingHandCursor
onPressed: mouse => set(mouse.x)
onPositionChanged: mouse => { if (pressed) set(mouse.x); }
onWheel: wheel => {
if (!audio || wheel.angleDelta.y === 0) return;
if (wheel.angleDelta.y > 0) {
audio.muted = false;
audio.volume = Math.min(1, audio.volume + 0.05);
} else {
audio.volume = Math.max(0, audio.volume - 0.05);
}
wheel.accepted = true;
}
function set(x) {
if (audio) audio.volume = Math.max(0, Math.min(1, x / width));
}
}
}
}
}
Rectangle { width: parent.width; height: 1; color: Qt.alpha(Theme.text, 0.12) }
// What is playing, with transport. Same Player singleton the OSD uses,
// so playerctld's duplicate is already filtered out by dbusName.
Column {
width: parent.width
spacing: 8
visible: Player.active
Text {
width: parent.width
elide: Text.ElideRight
text: Player.title || "Nothing playing"
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 1; bold: true }
color: Theme.text
}
Text {
width: parent.width
elide: Text.ElideRight
visible: Player.artist !== ""
text: Player.artist
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
color: Theme.subtext
}
Row {
spacing: 4
TransportButton {
glyph: ""
enabled: Player.current?.canGoPrevious ?? false
onClicked: Player.current?.previous()
}
TransportButton {
glyph: Player.playing ? "" : ""
enabled: Player.current?.canTogglePlaying ?? false
onClicked: Player.current?.togglePlaying()
}
TransportButton {
glyph: ""
enabled: Player.current?.canGoNext ?? false
onClicked: Player.current?.next()
}
}
}
}
|