Skip to content
New issue

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

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

Already on GitHub? # to your account

[Suggestion] Change the way of loading yabairc to execute yabairc file #2169

Closed
MirageTurtle opened this issue Mar 18, 2024 · 6 comments
Closed
Labels
suggestion Request for new feature or some form of enhancement

Comments

@MirageTurtle
Copy link

TL;DL:
Loading yabairc by executing yabairc file can support more flexible script, at least fork the process using bash instead of sh.

Full Details:
I found some issue when I use the following configuration in my ~/.yabairc:

#!/usr/bin/env bash
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa

declare -A opacity
opacity["active"]=1.0
opacity["normal"]=0.8
yabai -m config window_opacity on
yabai -m config active_window_opacity ${opacity["active"]} 
yabai -m config normal_window_opacity ${opacity["normal"]}

And I get output:

yabai: scripting-addition failed to inject payload into Dock.app!
declare: -A: invalid option
+ yabai -m config active_window_opacity 0.8
+ yabai -m config normal_window_opacity 0.8

Obviously, the interpreter/the process is not bash, or the one specified by the Shebang. And I confirmed this by issue #1993. As #1993 clarifys, the proccess is sh, and I confirmed this by some code like echo "Current Process Name: $(ps -p $$ -o comm=)".

I'm not sure if the failure of yabai injecting payload is caused by sh, but I get nothing wrong by execute them manually in a bash/zsh.

I'm not a good programmer. I tried to contribute to the source code but failed. So what I can only do is just raising an issue for suggestion.

@MirageTurtle
Copy link
Author

If you think this suggestion is stupid, or hard to do, please let me know, especially why.

@koekeishiya
Copy link
Owner

I don't particularly care how this works either way. You can argue the case with @penglei author of #1993 and other nix users (@gldtn, @danryan).

@koekeishiya
Copy link
Owner

koekeishiya commented Mar 18, 2024

Note that this specific part of the code has been untouched since like v1.0.0 from 5years ago, prior to #1993.
I didn't actually know that having it interpret rather than execute would break running as other shells.

@koekeishiya koekeishiya added the addressed on master; not released Fixed upstream, but not yet released label Mar 18, 2024
@koekeishiya
Copy link
Owner

After spending more than 5 seconds it is obviously clear why the change suggested in #1993 would change this behavior.
I've changed it on master to execute the config as before, if the exec-bit is set, and it will interpret as suggested in #1993 if the exec-bit is unset.

If you belong to a third group that require other behavior; feel free to go buy ice cream.

@koekeishiya koekeishiya added the suggestion Request for new feature or some form of enhancement label Mar 18, 2024
@gldtn
Copy link

gldtn commented Mar 18, 2024

I don't particularly care how this works either way. You can argue the case with @penglei author of #1993 and other nix users (@gldtn, @danryan).

I believe I was tagged by mistake, I don't use nix!

@MirageTurtle
Copy link
Author

After spending more than 5 seconds it is obviously clear why the change suggested in #1993 would change this behavior. I've changed it on master to execute the config as before, if the exec-bit is set, and it will interpret as suggested in #1993 if the exec-bit is unset.

Thank you very much! sh -c is powerful enough. Thank you again, and thank you for making yabai better.

Feel free to close this issue, or if you plan to do it after release.

@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label Mar 22, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
suggestion Request for new feature or some form of enhancement
Projects
None yet
Development

No branches or pull requests

3 participants