Skip to content

Commit 49695f8

Browse files
PixelKhaosgithub-actions[bot]soramanew
authored
audio: add default output sink cycle ipc (caelestia-dots#1200)
* [CI] chore: update flake * [CI] chore: update flake * [CI] chore: update flake * [CI] chore: update flake * audio: added default audio output cycle IPC * fix format --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
1 parent 148417b commit 49695f8

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

services/Audio.qml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pragma Singleton
22

33
import QtQuick
44
import Quickshell
5+
import Quickshell.Io
56
import Quickshell.Services.Pipewire
67
import Caelestia
78
import Caelestia.Services
@@ -67,6 +68,15 @@ Singleton {
6768
Pipewire.preferredDefaultAudioSource = newSource;
6869
}
6970

71+
function cycleNextAudioOutput(): void {
72+
if (sinks.length === 0)
73+
return;
74+
75+
const currentIndex = sinks.findIndex(s => s === sink);
76+
const nextIndex = (currentIndex + 1) % sinks.length;
77+
setAudioSink(sinks[nextIndex]);
78+
}
79+
7080
function setStreamVolume(stream: PwNode, newVolume: real): void {
7181
if (stream?.ready && stream?.audio) {
7282
stream.audio.muted = false;
@@ -162,4 +172,12 @@ Singleton {
162172
BeatTracker {
163173
id: beatTracker
164174
}
175+
176+
IpcHandler {
177+
function cycleOutput(): void {
178+
root.cycleNextAudioOutput();
179+
}
180+
181+
target: "audio"
182+
}
165183
}

0 commit comments

Comments
 (0)