From a14c5a9708b49901f501086723f7e79cda37b1b7 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 28 Apr 2026 15:40:44 -0700 Subject: [PATCH] Make monocle directional focus deterministic --- docs/hyprland-lua-migration-checklist.md | 3 ++- dotfiles/config/hypr/hyprland.lua | 29 ++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/docs/hyprland-lua-migration-checklist.md b/docs/hyprland-lua-migration-checklist.md index 09053633..8a0b8d2e 100644 --- a/docs/hyprland-lua-migration-checklist.md +++ b/docs/hyprland-lua-migration-checklist.md @@ -78,7 +78,8 @@ verifier mode. useful focus. - [x] Add "move to empty workspace on monitor in direction" without requiring `Hyper+Ctrl`. -- [ ] Verify directional focus in monocle behaves predictably. +- [x] Route directional focus in monocle through deterministic Lua cycling. +- [ ] Live-verify directional focus in monocle behaves predictably. ## 4. Script Elimination Priority diff --git a/dotfiles/config/hypr/hyprland.lua b/dotfiles/config/hypr/hyprland.lua index 3583f1a1..6da1ff76 100644 --- a/dotfiles/config/hypr/hyprland.lua +++ b/dotfiles/config/hypr/hyprland.lua @@ -389,6 +389,19 @@ local function monocle_prev() end end +local function focus_direction(direction) + if current_layout == monocle_layout then + if direction == "up" or direction == "left" then + monocle_prev() + else + monocle_next() + end + return + end + + hl.dsp.focus({ direction = direction })() +end + local function focus_workspace(workspace_id) hl.dsp.focus({ workspace = tostring(workspace_id), on_current_monitor = true })() end @@ -1179,10 +1192,18 @@ bind(main_mod .. " + SHIFT + B", function() enter_window_picker("replace") end) -bind(main_mod .. " + W", hl.dsp.focus({ direction = "up" })) -bind(main_mod .. " + S", hl.dsp.focus({ direction = "down" })) -bind(main_mod .. " + A", hl.dsp.focus({ direction = "left" })) -bind(main_mod .. " + D", hl.dsp.focus({ direction = "right" })) +bind(main_mod .. " + W", function() + focus_direction("up") +end) +bind(main_mod .. " + S", function() + focus_direction("down") +end) +bind(main_mod .. " + A", function() + focus_direction("left") +end) +bind(main_mod .. " + D", function() + focus_direction("right") +end) bind(main_mod .. " + SHIFT + W", hl.dsp.window.swap({ direction = "up" })) bind(main_mod .. " + SHIFT + S", hl.dsp.window.swap({ direction = "down" }))