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

Restarting the yabai service causes yabai to manage previously unmanaged windows #2322

Open
gloesch opened this issue Jun 10, 2024 · 7 comments

Comments

@gloesch
Copy link

gloesch commented Jun 10, 2024

I have a yabairc with the following sort of rules:

yabai -m rule --add app="Finder" manage=off

If I have a Finder window open (unmanaged, can drag around without snapping) and then restart yabai with yabai --restart-service (usually after I do a config change), the previously open and unmanaged Finder window is now managed.

If I close and open a new Finder window, it's not managed as expected. This happens with another application I selectively manually manage.

I just recently updated from something yabai-5.x.x to latest yabai-v7.1.1, so perhaps I missed some logic/config breaking change?

Any help would be great.

@gloesch gloesch changed the title Restarting the yabai service requires makes all Restarting the yabai service manages previously unmanaged windows Jun 10, 2024
@gloesch gloesch changed the title Restarting the yabai service manages previously unmanaged windows Restarting the yabai service causes yabai to manage previously unmanaged windows Jun 10, 2024
@tamasgal
Copy link

tamasgal commented Jul 2, 2024

I am using this line and it works fine:

yabai -m rule --add app="^Finder$" sub-layer=above manage=off

@gloesch
Copy link
Author

gloesch commented Jul 3, 2024

@tamasgal do you mind sharing your version and also full config? I tried something similar, and I still have the same behavior.

And what macOS version are you using? I'm on Sonoma 14.5

@tamasgal
Copy link

tamasgal commented Jul 3, 2024

I am still on macOS Sonoma 14.3 (23D56), maybe that's the reason 😕

Here is my full config:

#!/usr/bin/env sh

#
# for this to work you must configure sudo such that
# it will be able to run the command without password
#
# see this wiki page for information:
#  - https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)#configure-scripting-addition
#
# yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
# sudo yabai --load-sa
#

yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa

# 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_zoom_persist          on             \
    window_shadow                float             \
    window_animation_duration    0.0            \
    window_animation_frame_rate  120            \
    window_opacity               off            \
    window_opacity_duration      0.0            \
    active_window_opacity        1.0            \
    normal_window_opacity        0.40           \
    insert_feedback_color        0xffd75f5f     \
    split_ratio                  0.50           \
    split_type                   auto           \
    auto_balance                 off            \
    top_padding                  3             \
    bottom_padding               3             \
    left_padding                 3             \
    right_padding                3             \
    window_gap                   3             \
    layout                       bsp            \
    mouse_modifier               fn             \
    mouse_action1                move           \
    mouse_action2                resize         \
    mouse_drop_action            swap

yabai -m rule --add app="^System Settings$" sub-layer=above manage=off
yabai -m rule --add app="^Calculator$" sub-layer=above manage=off
yabai -m rule --add app="^Finder$" sub-layer=above manage=off
yabai -m rule --add app="^Karabiner-Elements$" sub-layer=above manage=off
yabai -m rule --add app="^MenuMeters$" sub-layer=above manage=off
yabai -m rule --add app="^Step Two$" sub-layer=above manage=off
yabai -m rule --add app="^Messages$" sub-layer=above manage=off
yabai -m rule --add app="^Calendar$" sub-layer=above manage=off
yabai -m rule --add app="^Signal$" sub-layer=above manage=off
yabai -m rule --add app="^VLC$" sub-layer=above manage=off
yabai -m rule --add app="^QuickTime Player$" sub-layer=above manage=off
yabai -m rule --add app="^Fusion$" sub-layer=above manage=off
yabai -m rule --add app='^Autodesk.*$' sub-layer=above manage=off
yabai -m rule --add app='^julia$' title='^RainbowAlga$' sub-layer=above manage=off
yabai -m rule --add app='^Hearthstone$' sub-layer=above manage=off

yabai -m config external_bar all:25:0
borders active_color=0xffebd234 inactive_color=0xff555555 width=6.0

echo "yabai configuration loaded.."

@gloesch
Copy link
Author

gloesch commented Jul 3, 2024

yeah, my config looks really similar. Well if you happen to upgrade and don't have the issue or upgrade and do have the same issue, would love to know!

@gloesch
Copy link
Author

gloesch commented Jul 3, 2024

oh, and I'm not using the scripting addition. Is another variable.

@szfkamil
Copy link

I have a similar issue #2307.

I just recently updated from something yabai-5.x.x to latest yabai-v7.1.1, so perhaps I missed some logic/config breaking change?

I have been regularly updating the binary manually for a long time and still have this.

And what macOS version are you using? I'm on Sonoma 14.5

I am also on Sonoma 14.5

I am led to believe it's a software bug and will try to work around this, for example:

Before the restart command runs, switch to a space with no windows, or a space that has windows which don't have this problem (i.e. with grid), after restart, switch focus to previous space by focus (delay if needed).

@szfkamil
Copy link

I hacked this script based on the above:

#!/bin/zsh


# Function to capture the current space index using yabai and jq
capture_space_index() {
    local space_index  # Declaring space_index as a local variable
    space_index=$(yabai -m query --spaces --space | jq -r '.index') 

    if [ -z "$space_index" ]; then  # Checking if space_index is empty
        echo "Error: Failed to capture space ID."
        exit 1
    fi
    echo "$space_index"  # Returning space_index
}

# Capture the current space ID dynamically
space_index_before_restart=$(capture_space_index)

yabai -m space --focus misc

# Restart the yabai service
yabai --restart-service

sleep 1

# Focus back on the original space using its dynamically captured index
yabai -m space --focus "$space_index_before_restart"

It works, but isn't perfect. At least for me, weird stuff with windows happens on-screen (probably because of grid rules being triggered).

Let me know how it works if you use, and feel free to suggest improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants