Add Override urgency to config (#199)
This commit is contained in:
@@ -125,6 +125,12 @@ config file to be able to detect config errors
|
||||
default: enabled ++
|
||||
values: ignored, muted, transient, enabled ++
|
||||
description: The notification visibility state. ++
|
||||
*override-urgency*++
|
||||
type: string ++
|
||||
optional: true ++
|
||||
default: unset ++
|
||||
values: unset, low, normal, critical ++
|
||||
description: The new urgency for the notification if set.++
|
||||
*app-name*++
|
||||
type: string ++
|
||||
optional: true ++
|
||||
@@ -147,7 +153,8 @@ config file to be able to detect config errors
|
||||
type: string ++
|
||||
optional: true ++
|
||||
description: Which category the notification belongs to. Uses Regex.++
|
||||
description: Set the visibility of each incoming notification. ++
|
||||
description: Set the visibility or override urgency of each incoming ++
|
||||
notification. ++
|
||||
If the notification doesn't include one of the properties, that ++
|
||||
property will be ignored. All properties (except for state) use ++
|
||||
regex. If all properties match the given notification, the ++
|
||||
|
@@ -200,8 +200,35 @@ namespace SwayNotificationCenter {
|
||||
}
|
||||
}
|
||||
|
||||
public enum NotificationUrgencyEnum {
|
||||
UNSET = -1,
|
||||
LOW = UrgencyLevels.LOW,
|
||||
NORMAL = UrgencyLevels.NORMAL,
|
||||
CRITICAL = UrgencyLevels.CRITICAL;
|
||||
|
||||
public uint8 to_byte () {
|
||||
return this;
|
||||
}
|
||||
|
||||
public string to_string () {
|
||||
switch (this) {
|
||||
case LOW:
|
||||
return "Low";
|
||||
case NORMAL:
|
||||
return "Normal";
|
||||
case CRITICAL:
|
||||
return "Critical";
|
||||
default:
|
||||
return "Unset";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NotificationVisibility : NotificationMatching {
|
||||
public NotificationStatusEnum state { get; set; }
|
||||
public NotificationUrgencyEnum override_urgency {
|
||||
get; set; default = NotificationUrgencyEnum.UNSET;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ScriptRunOnType {
|
||||
|
@@ -224,6 +224,12 @@
|
||||
"default": "Normal",
|
||||
"enum": ["Low", "Normal", "Critical"]
|
||||
},
|
||||
"override-urgency": {
|
||||
"type": "string",
|
||||
"description": "The new urgency of the notification (optional)",
|
||||
"default": "unset",
|
||||
"enum": ["unset", "low", "normal", "critical"]
|
||||
},
|
||||
"category": {
|
||||
"type": "string",
|
||||
"description": "Which category the notification belongs to. Uses Regex."
|
||||
|
@@ -147,6 +147,10 @@ namespace SwayNotificationCenter {
|
||||
unowned NotificationVisibility vis = visibilities[key];
|
||||
if (!vis.matches_notification (param)) continue;
|
||||
state = vis.state;
|
||||
if (vis.override_urgency != UNSET) {
|
||||
debug ("override urgency to %s\n", vis.override_urgency.to_string ());
|
||||
param.urgency = UrgencyLevels.from_value (vis.override_urgency.to_byte ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user