Keybindings and numeric pad

Introduction
The numeric pad is seldom used, and useful key bindings can easily be defined if you have 9 tags and 9 keys. This page goes through an example on how to use the numeric pad to "go to tags" and "show personalized menus", but you can go to the final section if you are already familiar with awesome and want to see the result.

Show a particular tag
Showing (moving to) a particular tag can be achieved associating the key (KP_End) with the tag:

awful.key({ }, "KP_End", function awful.tag.viewonly(tags[mouse.screen][1]) end),

Pressing keypad 1 (with the symbol end) shows tag number 1.

Go to a tag and show the menu corresponding to that tag
One of the first actions when configuring awesome has to do with the naming of the tags. For example:

tags = {} for s = 1, screen.count do    -- Each screen has its own tag table. tags[s] = awful.tag({ "File", "Mail", "Off", "FF", "Sys", "Oci", "Chro", "Net", "Aw" }, s, layouts[1]) end

The naming is normally related with the activities you are going to be doing in this particular tag; activities often related with a sub-section of the main menu. For example, in the main menu you may have a sub-menu with these items:

Menu_File = { {"&1_vifm", "urxvtc -e vifm"}, {"&2_Muntar usb", "urxvtc -e /usr/local/bin/Munta.sh usb" } }

This sub-menu with the activities related to "files" can be easily transformed into a menu of its own:

M_File = awful.menu ( 	{items = Menu_File} )

All right. Let's go to the tag and show the menu associated to the tag with Shift-KP_End:

awful.key({ "Shift" }, "KP_End", function  	awful.tag.viewonly(tags[mouse.screen][1]) 	M_File:show({keygrabber=true})  end),

You may have noticed that each item in the menu is numbered and preceded with an ampersand (&). If frequent items are positioned higher in the menu, pressing Shift-KP_End and 1 will give the most used item in the tag (workspace).

Show the menu when you are not in the tag
There may be situations where you want the menu associated to another tag. Let's associate this menu to the ctrl key:

awful.key({ "Control" }, "KP_End", function  	M_File:show({keygrabber=true})  end)

Having all together in few lines of code!!
Other window managers can more or less easily have multiple menus and "go to workspace and show the menu associated to the workspace", What is awesome is that you can define this in a few lines of code thanks to the use of the Lua language:

-- Define the keys and the menus in a lua table Numeric_Pad = { "KP_End", "KP_Down", "KP_Next", "KP_Left", "KP_Begin", "KP_Right", "KP_Home", "KP_Up", "KP_Prior" } Menu_Table = { M_File, M_Mail, M_Office, M_Fox, M_Sys, M_Oci, M_Chrome, M_Xarxa, M_Awesome } -- Associate each tag (1 to 9) with each key (Numeric_Pad) to each menu (Menu_Table) for i = 1, 9 do    globalkeys = awful.util.table.join(globalkeys, 	-- Got to tag with numeric pad   	awful.key({ }, Numeric_Pad[i], function  awful.tag.viewonly(tags[mouse.screen][i]) end), 	-- Go to tag and show menu with shift and numeric pad  	awful.key({ "Shift" }, Numeric_Pad[i], function awful.tag.viewonly(tags[mouse.screen][i]) Menu_Table[i]:show({keygrabber=true}) end), 	-- Show menu with control and numeric pad 	awful.key({ "Control" }, Numeric_Pad[i], function Menu_Table[i]:show({keygrabber=true}) end) 	) end

Voilà!

(note: let us know if this can be easily achieved with other window managers to give them recognition).
 * Fvwm can do this magic with Perl preprocessing. See this post