summaryrefslogtreecommitdiff
path: root/services/Notifs.qml
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-10 17:31:04 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-10 17:31:04 +1000
commit6b64c8a91804058fea99ed6944753758ee92c543 (patch)
tree9bf1d152c1f7e2135515e8302c93821d3e29b184 /services/Notifs.qml
parentlauncher: better style (diff)
downloadcaelestia-shell-6b64c8a91804058fea99ed6944753758ee92c543.tar.gz
caelestia-shell-6b64c8a91804058fea99ed6944753758ee92c543.tar.bz2
caelestia-shell-6b64c8a91804058fea99ed6944753758ee92c543.zip
feat: basic notifications
Also fix pixel issue with notif area background Add more log rules to run script
Diffstat (limited to 'services/Notifs.qml')
-rw-r--r--services/Notifs.qml76
1 files changed, 76 insertions, 0 deletions
diff --git a/services/Notifs.qml b/services/Notifs.qml
new file mode 100644
index 0000000..965e4f3
--- /dev/null
+++ b/services/Notifs.qml
@@ -0,0 +1,76 @@
+pragma Singleton
+
+import "root:/config"
+import Quickshell
+import Quickshell.Services.Notifications
+import QtQuick
+
+Singleton {
+ id: root
+
+ readonly property list<Notif> list: []
+
+ NotificationServer {
+ id: server
+
+ keepOnReload: false
+ actionsSupported: true
+ bodyHyperlinksSupported: true
+ bodyImagesSupported: true
+ bodyMarkupSupported: true
+ imageSupported: true
+
+ onNotification: notif => {
+ notif.tracked = true;
+
+ root.list.push(notifComp.createObject(root, {
+ popup: true,
+ notification: notif
+ }));
+ }
+ }
+
+ component Notif: QtObject {
+ id: notif
+
+ property bool popup
+ readonly property date time: new Date()
+ readonly property string timeStr: {
+ const diff = Time.date.getTime() - time.getTime();
+ const m = Math.floor(diff / 60000);
+ const h = Math.floor(m / 60);
+
+ if (h < 1 && m < 1)
+ return "now";
+ if (h < 1)
+ return `${m}m`;
+ return `${h}h`;
+ }
+
+ required property Notification notification
+ readonly property string summary: notification.summary
+ readonly property string body: notification.body
+ readonly property string appIcon: notification.appIcon
+ readonly property string image: notification.image
+
+ readonly property Timer timer: Timer {
+ running: true
+ interval: notif.notification.expireTimeout > 0 ? notif.notification.expireTimeout : NotifsConfig.defaultExpireTimeout
+ onTriggered: notif.popup = false
+ }
+
+ readonly property Connections conn: Connections {
+ target: notif.notification
+
+ function onClosed(): void {
+ notif.destroy();
+ }
+ }
+ }
+
+ Component {
+ id: notifComp
+
+ Notif {}
+ }
+}