awesome: alt+tab just switches between two apps
By default, the client sets focus to the previous window that had focus. When you alt+tab and it changes windows, the previous window is now the original window. Hence, it cycles between two windows.
To fix this, you will need to change the following:
In the default rc.lua, the section that controls window cycling looks like this:
awful.key({ modkey, }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end),
To cycle through all the windows, and not just the previous, change the above code to the following:
awful.key({ modkey, }, "Tab",
function ()
-- awful.client.focus.history.previous()
awful.client.focus.byidx(-1)
if client.focus then
client.focus:raise()
end
end),
awful.key({ modkey, "Shift" }, "Tab",
function ()
-- awful.client.focus.history.previous()
awful.client.focus.byidx(1)
if client.focus then
client.focus:raise()
end
end),
That will cycle through the windows when you press Alt+Tab
, and in reverse order when you press Alt+Shift+Tab
. (The two lines beginning with --
are comments, so they do not affect the outcome.)
To cycle through every client on a tag, even minimized ones, you may find this function helpful:
awful.key({ modkey, }, "Tab",
function ()
for c in awful.client.iterate(function (x) return true end) do
client.focus = c
client.focus:raise()
end
end),
Note that none of these solutions consider the history whatsoever, and instead will switch to the window that had focus least recently (i.e., does not consider the ordering in which windows had focus).
I have created a module for this: https://github.com/blueyed/awesome-cyclefocus
It supports different methods of Alt-Tab
(see the README) and can be easily configured to your liking via filters that get applied while cycling through the windows, e.g. to filter only windows with the same WM class, or on the same screen/tag.
I've done something similar with my setup that Chris provided in his solution. Rather than shifing focus through all the windows, however, it actually cycles them through the master and slave stack. In other words, they all visibly rotate on screen:
awful.key({ modkey, "Shift" }, "Tab",
function ()
awful.client.cycle(false)
awful.client.focus.byidx(0,awful.client.getmaster()) -- Added 2013-03-01
end),
awful.key({ modkey, }, "Tab",
function ()
awful.client.cycle(true)
awful.client.focus.byidx(0,awful.client.getmaster()) -- Added 2013-03-01
end),
I still need to tweak that a bit, since I'd like focus to (at least appear to) remain on the master window throughout the cycle operation. I'm still familiarizing myself with the Awesome Lua API when I found aweful.client.cycle that makes it so easy. :)
I figured I would just chime in with this current solution of mine since this is among the first resources I investigated that addressed my similar question. Hope it helps.