Added an option to toggle auto-dismissal of notifications. (#673)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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<AstalNotifd.Notification[]> = Variable([]);
|
||||
|
||||
trackActiveMonitor(curMonitor);
|
||||
trackPopupNotifications(popupNotifications);
|
||||
trackAutoTimeout();
|
||||
|
||||
export default (): JSX.Element => {
|
||||
const windowLayer = bind(tear).as((tear) => (tear ? Astal.Layer.TOP : Astal.Layer.OVERLAY));
|
||||
|
||||
@@ -49,10 +49,16 @@ export const NotificationSettings = (): JSX.Element => {
|
||||
/>
|
||||
<Option
|
||||
opt={options.notifications.timeout}
|
||||
title="Notification Timeout"
|
||||
subtitle="Duration in ms the notification stays"
|
||||
title="Popup Timeout"
|
||||
subtitle="Duration in ms the notification popup stays visible"
|
||||
type="number"
|
||||
/>
|
||||
<Option
|
||||
opt={options.notifications.autoDismiss}
|
||||
title="Automatically Dismiss"
|
||||
subtitle="Notifications with a timeout will dismiss automatically."
|
||||
type="boolean"
|
||||
/>
|
||||
<Option
|
||||
opt={options.notifications.cache_actions}
|
||||
title="Preserve Actions"
|
||||
|
||||
Reference in New Issue
Block a user