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:
1 parent
fa729f139c
commit
f814639556
7 files changed
+59
-5
No files matched your search
@@ -1,9 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Print the current working directory of the active terminal window
|
||||
# omarchy:args=[terminal-pid]
|
||||
# omarchy:hidden=true
|
||||
|
||||
terminal_pid=$(hyprctl activewindow | awk '/pid:/ {print $2}')
|
||||
terminal_pid=${1:-$(hyprctl activewindow | awk '/pid:/ {print $2}')}
|
||||
kitty_socket="$XDG_RUNTIME_DIR/omarchy-kitty-$terminal_pid"
|
||||
cwd=""
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Launch a terminal in the active terminal's current directory
|
||||
# omarchy:args=[command...]
|
||||
# omarchy:args=[--pid=<terminal-pid>] [command...]
|
||||
|
||||
exec setsid uwsm-app -- xdg-terminal-exec --dir="$(omarchy-cmd-terminal-cwd)" "$@"
|
||||
pid=""
|
||||
if [[ ${1:-} == --pid=* ]]; then
|
||||
pid=${1#--pid=}
|
||||
shift
|
||||
fi
|
||||
|
||||
exec setsid uwsm-app -- xdg-terminal-exec --dir="$(omarchy-cmd-terminal-cwd "$pid")" "$@"
|
||||
@@ -210,6 +210,9 @@ hl = setmetatable({
|
||||
elseif type(bind_dispatcher) == "string" and bind_dispatcher ~= "" then
|
||||
kind = "exec"
|
||||
arg = bind_dispatcher
|
||||
elseif o and o.bind_commands and o.bind_commands[bind_dispatcher] then
|
||||
kind = "exec"
|
||||
arg = o.bind_commands[bind_dispatcher]
|
||||
end
|
||||
|
||||
print(table.concat({ tostring(modmask), opts.description, key, kind, arg }, "\t"))
|
||||
@@ -530,7 +533,7 @@ output_binding_records_uncached() {
|
||||
|
||||
keybindings_cache_key() {
|
||||
{
|
||||
printf 'v13\n'
|
||||
printf 'v14\n'
|
||||
hyprctl devices 2>/dev/null | grep -F 'active keymap:'
|
||||
hyprctl binds 2>/dev/null
|
||||
} | sha256sum | awk '{ print $1 }'
|
||||
|
||||
Reference in new issue
Block a user