skhd icon indicating copy to clipboard operation
skhd copied to clipboard

zsh:1: command not found: yabai

Open lukebarton opened this issue 10 months ago • 5 comments

I've got yabai and skhd installed via brew and I've got zsh configured by nix w/ home-manager. I'm running the service via skhd --(start|restart|stop)-service.

The plist includes the homebrew prefix (/opt/homebrew/bin:/opt/homebrew/sbin:) in the PATH environment variable and echo $PATH from the shell returns /opt/homebrew/bin:/opt/homebrew/sbin:.. as expected.

Debugging skhd using: alt - p : echo $PATH, the /tmp/skhd_*.out.log does NOT include the homebrew prefix on the path. I don't understand why. It's in the plist for the service and it's also in my shell. What could I be missing that would mean it's not on the PATH of the service's zsh call?

lukebarton avatar Apr 21 '24 16:04 lukebarton

I can work around this by alt - p : eval $(/opt/homebrew/bin/brew shellenv) && yabai ... but it'd be good to resolve it correctly.

I suspect it has something to do with not-sourcing-.zshrc with a non-interactive shell. But to count against that, even forcing interactive shell with alt - o : /bin/zsh -ic 'echo $PATH' doesn't help (which might not work anyway for other reasons). I'm kinda at a loss. I probably need to spend a weekend learning more about shells and zsh.

lukebarton avatar Apr 21 '24 17:04 lukebarton

If you're already using homemanager, why not use nix-darwin and let that manage both yabai and skhd for you? That might fix the path issues because you wont depend on homebrew anymore for this.

tymscar avatar Apr 30 '24 02:04 tymscar

Because package versions.

In the end I’m no longer using Yabai. Instead I’m using AeroSpace, which is more suitable for my use cases.

lukebarton avatar May 13 '24 22:05 lukebarton

Noticing a similar issue.

I'm using skhd to set a hotkey to open Alacritty. While the hotkey works, I've noticed that shift-clicking on any urls within the terminal doesn't open the url, instead it errors:

Screenshot 2024-06-06 at 3 26 09 PM

The reason appears to be that Alacritty is calling open, and for some reason that command is not in the $PATH.

I also noticed when setting up the hotkey that it was necessary to call /usr/bin/open instead of plain open to launch the application.

Confirmed using the debug hotkey shown above that skhd's PATH does not contain /usr/bin (or any other system path for that matter, only Nix store paths. Maybe because the daemon is started by home-manager?)

My hotkey looks like this:

# if there's already an instance running, open new window, otherwise start a new instance
ctrl + cmd - return : /nix/store/xx9zzx3a9v96yxkbg5b85yb1m7x69gl5-alacritty-local/bin/alacritty msg create-window 2>&1 || /usr/bin/open -a /nix/store/xx9zzx3a9v96yxkbg5b85yb1m7x69gl5-alacritty-local/Applications/Alacritty.app

avrahamappel avatar Jun 06 '24 19:06 avrahamappel

Turned out my issue was that the PATH key of skhd's plist file did not include any system paths. Reran skhd --uninstall-service; skhd --install-service and all's well

avrahamappel avatar Jun 24 '24 15:06 avrahamappel