feat: transient notification visibility (#170)

This commit is contained in:
lazytanuki
2022-10-09 11:29:48 +02:00
committed by GitHub
parent 81fb57ecb7
commit ebd726e38a
4 changed files with 14 additions and 7 deletions

View File

@@ -110,7 +110,7 @@ config file to be able to detect config errors
type: string ++
optional: false ++
default: enabled ++
values: ignored, muted, enabled ++
values: ignored, muted, transient, enabled ++
description: The notification visibility state. ++
*app-name*++
type: string ++

View File

@@ -137,7 +137,8 @@ namespace SwayNotificationCenter {
public enum NotificationStatusEnum {
ENABLED,
MUTED,
IGNORED;
IGNORED,
TRANSIENT;
public string to_string () {
switch (this) {
@@ -147,6 +148,8 @@ namespace SwayNotificationCenter {
return "muted";
case IGNORED:
return "ignored";
case TRANSIENT:
return "transient";
}
}
@@ -158,6 +161,8 @@ namespace SwayNotificationCenter {
return MUTED;
case "ignored":
return IGNORED;
case "transient":
return TRANSIENT;
}
}
}

View File

@@ -186,7 +186,7 @@
"type": "string",
"description": "The notification visibility state.",
"default": "enabled",
"enum": ["ignored", "muted", "enabled"]
"enum": ["ignored", "muted", "enabled", "transient"]
},
"app-name": {
"type": "string",

View File

@@ -172,16 +172,18 @@ namespace SwayNotificationCenter {
synchronous_ids.set (param.synchronous, id);
}
// Only show popup notification if it is ENABLED
if (state == NotificationStatusEnum.ENABLED
// Only show popup notification if it is ENABLED or TRANSIENT
if ((state == NotificationStatusEnum.ENABLED || state == NotificationStatusEnum.TRANSIENT)
&& !control_center.get_visibility ()) {
if (param.urgency == UrgencyLevels.CRITICAL ||
(!dnd && param.urgency != UrgencyLevels.CRITICAL)) {
NotificationWindow.instance.add_notification (param, this);
}
}
// Only add notification to CC if it isn't IGNORED and not transient
if (state != NotificationStatusEnum.IGNORED && !param.transient) {
// Only add notification to CC if it isn't IGNORED and not transient/TRANSIENT
if (state != NotificationStatusEnum.IGNORED
&& state != NotificationStatusEnum.TRANSIENT
&& !param.transient) {
control_center.add_notification (param, this);
}