koekeishiya / yabai

A tiling window manager for macOS based on binary space partitioning
MIT License
24.15k stars 645 forks source link

Space-specific padding lost after sleeping #2225

Open 0xb7a7dd61 opened 7 months ago

0xb7a7dd61 commented 7 months ago

Been battling this a while thinking it was misconfiguration or not utilizing events/etc to solve. When specifying space padding, such as yabai -m space 7 --label mySpaceLabel --padding rel:0:0:195:0, I lose the padding when I return to my desk the next morning.

I've tried the above command with --padding as well as left_padding with yabai -m config --space mySpaceLabel left_padding 195.

Important context:

Reproducible yabairc:

# ~/.config/yabai/yabairc 

# event hook for enabling the dock injection for spaces management
# must be before --load-sa
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa

# left_padding              10              \
yabai -m config                               \
    window_placement          second_child    \
    window_gap                10              \
    top_padding               10              \
    bottom_padding            10              \
    right_padding             10              \
    layout                    bsp             \
    mouse_follows_focus       on              \
    mouse_modifier            alt             \
    mouse_action1             move            \
    mouse_action2             resize          \
    mouse_drop_action         swap

yabai -m space 1 --label l1 --padding rel:0:0:10:0
yabai -m space 2 --label l2 --padding rel:0:0:10:0
yabai -m space 3 --label l3 --padding rel:0:0:10:0
yabai -m space 4 --label l4 --padding rel:0:0:10:0
yabai -m space 5 --label l5 --padding rel:0:0:10:0
yabai -m space 6 --label l6 --padding rel:0:0:10:0
yabai -m space 7 --label l7 --padding rel:0:0:195:0

# left padding to show desktop widgets on the left of screen
# yabai -m signal --add event=window_created action="yabai -m space l7 --padding rel:0:0:195:0"
# yabai -m signal --add event=window_destroyed action="yabai -m space l7 --padding rel:0:0:195:0"
# yabai -m signal --add event=window_moved action="yabai -m space l7 --padding rel:0:0:195:0"
# yabai -m signal --add event=space_changed action="yabai -m space l7 --padding rel:0:0:195:0"
# yabai -m signal --add event=display_added action="yabai -m space l7 --padding rel:0:0:195:0"
# yabai -m signal --add event=display_removed action="yabai -m space l7 --padding rel:0:0:195:0"
# yabai -m signal --add event=system_woke action="yabai -m space l7 --padding rel:0:0:195:0"
0xb7a7dd61 commented 7 months ago

I ended up getting a workaround by creating a script that checks that my space is on the expected display and if so, set the padding.

I also removed space labels because it was losing the label after sleeping (that was the biggest issue), which ended up applying padding to a random space.

Lastly I hooked up the script to all of the display+space event hooks (since it will only do something if the space+display are correct and set the padding.

This results in very very chatty commands, since I do 2 queries plus a setter, but it works and I haven't experienced / don't foresee any performance issues with it for now.