koekeishiya / yabai

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

switch focus spaces doesn't work #2147

Open JocelynFloresz opened 8 months ago

JocelynFloresz commented 8 months ago

get stack when switch focus spces

sometimes yabai -m space --focus ${d} doesn't work with skhd or yabai command, especially after I typed on a space or focus long time on a space. and I get this info: cannot focus space because the display is in the middle of an animation.

I'm so confused, and I veryveryvery need this command. Can somebody help?

Environment

yabai version: 6.0.15 MacOS: 14.3.1 System Integrity Protection:

System Integrity Protection status: unknown (Custom Configuration).

Configuration:
    Apple Internal: disabled
    Kext Signing: enabled
    Filesystem Protections: disabled
    Debugging Restrictions: disabled
    DTrace Restrictions: enabled
    NVRAM Protections: disabled
    BaseSystem Verification: enabled
    Boot-arg Restrictions: disabled
    Kernel Integrity Protections: enabled
    Authenticated Root Requirement: enabled

This is an unsupported configuration, likely to break in the future and leave your machine in an unknown state.

yabai config:

#!/usr/bin/env sh

/opt/homebrew/bin/yabai -m signal --add event=dock_did_restart action="sudo /opt/homebrew/bin/yabai --load-sa"
sudo /opt/homebrew/bin/yabai --load-sa

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

# general space settings
/opt/homebrew/bin/yabai -m config layout                       bsp
/opt/homebrew/bin/yabai -m config top_padding                  00
/opt/homebrew/bin/yabai -m config bottom_padding               00
/opt/homebrew/bin/yabai -m config left_padding                 00
/opt/homebrew/bin/yabai -m config right_padding                00
/opt/homebrew/bin/yabai -m config window_gap                   8
/opt/homebrew/bin/yabai -m config window_animation_duration    0.00

/opt/homebrew/bin/yabai -m rule --add app="^iStat*" sticky=on layer=above manage=off border=off
/opt/homebrew/bin/yabai -m rule --add app="^系统设置*" manage=off

echo "yabai configuration loaded.."
whiterqbbit commented 8 months ago

This worked for me.

mairm1340 commented 8 months ago

Send window to space and focus on that space

cmd + shift - x : yabai -m window --space recent && yabai -m space --focus recent cmd + shift - 1 : yabai -m window --space 1 && yabai -m space --focus 1 cmd + shift - 2 : yabai -m window --space 2 && yabai -m space --focus 2 cmd + shift - 3 : yabai -m window --space 3 && yabai -m space --focus 3 cmd + shift - 4 : yabai -m window --space 4 && yabai -m space --focus 4 cmd + shift - 5 : yabai -m window --space 5 && yabai -m space --focus 5 cmd + shift - 6 : yabai -m window --space 6 && yabai -m space --focus 6 cmd + shift - 7 : yabai -m window --space 7 && yabai -m space --focus 7 cmd + shift - 8 : yabai -m window --space 8 && yabai -m space --focus 8

I have this configuration and when I send a window to other space it works but Focus doesn't happen. Can someone help me ?

I have SIP disabled and I am on yabai version: 6.0.15

mairm1340 commented 8 months ago

=== Load Scripting Additions ===

sudo nvram boot-args=-arm64e_preview_abi sudo yabai --uninstall-sa sudo yabai --install-sa sudo yabai --load-sa

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

=== Tiling setting ===

bsp, stack or float

yabai -m config layout bsp

New window spawns to the right if vertical split, or bottom if horizontal split

yabai -m config window_placement second_child

yabai -m config top_padding 3 yabai -m config bottom_padding 12 yabai -m config left_padding 12 yabai -m config right_padding 12 yabai -m config window_gap 12

center mouse on window with focus

yabai -m config mouse_follows_focus on

modifier for clicking and dragging with mouse

yabai -m config mouse_modifier alt

set modifier + left-click drag to move window

yabai -m config mouse_action1 move

set modifier + right-click drag to resize window

yabai -m config mouse_action2 resize

when window is dropped in center of another window, swap them (on edges it will split it)

yabai -m mouse_drop_action swap

yabai -m config window_topmost off yabai -m config window_opacity off yabai -m config window_shadow float

yabai -m config window_border on yabai -m config window_border_width 4 yabai -m config active_window_border_color 0xE032CD32 yabai -m config insert_feedback_color 0x00010101 yabai -m config normal_window_border_color 0xE02d74da yabai -m config active_window_opacity 1.0 yabai -m config normal_window_opacity 0.90 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 external_bar all:30:0

setup spaces

# for _ in $(yabai -m query --spaces | jq '.[].index | select(. > 6)'); do yabai -m space --destroy 7 done

function setup_space { local idx="$1" local name="$2" local space= echo "setup space $idx : $name"

space=$(yabai -m query --spaces --space "$idx") if [ -z "$space" ]; then yabai -m space --create fi

yabai -m space "$idx" --label "$name" }

setup_space 1 Cli setup_space 2 WWW setup_space 3 Outlook setup_space 4 Teams setup_space 5 Work setup_space 6 SecureCRT setup_space 7 RDP setup_space 8 Vmware setup_space 9 Files setup_space 10 VPN

move some apps automatically to specific spaces

yabai -m rule --add app="^iTerm2$" space=^1 yabai -m rule --add app="^Safari$" space=^2 yabai -m rule --add app="^Firefox$" space=^2 yabai -m rule --add app="^Microsoft Outlook$" space=^3 yabai -m rule --add app="^Microsoft Teams$" space=^4 yabai -m rule --add app="^Prospect mail$" space=^5 yabai -m rule --add app="^SecureCRT$" space=^6 yabai -m rule --add app="^Microsoft Remote Desktop$" space=^7 yabai -m rule --add app="^Telegram$" space=^10 yabai -m rule --add app="^Music$" space=5 yabai -m rule --add app="^cisco anyConnect Secure Mobility Client$" space=10

===== Workspace ==================================

yabai -m space 1 --label Cli

yabai -m space 2 --label WWW

yabai -m space 3 --label Outlook

yabai -m space 4 --label Teams

yabai -m space 5 --label Work

yabai -m space 6 --label SecureCRT

yabai -m space 7 --label RDP

yabai -m space 8 --label VMware

yabai -m space 9 --label Files

yabai -m space 10 --label VPN

===== Rules ==================================

yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off yabai -m rule --add label="Safari" app="^Safari$" title="^(General|(Tab|Password|Website|Extension)s|AutoFill|Se(arch|curity)|Privacy|Advance)$" manage=off yabai -m rule --add label="macfeh" app="^macfeh$" manage=off yabai -m rule --add label="System Preferences" app="^System Preferences$" title=".*" manage=off yabai -m rule --add label="App Store" app="^App Store$" manage=off yabai -m rule --add label="Activity Monitor" app="^Activity Monitor$" manage=off yabai -m rule --add label="Calculator" app="^Calculator$" manage=off yabai -m rule --add label="Dictionary" app="^Dictionary$" manage=off yabai -m rule --add label="mpv" app="^mpv$" manage=off yabai -m rule --add label="Software Update" title="Software Update" manage=off yabai -m rule --add label="About This Mac" app="System Information" title="About This Mac" manage=off yabai -m rule --add label="HHKB" app="HHKB Keymap Tool" title="About This Mac" manage=off

===== Signals ================================

Sample signal trigger that runs a command

yabai -m signal --add event=window_title_changed action="${ubersicht_spaces_refresh_command}"

ubersicht_spaces_refresh_command="osascript -e 'tell application id \"tracesOf.Uebersicht\" to refresh dwidget id \"simple-bar\"'"

echo "yabai: configuration loaded...\n"

*THIS IS THE CONFIG I AM USING*****

aaSchcolnik commented 8 months ago

Edit: running sudo yabai --load-sa fixed this.

I had ran this before and it had not fixed it but i tried it again after a reset and everything started working. Most likely my mistake.


Having the same issue, i had an older version of macOS ventura and just updated to the latest version of Ventura, everything was working fine before so i decided to uninstall and reinstall both yabai and skhd, everything is working including moving the focused container to a new space and setting focus to that space, but changing focus by itself doesnt work.

MacOS version: 13.6.5 (ventura) yabai version: 6.0.15 skhd version: 0.3.9

SIP disabled

This worked for me.

Have tried this, didn't work.

In case my config files are needed. Yabai config file:

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

# Space labels
yabai -m space 1 --label main
yabai -m space 2 --label web
yabai -m space 3 --label chat
yabai -m space 4 --label music
yabai -m space 5 --label editors
yabai -m space 6 --label immersion
yabai -m space 7 --label anki
yabai -m space 8 --label terminal

yabai -m rule --add app="^DaVinci Resolve$" space=main
yabai -m rule --add app="^Firefox$" space=web
yabai -m rule --add app="^Discord$" space=chat
yabai -m rule --add app="^Spotify$" space=music
yabai -m rule --add app="^Visual Studio Code$" space=editors
yabai -m rule --add app="^Google Chrome$" space=immersion
yabai -m rule --add app="^Anki$" space=anki
yabai -m rule --add app="^terminal$" space=terminal

# Window rules
yabai -m rule --add app="^(Calculator|System Preferences|System Settings|Archive Utility|Finder)$" manage=off
# Anki card preview
yabai -m rule --add title="^Preview" manage=off
yabai -m rule --add title="^Preferences" manage=off
yabai -m rule --add title="^Settings" manage=off
yabai -m rule --add app="^DaVinci Resolve$" manage=off
yabai -m rule --add app="^Steam$" manage=off
yabai -m rule --add app="^CrossOver$" manage=off
yabai -m rule --add app="^League of Legends$" manage=off
yabai -m rule --add app="^Notes$" manage=off
yabai -m rule --add app="^QuickTime Player$" manage=off
yabai -m rule --add app="^League of Legends$" manage=off
yabai -m rule --add app="^Numi$" manage=off
yabai -m rule --add app="^Kawa$" manage=off
yabai -m rule --add app="^Weather$" manage=off
yabai -m rule --add app="CleanShot X" manage=off mouse_follows_focus=off
yabai -m rule --add app="^CleanShot X$" manage=off
yabai -m config window_border_blur off

# Set all padding and gaps to 20pt (default: 0)
# yabai -m config top_padding    0
# yabai -m config bottom_padding 0
# yabai -m config left_padding   0
# yabai -m config right_padding  0
yabai -m config window_gap     12

# Useful optional stuff
yabai -m config focus_follows_mouse autofocus
yabai -m config window_shadow float
yabai -m config window_border on
yabai -m config window_border_width 1.3
yabai -m config active_window_border_color  0xff00FFB4
yabai -m config normal_window_border_color 0x002E3440
# yabai -m config insert_feedback_color 0xFFA3BE8C
# yabai -m config window_opacity on
# yabai -m config normal_window_opacity 0.9

# Drag/resizes Windows with mouse without having to grab the edges first by holding ctrl
yabai -m config mouse_modifier ctrl
yabai -m config mouse_action1 move
yabai -m config mouse_action2 resize

SKHD config file

# https://github.com/koekeishiya/yabai/wiki/Commands#focus-display
# https://github.com/koekeishiya/dotfiles/blob/master/skhd/skhdrc

# Shouldnt need to blacklist anymore as switching everything over to ctrl not alt
.blacklist [
    "League Of Legends"
]

# Navigation
ctrl + alt + shift + cmd - a : yabai -m window --focus west
ctrl + alt + shift + cmd - d : yabai -m window --focus east
ctrl + alt + shift + cmd - s : yabai -m window --focus south
ctrl + alt + shift + cmd - w : yabai -m window --focus north

# Moving windows
ctrl + shift - a : yabai -m window --warp west
ctrl + shift - d : yabai -m window --warp east
ctrl + shift - s : yabai -m window --warp south
ctrl + shift - w : yabai -m window --warp north

# Rotate layout
ctrl - l : yabai -m space --rotate 90
# Balance the layout
ctrl - k : yabai -m space --balance

# Move focus container to display (use "space" instead of display to move to just per space instead)
ctrl + shift - x : yabai -m window --display 1 --focus # main monitor
ctrl + shift - z : yabai -m window --display 2 --focus # vertical
ctrl + shift - c : yabai -m window --display 3 --focus # laptop

# Move focus container to space
ctrl + alt - 1 : yabai -m window --space 1 --focus # main
ctrl + alt - 2 : yabai -m window --space 2 --focus # web
ctrl + alt - 3 : yabai -m window --space 3 --focus # chat
ctrl + alt - 4 : yabai -m window --space 4 --focus # music
ctrl + alt - 5 : yabai -m window --space 5 --focus # editors
ctrl + alt - 6 : yabai -m window --space 6 --focus # immersion
ctrl + alt - 7 : yabai -m window --space 7 --focus # anki
ctrl + alt - 8 : yabai -m window --space 8 --focus # terminal
ctrl + alt - 9 : yabai -m window --space 9 --focus # space 9

# Resize windows
ctrl - a : yabai -m window --resize left:-100:0 ; yabai -m window --resize right:-100:0
ctrl - s : yabai -m window --resize bottom:0:100 ; yabai -m window --resize top:0:100
ctrl - w : yabai -m window --resize top:0:-100 ; yabai -m window --resize bottom:0:-100
ctrl - d : yabai -m window --resize right:100:0 ; yabai -m window --resize left:100:0

# Float / Unfloat window
ctrl - space : yabai -m window --toggle float

# Make fullscreen
ctrl - f         : yabai -m window --toggle zoom-fullscreen
# Toggle padding on/off
ctrl - g         : yabai -m space --toggle padding --toggle gap
# Disable padding overall

ctrl - y         : yabai -m config top_padding 0 \ yabai -m config bottom_padding 0 \ yabai -m config left_padding 0 \ yabai -m config right_padding 0 \ yabai -m config window_gap 0
ctrl - u         : yabai -m config window_gap 12
# Toggle floating/bsp
ctrl - h         : yabai -m space --layout $(yabai -m query --spaces --space | jq -r 'if .type == "bsp" then "float" else "bsp" end')
ctrl - o         : yabai -m config focus_follows_mouse autofocus
ctrl - p         : yabai -m config focus_follows_mouse off

# Change desktop
ctrl - 1 : yabai -m space --focus 1
ctrl - 2 : yabai -m space --focus 2
ctrl - 3 : yabai -m space --focus 3
ctrl - 4 : yabai -m space --focus 4
ctrl - 5 : yabai -m space --focus 5
ctrl - 6 : yabai -m space --focus 6
ctrl - 7 : yabai -m space --focus 7
ctrl - 8 : yabai -m space --focus 8
ctrl - 9 : yabai -m space --focus 9
ctrl - 0 : yabai -m space --focus 10

# Create space on the active display
ctrl - n : yabai -m space --create && yabai -m space --focus last

# Delete focused space and focus first space on display
ctrl - m : yabai -m space --destroy
koekeishiya commented 8 months ago

It may be that support for older versions of macOS need to be updated in yabai when Apple releases fixes. Ventura 13.6.5 is a new release and it may have changed things. I don't have a Ventura machine so I cannot verify/fix that. If you have a Ventura 13.6.5 machine, upload Dock.app and post a link and I can take a look.

The same applies to macOS Monterey 12.7.4.

All versions of Sonoma should be working fine on master.

JocelynFloresz commented 8 months ago

My macOS Version is Sonoma 14.3.1. yabai version: 6.0.15. when switch space stuck, i get this info from terminal cannot focus space because the display is in the middle of an animation.

Can u help me? What other information can I provide?

koekeishiya commented 8 months ago

Hm that error used to indicate that the display is in the middle of a space transition, but I haven't seen that message in Sonoma.

Image

aaSchcolnik commented 8 months ago

It may be that support for older versions of macOS need to be updated in yabai when Apple releases fixes. Ventura 13.6.5 is a new release and it may have changed things. I don't have a Ventura machine so I cannot verify/fix that. If you have a Ventura 13.6.5 machine, upload Dock.app and post a link and I can take a look.

The same applies to macOS Monterey 12.7.4.

All versions of Sonoma should be working fine on master.

Hey mate, im going to be real, im not sure if this is the Dock.app file you're asking for but here you go, i found it on /System/Library/CoreServices/. I apologize if this is the wrong one.

Here's a download link for said file (it'll last three days): https://dropover.cloud/68c67ceb908cd96e0092fcf77c0bb155

Anyways, like i said if for some reason the focus space feature stops working i run this: sudo yabai --load-sa and it starts working again. Thanks for your time.

koekeishiya commented 8 months ago

Dock for 13.6.5 should be compatible with yabai already without further changes.

tjex commented 7 months ago

@JocelynFloresz , as a side note, if you could fix the typo in the issue title spces -> spaces, it will help others to find this issue in the future, as there's lots of useful help in here!

mairm1340 commented 7 months ago

I have this one... still does not work for me....

/opt/homebrew/bin/yabai -m signal --add event=dock_did_restart action="sudo /opt/homebrew/bin/yabai --load-sa" sudo /opt/homebrew/bin/yabai --load-sa

mairm1340 commented 7 months ago

I ran on the terminal

❯ sudo /opt/homebrew/bin/yabai --load-sa

it asked for password and it loaded... nothing fancy...

I then ran

❯ sudo yabai --load-sa

there was a notification which I had to select to allow and once I did it started to work.

JocelynFloresz commented 7 months ago

Hm that error used to indicate that the display is in the middle of a space transition, but I haven't seen that message in Sonoma.

Image

image

this is what i experienced. yabai can auto resize window size. but can't switch spaces