Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notification hint to bypass dnd/inhibition #334

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/notiDaemon/notiDaemon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,20 @@ namespace SwayNotificationCenter {
synchronous_ids.set (param.synchronous, id);
}

// Only show popup notification if it is ENABLED or TRANSIENT
if ((state == NotificationStatusEnum.ENABLED || state == NotificationStatusEnum.TRANSIENT)
&& !control_center.get_visibility ()
// Also check if urgency is Critical and not inhibited and dnd
&& (param.urgency == UrgencyLevels.CRITICAL
|| (!dnd && !swaync_daemon.inhibited && param.urgency != UrgencyLevels.CRITICAL))) {
bool show_notification = state == NotificationStatusEnum.ENABLED
|| state == NotificationStatusEnum.TRANSIENT;
// Don't show the notification window if the control center is open
if (control_center.get_visibility ()) {
show_notification = false;
}

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) {
NotificationWindow.instance.replace_notification (replace_notification, param);
} else {
Expand All @@ -201,6 +209,7 @@ namespace SwayNotificationCenter {
// Remove the old notification due to it not being replaced
NotificationWindow.instance.close_notification (replace_notification, false);
}

// Only add notification to CC if it isn't IGNORED and not transient/TRANSIENT
if (state != NotificationStatusEnum.IGNORED
&& state != NotificationStatusEnum.TRANSIENT
Expand Down
8 changes: 8 additions & 0 deletions src/notiModel/notiModel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ namespace SwayNotificationCenter {
/** Disables scripting for notification */
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 NotifyParams (uint32 applied_id,
Expand Down Expand Up @@ -147,6 +150,11 @@ namespace SwayNotificationCenter {
swaync_no_script = hint_value.get_boolean ();
}
break;
case "SWAYNC_BYPASS_DND":
if (hint_value.is_of_type (VariantType.BOOLEAN)) {
swaync_bypass_dnd = hint_value.get_boolean ();
}
break;
case "value":
if (hint_value.is_of_type (VariantType.INT32)) {
this.has_synch = true;
Expand Down