Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exec-and-forget doesn't seem like to run the script #1085

Closed
nickkadutskyi opened this issue Feb 13, 2025 · 1 comment
Closed

exec-and-forget doesn't seem like to run the script #1085

nickkadutskyi opened this issue Feb 13, 2025 · 1 comment

Comments

@nickkadutskyi
Copy link

nickkadutskyi commented Feb 13, 2025

I have this config:

[mode.main.binding]
alt-shift-1 = ["exec-and-forget /nix/store/96bgmvwqx3c77i4gpklmb5nk5d1aig3z-aerospace-switcher.sh"]
alt-shift-2 = ["exec-and-forget /nix/store/dxipn2am8n9nmqqw0ss3r6n8jc53kwb5-aerospace-switcher.sh"]

When I press the key combos it only switches to the workspace and doesn't seem like to run the script.

aerospace-switcher.sh scripts contain this, the only difference in those scripts is which workspace they are switching to:

#!/nix/store/x7m765hh1m4yikg9spw18lxldddvdnd0-bash-5.2p37/bin/bash
APP_FOCUSED=$(/nix/store/w0wlb3d23g7f3winv6vsn6965a7ndmw7-aerospace-0.16.2-Beta/bin/aerospace list-windows --focused --json | jq -cr '.[] | ."app-name"')
if [[ "$APP_FOCUSED" == "Ghostty" ]]; then
  /nix/store/w0wlb3d23g7f3winv6vsn6965a7ndmw7-aerospace-0.16.2-Beta/bin/aerospace list-windows --all --json |
    /nix/store/lmlmb3a5kzza0si8xfghr7x17vg8bzxb-jq-1.7.1-bin/bin/jq '.[] | select(."app-name"=="Ghostty") | ."window-id"' -cr |
    /usr/bin/xargs -I _ aerospace move-node-to-workspace C --window-id _
else
  /nix/store/w0wlb3d23g7f3winv6vsn6965a7ndmw7-aerospace-0.16.2-Beta/bin/aerospace move-node-to-workspace C
fi

Simplified script for testing:

APP_FOCUSED=$(aerospace list-windows --focused --json | jq -cr '.[] | ."app-name"')
if [[ "$APP_FOCUSED" == "Ghostty" ]]; then
  aerospace list-windows --all --json |
    jq '.[] | select(."app-name"=="Ghostty") | ."window-id"' -cr |
    xargs -I _ aerospace move-node-to-workspace C --window-id _
else
  aerospace move-node-to-workspace C
fi

The goal is to move all the tabs (windows) of the app to a workspace if the app is Ghostty otherwise just move the focused window.

Running script directly from the terminal works but doesn't work when I click alt+shift+1 or alt+shift+2.

Is there a way to troubleshoot script execution by the Aerospace?

I used macOS /usr/bin/say to that it actually runs this part:

aerospace list-windows --all --json |
    jq '.[] | select(."app-name"=="Ghostty") | ."window-id"' -cr |
    xargs -I _ aerospace move-node-to-workspace C --window-id _
@nickkadutskyi
Copy link
Author

Nvm, missed couple places to refer to aerospace via full path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant