feat(audiomanager): display all sinks

This commit is contained in:
Nydragon 2024-08-27 19:28:11 +02:00
parent 388d31b1ec
commit 16a5743c6a
Signed by: nydragon
SSH key fingerprint: SHA256:iQnIC12spf4QjWSbarmkD2No1cLMlu6TWoV7K6cYF5g
3 changed files with 18 additions and 16 deletions

View file

@ -10,8 +10,6 @@ import "windows"
// - adjust sink & source volume // - adjust sink & source volume
// - mute sinks & sources // - mute sinks & sources
// BUG: When controlling audio from outside of QS, the change is reflected, but if audio in pavucontrol is not 100%
// QS can only change from 0 to whatever is set in pavucontrol
Rectangle { Rectangle {
id: aoutput id: aoutput
width: parent.width width: parent.width
@ -65,6 +63,7 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
} }
Slider { Slider {
id: slider id: slider
anchors.top: icon.bottom anchors.top: icon.bottom
@ -72,9 +71,8 @@ Rectangle {
height: background.height height: background.height
width: parent.width * 0.75 width: parent.width * 0.75
enabled: false enabled: false
value: sink.audio.volume value: sink?.audio.volume ?? 0
stepSize: 0.01 stepSize: 0.01
wheelEnabled: true
contentItem: Rectangle { contentItem: Rectangle {
color: "#3191CD" // Change color based on value color: "#3191CD" // Change color based on value
@ -92,7 +90,6 @@ Rectangle {
} }
handle: Rectangle {} handle: Rectangle {}
onMoved: sink.audio.volume = value
} }
} }
} }

View file

@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Controls import QtQuick.Controls
import Quickshell.Services.Pipewire import Quickshell.Services.Pipewire
import Quickshell
RowLayout { RowLayout {
required property PwNode node required property PwNode node
@ -33,11 +34,14 @@ RowLayout {
spacing: 6 spacing: 6
Layout.preferredHeight: 30 Layout.preferredHeight: 30
Text { Label {
id: name
text: { text: {
const app = node.isStream ? `[${node.properties["application.name"]}] ` : ""; const app = node.isStream ? `[${node.properties["application.name"]}] ` : "";
return app + (node.properties["media.name"] ?? node.description); return app + (node.properties["media.name"] ?? node.description);
} }
// Cede space to other elements -> don't have stupidly long names detroying the layout
Layout.maximumWidth: 0
} }
Item { Item {
@ -61,6 +65,7 @@ RowLayout {
} }
Button { Button {
// TODO: setting a default sink is not implemented yet in QS
visible: node.isSink visible: node.isSink
text: "default" text: "default"
} }

View file

@ -26,16 +26,17 @@ PopupWindow {
contentWidth: availableWidth contentWidth: availableWidth
ColumnLayout { ColumnLayout {
// BUG: We access nodes before they are initialized
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 anchors.margins: 10
PwNodeLinkTracker { Repeater {
id: linkTracker model: Pipewire.nodes.values.filter(e => e.isSink)
node: Pipewire.defaultAudioSink
}
AudioEntry { AudioEntry {
node: Pipewire.defaultAudioSink required property PwNode modelData
node: modelData
}
} }
Rectangle { Rectangle {
@ -46,12 +47,11 @@ PopupWindow {
} }
Repeater { Repeater {
// Show all sources, regardless of what sink they are assigned to model: Pipewire.nodes.values.filter(e => e.isStream)
model: Pipewire.linkGroups
AudioEntry { AudioEntry {
required property PwLinkGroup modelData required property PwNode modelData
node: modelData.source node: modelData
} }
} }
} }