From 390b2185264a7c36dae5486342bc177f9462d85c Mon Sep 17 00:00:00 2001 From: koniu Date: Wed, 5 Nov 2008 02:03:28 +0000 Subject: [PATCH] naughty: new notify() parameter 'run' Signed-off-by: koniu --- lib/naughty.lua.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in index de65887e..00196aad 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -170,6 +170,7 @@ end -- @param bg Background color -- @param screen 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 }) function notify(args) -- gather settings together @@ -221,6 +222,8 @@ function notify(args) hooks.timer.register(timeout, timer) notification.timer = timer + local run = args.run or function () destroy(notification) end + local hover_destroy = function () if config.hover_timeout == 0 then destroy(notification) else hooks.timer.register(config.hover_timeout, timer) end @@ -228,7 +231,8 @@ function notify(args) -- populate the wibox with widgets 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('%s %s', config.font, title, text) if config.hover_timeout then textbox.mouse_enter = hover_destroy end @@ -236,7 +240,8 @@ function notify(args) local iconbox = nil if icon then 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) if icon_size then img = img:crop_and_scale(0,0,img.height,img.width,icon_size,icon_size)