add hyprstage binds

This commit is contained in:
2026-08-14 00:11:09 -07:00
parent 29f19bb45d
commit 816eb22b2f
5 changed files with 84 additions and 10 deletions
+70 -4
View File
@@ -12,6 +12,60 @@ local function chord(...)
return table.concat({ ... }, " + ")
end
-- Stage uses vertical navigation to move through its preview ordering. Keep
-- the ordinary directional-focus behavior for every other tiled layout.
local function focus_or_stage(direction, stage_message)
local focus = hl.dsp.focus({ direction = direction })
if not stage_message then
return focus
end
return function()
local workspace = hl.get_active_special_workspace() or hl.get_active_workspace()
if workspace and workspace.tiled_layout == "stage" then
hl.dispatch(hl.dsp.layout(stage_message))
return
end
hl.dispatch(focus)
end
end
local tiled_layouts = { "dwindle", "master", "scrolling", "monocle", "stage" }
local active_workspace_layout_rules = {}
local function cycle_active_workspace_layout()
local workspace = hl.get_active_special_workspace() or hl.get_active_workspace()
if not workspace or workspace.special then
return
end
local next_index = 1
for index, layout in ipairs(tiled_layouts) do
if layout == workspace.tiled_layout then
next_index = index % #tiled_layouts + 1
break
end
end
local selector = workspace.config_name
if not selector or selector == "" then
selector = tostring(workspace.id)
end
local previous_rule = active_workspace_layout_rules[workspace.id]
if previous_rule then
previous_rule:set_enabled(false)
end
active_workspace_layout_rules[workspace.id] = hl.workspace_rule({
workspace = selector,
layout = tiled_layouts[next_index],
})
end
-- Generate matching focus/move bindings for numbered workspaces. Workspace 10
-- maps to the 0 key because `% 10` returns zero.
local function bind_numbered_workspaces(modifier, move_modifier, count)
@@ -78,11 +132,16 @@ hl.bind(
local directions = {
{ arrow = "left", key = "A", direction = "l", monitor = "left" },
{ arrow = "right", key = "D", direction = "r", monitor = "right" },
{ arrow = "up", key = "W", direction = "u", monitor = "above" },
{ arrow = "down", key = "S", direction = "d", monitor = "below" },
{ arrow = "up", key = "W", direction = "u", monitor = "above", stage_message = "cycleprev" },
{ arrow = "down", key = "S", direction = "d", monitor = "below", stage_message = "cyclenext" },
}
for _, direction in ipairs(directions) do
local description = "Focus window " .. direction.arrow
if direction.stage_message then
description = description .. " / navigate Stage"
end
hl.bind(
chord(main, direction.arrow),
hl.dsp.focus({ direction = direction.arrow }),
@@ -90,8 +149,8 @@ for _, direction in ipairs(directions) do
)
hl.bind(
chord(hyper, direction.key),
hl.dsp.focus({ direction = direction.direction }),
{ description = "Focus window " .. direction.arrow }
focus_or_stage(direction.direction, direction.stage_message),
{ description = description }
)
hl.bind(
chord(hyper, "CTRL", direction.key),
@@ -105,6 +164,13 @@ for _, direction in ipairs(directions) do
)
end
-- Cycle only the active workspace through the configured tiled layouts.
hl.bind(
chord(hyper, "grave"),
cycle_active_workspace_layout,
{ description = "Cycle active workspace layout" }
)
bind_numbered_workspaces(main, "SHIFT", 10)
bind_numbered_workspaces(hyper, "CTRL", 9)