44 lines
1.3 KiB
QML
44 lines
1.3 KiB
QML
pragma Singleton
|
|
|
|
// Shared PipeWire device discovery and default selection. Quick Settings and
|
|
// Panama Settings intentionally use this same boundary so they cannot disagree
|
|
// about what counts as an input or which node should become the default.
|
|
|
|
import Quickshell
|
|
import Quickshell.Services.Pipewire
|
|
import QtQuick
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
readonly property var outputs: Pipewire.nodes.values.filter(node =>
|
|
!node.isStream && node.isSink)
|
|
|
|
readonly property var inputs: Pipewire.nodes.values.filter(node =>
|
|
!node.isStream
|
|
&& (node.type & PwNodeType.AudioSource) === PwNodeType.AudioSource)
|
|
|
|
function nodes(output: bool): var {
|
|
return output ? root.outputs : root.inputs;
|
|
}
|
|
|
|
function current(output: bool): var {
|
|
return output ? Pipewire.defaultAudioSink : Pipewire.defaultAudioSource;
|
|
}
|
|
|
|
function select(output: bool, node: var): void {
|
|
if (!node)
|
|
return;
|
|
if (output)
|
|
Pipewire.preferredDefaultAudioSink = node;
|
|
else
|
|
Pipewire.preferredDefaultAudioSource = node;
|
|
}
|
|
|
|
function label(node: var): string {
|
|
if (!node)
|
|
return "Unknown device";
|
|
return node.description || node.nickname || node.name || "Unknown device";
|
|
}
|
|
}
|