summaryrefslogtreecommitdiffstats
path: root/home-configuration/config/quickshell/modules/notifications/Notifications.qml
diff options
context:
space:
mode:
Diffstat (limited to 'home-configuration/config/quickshell/modules/notifications/Notifications.qml')
-rw-r--r--home-configuration/config/quickshell/modules/notifications/Notifications.qml125
1 files changed, 125 insertions, 0 deletions
diff --git a/home-configuration/config/quickshell/modules/notifications/Notifications.qml b/home-configuration/config/quickshell/modules/notifications/Notifications.qml
new file mode 100644
index 0000000..2965b90
--- /dev/null
+++ b/home-configuration/config/quickshell/modules/notifications/Notifications.qml
@@ -0,0 +1,125 @@
+import QtQuick
+import QtQuick.Layouts
+import Quickshell
+import Quickshell.Wayland
+import Quickshell.Services.Notifications
+import "../../config.js" as Config
+import "./"
+
+Item {
+ id: root
+
+ NotificationServer {
+ id: server
+
+ bodySupported: true
+ imageSupported: true
+ actionsSupported: true
+ actionIconsSupported: true
+ bodyMarkupSupported: true
+
+ onNotification: function(notification) {
+ console.log("NOTIFICATION")
+ console.log(" app:", notification.appName)
+ console.log(" summary:", notification.summary)
+ console.log(" body:", notification.body)
+ console.log(" actions:", notification.actions.length)
+
+ for (var i = 0; i < notification.actions.length; i++) {
+ console.log(
+ " action:",
+ notification.actions[i].identifier,
+ notification.actions[i].text
+ )
+ }
+
+ notification.tracked = true
+ }
+ }
+
+ NotificationFocus {
+ id: focus
+ }
+
+ function activateNotification(notification) {
+ if (!notification)
+ return
+
+ console.log(
+ "ACTIVATE:",
+ notification.appName,
+ notification.summary
+ )
+
+ focus.focusSource(notification)
+
+ for (var i = 0; i < notification.actions.length; i++) {
+ var action = notification.actions[i]
+
+ if (action.identifier === "default") {
+ console.log(
+ "Invoking default action:",
+ action.text
+ )
+
+ action.invoke()
+ return
+ }
+ }
+
+ console.log("No default action available")
+ notification.dismiss()
+ }
+
+ PanelWindow {
+ id: window
+
+ screen: Quickshell.screens.find(function(screen) {
+ return screen.name === Config.barOutput
+ })
+
+ anchors {
+ top: true
+ right: true
+ }
+
+ margins {
+ top: Config.notificationMarginTop
+ right: Config.notificationMarginRight
+ }
+
+ exclusionMode: ExclusionMode.Ignore
+
+ WlrLayershell.layer: WlrLayer.Overlay
+ WlrLayershell.namespace: "notifications"
+
+ color: "transparent"
+
+ implicitWidth: Config.notificationWidth
+ implicitHeight: list.implicitHeight
+
+ ColumnLayout {
+ id: list
+
+ anchors.top: parent.top
+ anchors.right: parent.right
+
+ width: Config.notificationWidth
+ spacing: Config.notificationSpacing
+
+ Repeater {
+ model: server.trackedNotifications
+
+ delegate: NotificationCard {
+ required property var modelData
+
+ notification: modelData
+
+ onActivated: {
+ root.activateNotification(modelData)
+ }
+ }
+ }
+ }
+ }
+}