Quickshell marks playback streams as sinks, so the mixer showed recording streams instead of players. Right-clicking Sound now shows only the app sliders; Microphone no longer extends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.8 KiB
QML
70 lines
2.8 KiB
QML
pragma Singleton
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Services.Pipewire
|
|
|
|
Singleton {
|
|
id: root
|
|
property var backend: Pipewire
|
|
readonly property var sink: backend.defaultAudioSink
|
|
readonly property var source: backend.defaultAudioSource
|
|
readonly property var outputs: backend.nodes.values.filter(n => n.audio && n.isSink && !n.isStream)
|
|
readonly property var inputs: backend.nodes.values.filter(n => n.audio && !n.isSink && !n.isStream)
|
|
// App playback streams, e.g. the players EasyEffects processes. Quickshell
|
|
// marks playback streams (Stream/Output/Audio) as sinks.
|
|
readonly property var streams: backend.nodes.values.filter(n => n.audio && n.isStream && n.isSink)
|
|
readonly property bool available: backend.ready
|
|
// Views listing streams hold a Demand on this, so their volumes are only
|
|
// tracked while shown.
|
|
property int streamConsumers: 0
|
|
PwObjectTracker {
|
|
objects: root.backend === Pipewire ? [root.sink, root.source].filter(n => n !== null).concat(root.streamConsumers > 0 ? root.streams : []) : []
|
|
}
|
|
function streamName(node) {
|
|
const p = node && node.properties || {};
|
|
return p["application.name"] || node.description || p["media.name"] || node.name || "Unknown";
|
|
}
|
|
// Icon path: the stream's own icon name, else its app's desktop entry.
|
|
function streamIcon(node) {
|
|
const p = node && node.properties || {};
|
|
const named = p["application.icon-name"] ? Quickshell.iconPath(p["application.icon-name"], true) : "";
|
|
return named || ApplicationsService.icon(ApplicationsService.byId(p["application.process.binary"] || "") || ApplicationsService.byId(p["application.name"] || ""));
|
|
}
|
|
function streamVolume(node, value) {
|
|
if (!node || !node.audio || !Number.isFinite(value))
|
|
return false;
|
|
node.audio.volume = Math.max(0, Math.min(1, value));
|
|
return true;
|
|
}
|
|
function streamMute(node) {
|
|
if (!node || !node.audio)
|
|
return false;
|
|
node.audio.muted = !node.audio.muted;
|
|
return true;
|
|
}
|
|
function volume(input, value) {
|
|
const node = input ? source : sink;
|
|
if (!node || !node.audio || !Number.isFinite(value))
|
|
return false;
|
|
node.audio.volume = Math.max(0, Math.min(1, value));
|
|
return true;
|
|
}
|
|
function mute(input) {
|
|
const node = input ? source : sink;
|
|
if (!node || !node.audio)
|
|
return false;
|
|
node.audio.muted = !node.audio.muted;
|
|
return true;
|
|
}
|
|
function select(input, index) {
|
|
const node = (input ? inputs : outputs)[index];
|
|
if (!node)
|
|
return false;
|
|
if (input)
|
|
backend.preferredDefaultAudioSource = node;
|
|
else
|
|
backend.preferredDefaultAudioSink = node;
|
|
return true;
|
|
}
|
|
}
|