How to avoid some keybind repetition in Hyprland

2 months ago by alecsargent to c/windowmanagers

I found the following useful to keep they keybind configuration shorter and easier to modify.

for i = 1, 10 do
    local key = i % 10

    hl.bind(
        M .. "+" .. key,
        hl.dsp.focus({ workspace = i })
    )
    hl.bind(
        M .. "+SHIFT+" .. key,
        hl.dsp.window.move({ workspace = i, follow = true })
    )
    hl.bind(
        M .. "+CTRL+" .. key,
        hl.dsp.window.move({ workspace = i, follow = false })
    )
end

And for special workspaces too:

local function specialWorkspaceKeybind(name, key)
    hl.bind(
        M .. "+" .. key,
        hl.dsp.workspace.toggle_special(name)
    )
    hl.bind(
        M .. "+SHIFT+" .. key,
        hl.dsp.window.move({ workspace = "special:" .. name })
    )
    hl.bind(
        M .. "+CTRL+" .. key,
        hl.dsp.window.move({ workspace = "special:" .. name, follow = false })
    )
end

specialWorkspaceKeybind("quickterm", "i")
specialWorkspaceKeybind("calc", "h")
specialWorkspaceKeybind("matrix", "u")
windowmanagers
windowmanagers

@lemmy.zip

login for more options
387
252
18

A place to share, discuss & comment the window manager experience.

Visit our website


Related Communities

go to feed...