Fix naughty notifications

Commit d14d6959ea caused every notify() call to fail with 'attempt to
compare number with nil' because the default_preset table no longer exists.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2012-06-05 16:20:30 +02:00
parent 2ec6635adc
commit ab7788e2f5

View file

@ -33,8 +33,6 @@ module("naughty")
-- Default: { "/usr/share/pixmaps/", } -- Default: { "/usr/share/pixmaps/", }
-- @field icon_formats List of formats that will be checked by getIcon() -- @field icon_formats List of formats that will be checked by getIcon()
-- Default: { "png", "gif" } -- 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. -- @field notify_callback Callback used to modify or reject notifications.
-- Default: nil -- Default: nil
-- Example: -- Example:
@ -75,10 +73,10 @@ config.presets = {
} }
} }
-- @name config.defaults --- Default values for the params to notify().
-- holds the default values for the parameters to @see notify(). These -- These can optionally be overridden by specifying a preset
-- can optionally be overridden by specifying a preset (@see config.presets) -- @see config.presets
-- @class table -- @see notify
config.defaults = { config.defaults = {
timeout = 5, timeout = 5,
text = "", text = "",
@ -292,7 +290,7 @@ function notify(args)
end end
-- gather variables together -- gather variables together
local preset = util.table.join(config.default_preset or {}, local preset = util.table.join(config.defaults or {},
args.preset or config.presets.normal or {}) args.preset or config.presets.normal or {})
local timeout = args.timeout or preset.timeout local timeout = args.timeout or preset.timeout
local icon = args.icon or preset.icon local icon = args.icon or preset.icon
@ -505,7 +503,7 @@ end
-- Notify -- Notify
if capi.dbus then if capi.dbus then
capi.dbus.connect_signal("org.freedesktop.Notifications", function (data, appname, replaces_id, icon, title, text, actions, hints, expire) capi.dbus.connect_signal("org.freedesktop.Notifications", function (data, appname, replaces_id, icon, title, text, actions, hints, expire)
args = { preset = config.default_preset } args = { }
if data.member == "Notify" then if data.member == "Notify" then
if text ~= "" then if text ~= "" then
args.text = text args.text = text