Rotate Clients

From awesome

Jump to: navigation, search

[edit] Rotate visible clients and keep the focus in place

With these two functions you can rotate all the currently visible clients on the active screen (no matter how many tags are active) by one position and still keep the focus in place.

This is useful when you want to mimick "Alt-Tab" behavior of other window managers when using more than 2 windows (for 2 windows this is obviously the same as simply switching) and maybe if you want to use very few keys to navigate.

-- rotate clients and focus master...
keybinding({ modkey }, "Tab", function ()
    local allclients = awful.client.visible(client.focus.screen)
  
    for i,v in ipairs(allclients) do
      if allclients[i+1] then
        allclients[i+1]:swap(v)
      end
    end
    awful.client.focus.byidx(-1)
  end):add()

-- ... the other way 'round!
keybinding({ modkey, "Shift" }, "Tab", function ()
    local allclients = awful.client.visible(client.focus.screen)

    for i,v in ipairs(allclients) do
      allclients[1]:swap(allclients[i])
    end
    awful.client.focus.byidx(1)
  end):add()


Kudos to bioe007 on #awesome for key insights on how to do this!

Personal tools