asmvik / asmvik/yabai

Periodic Boundaries for DIR_SEL: farthest_west/east/north/south

Open
#1,165 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
29.6k
Forks
750
PR merge metrics
No merged PRs in 30d

Description

I would like to add to my directional commands cyclic behaviour if I hit the boundary of a direction.

### Stacks ☑

For stacks I cycle through with `stack.next` and `stack.prev`. When there is no next or prev I go to `stack.first` and `stack.last` which fits into my desired periodic boundary behaviour:
```yaml
- shortcut_name: "Down in Stack"
shortcut_modifier: *mod_focus
shortcut_key: *nextinstack
shortcut_cmd: |
yabai -m window --focus stack.next \
|| yabai -m window --focus stack.first
- shortcut_name: "Up in Stack"
shortcut_modifier: *mod_focus
shortcut_key: *previnstack
shortcut_cmd: |
yabai -m window --focus stack.prev \
|| yabai -m window --focus stack.last
```
I use [stackline](https://github.com/AdamWagner/stackline) which shows vertical symbols for the windows in a stack and nicely illustrates the changing of the focused windows (I only miss the possibility to swap stacked windows which has already been reported).

### Spaces ☑

I work with a fixed set of spaces 1-5 on display 1 and spaces 6-10 on display 2 where I treat space 6 as the partner to space 1 and similarly for the other spaces.

So I could specify the desired space numbers. However, I use Total Spaces 2 for this since changing two spaces at the same time with yabai has a delay and is distracting.

### Displays ☑

Currently, I have two displays aligned horizontally.

Since they are also fixed, I can also work with display identifiers when hitting a boundary.

### Windows ❌

Now we get to my problem:

When e.g. `yabai -m window --focus east` fails since there is no window in the east, I would like to select the window on the west border. Something like `yabai -m window --focus farthest_west` The same for the other directions.

To make it clearer: Consider following regular grid layout of nine windows on a single space:
```
+-----++-----++-----+
| W1 || W2 || W3 |
+-----++-----++-----+
+-----++-----++-----+
| W4 || W5 || W6 |
+-----++-----++-----+
+-----++-----++-----+
| W7 || W8 || W9 |
+-----++-----++-----+
```

When window `W9` is focused and I press the shortcut to focus the window to the east, it should select `W7`. The shortcut for the direction south should select `W3`.

Is there a convenient scripting possibility or would extending yabai be better?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the existing `yabai -m window --focus east|west|north|south` command behavior and its failure path. Verify the nine-window grid examples and define done as directional focus wrapping to the opposite border while preserving normal directional selection; also determine whether this belongs in yabai or in scripting.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.