1

How would I focus on specific client in awesome window manager by pressing Alt-1 to first window, Alt-2 to go to second window, and so on? I made this script but it doesn't work properly, it selects random windows:

awful.key({"Mod1"            }, "1",
    function ()
        awful.client.focus.byidx(1)
        if client.focus then
            client.focus:raise()
        end
    end         ),
awful.key({"Mod1"            }, "2",
    function ()
        awful.client.focus.byidx(2)
        if client.focus then
            client.focus:raise()
        end
    end         ),
awful.key({"Mod1"            }, "3",
    function ()
        awful.client.focus.byidx(3)
        if client.focus then
            client.focus:raise()
        end
    end         ),
Nulik
  • 6,748
  • 10
  • 60
  • 129

1 Answers1

5

For 3.5.6

awful.key({"Mod1"            }, "2",
    function ()
        local cc = {}
        for _, c in ipairs(client.get()) do
            if awful.widget.tasklist.filter.currenttags(c, mouse.screen) then cc[#cc + 1] = c end
        end
        local new_focused = cc[2]
        if new_focused then client.focus = new_focused; new_focused:raise() end
    end
),
Worron
  • 181
  • 3