diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-01-14 19:53:49 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-01-14 19:53:49 +1100 |
| commit | c2e03775dba9aedbb52c9bf1135a2290faaa21bf (patch) | |
| tree | 7909f68f820b68407f8c49e74d1464653d385348 /modules/notifpopups.tsx | |
| parent | launcher: better math error message (diff) | |
| download | caelestia-shell-c2e03775dba9aedbb52c9bf1135a2290faaa21bf.tar.gz caelestia-shell-c2e03775dba9aedbb52c9bf1135a2290faaa21bf.tar.bz2 caelestia-shell-c2e03775dba9aedbb52c9bf1135a2290faaa21bf.zip | |
better config + notifpopups max popups
Use a config file
Diffstat (limited to 'modules/notifpopups.tsx')
| -rw-r--r-- | modules/notifpopups.tsx | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/modules/notifpopups.tsx b/modules/notifpopups.tsx index a46f218..1830079 100644 --- a/modules/notifpopups.tsx +++ b/modules/notifpopups.tsx @@ -1,6 +1,7 @@ import { GLib, register, timeout } from "astal"; import { Astal, Gtk, Widget } from "astal/gtk3"; import AstalNotifd from "gi://AstalNotifd"; +import { notifpopups as config } from "../config"; import { desktopEntrySubs } from "../utils/icons"; import { setupChildClickthrough } from "../utils/widgets"; @@ -104,8 +105,8 @@ class NotifPopup extends Widget.Box { this.css = `transition: 300ms cubic-bezier(0.05, 0.9, 0.1, 1.1); margin-left: 0; margin-right: 0;`; }); - // Close popup after timeout if transient - if (notification.transient) + // Close popup after timeout if transient or expire enabled in config + if (config.expire || notification.transient) timeout( notification.expireTimeout > 0 ? notification.expireTimeout @@ -145,8 +146,11 @@ export default () => ( const map = new Map<number, NotifPopup>(); self.hook(notifd, "notified", (self, id) => { const notification = notifd.get_notification(id); + const popup = (<NotifPopup notification={notification} />) as NotifPopup; + popup.connect("destroy", () => map.delete(notification.id)); map.set(notification.id, popup); + self.add( <eventbox // Dismiss on middle click @@ -157,14 +161,12 @@ export default () => ( {popup} </eventbox> ); + + // Limit number of popups + if (config.maxPopups > 0 && self.children.length > config.maxPopups) + map.values().next().value?.destroyWithAnims(); }); - self.hook(notifd, "resolved", (_, id) => { - const popup = map.get(id); - if (popup) { - popup.destroyWithAnims(); - map.delete(id); - } - }); + self.hook(notifd, "resolved", (_, id) => map.get(id)?.destroyWithAnims()); // Change input region to child region so can click through empty space setupChildClickthrough(self); |