Improving Awesome Qubes - Partioned Menu & VM sensitive shortcuts

This small patch for the Qubes OS patch for the Awesome WM allows to retrieve the domain a client (window) belongs to. This allows to configure behaviour that is domain context sensitive. One example would be spawning a terminal in the domain of the current focused client when pressing ALT+SPACE. Also added is a function that generates the menu with sub-menus (see screenshot) for Temaplate and Net/Proxy VMs.

The patch in total introduces only four new functions to the modul:

-- Return vmname of a client
function qubes.get_vmname(c)
-- Execute command in the vm , including dom0
function qubes.execute_in_vm(vmname, command)
-- Execute command in the vm of the client, including dom0
function qubes.execute_in_vm_of_client(c, command)
-- Return  menu like qubes.make_menu() but with subs for Net/ProxyVMs and TemplateVMs
function qubes.make_partitioned_menu()

mymainmenu = awful.menu({ items = {
	{"qubes", qubes.make_partitioned_menu()},
	{ "awesome", myawesomemenu, beautiful.awesome_icon },
	{ "open terminal", terminal }
}})

terminal = "urxvt"
[..]
awful.key({altkey,}, "space", function () qubes.execute_in_vm_of_client(client.focus, terminal) end),
[..]

Download: Patch-File for qubes.lua