aboutsummaryrefslogtreecommitdiff
path: root/dot_config/hypr/config/binds.lua
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/hypr/config/binds.lua')
-rw-r--r--dot_config/hypr/config/binds.lua54
1 files changed, 40 insertions, 14 deletions
diff --git a/dot_config/hypr/config/binds.lua b/dot_config/hypr/config/binds.lua
index a5a9e6b..a72777f 100644
--- a/dot_config/hypr/config/binds.lua
+++ b/dot_config/hypr/config/binds.lua
@@ -52,6 +52,28 @@ local function ask_direct_nvim(win, direction)
return response:find("success", 1, true) ~= nil
end
+local function ask_tmux(win, direction)
+ local pid = tonumber(win.pid)
+
+ if not pid then
+ return false
+ end
+
+ local helper = (os.getenv("HOME") or "")
+ .. "/.config/hypr/scripts/tmux-smart-nav"
+
+ local handle = io.popen(string.format("%s %s %d", helper, direction, pid))
+
+ if not handle then
+ return false
+ end
+
+ local result = handle:read("*a")
+ handle:close()
+
+ return result:find("handled", 1, true) ~= nil
+end
+
local function smart_nav(direction)
return function()
local win = hl.get_active_window()
@@ -67,25 +89,29 @@ local function smart_nav(direction)
local title = (win.title or ""):lower()
- if title == "herdr" then
+ if ask_tmux(win, direction) then
+ return
+ end
+
+ -- Herdr now uses changing window titles. The helper checks whether its
+ -- foreground client belongs to this terminal before attempting navigation.
+ local pid = tonumber(win.pid)
+ if pid then
local helper = (os.getenv("HOME") or "")
.. "/.config/hypr/scripts/herdr-smart-nav"
+ local handle = io.popen(string.format("%q %s %d", helper, direction, pid))
- local handle = io.popen(helper .. " " .. direction)
+ if handle then
+ local result = handle:read("*a"):match("^%s*(.-)%s*$")
+ handle:close()
- if not handle then
- focus_hyprland(direction)
- return
+ if result == "handled" then
+ return
+ elseif result == "hyprland" then
+ focus_hyprland(direction)
+ return
+ end
end
-
- local result = handle:read("*a")
- handle:close()
-
- if result:find("hyprland", 1, true) then
- focus_hyprland(direction)
- end
-
- return
end
if is_direct_nvim(title) and ask_direct_nvim(win, direction) then