From d49a750bfd569d4cecf05b9bb0283f0034dcf929 Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Mon, 30 Dec 2024 01:23:52 -0800 Subject: [PATCH] Added an option to toggle auto-dismissal of notifications. (#673) --- src/components/notifications/helpers.ts | 8 +++++++- src/components/notifications/index.tsx | 3 ++- .../settings/pages/config/notifications/index.tsx | 10 ++++++++-- src/options.ts | 1 + 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/notifications/helpers.ts b/src/components/notifications/helpers.ts index 2086207..308398e 100644 --- a/src/components/notifications/helpers.ts +++ b/src/components/notifications/helpers.ts @@ -4,7 +4,7 @@ import options from 'src/options'; import { hyprlandService, notifdService } from 'src/lib/constants/services'; import { isNotificationIgnored } from 'src/lib/shared/notifications'; -const { ignore, timeout: popupTimeout } = options.notifications; +const { ignore, timeout: popupTimeout, autoDismiss } = options.notifications; /** * Checks if a notification has an image. @@ -85,3 +85,9 @@ const dropNotificationPopup = ( popupNotifications.set(undismissedNotifications); }; + +export const trackAutoTimeout = (): void => { + autoDismiss.subscribe((shouldAutoDismiss) => { + notifdService.set_ignore_timeout(!shouldAutoDismiss); + }); +}; diff --git a/src/components/notifications/index.tsx b/src/components/notifications/index.tsx index 3b9437f..5e5f373 100644 --- a/src/components/notifications/index.tsx +++ b/src/components/notifications/index.tsx @@ -3,7 +3,7 @@ import options from 'src/options.js'; import { getPosition } from 'src/lib/utils.js'; import Variable from 'astal/variable.js'; import { bind } from 'astal/binding.js'; -import { trackActiveMonitor, trackPopupNotifications } from './helpers.js'; +import { trackActiveMonitor, trackAutoTimeout, trackPopupNotifications } from './helpers.js'; import { Astal } from 'astal/gtk3'; import { NotificationCard } from './Notification.js'; import AstalNotifd from 'gi://AstalNotifd?version=0.1'; @@ -16,6 +16,7 @@ const popupNotifications: Variable = Variable([]); trackActiveMonitor(curMonitor); trackPopupNotifications(popupNotifications); +trackAutoTimeout(); export default (): JSX.Element => { const windowLayer = bind(tear).as((tear) => (tear ? Astal.Layer.TOP : Astal.Layer.OVERLAY)); diff --git a/src/components/settings/pages/config/notifications/index.tsx b/src/components/settings/pages/config/notifications/index.tsx index 40d4226..720463f 100644 --- a/src/components/settings/pages/config/notifications/index.tsx +++ b/src/components/settings/pages/config/notifications/index.tsx @@ -49,10 +49,16 @@ export const NotificationSettings = (): JSX.Element => { />