Created
September 9, 2015 18:57
-
-
Save blueyed/d7ba5d51fafff1605fff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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