naughty.widget.legacy: Use values from the notification objects.
Previously it used the `args` table passed to the constructor. This will not work with rules since they modify the object, not the args.
This commit is contained in:
parent
78c616c358
commit
e77ca1f4d8
|
@ -297,6 +297,14 @@ end
|
||||||
|
|
||||||
naughty.connect_signal("destroyed", cleanup)
|
naughty.connect_signal("destroyed", cleanup)
|
||||||
|
|
||||||
|
-- Don't copy paste the list of fallback, it is hard to spot mistakes.
|
||||||
|
local function get_value(notification, args, preset, prop)
|
||||||
|
return notification[prop] -- set by the rules
|
||||||
|
or args[prop] -- magic and undocumented, but used by the legacy API
|
||||||
|
or preset[prop] --deprecated
|
||||||
|
or beautiful["notification_"..prop] -- from the theme
|
||||||
|
end
|
||||||
|
|
||||||
function naughty.default_notification_handler(notification, args)
|
function naughty.default_notification_handler(notification, args)
|
||||||
-- This is a fallback for users whose config doesn't have the newer
|
-- This is a fallback for users whose config doesn't have the newer
|
||||||
-- `request::display` section.
|
-- `request::display` section.
|
||||||
|
@ -310,9 +318,14 @@ function naughty.default_notification_handler(notification, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
local preset = notification.preset or {}
|
local preset = notification.preset or {}
|
||||||
local text = args.message or args.text or preset.message or preset.text
|
|
||||||
local title = args.title or preset.title
|
local title = get_value(notification, args, preset, "title" )
|
||||||
local s = get_screen(args.screen or preset.screen or screen.focused())
|
local text = get_value(notification, args, preset, "message")
|
||||||
|
or args.text or preset.text
|
||||||
|
|
||||||
|
local s = get_screen(
|
||||||
|
get_value(notification, args, preset, "screen") or screen.focused()
|
||||||
|
)
|
||||||
|
|
||||||
if not s then
|
if not s then
|
||||||
local err = "naughty.notify: there is no screen available to display the following notification:"
|
local err = "naughty.notify: there is no screen available to display the following notification:"
|
||||||
|
@ -321,14 +334,14 @@ function naughty.default_notification_handler(notification, args)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local timeout = args.timeout or preset.timeout
|
local timeout = get_value(notification, args, preset, "timeout" )
|
||||||
local icon = args.icon or preset.icon
|
local icon = get_value(notification, args, preset, "icon" )
|
||||||
local icon_size = args.icon_size or preset.icon_size
|
local icon_size = get_value(notification, args, preset, "icon_size" )
|
||||||
or beautiful.notification_icon_size
|
local ontop = get_value(notification, args, preset, "ontop" )
|
||||||
local ontop = args.ontop or preset.ontop
|
local hover_timeout = get_value(notification, args, preset, "hover_timeout")
|
||||||
local hover_timeout = args.hover_timeout or preset.hover_timeout
|
local position = get_value(notification, args, preset, "position" )
|
||||||
local position = args.position or preset.position
|
|
||||||
local actions = args.actions
|
local actions = notification.actions or args.actions
|
||||||
local destroy_cb = args.destroy
|
local destroy_cb = args.destroy
|
||||||
|
|
||||||
notification.screen = s
|
notification.screen = s
|
||||||
|
@ -336,30 +349,26 @@ function naughty.default_notification_handler(notification, args)
|
||||||
notification.timeout = timeout
|
notification.timeout = timeout
|
||||||
|
|
||||||
-- beautiful
|
-- beautiful
|
||||||
local font = args.font or preset.font or beautiful.notification_font or
|
local font = get_value(notification, args, preset, "font" )
|
||||||
beautiful.font or capi.awesome.font
|
or beautiful.font or capi.awesome.font
|
||||||
local fg = args.fg or preset.fg or
|
|
||||||
beautiful.notification_fg or beautiful.fg_normal or '#ffffff'
|
local fg = get_value(notification, args, preset, "fg" )
|
||||||
local bg = args.bg or preset.bg or
|
or beautiful.fg_normal or '#ffffff'
|
||||||
beautiful.notification_bg or beautiful.bg_normal or '#535d6c'
|
|
||||||
local border_color = args.border_color or preset.border_color or
|
local bg = get_value(notification, args, preset, "bg" )
|
||||||
beautiful.notification_border_color or beautiful.bg_focus or '#535d6c'
|
or beautiful.bg_normal or '#535d6c'
|
||||||
local border_width = args.border_width or preset.border_width or
|
|
||||||
beautiful.notification_border_width
|
local border_color = get_value(notification, args, preset, "border_color")
|
||||||
local shape = args.shape or preset.shape or
|
or beautiful.bg_focus or '#535d6c'
|
||||||
beautiful.notification_shape
|
|
||||||
local width = args.width or preset.width or
|
local border_width = get_value(notification, args, preset, "border_width")
|
||||||
beautiful.notification_width
|
local shape = get_value(notification, args, preset, "shape" )
|
||||||
local height = args.height or preset.height or
|
local width = get_value(notification, args, preset, "width" )
|
||||||
beautiful.notification_height
|
local height = get_value(notification, args, preset, "height" )
|
||||||
local max_width = args.max_width or preset.max_width or
|
local max_width = get_value(notification, args, preset, "max_width" )
|
||||||
beautiful.notification_max_width
|
local max_height = get_value(notification, args, preset, "max_height" )
|
||||||
local max_height = args.max_height or preset.max_height or
|
local margin = get_value(notification, args, preset, "margin" )
|
||||||
beautiful.notification_max_height
|
local opacity = get_value(notification, args, preset, "opacity" )
|
||||||
local margin = args.margin or preset.margin or
|
|
||||||
beautiful.notification_margin
|
|
||||||
local opacity = args.opacity or preset.opacity or
|
|
||||||
beautiful.notification_opacity
|
|
||||||
|
|
||||||
notification.position = position
|
notification.position = position
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue