naughty.notify: inherit from default preset
Build the preset values by merging the default preset with the one actually specified, falling back to the normal preset if no preset is specified. This allows changing the position/font/whatever of all notification by only setting up the default preset value (modulo overrides in the other presets), instead of having to manually set it in all presets. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
982ac6f8c1
commit
d14d6959ea
|
@ -53,9 +53,9 @@ config.notify_callback = nil
|
||||||
|
|
||||||
|
|
||||||
--- Notification Presets - a table containing presets for different purposes
|
--- Notification Presets - a table containing presets for different purposes
|
||||||
-- Preset is a table of any parameters available to notify()
|
-- Preset is a table of any parameters available to notify(), overriding default
|
||||||
|
-- values (@see defaults)
|
||||||
-- You have to pass a reference of a preset in your notify() call to use the preset
|
-- You have to pass a reference of a preset in your notify() call to use the preset
|
||||||
-- At least the default preset named "normal" has to be defined
|
|
||||||
-- The presets "low", "normal" and "critical" are used for notifications over DBUS
|
-- The presets "low", "normal" and "critical" are used for notifications over DBUS
|
||||||
-- @name config.presets
|
-- @name config.presets
|
||||||
-- @field low The preset for notifications with low urgency level
|
-- @field low The preset for notifications with low urgency level
|
||||||
|
@ -75,7 +75,19 @@ config.presets = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.default_preset = config.presets.normal
|
-- @name config.defaults
|
||||||
|
-- holds the default values for the parameters to @see notify(). These
|
||||||
|
-- can optionally be overridden by specifying a preset (@see config.presets)
|
||||||
|
-- @class table
|
||||||
|
config.defaults = {
|
||||||
|
timeout = 5,
|
||||||
|
text = "",
|
||||||
|
screen = 1,
|
||||||
|
ontop = true,
|
||||||
|
margin = "5",
|
||||||
|
border_width = "1",
|
||||||
|
position = "top_right"
|
||||||
|
}
|
||||||
|
|
||||||
-- DBUS Notification constants
|
-- DBUS Notification constants
|
||||||
urgency = {
|
urgency = {
|
||||||
|
@ -280,21 +292,22 @@ function notify(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- gather variables together
|
-- gather variables together
|
||||||
local preset = args.preset or config.default_preset or {}
|
local preset = util.table.join(config.default_preset or {},
|
||||||
local timeout = args.timeout or preset.timeout or 5
|
args.preset or config.presets.normal or {})
|
||||||
|
local timeout = args.timeout or preset.timeout
|
||||||
local icon = args.icon or preset.icon
|
local icon = args.icon or preset.icon
|
||||||
local icon_size = args.icon_size or preset.icon_size
|
local icon_size = args.icon_size or preset.icon_size
|
||||||
local text = args.text or preset.text or ""
|
local text = args.text or preset.text
|
||||||
local title = args.title or preset.title
|
local title = args.title or preset.title
|
||||||
local screen = args.screen or preset.screen or 1
|
local screen = args.screen or preset.screen
|
||||||
local ontop = args.ontop or preset.ontop or true
|
local ontop = args.ontop or preset.ontop
|
||||||
local width = args.width or preset.width
|
local width = args.width or preset.width
|
||||||
local height = args.height or preset.height
|
local height = args.height or preset.height
|
||||||
local hover_timeout = args.hover_timeout or preset.hover_timeout
|
local hover_timeout = args.hover_timeout or preset.hover_timeout
|
||||||
local opacity = args.opacity or preset.opacity
|
local opacity = args.opacity or preset.opacity
|
||||||
local margin = args.margin or preset.margin or "5"
|
local margin = args.margin or preset.margin
|
||||||
local border_width = args.border_width or preset.border_width or "1"
|
local border_width = args.border_width or preset.border_width
|
||||||
local position = args.position or preset.position or "top_right"
|
local position = args.position or preset.position
|
||||||
|
|
||||||
-- beautiful
|
-- beautiful
|
||||||
local beautiful = bt.get()
|
local beautiful = bt.get()
|
||||||
|
|
Loading…
Reference in New Issue