blob: 2965b90d84e36cfe01d7418941f83121019068b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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)
}
}
}
}
}
}
|