From b805492c2aed6794a481b2cebfacb9eb982f9d93 Mon Sep 17 00:00:00 2001 From: Anurag Priyam Date: Thu, 27 Jan 2011 02:12:58 +0530 Subject: [PATCH] add usage example for awful.menu Added a very simple example to show the usage, and applicability of awful.menu by dynamically constructing a menu of clients that match a particular rule. Signed-off-by: Anurag Priyam Signed-off-by: Uli Schlachter --- lib/awful/menu.lua.in | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in index 8cd6c519..4b11d8c9 100644 --- a/lib/awful/menu.lua.in +++ b/lib/awful/menu.lua.in @@ -386,6 +386,32 @@ end -- -- @param parent Specify the parent menu if we want to open a submenu, this value should never be set by the user. -- @param num Specify the parent's clicked item number if we want to open a submenu, this value should never be set by the user. +-- @usage The following function builds, and shows a menu of clients that match +-- a particular rule. Bound to a key, it can for example be used to select from +-- dozens of terminals open on several tags. With the use of +-- match_any instead of match, menu of clients with +-- different classes can also be build. +-- +--

+-- function terminal_menu ()
+--   terms = {}
+--   for i, c in pairs(client.get()) do
+--    if awful.rules.match(c, {class = "URxvt"}) then
+--     terms[i] =
+--     {c.name,
+--     function()
+--      awful.tag.viewonly(c:tags()[1])
+--      client.focus = c
+--     end,
+--     c.icon
+--     }
+--    end
+--   end
+--   m = awful.menu({items = terms})
+--   m:show({keygrabber=true})
+--   return m
+-- end
+--

function new(menu, parent, num) -- Create a table to store our menu informations local data = {}