diff options
Diffstat (limited to 'internal/notify/policy.go')
| -rw-r--r-- | internal/notify/policy.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/internal/notify/policy.go b/internal/notify/policy.go index c1dc647..5c70390 100644 --- a/internal/notify/policy.go +++ b/internal/notify/policy.go @@ -22,8 +22,9 @@ const ( Critical Urgency = "critical" ) -// DefaultTimeoutMS is the balloon lifetime for an urgency when the client sends -// expire_timeout 0. Critical never expires, which is 0 here. +// DefaultTimeoutMS is the balloon lifetime for an urgency when the client +// leaves the choice to the server (expire_timeout -1). Critical never expires, +// which is 0 here. func DefaultTimeoutMS(u Urgency) int64 { switch u { case Low, Normal: @@ -33,14 +34,17 @@ func DefaultTimeoutMS(u Urgency) int64 { } } -// EffectiveTimeoutMS resolves the client's expire_timeout: 0 means the urgency -// default, -1 means never, anything positive is milliseconds and wins. +// EffectiveTimeoutMS resolves the client's expire_timeout per the freedesktop +// spec: -1 means the server decides (the urgency default), 0 means never, and +// anything positive is milliseconds and wins. The spec is precise about the +// direction and libnotify's default is -1, so getting it backwards would make +// every plain notify-send immortal. func EffectiveTimeoutMS(expire int32, u Urgency) int64 { switch { case expire == -1: - return 0 - case expire == 0: return DefaultTimeoutMS(u) + case expire == 0: + return 0 default: return int64(expire) } |
