From 05ba03538fa40f0ed986cb7a5feeb0e517ddc8a4 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 16 Feb 2020 01:27:22 -0500 Subject: [PATCH] ruled.notification: Add a `never_timeout` property. It was possible to set `timeout = 0`, but this is weird to document. Better just add a variable. --- lib/ruled/notification.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/ruled/notification.lua b/lib/ruled/notification.lua index 0aca71df9..02882169f 100644 --- a/lib/ruled/notification.lua +++ b/lib/ruled/notification.lua @@ -71,6 +71,10 @@ local gobject = require("gears.object") -- @clientruleproperty implicit_timeout -- @param number +--- Do not let this notification timeout, even if it asks for it. +-- @clientruleproperty never_timeout +-- @param boolean + local nrules = matcher() local function client_match_common(n, prop, value) @@ -116,7 +120,20 @@ end) nrules:add_property_setter("implicit_timeout", function(n, value) -- Check if there is an explicit timeout. - if not n._private.timeout then + if (not n._private.timeout) and (not n._private.never_timeout) then + n.timeout = value + end +end) + +nrules:add_property_setter("never_timeout", function(n, value) + if value then + n.timeout = 0 + end +end) + +nrules:add_property_setter("timeout", function(n, value) + -- `never_timeout` has an higher priority than `timeout`. + if not n._private.never_timeout then n.timeout = value end end)