repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

skill(quickshell): add notification daemon example (08)

33cea99deb0061c09cc72d67c2bcde87aba4d355

Review <review@example.invalid> ·

unsigned

Browse filesCompare with HEAD

Changed files (1)

skills/quickshell/examples/08-notification-daemon/shell.qml

Added
new file mode 100644
1 +// 08-notification-daemon/shell.qml
2 +// A minimal notification daemon. Replaces mako/dunst/swaync.
3 +// Run with: qs -p examples/08-notification-daemon/shell.qml
4 +// After starting, trigger a notify-send to test:
5 +// notify-send "Hello" "This is a test"
6 +//
7 +// To replace your real notification daemon: stop mako/dunst, then run this.
9 +import QtQuick
10 +import Quickshell
11 +import Quickshell.Services.Notifications
13 +Scope {
14 + id: root
16 + // The server registers itself on the DBus session bus as a notification daemon.
17 + NotificationServer {
18 + id: server
20 + // Optional capability hints (advertise what we support).
21 + actionsSupported: true
22 + bodyMarkupSupported: true
23 + persistenceSupported: true
24 + bodyHyperlinksSupported: true
25 + bodyImagesSupported: true
26 + inlineReplySupported: true
27 + keepOnReload: true
29 + // Keep the notification around (otherwise it's auto-dismissed on emit).
30 + onNotification: (notification) => {
31 + notification.tracked = true
32 + // Schedule auto-dismiss after expireTimeout.
33 + if (notification.expireTimeout > 0) {
34 + dismissTimer(notification)
35 + }
36 + }
37 + }
39 + // Helper: dismiss a notification after N ms.
40 + function dismissTimer(notif) {
41 + const ms = notif.expireTimeout * 1000
42 + expireTimer.createObject(root, {
43 + target: notif,
44 + interval: ms
45 + })
46 + }
48 + Component {
49 + id: expireTimer
50 + Timer {
51 + property var target: null
52 + running: true
53 + repeat: false
54 + onTriggered: if (target) target.tracked = false
55 + }
56 + }
58 + // Render each tracked notification as a panel.
59 + Repeater {
60 + model: server.trackedNotifications
61 + delegate: PanelWindow {
62 + id: popupWindow
63 + required property var modelData // the Notification
65 + // Stack each popup above the previous one.
66 + anchors.bottom: true
67 + margins.bottom: 30 + (index * 80)
68 + exclusiveZone: 0
70 + implicitWidth: 360
71 + implicitHeight: 80
72 + color: "transparent"
73 + mask: Region {} // click-through
75 + Rectangle {
76 + anchors.fill: parent
77 + radius: 8
78 + color: "#dd1e1e2e"
79 + border.color: "#444"
80 + border.width: 1
82 + Column {
83 + anchors.fill: parent
84 + anchors.margins: 12
85 + spacing: 4
87 + Text {
88 + text: popupWindow.modelData ? popupWindow.modelData.summary : ""
89 + color: "white"
90 + font.pointSize: 12
91 + font.bold: true
92 + elide: Text.ElideRight
93 + width: parent.width
94 + }
95 + Text {
96 + text: popupWindow.modelData ? popupWindow.modelData.body : ""
97 + color: "#ccc"
98 + font.pointSize: 10
99 + wrapMode: Text.Wrap
100 + width: parent.width
101 + visible: text.length > 0