From cab352781da9514eb3aad4c7fed19ce0b24e6c96 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 15 Feb 2020 21:45:35 -0500 Subject: [PATCH] ruled.notifications: Add an implicit timeout to the rules. This replaces the old preset one. --- lib/ruled/notification.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/ruled/notification.lua b/lib/ruled/notification.lua index 1e7f0aca..548a7b65 100644 --- a/lib/ruled/notification.lua +++ b/lib/ruled/notification.lua @@ -64,6 +64,14 @@ local naughty = require("naughty") -- @clientruleproperty append_actions -- @param table +--- Set a fallback timeout the notification has no explicit timeout. +-- +-- The value is in seconds. If none is specified, the default is 5 seconds. If +-- the notification specifies its own timeout, this property will be skipped. +-- +-- @clientruleproperty implicit_timeout +-- @param number + local nrules = matcher() local function client_match_common(n, prop, value) @@ -107,6 +115,13 @@ nrules:add_property_setter("append_actions", function(n, value) n.actions = gtable.merge(new_actions, value) end) +nrules:add_property_setter("implicit_timeout", function(n, value) + -- Check if there is an explicit timeout. + if not n._private.timeout then + n.timeout = value + end +end) + local module = {} gobject._setup_class_signals(module)