pragma Singleton import QtQuick import Quickshell import Quickshell.Io import Quickshell.Hyprland import Quickshell.Services.Notifications import "../../../config" Item { id: notificationServerState property var focusedMonitor: null property var newestNotification: null property bool soundEnabled: true signal notificationReceived(var notification) function correctMonitor(screen) { return (Hyprland.monitorFor(screen) === focusedMonitor) } Process { id: notificationSound command: ["pw-play", "--volume", "0.25", Config.configDir + "/modules/notification/assets/notification.ogg"] function play() { if (running) return console.log( "[NotificationSound] Playing:", Config.configDir + "/modules/notification/assets/notification.ogg" ) notificationSound.startDetached() } } NotificationServer { id: notificationServer actionsSupported: true bodyHyperlinksSupported: true bodyImagesSupported: true actionIconsSupported: true imageSupported: true persistenceSupported: true bodyMarkupSupported: true inlineReplySupported: true onNotification: function(notification) { // if(notification.lastGeneration){ // console.log( // "[NotificationServer] Closing Notification:", // notification.appName, notification.id, notification.summary, notification.body // ) // notification.dismiss() // return // } notification.tracked = true console.log( "[NotificationServer] Notification received:", notification.appName, notification.id, notification.summary, notification.body ) let timer = notificationTimerComponent.createObject( notificationServerState, { notification: notification } ) Hyprland.refreshMonitors() timer.start() } } Component { id: notificationTimerComponent Timer { required property var notification interval: 2000 repeat: false onTriggered: { focusedMonitor = Hyprland.focusedMonitor notificationReceived(notification) if(!notification.lastGeneration && notificationServerState.soundEnabled){ notificationSound.play() } // destroy() } } } Component.onCompleted: { focusedMonitor = Hyprland.focusedMonitor console.log("[NotificationServer]: Component completed") } }