From 9358f8fe6e6d03cba679e48d23de1ea6edbec521 Mon Sep 17 00:00:00 2001 From: Damocles Date: Mon, 13 Apr 2026 15:35:12 +0200 Subject: [PATCH] notifications: disableable popups, configurable max popup count --- modules/Modules.qml | 4 +++- modules/NotifPopup.qml | 2 +- modules/NotifService.qml | 9 +++++++++ nix/hm-module.nix | 10 ++++++++++ shell.qml | 7 +++++-- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/Modules.qml b/modules/Modules.qml index c385754..3be68c1 100644 --- a/modules/Modules.qml +++ b/modules/Modules.qml @@ -21,7 +21,9 @@ QtObject { }) property var notifications: ({ enable: true, - timeout: 3000 + timeout: 3000, + popups: true, + maxPopups: 4 }) property var mpris: ({ enable: true diff --git a/modules/NotifPopup.qml b/modules/NotifPopup.qml index 09db576..0720c85 100644 --- a/modules/NotifPopup.qml +++ b/modules/NotifPopup.qml @@ -34,7 +34,7 @@ PanelWindow { property var _knownIds: ({}) Repeater { - model: M.NotifService.popups.slice(0, 4) + model: M.NotifService.popups.slice(0, M.Modules.notifications.maxPopups || 4) delegate: Item { id: popupItem diff --git a/modules/NotifService.qml b/modules/NotifService.qml index 5e408fb..130dbd7 100644 --- a/modules/NotifService.qml +++ b/modules/NotifService.qml @@ -83,6 +83,15 @@ QtObject { root.list = [data, ...root.list]; + // Dismiss excess popups (keep in history, just hide popup) + const max = M.Modules.notifications.maxPopups || 4; + const currentPopups = root.list.filter(n => n.popup && !n.closed); + if (currentPopups.length > max) { + for (let i = max; i < currentPopups.length; i++) + currentPopups[i].popup = false; + root._changed(); + } + // Auto-expire popup if (data.popup) { const timeout = notif.expireTimeout > 0 ? notif.expireTimeout : (M.Modules.notifications.timeout || 3000); diff --git a/nix/hm-module.nix b/nix/hm-module.nix index e7487bb..a62a401 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -98,6 +98,16 @@ in default = 3000; description = "Notification popup timeout in milliseconds."; }; + popups = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Show notification popups."; + }; + maxPopups = lib.mkOption { + type = lib.types.int; + default = 4; + description = "Maximum number of notification popups shown simultaneously."; + }; }; bluetooth = moduleOpt "bluetooth" (intervalOpt 5000); network = moduleOpt "network" (intervalOpt 5000); diff --git a/shell.qml b/shell.qml index e4c4f64..7467ef3 100644 --- a/shell.qml +++ b/shell.qml @@ -19,8 +19,11 @@ ShellRoot { screen: scope.modelData } - NotifPopup { - screen: scope.modelData + LazyLoader { + active: Modules.notifications.popups + NotifPopup { + screen: scope.modelData + } } LazyLoader {