feat: add notification module with functionality to display notifications on focused monitor with a NotificationServer as Singleton
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user