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

Can yabai move a window to the display that is on the left? #526

Closed
danijar opened this issue May 17, 2020 · 11 comments
Closed

Can yabai move a window to the display that is on the left? #526

danijar opened this issue May 17, 2020 · 11 comments
Labels
question Request for information or help, not an issue

Comments

@danijar
Copy link

danijar commented May 17, 2020

On Linux, I used i3 which has a nice way to support multiple displays. The key combination Super+Shift+H moves a window to the left in the tree. Usually, this would just swap the window with one that is further left on the same display. But if the window is already left most on the display, it moves the window over to the next display on the left.

I would like to replicate this behavior with yabai because I've found myself not use my displays on the side as much when I manually have to think about which workspace to send a window to.

@koekeishiya
Copy link
Owner

If the provided display selectors are not enough you can use the script mentioned in this issue: #225

@koekeishiya koekeishiya added the question Request for information or help, not an issue label May 18, 2020
@koekeishiya
Copy link
Owner

#225 is implemented on master and allows the usage of cardinal directions to target a display. In your case yabai -m display --focus west should do what you want based on the original question.

@danijar
Copy link
Author

danijar commented Jun 5, 2020

Thank you! I assume the correct way to do what I'm trying will be this?

alt - h : yabai -m window --focus west || yabai -m display --focus west
alt - j : yabai -m window --focus south || yabai -m display --focus south
alt - k : yabai -m window --focus north || yabai -m display --focus north
alt - l : yabai -m window --focus east || yabai -m display --focus east

Looking at previous releases, it seems like you prepare one about every two weeks. Will #225 and #459 be included in the next release?

@koekeishiya
Copy link
Owner

As far as focusing goes, yeah, that does seem correct to me.
I noticed that you also mentioned swapping windows in your original question, and that would be something like yabai -m window --swap west || yabai -m window --display west.

They'll be in the next release, yeah. If you don't mind running from the master branch, it is usually very stable, except for when I decide to make breaking changes, but you can just look at the changelog before updating to see what changes have been made.

I don't have a set schedule for when a new release is made. It mostly depends on what changes have been made and if I think some of them are important enough to get out before any additional major changes. I suppose it also depends on how much I think I will be working on the project in the upcoming days/weeks.

If there has been a reasonable amount of changes and I don't think I'll be doing too much in the near future, I usually do a release.

@danijar
Copy link
Author

danijar commented Jun 6, 2020

I've updated to the master branch --- this is a huge improvement!

I'm still running into an issue with moving windows across displays and am wondering if you can think of a solution to this. I'm using this skhd configuration:

alt + shift - h : yabai -m window --swap west || $(yabai -m window --display west; yabai -m display --focus west)
alt + shift - j : yabai -m window --swap south || $(yabai -m window --display south; yabai -m display --focus south)
alt + shift - k : yabai -m window --swap north || $(yabai -m window --display north; yabai -m display --focus north)
alt + shift - l : yabai -m window --swap east || $(yabai -m window --display east; yabai -m display --focus east)

The windows move as expected within a display and also move over to the nearest display when expected. However, when a window moves to the next display, it doesn't necessarily end up on the nearest side of that new display. Can you think of a way this might be possible?

@danijar
Copy link
Author

danijar commented Jun 23, 2020

@koekeishiya Can you think of a solution to this?

@koekeishiya
Copy link
Owner

You can focus the new display first and then set the the insertion point by using yabai -m window last --insert east or query the active space of the target display, retrieve the window_id from last-window and use that to set the insertion point on that space.

Alternatively if you don't mind some jumping around, the absolute simplest way is to simply move the window, follow focus, and then just yabai -m window --warp last.

@danijar
Copy link
Author

danijar commented Jun 24, 2020

Thanks! Would last work here? When moving a window to the west screen, it should take the east edge of that screen. When moving to the east screen, it should take the west edge of that screen.

@koekeishiya
Copy link
Owner

koekeishiya commented Jun 24, 2020 via email

@vizcay
Copy link

vizcay commented Aug 5, 2021

I came here trying to find a way to rotate the focused window between displays AND keeping the focus. End up doing:

WIN_ID=$(yabai -m query --windows --window | jq '.id') && yabai -m window --display recent && yabai -m window --focus $WIN_ID

Maybe someone finds it useful.

@kerryj89
Copy link

kerryj89 commented Oct 23, 2022

Here is how I got it working, it could probably be simplified but I couldn't fuss with it any longer, using some of koekeishiya and vizcay's ideas.

shift + ctrl - left : WIN_ID=$(yabai -m query --windows --window | jq '.id'); yabai -m window --swap west; [[ ! $? == 0 ]] && (yabai -m display --focus west; yabai -m window last --insert east; yabai -m window --focus $WIN_ID; yabai -m window --display prev; yabai -m window --focus $WIN_ID);
shift + ctrl - right : WIN_ID=$(yabai -m query --windows --window | jq '.id'); yabai -m window --swap east; [[ ! $? == 0 ]] && (yabai -m display --focus east; yabai -m window first --insert west; yabai -m window --focus $WIN_ID; yabai -m window --display next; yabai -m window --focus $WIN_ID);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Request for information or help, not an issue
Projects
None yet
Development

No branches or pull requests

4 participants