From b47ac6dd8a88d2525ddf0c1d9d8b3c48adfcd783 Mon Sep 17 00:00:00 2001 From: FUFSoB Date: Tue, 23 Sep 2025 10:53:44 +0500 Subject: [PATCH] feat: set if respecting custom notif timeout --- Assets/settings-default.json | 3 ++- Commons/Settings.qml | 1 + Modules/Notification/Notification.qml | 1 + Modules/SettingsPanel/Tabs/NotificationsTab.qml | 8 ++++++++ Services/NotificationService.qml | 7 ++++++- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Assets/settings-default.json b/Assets/settings-default.json index 37d85a50..bad0e5f2 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -128,6 +128,7 @@ "monitors": [], "location": "top_right", "lastSeenTs": 0, + "respectExpireTimeout": false, "lowUrgencyDuration": 3, "normalUrgencyDuration": 8, "criticalUrgencyDuration": 15 @@ -181,4 +182,4 @@ "wallpaperChange": "", "darkModeChange": "" } -} \ No newline at end of file +} diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 1339f952..55f7a09f 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -249,6 +249,7 @@ Singleton { property list monitors: [] property string location: "top_right" property real lastSeenTs: 0 + property bool respectExpireTimeout: false property int lowUrgencyDuration: 3 property int normalUrgencyDuration: 8 property int criticalUrgencyDuration: 15 diff --git a/Modules/Notification/Notification.qml b/Modules/Notification/Notification.qml index 5c174f21..956bfd3a 100644 --- a/Modules/Notification/Notification.qml +++ b/Modules/Notification/Notification.qml @@ -39,6 +39,7 @@ Variants { screen: modelData WlrLayershell.namespace: "noctalia-notifications" + WlrLayershell.layer: WlrLayer.Top color: Color.transparent diff --git a/Modules/SettingsPanel/Tabs/NotificationsTab.qml b/Modules/SettingsPanel/Tabs/NotificationsTab.qml index 64093d49..b14f6275 100644 --- a/Modules/SettingsPanel/Tabs/NotificationsTab.qml +++ b/Modules/SettingsPanel/Tabs/NotificationsTab.qml @@ -89,6 +89,14 @@ ColumnLayout { description: "Configure how long notifications stay visible based on their urgency level." } + // Respect Expire Timeout (eg. --expire-time flag in notify-send) + NToggle { + label: "Respect expire timeout" + description: "Use the expire timeout set in the notification." + checked: Settings.data.notifications.respectExpireTimeout + onToggled: checked => Settings.data.notifications.respectExpireTimeout = checked + } + // Low Urgency Duration ColumnLayout { spacing: Style.marginXXS * scaling diff --git a/Services/NotificationService.qml b/Services/NotificationService.qml index f98e55c4..eb0fb3ba 100644 --- a/Services/NotificationService.qml +++ b/Services/NotificationService.qml @@ -192,7 +192,12 @@ Singleton { for (var i = activeList.count - 1; i >= 0; i--) { const notif = activeList.get(i) const elapsed = now - notif.timestamp.getTime() - const expire = notif.expireTimeout > 0 ? notif.expireTimeout : durations[notif.urgency] + var expire = 0 + + if (Settings.data.notifications?.respectExpireTimeout) + expire = notif.expireTimeout > 0 ? notif.expireTimeout : durations[notif.urgency] + else + expire = durations[notif.urgency] const progress = Math.max(1.0 - (elapsed / expire), 0.0) updateModel(activeList, notif.id, "progress", progress)