Skip to content

Commit 7d0bfb6

Browse files
committed
mixer: add example
1 parent b9e744b commit 7d0bfb6

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

mixer/MixerEntry.qml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import QtQuick
2+
import QtQuick.Layouts
3+
import QtQuick.Controls
4+
import Quickshell.Services.Pipewire
5+
6+
ColumnLayout {
7+
required property PwNode node;
8+
9+
// bind the node so we can read its properties
10+
PwObjectTracker { objects: [ node ] }
11+
12+
RowLayout {
13+
Image {
14+
visible: source != ""
15+
source: {
16+
const icon = node.properties["application.icon-name"] ?? "audio-volume-high-symbolic";
17+
return `image://icon/${icon}`;
18+
}
19+
20+
sourceSize.width: 20
21+
sourceSize.height: 20
22+
}
23+
24+
Label {
25+
text: {
26+
// application.name -> description -> name
27+
const app = node.properties["application.name"] ?? (node.description != "" ? node.description : node.name);
28+
const media = node.properties["media.name"];
29+
return media != undefined ? `${app} - ${media}` : app;
30+
}
31+
}
32+
33+
Button {
34+
text: node.audio.muted ? "unmute" : "mute"
35+
onClicked: node.audio.muted = !node.audio.muted
36+
}
37+
}
38+
39+
RowLayout {
40+
Label {
41+
Layout.preferredWidth: 50
42+
text: `${Math.floor(node.audio.volume * 100)}%`
43+
}
44+
45+
Slider {
46+
Layout.fillWidth: true
47+
value: node.audio.volume
48+
onValueChanged: node.audio.volume = value
49+
}
50+
}
51+
}

mixer/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Audio mixer
2+
3+
This is a simple audio mixer built with the pipewire API.
4+
5+
You can run the mixer with `quickshell -p shell.qml`.
6+
7+
![](./image.png)

mixer/image.png

42.2 KB
Loading

mixer/shell.qml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import QtQuick.Layouts
4+
import Quickshell
5+
import Quickshell.Services.Pipewire
6+
7+
ShellRoot {
8+
FloatingWindow {
9+
// match the system theme background color
10+
color: contentItem.palette.active.window
11+
12+
ScrollView {
13+
anchors.fill: parent
14+
contentWidth: availableWidth
15+
16+
ColumnLayout {
17+
anchors.fill: parent
18+
anchors.margins: 10
19+
20+
// get a list of nodes that output to the default sink
21+
PwNodeLinkTracker {
22+
id: linkTracker
23+
node: Pipewire.defaultAudioSink
24+
}
25+
26+
MixerEntry {
27+
node: Pipewire.defaultAudioSink
28+
}
29+
30+
Rectangle {
31+
Layout.fillWidth: true
32+
color: palette.active.text
33+
implicitHeight: 1
34+
}
35+
36+
Repeater {
37+
model: linkTracker.linkGroups
38+
39+
MixerEntry {
40+
required property PwLinkGroup modelData
41+
// Each link group contains a source and a target.
42+
// Since the target is the default sink, we want the source.
43+
node: modelData.source
44+
}
45+
}
46+
}
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)