Skip to content
The Chat Archive
gpt-4o-search-preview-high· OpenAI LMArena Search Arena 24K

awesomewm lua code to cycle windows and activate the selection with hotkey alt+tab (like…

  1. User

    awesomewm lua code to cycle windows and activate the selection with hotkey alt+tab (like mac), hotkey to go to workspace 1-4, and hotkeys to move focused window to workspace 1-4. include making the windows themselves draggable

  2. Assistant

    To configure AwesomeWM to cycle through windows using Alt+Tab (similar to macOS), set up hotkeys for switching to and moving windows between workspaces 1-4, and enable draggable windows, follow these steps:

    1. Cycle Through Windows with Alt+Tab:

    By default, Mod+Tab in AwesomeWM switches between the last two focused windows. To cycle through all windows, you can modify your rc.lua configuration file:

    -- Replace the existing Mod+Tab keybinding with the following:
    awful.key({ "Mod1" }, "Tab",
        function ()
            awful.client.focus.byidx(1)
            if client.focus then
                client.focus:raise()
            end
        end,
        {description = "cycle through windows", group = "client"}
    ),
    awful.key({ "Mod1", "Shift" }, "Tab",
        function ()
            awful.client.focus.byidx(-1)
            if client.focus then
                client.focus:raise()
            end
        end,
        {description = "cycle through windows in reverse", group = "client"}
    )
    

    This configuration allows you to cycle forward through windows with Alt+Tab and backward with Alt+Shift+Tab[1].

    2. Switch to Workspaces 1-4 with Hotkeys:

    To navigate to workspaces 1 through 4 using Mod+1 to Mod+4, add the following keybindings to your rc.lua:

    -- Keybindings to switch to workspaces 1-4
    for i = 1, 4 do
        globalkeys = awful.util.table.join(globalkeys,
            awful.key({ modkey }, "#" .. i + 9,
                function ()
                    local screen = awful.screen.focused()
                    local tag = screen.tags[i]
                    if tag then
                        tag:view_only()
                    end
                end,
                {description = "view workspace " .. i, group = "tag"}
            )
        )
    end
    

    This loop assigns Mod+1 to Mod+4 to switch to workspaces 1 through 4, respectively.

    3. Move Focused Window to Workspaces 1-4:

    To move the currently focused window to workspaces 1 through 4 using Mod+Shift+1 to Mod+Shift+4, include the following in your rc.lua:

    -- Keybindings to move focused window to workspaces 1-4
    for i = 1, 4 do
        globalkeys = awful.util.table.join(globalkeys,
            awful.key({ modkey, "Shift" }, "#" .. i + 9,
                function ()
                    if client.focus then
                        local tag = client.focus.screen.tags[i]
                        if tag then
                            client.focus:move_to_tag(tag)
                        end
                    end
                end,
                {description = "move focused window to workspace " .. i, group = "tag"}
            )
        )
    end
    

    This configuration allows you to move the focused window to workspaces 1 through 4 using Mod+Shift+1 to Mod+Shift+4.

    4. Enable Draggable Windows:

    To make windows draggable (floating), you can modify the mouse bindings in your rc.lua:

    -- Mouse bindings for draggable (floating) windows
    clientbuttons = awful.util.table.join(
        awful.button({ }, 1, function (c)
            c:emit_signal("request::activate", "mouse_click", {raise = true})
            if c.floating then
                awful.mouse.client.move(c)
            end
        end),
        awful.button({ modkey }, 1, function (c)
            c:emit_signal("request::activate", "mouse_click", {raise = true})
            awful.mouse.client.move(c)
        end),
        awful.button({ modkey }, 3, function (c)
            c:emit_signal("request::activate", "mouse_click", {raise = true})
            awful.mouse.client.resize(c)
        end)
    )
    

    This setup allows you to click and drag floating windows with the left mouse button.

    Note: Ensure that you replace modkey with your actual modifier key (commonly Mod4 or the Super/Windows key) in the configurations above.

    After making these changes, reload your AwesomeWM configuration to apply them.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.