Hello, I was trying to come up with a rule that makes all preferences windows floating. There was the suggestion in #272 to have a rule like
yabai -m rule --add title='Preferences$' manage=off topmost=on
which works well for those windows with titles ending in "Preferences". Unfortunately, some apps (e.g. Safari and Calendar) have preference windows that don't have such titles, so this rule doesn't work. However, these preference windows are all non-resizable (the output of yabai -m query contains "resizable":0 for those windows).
Is there any way to make a rule that applies to all such non-resizable windows?
This is the best you can do I think:
yabai -m signal --add event=window_created action='yabai -m query --windows --window $YABAI_WINDOW_ID | jq -er ".resizable == 0 and .floating == 0" && yabai -m window $YABAI_WINDOW_ID --toggle float'
This will toggle a window to floating when it is neither resizable nor floating at the time it is created. Note that some windows misreport their resizable attribute (e.g., Safari preferences).
If you don't want the window to be tiled for a split second, you can revert the logic: Create a rule that makes every window float and then tile all windows with an action that don't match the desired behavior.
Another thing you can do: Use skhd to create a passthrough mapping for cmd + , that floats the next window that gets created and get used to only ever spawning preferences windows using that almost universal keyboard shortcut.
Another thing you can do: Use
skhdto create a passthrough mapping for cmd + , that floats the next window that gets created and get used to only ever spawning preferences windows using that almost universal keyboard shortcut.
This does the trick:
# Float the next window and forward the keypress
cmd - 0x2B -> : \
yabai -m signal --add label=float_next_window_created event=window_created action='yabai -m signal --remove float_next_window_created; yabai -m signal --remove float_next_application_launched; yabai -m query --windows --window $YABAI_WINDOW_ID | jq -er ".floating == 0" && yabai -m window $YABAI_WINDOW_ID --toggle float' && \
yabai -m signal --add label=float_next_application_launched event=application_launched action='yabai -m signal --remove float_next_window_created; yabai -m signal --remove float_next_application_launched; yabai -m query --windows | jq -r ".[] | select(.pid == $YABAI_PROCESS_ID && .floating == 0).id" | xargs -I{} yabai -m window {} --toggle float'
Note that 0x2B is the , key on my german Mac keyboard layout. It might be different for your keyboard layout (see koekeishiya/skhd#1).
Most helpful comment
This is the best you can do I think:
This will toggle a window to floating when it is neither resizable nor floating at the time it is created. Note that some windows misreport their resizable attribute (e.g., Safari preferences).
If you don't want the window to be tiled for a split second, you can revert the logic: Create a rule that makes every window float and then tile all windows with an action that don't match the desired behavior.
Another thing you can do: Use
skhdto create a passthrough mapping for cmd + , that floats the next window that gets created and get used to only ever spawning preferences windows using that almost universal keyboard shortcut.