-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Constant number of spaces, organized evenly across displays #365
Comments
Btw, the idea after I get this working is to put the "redistributing" code into a function and call that on a rule when the number of displays changes... but one step at a time. |
After playing around with assigning labels, I see that the "right" thing is happening, and the issue is that the space indices are changing when spaces move. Maybe I don't fully understand how Mac treats indices |
After finding this SO answer and playing around a bit I think I figured it out. It looks like Mac will always assign spaces 1,2,3,4,5 to display 1 and 6,7,8,9,10 to display 2. To work around this, I assigned labels "s{space_number}" to each space:
Then my keybindings to switch spaces look like this:
Do you see another possibly better way to do this? |
Some notes:
These are just the indices as defined by Mission Control: contiguous across displays (in order), and starting at index 1. There is no signal that notifies you when yabai notices that a space has been moved, created, or destroyed through any means that is not yabai itself, which makes it hard to automate this reliably. Note that you always need to have at least one space per display with a desktop on it. Move and destroy operations on the last space with a desktop on a display fail with a non-zero exit-code, which you can check to make your script more robust.
skhd runs through your non-interactive and non-login As an optimization, put it in yet another file and source that only when
Yes, a rough idea for distributing the spaces evenly. I've bookmarked this and will get back to you when I've got time to figure that out completely. |
Thanks for the thorough response!
Great, that makes sense. I think I can have something in the
How would I go about doing that? I've been looking for how to source files from within skhd and can't find anything... I suppose I could do it in each command, but that still leads to a pretty ugly config file.
Awesome, looking forward to it! |
Well, I got to test the above today with 3 monitors.... and it failed miserably. On every yabai restart it seemed to change which one is display 1, 2, and 3, making it difficult to be deterministic (maybe I could use labels there too, but not sure how). It also seemed to randomly crash, and couldn't quite pinpoint why. |
Put the below in your if (( $PPID == $(ps aux | grep skhd | awk 'NR==1 { print $2 }') )); then
terminal-notifier -message "from inside skhd"
fi |
In case anyone ends up here, I've written a Python script that allows me to basically re-configure the display indexing and how spaces are distributed among displays: https://github.com/aiguofer/dotfiles/blob/master/user/.local/bin/yabaictl It could use some work, but it's in a "good enough for now" state. If you want to use this you'll need to change the hashbang at the top and update the |
Hey! first off, I want to thank you for all your work on this! Now that I have to use a Mac, your project has enabled me to at least come a bit closer to my Linux i3 setup.
One thing I'm stuck on is, I want to have 10 spaces, spread evenly among displays. For example, if use : to show expected setup:
1 display:
1:1, 2:1, 3:1 ...
2 displays:
1:1, 2:2, 3:1, 4:2 ...
3 displays:
1:1, 2:2, 3:3, 4:1 ...
I tried the following in my yabairc:
The echos seem to suggest it did the right thing:
but the spaces don't seem to be correctly organized:
The text was updated successfully, but these errors were encountered: