mirror of
https://github.com/ErikReider/SwayNotificationCenter.git
synced 2024-10-06 05:17:15 +03:00
Configurable critical notification timeout (#40)
I think there was also a logic error related to setting an expiry timeout. It was only set if `params.expire_timeout` was not `0`, instead of checking that both the user configured timeout and the one requested was set to `0`.
This commit is contained in:
parent
9fb9ffa54f
commit
a41f2b6e56
@ -88,6 +88,7 @@ To reload the config, you'll need to run `swaync-client --reload-config`
|
||||
- `positionY`: `top` or `bottom`
|
||||
- `timeout`: uint (Any positive number). The notification timeout for notifications with normal priority
|
||||
- `timeout-low`: uint (any positive number without decimals). The notification timeout for notifications with low priority
|
||||
- `timeout-critical`: uint (any positive number without decimals, 0 to disable). The notification timeout for notifications with critical priority
|
||||
- `keyboard-shortcuts`: `true` or `false`. If control center should use keyboard shortcuts
|
||||
- `image-visibility`: `always`, `when-available` or `never`. Notification image visiblilty
|
||||
- `transition-time`: uint (Any positive number, 0 to disable). The notification animation duration
|
||||
|
@ -3,6 +3,7 @@
|
||||
"positionY": "top",
|
||||
"timeout": 10,
|
||||
"timeout-low": 5,
|
||||
"timeout-critical": 0,
|
||||
"keyboard-shortcuts": true,
|
||||
"image-visibility": "always",
|
||||
"transition-time": 200
|
||||
|
@ -119,6 +119,18 @@ namespace SwayNotificatonCenter {
|
||||
}
|
||||
}
|
||||
|
||||
/** The timeout for notifications with CRITICAL priority */
|
||||
private const int _timeout_critical_def = 0;
|
||||
private int _timeout_critical = _timeout_critical_def;
|
||||
public int timeout_critical {
|
||||
get {
|
||||
return _timeout_critical;
|
||||
}
|
||||
set {
|
||||
_timeout_critical = value < 0 ? _timeout_critical_def : value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Specifies if the control center should use keyboard shortcuts
|
||||
* and block keyboard input for other applications while open
|
||||
|
@ -131,7 +131,8 @@ namespace SwayNotificatonCenter {
|
||||
var noti = new Notification.timed (param,
|
||||
notiDaemon,
|
||||
ConfigModel.instance.timeout,
|
||||
ConfigModel.instance.timeout_low);
|
||||
ConfigModel.instance.timeout_low,
|
||||
ConfigModel.instance.timeout_critical);
|
||||
|
||||
if (list_reverse) {
|
||||
box.pack_start (noti);
|
||||
|
@ -41,6 +41,7 @@ namespace SwayNotificatonCenter {
|
||||
private uint timeout_delay;
|
||||
private uint timeout_low_delay;
|
||||
private int transition_time;
|
||||
private uint timeout_critical_delay;
|
||||
|
||||
private int carpusel_empty_widget_index = 0;
|
||||
|
||||
@ -54,10 +55,12 @@ namespace SwayNotificatonCenter {
|
||||
public Notification.timed (NotifyParams param,
|
||||
NotiDaemon notiDaemon,
|
||||
uint timeout,
|
||||
uint timeout_low) {
|
||||
uint timeout_low,
|
||||
uint timeout_critical) {
|
||||
this.is_timed = true;
|
||||
this.timeout_delay = timeout;
|
||||
this.timeout_low_delay = timeout_low;
|
||||
this.timeout_critical_delay = timeout_critical;
|
||||
build_noti (param, notiDaemon);
|
||||
add_noti_timeout ();
|
||||
}
|
||||
@ -366,10 +369,14 @@ namespace SwayNotificatonCenter {
|
||||
timeout = timeout_delay * 1000;
|
||||
break;
|
||||
case UrgencyLevels.CRITICAL:
|
||||
if (timeout_critical_delay == 0) {
|
||||
return;
|
||||
}
|
||||
timeout = timeout_critical_delay * 1000;
|
||||
break;
|
||||
}
|
||||
uint ms = param.expire_timeout > 0 ? param.expire_timeout : timeout;
|
||||
if (param.expire_timeout != 0) {
|
||||
if (ms != 0) {
|
||||
timeout_id = Timeout.add (ms, () => {
|
||||
close_notification (true);
|
||||
return GLib.Source.REMOVE;
|
||||
|
Loading…
Reference in New Issue
Block a user