feat(wm): configuration in komorebi.json

The daemon takes its settings from a komorebi.json: the file --config names, or
the one in the config home ($KOMOREBI_CONFIG_HOME, else ~/.config/komorebi).
Without a file it runs on its defaults, as before.

StaticConfig reads the file in three steps, because the monitors are known only
after the backend has been asked. preload makes the window manager and applies
the settings that are process-wide, postload gives each monitor and workspace
the entry of its place (by the index display_index_preferences gives a monitor's
serial number id, else in order), and main asks KWin for a desktop for each
workspace the file lists. A watcher on the file sends the daemon a
ReloadStaticConfiguration about two seconds after it changes, whether an editor
wrote the file in place or renamed a new one over it, and a file that does not
parse changes nothing.

A workspace can change its layout, its work area offset and its layout options
with the number of its containers, from the file or with komorebic
(workspace-layout-rule, its named form and the two that clear), and
layout_defaults gives every workspace of a layout the options it sets none of.
One file is meant to serve every platform, so a key that does nothing on Plasma
is accepted and ignored. config_parity checks the example and the files of other
platforms; the keys of features that are not in yet are listed there, and the
test fails when a list names a key that is read.

The file also sets what the stacks, the float override, the floating layer and
monocle set while the daemon runs: window_container_behaviour, with its rules by
container count in a workspace, float_override, float_override_placement,
floating_layer_behaviour (for a monitor and a workspace too),
floating_layer_placement and monocle_focus_behaviour. Their features come before
this commit, but a file to put the keys in does not, so they are part of this
one.

komorebic gains configuration, generate-static-config and start --config. The
NixOS module gets configFile, which the unit gives the daemon as --config.
This commit is contained in:
LGUG2Z committed 2026-10-28 07:20:37 -07:00
1 parent 12b0aa9301
commit 5eaa613f50
49 files changed
+4778 -59

No files matched your search

+19
View File
@@ -328,3 +328,22 @@ the window cannot be a container: a layout would give it a tile, less the paddin
that index in a container of its own. It is restored before it is tiled again, because "it is its
tile's size that it has to get back, not the compositor's idea of its old size" (the comment in
`reintegrate_maximized_window`).
## Why does one `komorebi.json` work on every platform?
Spike 8 asked whether it could, and it can. With the `StaticConfig` of komorebi for Mac, the
example of komorebi for Windows loaded and read back, and so did a file with every key that only
Windows has, a real file of komorebi for Mac, and this repository's example; what serde dropped
was the keys that mean nothing outside their platform. So a key that does nothing on KDE Plasma is accepted and
ignored, and `config_parity` checks that the keys it ignores are the Windows-only ones and, until
the features are in, the ones of features that are not. Where the Mac struct had no key that the
native mapping needs (`focus_follows_mouse`, `transparency`), the KDE struct has the Windows one.
## Why does komorebi reload its configuration when the file changes?
It does what komorebi for Mac does: it watches `komorebi.json` and reloads it after about two
seconds. On Windows, `watch-configuration` is about the legacy AutoHotkey and PowerShell files,
which do not exist here. The watcher is `hotwatch`, whose default is to wait two seconds for the events of an
editor to settle. An editor either writes a file in place or replaces it with a new one, so the
daemon reloads on a modification and on a removal, and the test that follows a real daemon
through both of them is `the_daemon_follows_the_file_it_is_given_when_the_file_changes`.