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 <anurag08priyam@gmail.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
2a4503ef04
commit
514fd796f3
|
@ -398,6 +398,32 @@ end
|
||||||
-- </ul>
|
-- </ul>
|
||||||
-- @param parent Specify the parent menu if we want to open a submenu, this value should never be set by the user.
|
-- @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.
|
-- @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
|
||||||
|
-- <code>match_any</code> instead of <code>match</code>, menu of clients with
|
||||||
|
-- different classes can also be build.
|
||||||
|
--
|
||||||
|
-- <p><code>
|
||||||
|
-- function terminal_menu () <br/>
|
||||||
|
-- terms = {} <br/>
|
||||||
|
-- for i, c in pairs(client.get()) do <br/>
|
||||||
|
-- if awful.rules.match(c, {class = "URxvt"}) then <br/>
|
||||||
|
-- terms[i] = <br/>
|
||||||
|
-- {c.name, <br/>
|
||||||
|
-- function() <br/>
|
||||||
|
-- awful.tag.viewonly(c:tags()[1]) <br/>
|
||||||
|
-- client.focus = c <br/>
|
||||||
|
-- end, <br/>
|
||||||
|
-- c.icon <br/>
|
||||||
|
-- } <br/>
|
||||||
|
-- end <br/>
|
||||||
|
-- end <br/>
|
||||||
|
-- m = awful.menu({items = terms}) <br/>
|
||||||
|
-- m:show({keygrabber=true}) <br/>
|
||||||
|
-- return m <br/>
|
||||||
|
-- end <br/>
|
||||||
|
--</code></p>
|
||||||
function new(menu, parent, num)
|
function new(menu, parent, num)
|
||||||
-- Create a table to store our menu informations
|
-- Create a table to store our menu informations
|
||||||
local data = {}
|
local data = {}
|
||||||
|
|
Loading…
Reference in New Issue