Yesterday I discovered yabai and I already love it. I now can replace TotalSpaces 2. I just needed a simple way to switch displays without any animation and until yesterday ts2 was my only option.
For my purpose, I implemented this small script: https://raw.githubusercontent.com/TheNoim/MacOS/master/yabai-functions.sh
With this script, I can cycle through my spaces on the current desktop. It works great in combination with keyboard shortcuts. It has just one flaw. With yabai I am only able to query the currently focused display. However, sometimes I trigger my space switch shortcut when I am just hovering over my second monitor. A workaround is to use yabai -m config focus_follows_mouse autoraise. But I don't want to focus, I just want to change spaces. I would need an additional field in the json. Something like this:
[{
"id":10,
"label":"",
"index":8,
"display":2,
"windows":[],
"type":"float",
"visible":0,
"focused":0, // Mouse is on display 2, but display is not focused
"native-fullscreen":0,
"first-window":0,
"last-window":0,
"mouse": 1 // Mouse is on display 2
}]
Then I could update the getCurrentDisplay function to:
function getCurrentDisplay() {
echo $(yabai -m query --spaces | jq 'map(select(.mouse == 1)) | .[0] | .display')
}
Temporary dirty solution:
Use a small swift cli utility https://github.com/TheNoim/MacOS/blob/master/mousePosition/mousePosition/main.swift in combination with echo $(yabai -m query --displays | jq --argjson display "$displayID" 'map(select(.id == $display)) | .[0].index')
On the latest master you can use the mouse selector to query information about displays and/or spaces that currently contain the cursor.
# output list of all spaces that belong to the display that contain the cursor
yabai -m query --spaces --display mouse
# output single space that contain the mouse cursor (focused space of the display that holds the mouse cursor)
yabai -m query --spaces --space mouse
# output the single display that contain the mouse cursor
yabai -m query --displays --display mouse
The above are some examples of what you can do with these.
You can experiment with other permutations if you need more/other info.
This is exactly what I was searching for. Already excited for the release. Until then, I will use my workaround cli.
Most helpful comment
On the latest master you can use the
mouseselector to query information about displays and/or spaces that currently contain the cursor.The above are some examples of what you can do with these.
You can experiment with other permutations if you need more/other info.