Skip to content

Instantly share code, notes, and snippets.

@blueyed
Created September 9, 2015 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blueyed/d7ba5d51fafff1605fff to your computer and use it in GitHub Desktop.
Save blueyed/d7ba5d51fafff1605fff to your computer and use it in GitHub Desktop.
-- 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