diff --git a/services/Audio.qml b/services/Audio.qml index 100f0010..e2d936a0 100644 --- a/services/Audio.qml +++ b/services/Audio.qml @@ -2,6 +2,7 @@ pragma Singleton import QtQuick import Quickshell +import Quickshell.Io import Quickshell.Services.Pipewire import Caelestia import Caelestia.Services @@ -67,6 +68,15 @@ Singleton { Pipewire.preferredDefaultAudioSource = newSource; } + function cycleNextAudioOutput(): void { + if (sinks.length === 0) + return; + + const currentIndex = sinks.findIndex(s => s === sink); + const nextIndex = (currentIndex + 1) % sinks.length; + setAudioSink(sinks[nextIndex]); + } + function setStreamVolume(stream: PwNode, newVolume: real): void { if (stream?.ready && stream?.audio) { stream.audio.muted = false; @@ -162,4 +172,12 @@ Singleton { BeatTracker { id: beatTracker } + + IpcHandler { + function cycleOutput(): void { + root.cycleNextAudioOutput(); + } + + target: "audio" + } }