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
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
To configure AwesomeWM to cycle through windows using Alt+Tab, switch to workspaces 1-4, move the focused window to workspaces 1-4, and make windows draggable, you can modify your rc.lua configuration file as follows:
1. Cycle Windows with Alt+Tab:
Add the following keybindings to your rc.lua to cycle through clients:
lua
-- Cycle through clients with Alt+Tab
awful.key({ "Mod1" }, "Tab",
function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end,
{description = "cycle through clients", group = "client"})
This binds Alt+Tab to focus the next client window.
2. Switch to Workspaces 1-4:
Define keybindings to switch to specific workspaces (tags):
lua
-- Switch to workspace 1-4
for i = 1, 4 do
globalkeys = gears.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 binds Mod4+1 to Mod4+4 (usually Super+1 to Super+4) to switch to workspaces 1 through 4.
3. Move Focused Window to Workspaces 1-4:
Add keybindings to move the focused client to a specific workspace:
lua
-- Move focused client to workspace 1-4
for i = 1, 4 do
globalkeys = gears.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 client to workspace " .. i, group = "tag"})
)
end
This binds Mod4+Shift+1 to Mod4+Shift+4 to move the focused window to workspaces 1 through 4.
4. Make Windows Draggable:
To enable dragging of windows with the mouse, ensure the following mouse bindings are set:
lua
-- Enable dragging of windows
clientbuttons = gears.table.join(
awful.button({ }, 1, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
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 allows you to drag windows by holding the Mod4 key (usually the Super key) and left-clicking on the window.
Note: Replace modkey with your defined modifier key (commonly Mod4 for the Super key). Ensure you have the gears and awful libraries required for these configurations.
After adding these configurations to your rc.lua, reload AwesomeWM to apply the changes.