All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 Licensed under GNU General Public License v2
4 * (c) 2017, Simon Désaulniers <sim.desaulniers@gmail.com>
5 * (c) 2017, Uli Schlachter
6 * (c) 2017, Jeferson Siqueira <jefersonlsiq@gmail.com>
10 -- Menu iterator using naughty.notify
12 local naughty = require("naughty")
14 local state = { cid = nil }
16 local function naughty_destroy_callback(reason)
17 if reason == naughty.notificationClosedReason.expired or
18 reason == naughty.notificationClosedReason.dismissedByUser then
19 local actions = state.index and state.menu[state.index - 1][2]
21 for _,action in pairs(actions) do
22 -- don't try to call nil callbacks
23 if action then action() end
30 -- Iterates over a list of pairs {label, {callbacks}}. After timeout, the last
31 -- visited choice associated callbacks are executed.
32 -- * menu: a list of pairs {label, {callbacks}
33 -- * timeout: time to wait before confirming menu selection
34 -- * icon: icon to display left to the choiced label
35 local function iterate(menu, timeout, icon)
36 timeout = timeout or 4 -- default timeout for each menu entry
37 icon = icon or nil -- icon to display on the menu
39 -- Build the list of choices
40 if not state.index then
45 -- Select one and display the appropriate notification
47 local next = state.menu[state.index]
48 state.index = state.index + 1
54 label, _ = unpack(next)
56 state.cid = naughty.notify({
60 screen = mouse.screen,
61 replaces_id = state.cid,
62 destroy = naughty_destroy_callback
66 return { iterate = iterate }