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 { hyprlandService, notifdService } from 'src/lib/constants/services';
|
||||||
import { isNotificationIgnored } from 'src/lib/shared/notifications';
|
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.
|
* Checks if a notification has an image.
|
||||||
@@ -85,3 +85,9 @@ const dropNotificationPopup = (
|
|||||||
|
|
||||||
popupNotifications.set(undismissedNotifications);
|
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 { getPosition } from 'src/lib/utils.js';
|
||||||
import Variable from 'astal/variable.js';
|
import Variable from 'astal/variable.js';
|
||||||
import { bind } from 'astal/binding.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 { Astal } from 'astal/gtk3';
|
||||||
import { NotificationCard } from './Notification.js';
|
import { NotificationCard } from './Notification.js';
|
||||||
import AstalNotifd from 'gi://AstalNotifd?version=0.1';
|
import AstalNotifd from 'gi://AstalNotifd?version=0.1';
|
||||||
@@ -16,6 +16,7 @@ const popupNotifications: Variable<AstalNotifd.Notification[]> = Variable([]);
|
|||||||
|
|
||||||
trackActiveMonitor(curMonitor);
|
trackActiveMonitor(curMonitor);
|
||||||
trackPopupNotifications(popupNotifications);
|
trackPopupNotifications(popupNotifications);
|
||||||
|
trackAutoTimeout();
|
||||||
|
|
||||||
export default (): JSX.Element => {
|
export default (): JSX.Element => {
|
||||||
const windowLayer = bind(tear).as((tear) => (tear ? Astal.Layer.TOP : Astal.Layer.OVERLAY));
|
const windowLayer = bind(tear).as((tear) => (tear ? Astal.Layer.TOP : Astal.Layer.OVERLAY));
|
||||||
|
|||||||
@@ -49,10 +49,16 @@ export const NotificationSettings = (): JSX.Element => {
|
|||||||
/>
|
/>
|
||||||
<Option
|
<Option
|
||||||
opt={options.notifications.timeout}
|
opt={options.notifications.timeout}
|
||||||
title="Notification Timeout"
|
title="Popup Timeout"
|
||||||
subtitle="Duration in ms the notification stays"
|
subtitle="Duration in ms the notification popup stays visible"
|
||||||
type="number"
|
type="number"
|
||||||
/>
|
/>
|
||||||
|
<Option
|
||||||
|
opt={options.notifications.autoDismiss}
|
||||||
|
title="Automatically Dismiss"
|
||||||
|
subtitle="Notifications with a timeout will dismiss automatically."
|
||||||
|
type="boolean"
|
||||||
|
/>
|
||||||
<Option
|
<Option
|
||||||
opt={options.notifications.cache_actions}
|
opt={options.notifications.cache_actions}
|
||||||
title="Preserve Actions"
|
title="Preserve Actions"
|
||||||
|
|||||||
@@ -1322,6 +1322,7 @@ const options = mkOptions(CONFIG, {
|
|||||||
active_monitor: opt(true),
|
active_monitor: opt(true),
|
||||||
showActionsOnHover: opt(false),
|
showActionsOnHover: opt(false),
|
||||||
timeout: opt(7000),
|
timeout: opt(7000),
|
||||||
|
autoDismiss: opt(false),
|
||||||
cache_actions: opt(true),
|
cache_actions: opt(true),
|
||||||
clearDelay: opt(100),
|
clearDelay: opt(100),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user