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

Set window size and/or position #63

Open
Just-Insane opened this issue Jan 30, 2021 · 10 comments
Open

Set window size and/or position #63

Just-Insane opened this issue Jan 30, 2021 · 10 comments
Labels
feature new feature

Comments

@Just-Insane
Copy link

Hello,

I am wondering if there is any plan to add functionality for setting specific window sizes and/or positions on screen?

I have an ultrawide monitor and I prefer having a “priority” window in the center that is wider than the two+ windows to each side. As far as I can tell this isn’t easily possible in Yabai unless you float all windows, which IMO defeats the purpose. It doesn’t help that the window resize commands for managed non-floated windows is relative and not pixel based from what I can tell.

@davelosert
Copy link
Owner

Hi @Just-Insane ,

thanks for the question - didn't even know there were alredy people interested in this. :)

Actually I was planning to implement something like that as I am also having an ultra wide screen.
But as you say this is not easily doable with yabai unless using floating windows + a grid.

I still have two very raw ideas, but I did not come around to experiment / try this out yet:

  1. First put all windows into float mode and where we want them to be (e.g. with a grid) and only then turn them into bsps. However, I'm not sure if the window would end up as they were with float.
  2. Resize the windows accordingly from right to left (or left to right?) so that the relative resizing might not be that big of an issue? However, also not sure if that will actually work as it is - as you say - not pixel based.

The positions however might be a bit easier: E.g. after apply-layout, we could do another query for the windows and then warp them according to their x- and y-positions.

As I am currently working on #30 , I am not sure when I'll come around to trying this. I am happy for contributions, however ;)

@Just-Insane
Copy link
Author

Yea, I have an open issue for this on the Yabai repo. koekeishiya/yabai#814

I’m honestly not sure why the resize option in bsp is not pixel based, it seems odd to me for it to be a ratio.

i am currently trying out the float option, but I’m having a hard time figuring out a one-command solution for gridding multiple windows in a desired order.

It is certainly a tuff situation since there is no easy way to tell which windows are beside each other that I could find?

@davelosert
Copy link
Owner

If I am not mistaken, I think this was also already discuseed in this thread: koekeishiya/yabai#658

Unfortunately, with no real conclussion. I will also play around with it a little bit more.

@Just-Insane
Copy link
Author

Just-Insane commented Jan 31, 2021

Yea... I was in that thread as well.

Looking at the source, with my non-existent C knowledge, I'm not sure why resizing in BSP was done as a ratio.

I'm also not sure why resizing in one direction works, but then not the other direction, but both directions work fine individually.

@davelosert
Copy link
Owner

I was just playing around a bit more. It seems like when applying resizing from left to right and actually just always resizing the right border, it works more reliably.

So it might actually be possible to support a fixed layout with sizes in yco. We just have to implement the algorithm to apply several commands for the windows from left to right on a space. However, this can be a bit tricky if there are more windows for a given app (e.g. I have two terminals in a vertical split on the left pane).

I'll try some stuff this week and see what I can do.

@davelosert davelosert added the feature new feature label Jan 31, 2021
@Just-Insane
Copy link
Author

What commands where you using to resize only the right border?

I think I had tried that also, but it was still failing due to the ratio.

@davelosert
Copy link
Owner

davelosert commented Feb 1, 2021

I used e.g. yabai -m window 104 --resize right:100:0.

At least for me this always just expands/decreases the right side of the window.

@Just-Insane
Copy link
Author

Just-Insane commented Feb 1, 2021 via email

@davelosert
Copy link
Owner

I just released Version v1.5.0-alpha.1. It should actually be 2.0.0.-alpha.1, but I messed up the commit message. Will fix that later. And it took a while but I just had a kid so time is precious ;).

In the new version i completely reimplemented the apply-layout-function. Resizing is still on the todo-list, but the config now honors the positions - and more: you can now define a full layout including all the splits (aka bsp-tree) you like, for example a config for a three column layout with two rows in the first column (my current setup) looks like this:

{
  "$schema": "https://raw.githubusercontent.com/davelosert/yco/alpha/src/schemas/YcoConfigSchema.json",
  "layoutModeTriggerKey": "alt - s",
  "layoutModeIgnoreWindows": [
    {
      "app": "Microsoft Teams",
      "title": "Microsoft Teams-Benachrichtigung"
    }
  ],
  "layoutModeBinaryMap": {
    "iTerm2": "iTerm"
  },
"layouts": [{
    "name": "monitor",
    "triggerKey": "m",
    "nonManaged": "allInOneSpace",
    "spaces": [[
      [
        { "windows": ["iTerm2", "iTerm2"], "split": "horizontal" },
        { "app": "Code" } , 
        { "app": "Firefox"}
      ],
      [{ "windows": ["Toggl Track", "Google Chrome"], "split": "horizontal" }, "Slack", "Microsoft Outlook"],
      ["Microsoft Teams", "Spotify"]
    ]]
  }]
}

I chose to make the layouts- config an array rather than a map as I think its better readable.

Also, as you can now define the number of windows, I implemented the Open Windows Feature (#65).

I still have a lot of cleanup todo (I am still not happy with the spaces-Config as those nested arrays are hard to read), document the whole thing and everything, so a full 2.0.0 release might still take a while.

But if you are just looking for the dirty functionality for now, you can try the 1.5.0-alpha and tell me if everything is not working.

@davelosert
Copy link
Owner

Oh, and the layoutModeIgnoreWindows was necessary as e.g. Microsoft Teams has some hidden notification windows on every space - and with the allInOneSpace-Option, it would always double the amount of existing spaces.

The layoutModeBinaryMap was necessry as for example iTerm2s name in yabai is {"app": "iTerm2"}, but you have to open it with open -n -s iTerm.

Gonna try to implement a default config that kind of already includes those common cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new feature
Projects
None yet
Development

No branches or pull requests

2 participants