feat: add notification sound and notification window enhancements. Ready for alpha.NotificationBody needs work
This commit is contained in:
@@ -2,15 +2,16 @@ 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 var trackedNotifications: [] // TODO
|
||||
|
||||
signal notificationReceived(var notification)
|
||||
|
||||
@@ -18,33 +19,69 @@ Item {
|
||||
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
|
||||
onNotification: function(notification) {
|
||||
if(notification.lastGeneration){
|
||||
console.log(
|
||||
"[NotificationServer] Closing Notification:",
|
||||
notification.appName, notification.id, notification.summary, notification.body
|
||||
)
|
||||
notification.dismiss()
|
||||
return
|
||||
}
|
||||
// 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)
|
||||
|
||||
let timer = notificationTimerComponent.createObject(
|
||||
notificationServerState,
|
||||
{ notification: notification }
|
||||
)
|
||||
|
||||
Hyprland.refreshMonitors()
|
||||
waitTimer.start()
|
||||
timer.start()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: waitTimer
|
||||
interval: 2000
|
||||
repeat: false
|
||||
onTriggered: focusedMonitor = Hyprland.focusedMonitor
|
||||
Component {
|
||||
id: notificationTimerComponent
|
||||
|
||||
Timer {
|
||||
required property var notification
|
||||
|
||||
interval: 2000
|
||||
repeat: false
|
||||
|
||||
onTriggered: {
|
||||
focusedMonitor = Hyprland.focusedMonitor
|
||||
notificationReceived(notification)
|
||||
if(!notification.lastGeneration){
|
||||
notificationSound.play()
|
||||
}
|
||||
|
||||
// destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
focusedMonitor = Hyprland.focusedMonitor
|
||||
console.log("[NotificationServer]: Component completed")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user