yqrashawn / GokuRakuJoudo

config karabiner with ease
GNU General Public License v3.0
1.13k stars 122 forks source link

Yabai - function with arguments #232

Open lukakemperle opened 9 months ago

lukakemperle commented 9 months ago

Hi there, I would like to execute a function (yabai) with the argument living outside the karabiner.edn:

karabiner.edn:

{:des "b-mode" :rules [ :b-sim
  [:p "~/.config/yabai/actions grid"]
]}

~/.config/yabai/actions.sh:

function float() {
  yabai -m window --toggle float
}

function grid() {
  yabai -m window --grid 3:1:1:1:1:1
}

if [ "$1" == "float" ] ; then
  float
elif [ "$1" == "grid" ] ; then
  grid
fi

# /usr/local/bin/yabai

Could please someone enlighten me on what I'm doing wrong - executing file in the terminal with arguments works (eg. ./actions.sh grid). Thank you!

hotsezus commented 6 months ago

@lukakemperle I had the same problem until i figured out that Karabiner does not source my ~/.zshrc and so there is no yabai binary in PATH. In order to fix it you can use full path to the location where your yabai binary lives

image
lukakemperle commented 6 months ago

I had the same problem until i figured out that Karabiner does not source my ~/.zshrc and so there is no yabai binary in PATH.

@hotsezus, thank you for the suggestion. -I currently use yabai in the template:

:templates {
:yabai "/usr/local/bin/yabai -m %s"
}

And the call it as [:##semicolon [:yabai "display --focus east || yabai -m display --focus recent"]]

Anyway, thank you & wish you a happy and productive 2024!