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

yabai -m space --focus doesn't seem to do anything on Ventura 13.3 #1677

Closed
ekmekjian opened this issue Mar 23, 2023 · 15 comments
Closed

yabai -m space --focus doesn't seem to do anything on Ventura 13.3 #1677

ekmekjian opened this issue Mar 23, 2023 · 15 comments

Comments

@ekmekjian
Copy link

So Yabai seems to work fine of itself but the issue is that I can't seem to switch spaces. I reinstalled the HEAD version. Re did the code sign and update the sudoers with a new sha256. Everything is tiling but `yabai -m space --focus 3' does nothing. This isn't the scripting addition error, in fact there are no errors when entering the command in terminal I believe It thinks it did it so I ran yabai in verbose tried the command again and I got the following:

EVENT_HANDLER_DAEMON_MESSAGE: space --focus 3
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 180
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 180

here is the result of yabai -m rule --list if it helps:

[{
	"index":0,
	"label":"",
	"app":"Discord",
	"title":"",
	"role":"",
	"subrole":"",
	"display":1,
	"space":4,
	"follow_space":false,
	"opacity":0.0000,
	"manage":null,
	"sticky":null,
	"mouse_follows_focus":null,
	"layer":"",
	"border":null,
	"native-fullscreen":null,
	"grid":"0:0:0:0:0:0"
},{
	"index":1,
	"label":"",
	"app":"Code",
	"title":"",
	"role":"",
	"subrole":"",
	"display":1,
	"space":2,
	"follow_space":false,
	"opacity":0.0000,
	"manage":null,
	"sticky":null,
	"mouse_follows_focus":null,
	"layer":"",
	"border":null,
	"native-fullscreen":null,
	"grid":"0:0:0:0:0:0"
}]

If there is anything else I can provide please let me know.

@azinsharaf
Copy link

can you please post your skhdrc file?

@ekmekjian
Copy link
Author

ekmekjian commented Mar 23, 2023

can you please post your skhdrc file?

Just fyi I am entering the 'yabai -m space' in terminal but here:

# focus window
cmd - h : yabai -m window --focus west
cmd - j : yabai -m window --focus south
cmd - k : yabai -m window --focus north
cmd - l : yabai -m window --focus east

#Switch workspaces
cmd - 1 : yabai -m space --focus 1
cmd - 2 : yabai -m space --focus 2
cmd - 3 : yabai -m space --focus 3
cmd - 4 : yabai -m space --focus 4
cmd - 5 : yabai -m space --focus 5
cmd - 6 : yabai -m space --focus 6
cmd - 7 : yabai -m space --focus 7


# Toggle split
shift+cmd - v : yabai -m window --toggle split

# Toggle Float
shift+cmd - space : yabai -m window --toggle float

# Move Windows to Spaces
cmd+shift - 1: yabai -m window --space 1
cmd+shift - 2: yabai -m window --space 2
cmd+shift - 3: yabai -m window --space 3
cmd+shift - 4: yabai -m window --space 4
cmd+shift - 5: yabai -m window --space 5
cmd+shift - 6: yabai -m window --space 6
cmd+shift - 7: yabai -m window --space 7
cmd+shift - 8: yabai -m window --space 8
cmd+shift - 9: yabai -m window --space 9

# swap window position and size with window in direction of focused window
#   (options: north, east, south, west)
cmd+shift - k : yabai -m window --swap north
cmd+shift - j : yabai -m window --swap south
cmd+shift - h : yabai -m window --swap west
cmd+shift - l : yabai -m window --swap east

# swap with previously focused window
cmd+shift - p : yabai -m window --swap recent

@azinsharaf
Copy link

got it, the config and command in terminal both work fine in my machine. i have 13.2.1 OS so can't comment on 13.3. Probably delete the spaces and create them, do a reboot and test again?

@roni-estein
Copy link

Same here, I noticed that the next and previous also seem not to work. I was able to get some output while messing around with making a new version for next

cmd + alt - m: index="$(yabai -m query --spaces --display | jq 'map(select(."has-focus" == true))[-1].index')" && \
                    index=$(( $index + 1 )) && \
                    echo "moving to space ${index}" && \
                    yabai -m window --space "${index}" && \
                    yabai -m space --focus "${index}"

will yield this error in SKHD run in verbose
cannot focus space due to an error with the scripting-addition.

I noticed the same error no matter what screen I tried to focus. However, my scripting addition is installed exactly per the instructions.

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: disabled
	Authenticated Root Requirement: enabled

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

Hope this is useful. I'd love to get this working.

@ekmekjian
Copy link
Author

will yield this error in SKHD run in verbose cannot focus space due to an error with the scripting-addition.

For the Scripting additions error install from head as mention from other issues here #1532
Also do the code sign then do

sudo pkill Dock
rm /tmp/yabai*
sudo yabai --load-sa
brew services restart yabai

and that's what removes the error for me. Put like a couple seconds between commands for some reason calling them one after the other in a script doesn't work so I put sleep(2)

@roni-estein
Copy link

To clarify, I am on the --HEAD branch already. I did give this a try however it didn't solve anything yet. I tried moving this window to the next one and there weren't even any errors to see:

EVENT_HANDLER_MOUSE_DOWN: 102 -2092.76, 759.51
EVENT_HANDLER_MOUSE_DRAGGED: -2090.38, 759.51
EVENT_HANDLER_WINDOW_DESTROYED: iTerm2 154
EVENT_HANDLER_MOUSE_DRAGGED: -2090.14, 759.51
EVENT_HANDLER_MOUSE_UP: -2090.14, 759.51
EVENT_HANDLER_WINDOW_TITLE_CHANGED: Arc 102
EVENT_HANDLER_DAEMON_MESSAGE: query --spaces --display
EVENT_HANDLER_DAEMON_MESSAGE: window --space 7
EVENT_HANDLER_APPLICATION_FRONT_SWITCHED: Finder (504)
EVENT_HANDLER_APPLICATION_DEACTIVATED: Arc
EVENT_HANDLER_APPLICATION_ACTIVATED: Finder
EVENT_HANDLER_DAEMON_MESSAGE: space --focus 7
window_manager_create_and_add_window:154 iTerm2 - 1. skhd -V
EVENT_HANDLER_WINDOW_MOVED:DEBOUNCED iTerm2 154

If this is an issue unique to me, then I'll figure it out at some point in the future. I was hoping that installing the --HEAD branch would solve it but I can wait for some further progress to be mad. I'd happily supply some logs if it helps debug the situation.

@aileks
Copy link

aileks commented Mar 26, 2023

I'm having the same exact issue. I'm using the HEAD branch on Ventura 13.3 RC, just like @roni-estein. Both my hotkey to switch workspaces and the command run in the terminal do not work. Creating workspaces also doesn't work. Everything else does, however. I'm having to set the hotkey in macOS's system settings, which means I have to use a completely different hotkey than what I'm already used to. It seems the issue is with moving between and creating workspaces.

@koekeishiya
Copy link
Owner

If you searched the issues for macOS 13.3 you would find multiple comments saying that 13.3 is not supported yet. As mentioned several times before, Beta Versions will not be supported.

@koekeishiya
Copy link
Owner

No shit. But this is an issue that could arise when 13.3 is released (which is very soon anyway considering it's a RC), especially since the dev branch is being used by both of us.

and it will be fixed within 24hours after the official release is made public, as it has been done for the last 5 years. If you cannot wait for that amount of time before upgrading you are welcome to fix it on your own.

@roni-estein
Copy link

and it will be fixed within 24hours after the official release is made public, as it has been done for the last 5 years. If you cannot wait for that amount of time before upgrading you are welcome to fix it on your own.

Hi, I was just posting information in the hopes it would be helpful. I haven't used the project for 5 years and it's hard to know the ins and outs after a few hours of tinkering. Further on some of the closed comments it appeared that certain steps had resolved the issues for them. Knowing that my issue is that I'm running on an unsupported macOS is actually very helpful. It means that I haven't done something incorrectly and there is an upstream incompatibility at the moment which is great news :) no more burnt hours on this and the issue will resolve itself in time.

Thanks for the reply and the effort you put into this project.

@ekmekjian
Copy link
Author

If you searched the issues for macOS 13.3 you would find multiple comments saying that 13.3 is not supported yet. As mentioned several times before, Beta Versions will not be supported.

I apologize I had thought maybe a new version had broken something unexpected and was hoping this thread would help, I clearly missed the info you mention.

@roni-estein
Copy link

roni-estein commented Mar 27, 2023

I wanted to pass on something, I have a bit of an issue leaving a problem unsolved, and I haven't looked at C since university. However, I found a brittle work around that may be interesting while waiting for an update. So it turns out you can automate key presses from the terminal.

** It will require you giving permission to the terminal to control system events.

Once thats done, you can tell the system to press keys for you via the terminal! Yay! Since you have probably mapped control + 1 - 9 to move you to to the appropriate space, you can actually just invoke the shortcut and it will just do it. The same thing will work for your control + right or control + left, with that in place, it's possible to re-allocate the commands you would be running from yabai to basic bash/zsh terminal commands. You can english style scripting to "tell application System Events to key code <the base-10 code of the key you want to press> using <modifiers>" Awesome!

This is probably mapped to different key-codes depending on your keyboard preference but you can look it up via this command. Assuming you have command line tools


open /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h

Remember these are in hex so you need to convert them to base 10. Also note they don't just run in order.

In my case Canadian macOS keybindings which as probably the same for US keybindings:

# I've modified moving to the space directly as follows, I've left the original endings commented per line

# move window and focus desktop
shift + alt - 1 : yabai -m window --space 1 && osascript -e 'tell application "System Events" to key code 18 using control down' # yabai -m space --focus 1
shift + alt - 2 : yabai -m window --space 2 && osascript -e 'tell application "System Events" to key code 19 using control down' #; yabai -m space --focus 2
shift + alt - 3 : yabai -m window --space 3 && osascript -e 'tell application "System Events" to key code 20 using control down' #; yabai -m space --focus 3
shift + alt - 4 : yabai -m window --space 4 && osascript -e 'tell application "System Events" to key code 21 using control down' #; yabai -m space --focus 4
shift + alt - 5 : yabai -m window --space 5 && osascript -e 'tell application "System Events" to key code 23 using control down' #; yabai -m space --focus 5
shift + alt - 6 : yabai -m window --space 6 && osascript -e 'tell application "System Events" to key code 22 using control down' #; yabai -m space --focus 6
shift + alt - 7 : yabai -m window --space 7 && osascript -e 'tell application "System Events" to key code 27 using control down' #; yabai -m space --focus 7
shift + alt - 8 : yabai -m window --space 8 && osascript -e 'tell application "System Events" to key code 28 using control down' #; yabai -m space --focus 8
shift + alt - 9 : yabai -m window --space 9 && osascript -e 'tell application "System Events" to key code 25 using control down' #; yabai -m space --focus 9

# also like to move things to the next or previous space which I couldn't get working. My shortcuts are mapped to ctrl + right and left

# next space
# shift + alt - n : yabai -m window --display next; yabai -m display --focus next
shift + alt - n: index="$(yabai -m query --spaces --display | jq 'map(select(."has-focus" == true))[-1].index')" && \
                 index=$(( $index + 1 )) && \
                 echo "moving to space ${index}" && \
                 yabai -m window --space "${index}" && \
                 osascript -e 'tell application "System Events" to key code 124 using control down' #control + right arrow
                # yabai -m space --focus "${index}" && \


# prev space
# shift + alt - n : yabai -m window --display previos; yabai -m display --focus previous
shift + alt - p: index="$(yabai -m query --spaces --display | jq 'map(select(."has-focus" == true))[-1].index')" && \
                 index=$(( $index - 1 )) && \
                 echo "moving to space ${index}" && \
                 yabai -m window --space "${index}" && \
                 osascript -e 'tell application "System Events" to key code 123 using control down' # control + left arrow
                # yabai -m window --focus "${index}" && \

Ok I know it's not a fix and on occasion I've just heard the occasional ding. I'm not sure what happens if you have CAPS lock or any other modes. But if it helps someone else, thats great. I'll dust off my C at some point so I can contribute in earnest.

Cheers!

@koekeishiya
Copy link
Owner

Upgrade to v5.0.3 for macOS 13.3 support.

@vietvudanh
Copy link

vietvudanh commented Apr 8, 2023

Damn, just upgrade to 13.3 today.

Upgrade to v5.0.3 for macOS 13.3 support.

I have just install yabai, so it's v5.0.3 but still got this error.

cannot focus space due to an error with the scripting-addition.

@roni-estein
Copy link

I forgot to disable beta, but luckily this works even on my 13.4 installation. Perhaps try all the steps over again. I can certify it currently works on 13.3 and 13.4.

You can always try my solution above for alternate commands if it doesn't work out.

Good luck!

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

6 participants