-
-
Notifications
You must be signed in to change notification settings - Fork 643
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
Signal window_created does not always fire for windows created on application launch #174
Comments
macOS don't send window_created notifications for these windows as far as I know, and I don't want to make yabai's internal signals cross that event boundary. Could you not register for app launch and query windows for that application using the pid? |
Sure thing, just considered this a bug. You can always do this, with the downside of needing a sleep because windows may be created after the application is launched. yabai -m signal --add event=application_launched \
action='sleep 0.5 \
&& yabai -m query --windows \
| jq ".[] | select(.pid | tostring == env.YABAI_PROCESS_ID).id" \
| xargs -I{} terminal-notifier -message {}' Also I noticed that I get the # process id will show up multiple times in stdout
yabai -m signal --add label=test event=application_launched \
action="echo \$YABAI_PROCESS_ID" Edit: For example, I just opened Preview with a slightly modified script running and had this in my log: querying pid 21646
querying pid 21646
querying pid 21646
found wid 3143
found wid 3143 So I get the I think this really shows why this method is unreliable. |
Fixed on master. See #175 |
So the fix in #175 actually fixed the unreliability issue with the window id's as well. That's good. Now it's just a matter of discussing whether windows created during the application launch should be triggering a window_created event or not. |
I personally prefer that signals mirror what macOS reports to us. I have had a lot of bad experience in the past trying to do otherwise. |
I feel like I'm doing something horribly wrong, because my action works when executed from a file but not when inline (re: confusion in #177 / from #167). Maybe you know what's up here. yabai -m signal --add event=application_launched label=test action="yabai -m query --windows | jq -r '.[] | select(.pid | tostring == env.YABAI_PROCESS_ID)'"
# fails with this is on stdout
# sh: -c: line 0: unexpected EOF while looking for matching `''
# sh: -c: line 1: syntax error: unexpected end of file
# this works
export YABAI_PROCESS_ID=19210 && yabai -m query --windows | jq -r '.[] | select(.pid | tostring == env.YABAI_PROCESS_ID)'
# this works as well
/usr/bin/env YABAI_PROCESS_ID=19210 sh -c "yabai -m query --windows | jq -r '.[] | select(.pid | tostring == env.YABAI_PROCESS_ID)'" |
There is currently a cap of how many bytes yabai will read from the socket, and you are likely exceeding that cap when inlining the script this way. |
So this should print an error when trying to add the signal and support way longer signals, especially considering the example for acting on window ids from an |
The correct solution here is to simply remove the message cap. |
I'm closing this in favour of a newly created issue (#221). Will document this behaviour. |
Turns out this issue was not because of a message cap, but because I was using the c-std function strtok for parsing key-value pairs. The command you posted had an equals in it, which of course strtok splits on, as it simply splits the input string.. Added #307 |
Bug report
For some applications, windows created (restored?) when launching applications are not firing
event=window_created
signals.I can reliably reproduce this with System Preferences.app.
The text was updated successfully, but these errors were encountered: