awesome: alt+tab just switches between two apps

ziiweb picture ziiweb · Jul 28, 2012 · Viewed 10.6k times · Source

I've just installed awesome as my wm. When I do alt+tab using awesome, it just switch two apps, it's not possible to get active the others..any idea?

Answer

Christopher Corley picture Christopher Corley · Jul 29, 2012

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).