Hand the terminal launcher the focused window's pid from Lua (#13521)

To open a new terminal in the focused terminal's directory, the launcher
asked Hyprland for the active window with hyprctl, ~10ms on every
SUPER+RETURN. The binding now reads the pid from hl.get_active_window() and
passes it as --pid. Without one, from the menu or a shell, the launcher asks
Hyprland as before.

The bind is now a Lua function, which Hyprland reports only as __lua, so
o.bind_commands records the command it stands for and the keybindings menu
still launches a terminal when the entry is picked.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier HanssonandClaude Opus 5.5 authored and GitHub committed 2026-09-28 11:48:28 +02:00
1 parent fa729f139c
commit f814639556
7 files changed
+59 -5

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
-- Essential application bindings.
o.bind("SUPER + RETURN", "Terminal", { omarchy = "terminal" })
o.bind("SUPER + RETURN", "Terminal", o.launch_terminal())
o.bind("SUPER + SHIFT + RETURN", "Browser", { omarchy = "browser" })
o.bind("SUPER + SHIFT + F", "File manager", { omarchy = "nautilus" })
o.bind("SUPER + ALT + SHIFT + F", "File manager (cwd)", { omarchy = "nautilus-cwd" })
+20
View File
@@ -160,6 +160,26 @@ function o.launch(command)
return "uwsm-app -- " .. command
end
-- The command each function bind stands for, so the keybindings menu can still
-- run a bind that Hyprland only reports as Lua.
o.bind_commands = {}
-- Hand the launcher the focused window's pid, which it would otherwise ask
-- Hyprland for, to open the new terminal in that terminal's directory.
function o.launch_terminal()
local function launch()
local window = hl.get_active_window()
if window and window.pid then
hl.exec_cmd("omarchy-launch-terminal --pid=" .. window.pid)
else
hl.exec_cmd("omarchy-launch-terminal")
end
end
o.bind_commands[launch] = "omarchy-launch-terminal"
return launch
end
function o.exec_on_start(command)
hl.on("hyprland.start", function()
hl.exec_cmd(command)