import Quickshell import Quickshell.Io import Quickshell.Services.Pipewire Scope { id: root SocketServer { active: true path: `${Quickshell.env("XDG_RUNTIME_DIR")}/shell.sock` handler: Socket { parser: SplitParser { onRead: line => { try { const command = JSON.parse(line); if (command.Volume) root.onCommandVolume(command.Volume); else console.warn("UnixIPC: Command not handled:", JSON.stringify(command)); } catch (e) { console.warn("UnixIPC: Failed to parse command:", line, e); } } } onError: e => { if (e == 1) return; console.warn("QLocalSocket::LocalSocketError", e); } } } PwObjectTracker { objects: [ Pipewire.defaultAudioSink, Pipewire.defaultAudioSource ] } function onCommandVolume(command) { if (command.muted === "toggle") Pipewire.defaultAudioSink.audio.muted = !Pipewire.defaultAudioSink.audio.muted; if (command.volume === "up") Pipewire.defaultAudioSink.audio.volume += 0.02; if (command.volume === "down") Pipewire.defaultAudioSink.audio.volume -= 0.02; if (command["mic-muted"] === "toggle") Pipewire.defaultAudioSource.audio.muted = !Pipewire.defaultAudioSource.audio.muted; } }