Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

awesome: alt+tab just switches between two apps

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?

like image 948
ziiweb Avatar asked Jul 28 '12 00:07

ziiweb


2 Answers

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

like image 108
Christopher Corley Avatar answered Oct 12 '22 11:10

Christopher Corley


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.

like image 32
blueyed Avatar answered Oct 12 '22 13:10

blueyed