Add naughty.config.notify_callback
This optional callback can be used for filtering and/or editing notifications. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
23ff7a8414
commit
3eb12cdf00
|
@ -35,6 +35,13 @@ module("naughty")
|
||||||
-- Default: { "png", "gif" }
|
-- Default: { "png", "gif" }
|
||||||
-- @field default_preset Preset to be used by default.
|
-- @field default_preset Preset to be used by default.
|
||||||
-- Default: config.presets.normal
|
-- Default: config.presets.normal
|
||||||
|
-- @field notify_callback Callback used to modify or reject notifications.
|
||||||
|
-- Default: nil
|
||||||
|
-- Example:
|
||||||
|
-- naughty.config.notify_callback = function(args)
|
||||||
|
-- args.text = 'prefix: ' .. args.text
|
||||||
|
-- return args
|
||||||
|
-- end
|
||||||
-- @class table
|
-- @class table
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
|
@ -42,6 +49,7 @@ config.padding = 4
|
||||||
config.spacing = 1
|
config.spacing = 1
|
||||||
config.icon_dirs = { "/usr/share/pixmaps/", }
|
config.icon_dirs = { "/usr/share/pixmaps/", }
|
||||||
config.icon_formats = { "png", "gif" }
|
config.icon_formats = { "png", "gif" }
|
||||||
|
config.notify_callback = nil
|
||||||
|
|
||||||
|
|
||||||
--- Notification Presets - a table containing presets for different purposes
|
--- Notification Presets - a table containing presets for different purposes
|
||||||
|
@ -271,6 +279,11 @@ end
|
||||||
-- @usage naughty.notify({ title = "Achtung!", text = "You're idling", timeout = 0 })
|
-- @usage naughty.notify({ title = "Achtung!", text = "You're idling", timeout = 0 })
|
||||||
-- @return The notification object
|
-- @return The notification object
|
||||||
function notify(args)
|
function notify(args)
|
||||||
|
if config.notify_callback then
|
||||||
|
args = config.notify_callback(args)
|
||||||
|
if not args then return end
|
||||||
|
end
|
||||||
|
|
||||||
-- gather variables together
|
-- gather variables together
|
||||||
local preset = args.preset or config.default_preset or {}
|
local preset = args.preset or config.default_preset or {}
|
||||||
local timeout = args.timeout or preset.timeout or 5
|
local timeout = args.timeout or preset.timeout or 5
|
||||||
|
|
Loading…
Reference in New Issue