lucmos/UltrawideWindows

Simplifying the logic

snnsnn opened this issue · 2 comments

Hi, thank you for the add-on.

I like the idea of controlling window position and width but registering so many shortcuts does not feel right, so I have come up with a solution.

var opts = {
  grids: [
    [3, 2, 0, 0, 1, 1],
    [3, 2, 1, 0, 1, 1],
    [3, 2, 2, 0, 1, 1],
    [3, 2, 0, 1, 1, 1],
    [3, 2, 1, 1, 1, 1],
    [3, 2, 2, 1, 1, 1],
    [3, 1, 0, 0, 1, 1],
    [3, 1, 1, 0, 1, 1],
    [3, 1, 2, 0, 1, 1],
    [2, 2, 0, 0, 1, 1],
    [2, 2, 1, 0, 1, 1],
    [2, 2, 0, 1, 1, 1],
    [2, 2, 1, 1, 1, 1],
    [2, 1, 0, 0, 1, 1],
    [2, 1, 1, 0, 1, 1],
    [4, 2, 0, 0, 1, 1],
    [4, 2, 1, 0, 2, 1],
    [4, 2, 3, 0, 1, 1],
    [4, 2, 0, 1, 1, 1],
    [4, 2, 1, 1, 2, 1],
    [4, 2, 3, 1, 1, 1],
    [4, 1, 0, 0, 1, 1],
    [4, 1, 1, 0, 2, 1],
    [4, 1, 3, 0, 1, 1],
    [3, 2, 0, 0, 2, 1],
    [1, 2, 0, 0, 1, 1],
    [3, 2, 1, 0, 2, 1],
    [3, 2, 0, 1, 2, 1],
    [1, 2, 0, 1, 1, 1],
    [3, 2, 1, 1, 2, 1],
    [3, 1, 0, 0, 2, 1],
    [3, 1, 1, 0, 2, 1],
    [6, 2, 0, 0, 1, 1],
    [6, 2, 1, 0, 4, 1],
    [6, 2, 5, 0, 1, 1],
    [6, 2, 0, 1, 1, 1],
    [6, 2, 1, 1, 4, 1],
    [6, 2, 5, 1, 1, 1],
    [6, 1, 0, 0, 1, 1],
    [6, 1, 1, 0, 4, 1],
    [6, 1, 5, 0, 1, 1],
    [1, 1, 0, 0, 1, 1],
  ],
  current: 0,
};

registerShortcut("Next Grid", "Move window to next grid", "Meta+Space", function () {
    opts.current = opts.current === opts.grids.length - 1 ? 0: opts.current + 1;
    move(
      workspace,
      opts.grids[opts.current][0],
      opts.grids[opts.current][1],
      opts.grids[opts.current][2],
      opts.grids[opts.current][3],
      opts.grids[opts.current][4],
      opts.grids[opts.current][5]
    );
});

registerShortcut("Prev Grid", "Move window to previous grid", "Meta+Shift+Space", function () {
  opts.current = opts.current === 0 ? opts.grids.length - 1 : opts.current - 1;
  move(
    workspace,
    opts.grids[opts.current][0],
    opts.grids[opts.current][1],
    opts.grids[opts.current][2],
    opts.grids[opts.current][3],
    opts.grids[opts.current][4],
    opts.grids[opts.current][5]
  );
});

This way next window is tiled next to the previous one in the grid. Benefits are it is easier to add new grid areas and users can set their own shortcuts without any conflict.

Thank you for this suggestion!

I have mixed feelings about this. Overall I think I like more the possibility to move a window directly to the position that I want it to be (using the numpad), without cycling through all the slots.

I'm going to close this since it does not exploit the idea I like the most about this script: exploiting the numbers disposition in the numpad to move windows accordingly.

If you have strong opinions about this, feel free to comment to discuss more :)