feat(wm): initial window placement rules

A window that opens goes after the focused container. A workspace can now say
another place for its windows: the primary or the secondary tile, before or
after the focused container, the end of the list, or a place by number, counting
from 1. The place is for every window, or for the windows that match a rule on
their program, app id, title or path; the rules are the conditions the ignore
and manage rules are made of, and the first that matches in key order decides. A
place that does not exist, such as the secondary tile of a workspace with one
container, is the default place.

A place is read from a name, a number or text that is a number. The
documentation of the setting shows a number and a map's keys can only be text,
and komorebi for Windows (83c4e11d) reads only text, so the form its own page
shows is refused there.

A place that was reserved with preselect-direction is used before the rules are
asked, and a locked container keeps its index. A workspace whose
window_container_behaviour is Append puts a window in the focused container, and
the rules are not used.

A workspace takes the rules from the key initial_window_placement_rules of its
entry in komorebi.json. The key is in schema.json and so in the typed config
option of the module, and the page docs/initial-window-placement-rules.md says
how to write it. vm-placement opens windows in a headless KWin and checks where
they go, by program, app id and title.

The schema that schemars derives for a place is an object with a Placement or an
Index key, which is not what is read or written, so a check against it refuses a
file that the daemon reads. The schema of PlacementTarget is written by hand
instead: a name, a number, or text that is a number. A file with a place of each
form is checked against schema.json, and the module's config option takes them.
This commit is contained in:
LGUG2Z committed 2026-10-28 07:20:57 -07:00
1 parent e563988258
commit 21017b573f
22 files changed
+1567 -23

No files matched your search

+1
View File
@@ -192,6 +192,7 @@ named for it. A workspace has these keys:
| `float_override` | the default | Whether every window that opens on this workspace floats |
| `floating_layer_behaviour` | the default | What a window that opens while this workspace is on its floating layer gets: `Tile` or `Float` |
| `wallpaper` | none | The picture the monitor shows while this workspace is in front, instead of its monitor's: `{ "path": "~/Pictures/sea.png" }`, and `generate_theme` and `theme_options` for the borders' colors ([Wallpapers](wallpapers.md)) |
| `initial_window_placement_rules` | none | Where in the list of containers a window that opens on this workspace goes: a place, or a place for each kind of window ([Initial window placement rules](../initial-window-placement-rules.md)) |
A workspace that names no `layout` and does not say `"tile": true` does not tile: its windows
stay where they open. A workspace with `layout_rules` tiles. Otherwise a workspace tiles.
+2 -1
View File
@@ -27,7 +27,8 @@ container of its own, when it is restored.
It stays open, in the middle of the work area with the size it had, and komorebi leaves it alone
from then on: it does not tile it again, and it does not move it.
[`komorebic manage`](../cli/manage.md), with that window focused, puts it back in the layout,
after the focused window.
after the focused window, or where the workspace's
[placement rules](../initial-window-placement-rules.md) say.
```sh
komorebic unmanage
+5 -3
View File
@@ -13,9 +13,11 @@ komorebic toggle-maximize
A window that is the only one of its container takes the container with it, and the container is
made again when the window comes back. The tiles that were left are not moved while the window is
maximized: it covers them. A window that opens meanwhile is added to the layout, after the focused
container, and has its tile when the maximized window is restored. A window that closes while it
is maximized takes the maximize with it, and the other windows are tiled again.
maximized: it covers them. A window that opens meanwhile is added to the layout, where a new
window goes (after the focused container, unless the workspace has
[placement rules](../initial-window-placement-rules.md)), and has its tile when the maximized
window is restored. A window that closes while it is maximized takes the maximize with it, and the
other windows are tiled again.
A window in [monocle](monocle.md) that is maximized leaves the monocle. When the monitor of a
maximized window is unplugged, the window goes to a monitor that is left and stays maximized: see
+4 -3
View File
@@ -18,9 +18,10 @@ komorebic stack down
```
[`komorebic unstack`](../cli/unstack.md) takes the window in front out of its stack and puts it
in a tile of its own after the stack, and the next window of the stack is in front again. A
window that is alone on its tile cannot be unstacked, and the daemon logs "a container must have
at least one window".
in a tile of its own, and the next window of the stack is in front again. The tile is after the
stack, unless the workspace has [placement rules](../initial-window-placement-rules.md), which
say where a window goes that gets a tile of its own. A window that is alone on its tile cannot be
unstacked, and the daemon logs "a container must have at least one window".
```sh
komorebic unstack