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

allow multiple commands within same domain #1371

Closed
koekeishiya opened this issue Aug 24, 2022 · 0 comments
Closed

allow multiple commands within same domain #1371

koekeishiya opened this issue Aug 24, 2022 · 0 comments
Labels
suggestion Request for new feature or some form of enhancement

Comments

@koekeishiya
Copy link
Owner

koekeishiya commented Aug 24, 2022

For some domains (config, space, and window) it makes sense to allow combining multiple commands for ease of use (within the respective domain --- cross-domain is not allowed).

config:

# global settings
yabai -m config mouse_follows_focus          off
yabai -m config focus_follows_mouse          off
yabai -m config window_origin_display        default
yabai -m config window_placement             second_child
yabai -m config window_topmost               off
yabai -m config window_shadow                on
yabai -m config window_opacity               off
yabai -m config window_opacity_duration      0.0
yabai -m config active_window_opacity        1.0
yabai -m config normal_window_opacity        0.90
yabai -m config window_border                off
yabai -m config window_border_width          6
yabai -m config active_window_border_color   0xff775759
yabai -m config normal_window_border_color   0xff555555
yabai -m config insert_feedback_color        0xffd75f5f
yabai -m config split_ratio                  0.50
yabai -m config auto_balance                 off
yabai -m config mouse_modifier               fn
yabai -m config mouse_action1                move
yabai -m config mouse_action2                resize
yabai -m config mouse_drop_action            swap

# general space settings
yabai -m config layout                       bsp
yabai -m config top_padding                  12
yabai -m config bottom_padding               12
yabai -m config left_padding                 12
yabai -m config right_padding                12
yabai -m config window_gap                   06

echo "yabai configuration loaded.."

->

# global settings
yabai -m config                                 \
    mouse_follows_focus          off            \
    focus_follows_mouse          off            \
    window_origin_display        default        \
    window_placement             second_child   \
    window_topmost               off            \
    window_shadow                on             \
    window_opacity               off            \
    window_opacity_duration      0.0            \
    active_window_opacity        1.0            \
    normal_window_opacity        0.90           \
    window_border                off            \
    window_border_width          6              \
    active_window_border_color   0xff775759     \
    normal_window_border_color   0xff555555     \
    insert_feedback_color        0xffd75f5f     \
    split_ratio                  0.50           \
    auto_balance                 off            \
    mouse_modifier               fn             \
    mouse_action1                move           \
    mouse_action2                resize         \
    mouse_drop_action            swap           \
    layout                       bsp            \
    top_padding                  12             \
    bottom_padding               12             \
    left_padding                 12             \
    right_padding                12             \
    window_gap                   06

echo "yabai configuration loaded.."

window:

yabai -m window --swap west
yabai -m window --ratio abs:0.7

-> 

yabai -m window --swap west --ratio abs:0.7
yabai -m window --toggle float
yabai -m window --grid 4:4:1:1:2:2


->

yabai -m window --toggle float --grid 4:4:1:1:2:2

space:

yabai -m space --toggle padding
yabai -m space --toggle gap

->

yabai -m space --toggle padding --toggle gap

The way this works is by literally just looping through multiple commands if present, and performing them in order, so there is no functional difference between the two scenarios. Because of this, all commands are running with the same context (ie. they all operate on the selected entity if present or the focused entity if none is specified, as usual). Commands are processed even if the previous one may have failed (due to an error -- invalid argument, etc.) as long as there are no syntactical errors.

The main benefit is mainly that there is only a single sub-process spawned to send the message, instead of having to spawn x amounts of sub-processes -- this is likely most noticeable in the initial config statements during launch.

If you need to check the result (exit code) of a command to decide whether the next one should run, you should use two separate commands as before.

--

Just experimenting at the moment; might remove or tweak this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Request for new feature or some form of enhancement
Projects
None yet
Development

No branches or pull requests

1 participant