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

Feature Request: Position-based display selectors #550

Closed
jneen opened this issue May 30, 2020 · 14 comments
Closed

Feature Request: Position-based display selectors #550

jneen opened this issue May 30, 2020 · 14 comments
Labels
suggestion Request for new feature or some form of enhancement

Comments

@jneen
Copy link

jneen commented May 30, 2020

When scripting keybindings with yabai, it's often the case that Mission Control's choice of display order is unrelated to the physical and logical positioning of the displays. If it were possible to select displays sorted by position, it would be straightforward to map, say, alt-{w,e,r} to always indicate leftmost, middle, and rightmost.

My proposal for the selectors would be something like:

yabai -m display x:1 // first display, sorted by x-coordinate of the display's centre point
yabai -m display x:2 // second display, as above
yabai -m display x:-1 // last display, as above

yabai -m display y:1 // first display, sorted by y-coordinate of the display's centre point (for vertically stacked monitors)
yabai -m display y:2
yabai -m display y:-1
@jneen
Copy link
Author

jneen commented May 30, 2020

I've been poking around the code in my spare time, and I think I've got enough info so I'd be able to hack on this if it seems like a useful direction. Thanks for yabai!

@jneen
Copy link
Author

jneen commented May 30, 2020

The argument against relegating this to a scripting layer is that querying and parsing out JSON replies from yabai is slow enough to be noticeable when in a critical action like "focus a display", even on the newest most souped-up models.

@koekeishiya
Copy link
Owner

koekeishiya commented May 31, 2020

I agree that having to query and re-parse JSON every time you want to focus a display is not optimal for something like this. However, I do think that an alternative solution could be to support labeling displays the way you can label spaces. By doing this you could simply query the list of active displays upon startup and filter/sort by whatever. If displays are added/removed during an active session you could hook up the same script to the display added/removed signals, and have it reconfigure the labels.

The reason that I prefer these kinds of solutions is simply that a lot of people have different preferences in their workflow, and so I want the core implementation to be as simple as possible while providing the ability to let users customize on their end, without having to necessarily go and edit the source directly.

There are some related/similar issues on the board, although not directly related; I'm linking them here for reference: #225, #372, #365

@jneen
Copy link
Author

jneen commented May 31, 2020

Okay! I do think sorting by horizontal/vertical position is a relatively common use case, though, however people decide to script around it - this patch would definitely allow something like #225 to be much easier to script, for example.

@jneen
Copy link
Author

jneen commented May 31, 2020

To put it another way, labelling is certainly powerful, but the overhead of making the user maintain a script that computes position parameters and syncs its state with yabai's internals feels out of proportion to the actual functionality.

@jneen
Copy link
Author

jneen commented May 31, 2020

Alternatively, this could be replaced with a config option like displays_sort_method={none,vertical,horizontal}, and then the usual {next,prev} etc commands would also be meaningful. It's unlikely a user will want to change their sort method in a dynamic way, but it's likely they'll want to say "just consider them in this order" and be done.

@koekeishiya
Copy link
Owner

I'll give this issue some thought before I decide which way to proceed, but I do agree that we can definitely do better than the current situation.

@aiguofer
Copy link

aiguofer commented Jun 3, 2020

I like this proposal! I already use a left first based indexing for my yabai scripts... this functionality would certainly simplify some of my scripts and potentially make things a little faster :)

@jneen
Copy link
Author

jneen commented Jun 3, 2020

This is an alternate proposal, just to keep things properly linked together: #554

@koekeishiya
Copy link
Owner

koekeishiya commented Jun 5, 2020

Just so I'm not missing anything. In practice, this specific implementation would be pretty much the same as if cardinal directions where available for targetting displays, as described in #225, yeah?

Edit: So I guess this is different in the way that you can actually re-orient what is considered the first, second, third (etc.) display, where as cardinal directions only allow you to move around more intuitively.

@jneen
Copy link
Author

jneen commented Jun 6, 2020

That's correct. Some navigate based on where they are, some on absolute numbers, and in both cases it's useful to use a position-based ordering. #554 accomplishes the cardinal directions use case by simply making the behaviour of "next" and "prev" position-based.

@koekeishiya
Copy link
Owner

After thinking about this for some time I have to say that I''m not a huge fan of the kind of selector provided in the first alternative. The second alternative which allows for setting a display order seems more reasonable, but I'm not sold yet.

@koekeishiya koekeishiya added the suggestion Request for new feature or some form of enhancement label Aug 11, 2020
@koekeishiya koekeishiya added the addressed on master; not released Fixed upstream, but not yet released label Mar 12, 2024
@koekeishiya
Copy link
Owner

koekeishiya commented Mar 12, 2024

Implemented on master based on #554.

display_arrangement_order [default|vertical|horizontal]

Specify how displays are ordered (determined by center point).
default: Native macOS ordering.
vertical: Order by y-coordinate (followed by x-coordinate when equal).
horizontal: Order by x-coordinate (followed by y-coordinate when equal).

@koekeishiya
Copy link
Owner

Fixed in v7.0.0.

@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Request for new feature or some form of enhancement
Projects
None yet
Development

No branches or pull requests

3 participants