5

I'm new to awesome wm and I would like to set a shortcut that brings me back to the previous window (in history) no matter if it's on the current tag, another tag or even on another screen (like Alt+Tab in Gnome or Windows).

By default, there is Super+Tab for going back but only on the same tag.

And there is Super+Esc for going back to the previously active tag.

If there is no function for going to the previous window (globally), could I write my own in rc.lua (if I knew Lua)?

MaxGyver
  • 309

1 Answers1

5

You can use the history list in direct via awful.client.focus.history.list

The first element of the table is the current focused client, so 2 is the previous

From the client get the first tag to view this tag

Then raise the client to have it on top

function ()                                                                                                  
    local c = awful.client.focus.history.list[2]                                                             
    client.focus = c                                                                                         
    local t = client.focus and client.focus.first_tag or nil                                                 
    if t then                                                                                                
        t:view_only()                                                                                        
    end                                                                                                      
    c:raise()                                                                                                
end  

So you can change from the rc.lua

    awful.key({ modkey,           }, "Tab",
        function ()
            awful.client.focus.history.previous()
            if client.focus then
                client.focus:raise()
            end
        end,
        {description = "go back", group = "client"}),

To

    awful.key({ modkey,           }, "Tab",
        function ()
            local c = awful.client.focus.history.list[2]
            client.focus = c
            local t = client.focus and client.focus.first_tag or nil
            if t then
                t:view_only()
            end
            c:raise()
        end,
        {description = "go back", group = "client"}),
Ôrel
  • 315