Keeping multitags persistent

Summary
This configuration snipper/lua code will enable persistent multitags, for example :


 * type F1 to go to tag 1 ;


 * type Ctrl+F2 to add tag 2 to your view (you'll have clients of tags 1 and 2);


 * type F3 to switch to tag 3 (you'll have only clients from tag 3);


 * now, type F1 to go back to tag 1 : with this code, you'll be back to having tags 1 and 2, until you press Ctrl+F2 to remove tag 2.

Disclaimers

 * I use Fx keys to access tags, adjust if you want to keep the default (Mod4+numbers) or anything else.


 * This is my first lua code, so there may be more elegant ways of writing it.


 * If you restart awesome, everything will be forgotten (which is actually a good way of resetting if it gets lost, which it shouldn't but well...).


 * It only works if you switch with keyboard, not with mouse. That may be considered a feature ;)

The code
-- Bind all key numbers to F keys. -- Keep a (semi-)persistant mapping of active multitags -- This should map on the top row of your keyboard, usually F1 to F9. extra_tags = {} for i = 1, keynumber do   extra_tags[i] = {} globalkeys = awful.util.table.join(globalkeys,       awful.key({ }, "F" .. i,                 function local screen = mouse.screen local curtag = tags[screen][i] if curtag then awful.tag.viewonly(curtag) end for tag,v in pairs(extra_tags[i]) do 			if v then awful.tag.viewtoggle(tags[screen][tag]) end end end),       awful.key({ "Control" }, "F" .. i,                 function local screen = mouse.screen local curtag = awful.tag.getidx(awful.tag.selected(screen)) local selected = awful.tag.selectedlist(screen) local found = false for i_,v in ipairs(selected) do 			v = awful.tag.getidx(v) if v == i then found = true break end end if found then extra_tags[curtag][i] = false else extra_tags[curtag][i] = true end if tags[screen][i] then awful.tag.viewtoggle(tags[screen][i]) end end),       awful.key({ "Shift" }, "F" .. i,                 function if client.focus and tags[client.focus.screen][i] then awful.client.movetotag(tags[client.focus.screen][i]) end end),       awful.key({ "Control", "Shift" }, "F" .. i,                 function if client.focus and tags[client.focus.screen][i] then awful.client.toggletag(tags[client.focus.screen][i]) end end)) end