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
88aff03005
commit
4972a280b0
|
@ -33,6 +33,13 @@ module("naughty")
|
|||
-- Default: { "png", "gif" }
|
||||
-- @field default_preset Preset to be used by default.
|
||||
-- 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
|
||||
|
||||
config = {}
|
||||
|
@ -40,6 +47,7 @@ config.padding = 4
|
|||
config.spacing = 1
|
||||
config.icon_dirs = { "/usr/share/pixmaps/", }
|
||||
config.icon_formats = { "png", "gif" }
|
||||
config.notify_callback = nil
|
||||
|
||||
|
||||
--- Notification Presets - a table containing presets for different purposes
|
||||
|
@ -269,6 +277,11 @@ end
|
|||
-- @usage naughty.notify({ title = "Achtung!", text = "You're idling", timeout = 0 })
|
||||
-- @return The notification object
|
||||
function notify(args)
|
||||
if config.notify_callback then
|
||||
args = config.notify_callback(args)
|
||||
if not args then return end
|
||||
end
|
||||
|
||||
-- gather variables together
|
||||
local preset = args.preset or config.default_preset or {}
|
||||
local timeout = args.timeout or preset.timeout or 5
|
||||
|
|
Loading…
Reference in New Issue