fixed the omarchy-cmd-terminal-cwd for kitty#6315
Closed
xmagma-x wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
Thanks for reporting this. Fixed in 008f3a22 using a smaller deterministic approach: Kitty gets a per-process remote-control socket, and the cwd helper queries only |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title:
Fix omarchy-cmd-terminal-cwd to correctly detect cwd for Kitty terminal
Description:
Problem
omarchy-cmd-terminal-cwdalways returns$HOMEwhen used from Kitty terminal, making the keybindingSUPER+SHIFT+ALT+F(which uses$(omarchy-cmd-terminal-cwd)) useless.Root Cause
Three issues with the original script when running under Kitty:
Kitty's client-server architecture: Kitty uses a daemon that spawns tabs/windows as child processes.
hyprctl activewindowreturns the Kitty window PID, but that PID belongs to the Kitty daemon — not the shell process inside the window. The daemon has no directcwd./proc/$pid/childrendoesn't exist: The original script tried to read/proc/$pid/childrento walk the process tree, but this file does not exist on all kernels despiteCONFIG_PROC_CHILDREN=y. Usingpgrep -Pis the reliable alternative.IFS null-byte issue: The system's default
IFSincludes a null byte, which causesfor child in $childrento silently fail. Usingwhile IFS= read -rfixes this.Changes
hyprctl activewindowto detect Kitty.kitty @ ls+jqto query the focused window's shell PID and cwd directly via Kitty's remote control protocol.kitty @ lsfails (e.g., missingKITTY_PUBLIC_KEYin keybinding context), extracts the daemon PID from systemd transient scopes (/run/user/$UID/systemd/transient/kitty-*.scope), then recursively walks the process tree viapgrep -Pto find the deepest shell.pgrep -Pwalking instead of/proc/$pid/children.while IFS= read -rto handle null bytes in IFS correctly.PR body (markdown):
Problem
omarchy-cmd-terminal-cwdalways returns$HOMEwhen used from Kitty terminal, making theSUPER+SHIFT+ALT+Fkeybinding useless.Root Cause
Three issues under Kitty:
hyprctl activewindowreturns the Kitty daemon PID, which has no directcwd./proc/$pid/childrendoesn't exist: Not available on all kernels.pgrep -Pis the reliable alternative.for child in $children. Fixed withwhile IFS= read -r.Solution
kitty @ ls+jqto get focused window's shell PID and cwd.pgrep -P.pgrep -Pinstead of/proc/$pid/children.while IFS= read -r.Testing
Verified working on Kitty 0.47.4 with both manual command execution and the
SUPER+SHIFT+ALT+Fkeybinding.