summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2025-09-09 21:40:07 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2025-09-09 21:40:07 +0200
commit9fab3828698199718a3d2f2faf8826f77d9258f7 (patch)
tree6e6d567a3877b425bdd0329e898cd00013c766fb /accounts/gkleen@sif/shell/quickshell/UnixIPC.qml
parentdf1632d1c15cba4b7a361f8159b9988919ef8277 (diff)
downloadnixos-9fab3828698199718a3d2f2faf8826f77d9258f7.tar
nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.tar.gz
nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.tar.bz2
nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.tar.xz
nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.zip
...
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/UnixIPC.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/UnixIPC.qml49
1 files changed, 49 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml b/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml
new file mode 100644
index 00000000..7b308ec0
--- /dev/null
+++ b/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml
@@ -0,0 +1,49 @@
1import Quickshell
2import Quickshell.Io
3import Quickshell.Services.Pipewire
4
5Scope {
6 id: root
7
8 SocketServer {
9 active: true
10 path: `${Quickshell.env("XDG_RUNTIME_DIR")}/shell.sock`
11 handler: Socket {
12 parser: SplitParser {
13 onRead: line => {
14 try {
15 const command = JSON.parse(line);
16
17 if (command.Volume)
18 root.onCommandVolume(command.Volume);
19 else
20 console.warn("UnixIPC: Command not handled:", JSON.stringify(command));
21 } catch (e) {
22 console.warn("UnixIPC: Failed to parse command:", line, e);
23 }
24 }
25 }
26
27 onError: e => {
28 if (e == 1)
29 return;
30 console.warn("QLocalSocket::LocalSocketError", e);
31 }
32 }
33 }
34
35 PwObjectTracker {
36 objects: [ Pipewire.defaultAudioSink, Pipewire.defaultAudioSource ]
37 }
38 function onCommandVolume(command) {
39 if (command.muted === "toggle")
40 Pipewire.defaultAudioSink.audio.muted = !Pipewire.defaultAudioSink.audio.muted;
41 if (command.volume === "up")
42 Pipewire.defaultAudioSink.audio.volume += 0.02;
43 if (command.volume === "down")
44 Pipewire.defaultAudioSink.audio.volume -= 0.02;
45
46 if (command["mic-muted"] === "toggle")
47 Pipewire.defaultAudioSource.audio.muted = !Pipewire.defaultAudioSource.audio.muted;
48 }
49}