feat: add notification module with functionality to display notifications on focused monitor with a NotificationServer as Singleton

This commit is contained in:
Hannes
2026-08-25 01:00:52 +02:00
parent b9a455347d
commit 0b20e8eb85
6 changed files with 215 additions and 0 deletions
@@ -0,0 +1,50 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Services.Notifications
Item {
id: notificationServerState
property var focusedMonitor: null
property var newestNotification: null
property var trackedNotifications: [] // TODO
signal notificationReceived(var notification)
function correctMonitor(screen) {
return (Hyprland.monitorFor(screen) === focusedMonitor)
}
NotificationServer {
id: notificationServer
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
)
notificationReceived(notification)
Hyprland.refreshMonitors()
waitTimer.start()
}
}
Timer {
id: waitTimer
interval: 2000
repeat: false
onTriggered: focusedMonitor = Hyprland.focusedMonitor
}
}
@@ -0,0 +1 @@
singleton NotificationS NotificationServer.qml