Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- Generic back and forth switching between master and client. {{{
-- Bind it like this:
-- awful.key({ modkey, "Control" }, "Return", function (c) my_swap_back_and_forth.run(c, awful.client.getmaster) end),
local my_swap_back_and_forth = {
previous_by_tag_and_f = {}
}
my_swap_back_and_forth.run = function (c, swapf)
local f = swapf or awful.client.getmaster
local prev = my_swap_back_and_forth.previous_by_tag_and_f
if not prev.tag then
prev.tag = {}
end
local swap_with = f()
local tag = c:tags()[1]
if c == swap_with then
if prev.tag.f then
swap_with = prev.tag.f
else
bnote("No previous client to swap with.")
return
end
end
prev.tag.f = swap_with
c:swap(swap_with)
end
-- }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment