mirror of
https://github.com/ErikReider/SwayNotificationCenter.git
synced 2024-10-05 21:08:40 +03:00
Add notification hint to bypass dnd/inhibition (#334)
This commit is contained in:
parent
ab46163f1e
commit
5a23d5eeb5
@ -186,12 +186,20 @@ namespace SwayNotificationCenter {
|
|||||||
synchronous_ids.set (param.synchronous, id);
|
synchronous_ids.set (param.synchronous, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only show popup notification if it is ENABLED or TRANSIENT
|
bool show_notification = state == NotificationStatusEnum.ENABLED
|
||||||
if ((state == NotificationStatusEnum.ENABLED || state == NotificationStatusEnum.TRANSIENT)
|
|| state == NotificationStatusEnum.TRANSIENT;
|
||||||
&& !control_center.get_visibility ()
|
// Don't show the notification window if the control center is open
|
||||||
// Also check if urgency is Critical and not inhibited and dnd
|
if (control_center.get_visibility ()) {
|
||||||
&& (param.urgency == UrgencyLevels.CRITICAL
|
show_notification = false;
|
||||||
|| (!dnd && !swaync_daemon.inhibited && param.urgency != UrgencyLevels.CRITICAL))) {
|
}
|
||||||
|
|
||||||
|
bool bypass_dnd = param.urgency == UrgencyLevels.CRITICAL || param.swaync_bypass_dnd;
|
||||||
|
// Don't show the notification window if dnd or inhibited
|
||||||
|
if (!bypass_dnd && (dnd || swaync_daemon.inhibited)) {
|
||||||
|
show_notification = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_notification) {
|
||||||
if (replace_notification > 0) {
|
if (replace_notification > 0) {
|
||||||
NotificationWindow.instance.replace_notification (replace_notification, param);
|
NotificationWindow.instance.replace_notification (replace_notification, param);
|
||||||
} else {
|
} else {
|
||||||
@ -201,6 +209,7 @@ namespace SwayNotificationCenter {
|
|||||||
// Remove the old notification due to it not being replaced
|
// Remove the old notification due to it not being replaced
|
||||||
NotificationWindow.instance.close_notification (replace_notification, false);
|
NotificationWindow.instance.close_notification (replace_notification, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add notification to CC if it isn't IGNORED and not transient/TRANSIENT
|
// Only add notification to CC if it isn't IGNORED and not transient/TRANSIENT
|
||||||
if (state != NotificationStatusEnum.IGNORED
|
if (state != NotificationStatusEnum.IGNORED
|
||||||
&& state != NotificationStatusEnum.TRANSIENT
|
&& state != NotificationStatusEnum.TRANSIENT
|
||||||
|
@ -110,6 +110,9 @@ namespace SwayNotificationCenter {
|
|||||||
/** Disables scripting for notification */
|
/** Disables scripting for notification */
|
||||||
public bool swaync_no_script { get; set; }
|
public bool swaync_no_script { get; set; }
|
||||||
|
|
||||||
|
/** Always show the notification, regardless of dnd/inhibit state */
|
||||||
|
public bool swaync_bypass_dnd { get; set; }
|
||||||
|
|
||||||
public Array<Action> actions { get; set; }
|
public Array<Action> actions { get; set; }
|
||||||
|
|
||||||
public NotifyParams (uint32 applied_id,
|
public NotifyParams (uint32 applied_id,
|
||||||
@ -147,6 +150,11 @@ namespace SwayNotificationCenter {
|
|||||||
swaync_no_script = hint_value.get_boolean ();
|
swaync_no_script = hint_value.get_boolean ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "SWAYNC_BYPASS_DND":
|
||||||
|
if (hint_value.is_of_type (VariantType.BOOLEAN)) {
|
||||||
|
swaync_bypass_dnd = hint_value.get_boolean ();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "value":
|
case "value":
|
||||||
if (hint_value.is_of_type (VariantType.INT32)) {
|
if (hint_value.is_of_type (VariantType.INT32)) {
|
||||||
this.has_synch = true;
|
this.has_synch = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user