From 666464567055a2e4ba9f6bb310e901cdc27977f7 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 12 Sep 2025 22:01:51 +0200 Subject: ... --- accounts/gkleen@sif/shell/quickshell/UnixIPC.qml | 58 ++++++++++++++++-------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'accounts/gkleen@sif/shell/quickshell/UnixIPC.qml') diff --git a/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml b/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml index 4ec5186c..e19ccfb1 100644 --- a/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml +++ b/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml @@ -15,26 +15,32 @@ Scope { handler: Socket { parser: SplitParser { onRead: line => { - try { - const command = JSON.parse(line); + const command = (() => { + try { + return JSON.parse(line); + } catch (e) { + console.warn("UnixIPC: Failed to parse command:", line, e); + } + })(); + if (!command) + return; - if (command.Volume) - root.onCommandVolume(command.Volume); - else if (command.Brightness) - root.onCommandBrightness(command.Brightness); - else if (command.LockSession) - Custom.Systemd.lockSession(); - else if (command.Suspend) - Custom.Systemd.suspend(); - else if (command.Hibernate) - Custom.Systemd.hibernate(); - else if (command.Mpris) - root.onCommandMpris(command.Mpris); - else - console.warn("UnixIPC: Command not handled:", JSON.stringify(command)); - } catch (e) { - console.warn("UnixIPC: Failed to parse command:", line, e); - } + if (command.Volume) + root.onCommandVolume(command.Volume); + else if (command.Brightness) + root.onCommandBrightness(command.Brightness); + else if (command.LockSession) + Custom.Systemd.lockSession(); + else if (command.Suspend) + Custom.Systemd.suspend(); + else if (command.Hibernate) + Custom.Systemd.hibernate(); + else if (command.Mpris) + root.onCommandMpris(command.Mpris); + else if (command.Notifications) + root.onCommandNotifications(command.Notifications); + else + console.warn("UnixIPC: Command not handled:", JSON.stringify(command)); } } @@ -75,5 +81,17 @@ Scope { player.pause(); }); } - Binding { target: MprisProxy; } + Component.onCompleted: { (_ => {})(MprisProxy.players); } + + function onCommandNotifications(command) { + if (command.DismissGroup && !NotificationManager.displayInhibited) { + if (NotificationManager.groups.length > 0) + for (const notif of [...NotificationManager.groups[0]]) + notif.dismiss(); + } + if (command.DismissAll && !NotificationManager.displayInhibited) { + for (const notif of [...NotificationManager.trackedNotifications.values]) + notif.dismiss(); + } + } } -- cgit v1.2.3