naughty: new notify() parameter 'run'
Signed-off-by: koniu <gkusnierz@gmail.com>
This commit is contained in:
parent
9447d29204
commit
390b218526
|
@ -170,6 +170,7 @@ end
|
||||||
-- @param bg Background color
|
-- @param bg Background color
|
||||||
-- @param screen Target screen for the notification
|
-- @param screen Target screen for the notification
|
||||||
-- @param ontop Target screen for the notification
|
-- @param ontop Target screen for the notification
|
||||||
|
-- @param run Function to run on left click
|
||||||
-- @usage naughty.notify({ title = 'Achtung!', text = 'You\'re idling', timeout = 0 })
|
-- @usage naughty.notify({ title = 'Achtung!', text = 'You\'re idling', timeout = 0 })
|
||||||
function notify(args)
|
function notify(args)
|
||||||
-- gather settings together
|
-- gather settings together
|
||||||
|
@ -221,6 +222,8 @@ function notify(args)
|
||||||
hooks.timer.register(timeout, timer)
|
hooks.timer.register(timeout, timer)
|
||||||
notification.timer = timer
|
notification.timer = timer
|
||||||
|
|
||||||
|
local run = args.run or function () destroy(notification) end
|
||||||
|
|
||||||
local hover_destroy = function ()
|
local hover_destroy = function ()
|
||||||
if config.hover_timeout == 0 then destroy(notification)
|
if config.hover_timeout == 0 then destroy(notification)
|
||||||
else hooks.timer.register(config.hover_timeout, timer) end
|
else hooks.timer.register(config.hover_timeout, timer) end
|
||||||
|
@ -228,7 +231,8 @@ function notify(args)
|
||||||
|
|
||||||
-- populate the wibox with widgets
|
-- populate the wibox with widgets
|
||||||
local textbox = widget({ type = "textbox", name = "text", align = "flex" })
|
local textbox = widget({ type = "textbox", name = "text", align = "flex" })
|
||||||
textbox:buttons({ button({ }, 1, function () destroy(notification) end) })
|
textbox:buttons({ button({ }, 1, run),
|
||||||
|
button({ }, 3, function () destroy(notification) end) })
|
||||||
textbox.text = string.format('<span font_desc="%s"><b>%s</b> %s</span>',
|
textbox.text = string.format('<span font_desc="%s"><b>%s</b> %s</span>',
|
||||||
config.font, title, text)
|
config.font, title, text)
|
||||||
if config.hover_timeout then textbox.mouse_enter = hover_destroy end
|
if config.hover_timeout then textbox.mouse_enter = hover_destroy end
|
||||||
|
@ -236,7 +240,8 @@ function notify(args)
|
||||||
local iconbox = nil
|
local iconbox = nil
|
||||||
if icon then
|
if icon then
|
||||||
iconbox = widget({ type = "imagebox", name = "icon", align = "left" })
|
iconbox = widget({ type = "imagebox", name = "icon", align = "left" })
|
||||||
iconbox:buttons({ button({ }, 1, function () destroy(notification) end) })
|
iconbox:buttons({ button({ }, 1, run),
|
||||||
|
button({ }, 3, function () destroy(notification) end) })
|
||||||
local img = image(icon)
|
local img = image(icon)
|
||||||
if icon_size then
|
if icon_size then
|
||||||
img = img:crop_and_scale(0,0,img.height,img.width,icon_size,icon_size)
|
img = img:crop_and_scale(0,0,img.height,img.width,icon_size,icon_size)
|
||||||
|
|
Loading…
Reference in New Issue