awesome: alt+tab just switches between two apps

11,443

Solution 1

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

Solution 2

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.

Solution 3

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.

Solution 4

In the default binds Mod + Tab cycles between the last two used applications. I was looking for Mod + j or Mod + k (reverse order).

Solution 5

There is library for awesome called awesome-switcher-preview. This implements a alt-tab behavior similar to what you would expect on other operating systems and window managers. It cycles through windows in the order when they were most recently focused. It cycles through all clients in your selected tag set for a screen. It includes minimized clients. It attempts to not mess up the history until a selection is made. It does not alter the stack much. Holding alt down keeps the preview/alt-tab switcher up.

You can get it here: https://github.com/berlam/awesome-switcher-preview

Share:
11,443

Related videos on Youtube

ziiweb
Author by

ziiweb

Ziiweb is a web agency on creating websites and web applications. We also offer marketing online services (SEO/PPC) to promote your business through search engines and social networks. We always bet for the last and best web technologies: HTML5, CSS3, jQuery, PHP5 and symfony (all releases).

Updated on August 11, 2022

Comments

  • ziiweb
    ziiweb over 1 year

    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?

  • Jim Garrison
    Jim Garrison over 11 years
    What's nice about Alt + Tab in most window managers is that it cycles through windows in the order when they were most recently focused. Mod + j in Awesome, on the other hand, cycles through the windows in a pre-determined order, which is not nearly as useful to me.
  • Admin
    Admin over 11 years
    This most certainly does work. You may need to restart awesome or run kill -s SIGHUP $(which awesome) to get it to take effect.
  • Ciges
    Ciges over 10 years
    I have just begun to use awesome. Very useful your configuration tip, thanks!
  • blueyed
    blueyed about 10 years
    The first solution is just the same as the default for modkey+j and modkey+k.
  • blueyed
    blueyed about 10 years
    @JimGarrison See my answer. I have created a module for this: github.com/blueyed/awesome-cyclefocus
  • blueyed
    blueyed almost 9 years
    @ChristopherCorley Great. I have a lot of local, uncommitted modification which are cooking up, e.g. using on-top during cycling and having callbacks to set opacity on non-current windows. Let me know in the Github issues if you're missing something etc.
  • drgibbon
    drgibbon over 7 years
    Fantastic! IMO the default Alt-Tab in awesomewm is not very good, and this module fixes it :)