audio: add default output sink cycle ipc (#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>
This commit is contained in:
parent
148417baa1
commit
49695f8fd0
1 changed files with 18 additions and 0 deletions
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue