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

@@ -0,0 +1,14 @@
```text
Clear all dynamic layout rules for the specified workspace
Usage: clear-named-workspace-layout-rules <WORKSPACE>
Arguments:
<WORKSPACE>
Target workspace name
Options:
-h, --help
Print help
```
+17
View File
@@ -0,0 +1,17 @@
```text
Clear all dynamic layout rules for the specified workspace
Usage: clear-workspace-layout-rules <MONITOR> <WORKSPACE>
Arguments:
<MONITOR>
Monitor index (zero-indexed)
<WORKSPACE>
Workspace index on the specified monitor (zero-indexed)
Options:
-h, --help
Print help
```
+10
View File
@@ -0,0 +1,10 @@
```text
Show the path to komorebi.json
Usage: configuration
Options:
-h, --help
Print help
```
+10
View File
@@ -0,0 +1,10 @@
```text
Generates a static configuration JSON file based on the current window manager state
Usage: generate-static-config
Options:
-h, --help
Print help
```
+29
View File
@@ -0,0 +1,29 @@
```text
Add a dynamic layout rule for the specified workspace
Usage: named-workspace-layout-rule <WORKSPACE> <AT_CONTAINER_COUNT> <LAYOUT>
Arguments:
<WORKSPACE>
Target workspace name
<AT_CONTAINER_COUNT>
The number of window containers on-screen required to trigger this layout rule
<LAYOUT>
Possible values:
- bsp: BSP Layout
- columns: Columns Layout
- rows: Rows Layout
- vertical-stack: Vertical Stack Layout
- horizontal-stack: Horizontal Stack Layout
- ultrawide-vertical-stack: Ultrawide Vertical Stack Layout
- grid: Grid Layout
- right-main-vertical-stack: Right Main Vertical Stack Layout
- scrolling: Scrolling Layout
Options:
-h, --help
Print help (see a summary with '-h')
```
+4 -1
View File
@@ -1,13 +1,16 @@
```text
Start komorebi as a background process
Usage: start [-- <KOMOREBI_ARGS>...]
Usage: start [OPTIONS] [-- <KOMOREBI_ARGS>...]
Arguments:
[KOMOREBI_ARGS]...
Arguments to pass to komorebi, after a `--`: `komorebic start -- --log-level debug`
Options:
-c, --config <CONFIG>
Path to a static configuration JSON file
-h, --help
Print help
+32
View File
@@ -0,0 +1,32 @@
```text
Add a dynamic layout rule for the specified workspace
Usage: workspace-layout-rule <MONITOR> <WORKSPACE> <AT_CONTAINER_COUNT> <LAYOUT>
Arguments:
<MONITOR>
Monitor index (zero-indexed)
<WORKSPACE>
Workspace index on the specified monitor (zero-indexed)
<AT_CONTAINER_COUNT>
The number of window containers on-screen required to trigger this layout rule
<LAYOUT>
Possible values:
- bsp: BSP Layout
- columns: Columns Layout
- rows: Rows Layout
- vertical-stack: Vertical Stack Layout
- horizontal-stack: Horizontal Stack Layout
- ultrawide-vertical-stack: Ultrawide Vertical Stack Layout
- grid: Grid Layout
- right-main-vertical-stack: Right Main Vertical Stack Layout
- scrolling: Scrolling Layout
Options:
-h, --help
Print help (see a summary with '-h')
```
+88 -7
View File
@@ -9,8 +9,9 @@ This page describes that trait, who implements and calls it, where each of its r
enforced, the model of the desktop the window manager tiles, the backend that reaches KWin,
how an event about a window becomes a tile, how workspaces are the compositor's desktops, how
a stack hides its windows, how a message on the daemon's socket is answered, how subscribers
are notified of both, what the orders a message gives do, and how the NixOS module runs the
daemon. It grows with the code: each part of the daemon that is added has its place here.
are notified of both, what the orders a message gives do, how `komorebi.json` configures the
daemon, and how the NixOS module runs the daemon. It grows with the code: each part of the
daemon that is added has its place here.
## Vocabulary
@@ -51,6 +52,9 @@ daemon. It grows with the code: each part of the daemon that is added has its pl
- **Message**: what a client sends the daemon on its socket, a [`SocketMessage`]: an order
(focus a window, move it, change the layout, resize it, show a workspace, retile, stop) or a
question (the state, the monitors, one [`StateQuery`]).
- **Configuration**: `komorebi.json`, which the daemon reads when it starts and again when it
changes ([`StaticConfig`]). It lives in the **config home**, [`HOME_DIR`], unless `--config`
names another.
- **Rule**: a condition on a window's title, executable, class or path ([`MatchingRule`]), in
one of the process-wide lists that decide whether a window is managed (the ignore and the
manage rules) and whether it floats when it opens (the float rules).
@@ -638,14 +642,69 @@ gives a tile, and [`Workspace::new_container_for_window`] puts the next window i
`CancelPreselect` removes it. A workspace reserves one place at a time, and the grid layout
none.
## Configuration
The daemon is configured by `komorebi.json`, which [`StaticConfig`] reads. `main.rs` takes the
file `--config` names, or else `komorebi.json` in [`HOME_DIR`] (`$KOMOREBI_CONFIG_HOME`, or
`~/.config/komorebi`) if there is one; without a file, the daemon runs on its defaults. Loading
has three steps, because the monitors are known only after the backend is asked:
1. [`StaticConfig::preload`] reads the file, applies the settings that are process-wide (the
default paddings, [`LAYOUT_DEFAULTS`], the indices of the monitors, and the rules in
[`IGNORE_IDENTIFIERS`], [`MANAGE_IDENTIFIERS`] and [`FLOATING_APPLICATIONS`]) and makes the
[`WindowManager`], with the settings that are its own. It starts a watcher on the file.
2. [`WindowManager::init`] loads the monitors and the windows from the backend, in the order the
indices of the monitors give.
3. [`StaticConfig::postload`] gives each monitor the entry of the file that is its own, and each
workspace of the monitor the entry of its place ([`Workspace::load_static_config`]). A monitor
takes the entry at the index `display_index_preferences` gives its serial number id, or else
the first entry that no preference names and no monitor has taken. `main.rs` then asks the
backend for a desktop for each workspace ([`WindowManager::sync_workspace_desktops`]), and
tiles.
When the file changes, the watcher (a [`hotwatch`] watcher, which waits two seconds for a file
to settle) writes `ReloadStaticConfiguration` to the daemon's own socket, and the message is
handled like any other, with the window manager locked: [`StaticConfig::reload`] reads the file
first and applies it only when it parsed, so a file that is half written changes nothing. It does
for the window manager that is running what the three steps do for one that starts, and tiles
every monitor again.
Three kinds of key reach the model. A **setting** of the window manager is a field of it
([`WindowManager::resize_delta`] and the others). A **default** is a process-wide static that a
monitor or a workspace falls back to when it has no value of its own: the paddings, the layout
defaults. A **rule** is an entry of one of the process-wide lists. A workspace's own
`layout_rules`, `work_area_offset_rules` and `window_container_behaviour_rules` are fields of the
[`Workspace`], which [`Workspace::update`] reads each time it tiles.
One `komorebi.json` is meant for every platform komorebi runs on, so [`StaticConfig`] has no
`deny_unknown_fields`: a key it does not read is dropped, and the keys of other platforms that
mean nothing on KDE Plasma are fields that nothing reads. `StaticConfig::from(&WindowManager)`
goes the other way, for `GenerateStaticConfig`.
| Rule | Enforced by | Proof | Escape hatch |
|---|---|---|---|
| A key komorebi does not read does not stop a configuration from loading | serde: [`StaticConfig`] ignores unknown keys, and a key of another platform is a field nothing reads | `the_keys_that_do_nothing_on_kde_are_accepted_and_ignored`, `fixtures_load_round_trip_and_only_lose_windows_only_keys` | none |
| The keys the parity test ignores are keys `StaticConfig` does not read | test: the ignore lists are compared with the schema of [`StaticConfig`] | `the_lists_name_no_key_that_is_read` | none |
| The example in the docs is the example file, which loads | test | `the_example_in_the_docs_is_the_example_file`, `fixtures_load_round_trip_and_only_lose_windows_only_keys` | none |
| A file that cannot be read changes nothing | framework path: [`StaticConfig::reload`] reads and parses the file before it applies anything | `a_configuration_that_cannot_be_read_changes_nothing`, `the_daemon_follows_the_file_it_is_given_when_the_file_changes` | none |
| The daemon applies a change to its file, written in place or replaced by a rename | framework path: the watcher sends `ReloadStaticConfiguration` to the daemon's own socket | `the_daemon_follows_the_file_it_is_given_when_the_file_changes`, `vm-module` | none: the file has to be the one the daemon was started with |
| A monitor takes the entry its display index preference gives it, else the first nobody has | framework path: [`StaticConfig::postload`] and [`StaticConfig::reload`] choose the entry by serial number id first | `a_monitor_takes_the_configuration_its_display_index_preference_gives_it` | none |
| A workspace that names no layout and does not say it tiles moves no window | framework path: [`Workspace::load_static_config`] sets [`Workspace::tile`] | `a_workspace_with_no_layout_does_not_tile`, `a_workspace_tiles_when_it_has_a_layout_or_is_told_to` | `"tile": true` |
| A workspace's own layout options replace the defaults of its layout, whole | framework path: [`Workspace::update`] takes the workspace's options and rules when it has either, and else those of `layout_defaults` | `layout_options_of_a_workspace_replace_the_defaults_of_its_layout` | none |
| The highest of the rules a count of containers reaches decides the layout, the offset and the container behavior | framework path: [`Workspace::update`] reads the rules, kept in the order of their thresholds | `layout_rules_change_the_layout_with_the_number_of_windows`, `work_area_offset_rules_change_the_offset_with_the_number_of_windows`, `window_container_behaviour_rules_change_the_behaviour_with_the_number_of_containers` | none |
| A workspace's own container behavior and float override come before the one for every workspace, and its floating layer behavior before its monitor's, which comes before the one for every workspace | framework path: [`WindowManager::window_management_behaviour`] reads the workspace, then (for the floating layer) the monitor, then the window manager | `the_behaviour_of_a_workspace_comes_before_the_one_for_every_workspace`, `the_float_override_of_a_workspace_comes_before_the_one_for_every_workspace`, `the_floating_layer_behaviour_of_a_workspace_comes_before_a_monitors_and_that_before_the_default` | none |
| The configuration the daemon generates loads and says the same | test | `a_configuration_comes_out_again_as_the_settings_of_the_window_manager` | none |
| The daemon reads the file it is given or the one in the config home, not both | startup order: `main.rs` takes `--config` before the config home | `the_daemon_follows_the_file_it_is_given_when_the_file_changes`, `the_daemon_reads_komorebi_json_from_the_config_home` | none |
## The NixOS module
The flake exports one module under two names, `nixosModules.default` and
`nixosModules.komorebi`: [`nixos-module.nix`] and the flake's overlay, which builds
`komorebi-full` (both programs) with the flake's nixpkgs and Rust toolchain. Its options are
`enable`, `package` (by default `pkgs.komorebi-full`, from the overlay), `logLevel`, and
`execStart`, which is read-only: the module sets it to `bin/komorebi` of the package with
`--log-level`. With `services.komorebi.enable`, the module:
`enable`, `package` (by default `pkgs.komorebi-full`, from the overlay), `logLevel`,
`configFile`, and `execStart`, which is read-only: the module sets it to `bin/komorebi` of the
package with `--log-level`, and `--config` with `configFile` when that is set. With
`services.komorebi.enable`, the module:
- installs the package in the system profile;
- defines the user unit `komorebi.service`, which every user of the machine has. Plasma's
@@ -666,6 +725,7 @@ module's unit.
| komorebi is enabled only on a machine with Plasma 6 | evaluation error: an assertion of the module | `nixos-module-eval` ("without Plasma 6, an assertion fails") | none |
| The log level is one the daemon accepts | evaluation error: `logLevel` is an enum of the daemon's `--log-level` values | `nixos-module-eval` ("a log level the daemon does not have does not evaluate") | none |
| The unit runs `execStart`, and nothing but the module sets it | evaluation error: the option is read-only | `nixos-module-eval` ("execStart cannot be set", "the unit runs execStart") | a unit of your own |
| The daemon is configured by `configFile` when it is set | framework path: `execStart` passes it as `--config`, which comes before the config home | `nixos-module-eval` ("configFile reaches execStart and the unit as --config"), `vm-module` | none: with no `configFile` the daemon reads the file of the config home |
| `komorebi` and `komorebic` are on every user's `PATH` | the module installs the package in the system profile | `nixos-module-eval`; every VM suite runs `komorebic` | none |
| Every Plasma session starts komorebi, once KWin's service has started | systemd: the user unit is wanted by `plasma-workspace.target`, after `plasma-core.target` | `nixos-module-eval`, `vm-module` | `systemctl --user mask komorebi` |
| A daemon that fails or is killed is started again | systemd: `Restart=on-failure` | `vm-module` (`SIGKILL`) | none |
@@ -710,6 +770,8 @@ module's unit.
keeps the values it changes and puts them back; the parking desktop is made, swept and removed
in `kwin` and tracked in `kwin::state`; and
[`bridge.js`](../../komorebi/src/kwin/bridge.js), the bridge.
- [`static_config`](../../komorebi/src/static_config.rs): `komorebi.json`, [`StaticConfig`], and
how it is loaded, reloaded and generated.
- [`process_command`](../../komorebi/src/process_command.rs): the thread that listens on the
socket, and what the window manager does with each message.
- [`state`](../../komorebi/src/state.rs): the [`State`] a `State` message is answered with,
@@ -724,8 +786,8 @@ module's unit.
daemon, `log` follows its log file in [`LOG_DIR`], and the hidden `docgen` writes
`docs/cli`.
- [`main.rs`](../../komorebi/src/main.rs): the daemon. It connects to KWin, or installs the
fake with `--fake-backend`, makes the window manager, which binds the socket, loads and
tiles the desktop, starts the threads that listen on the socket and handle events, and
fake with `--fake-backend`, makes the window manager from `komorebi.json` when there is one,
which binds the socket, loads the desktop, gives the monitors their configuration and tiles, starts the threads that listen on the socket and handle events, and
waits to be stopped.
- [`nixos-module.nix`]: the NixOS module, which installs komorebi and runs the daemon as a
systemd user unit of every Plasma session.
@@ -919,6 +981,13 @@ A window is shown, and ends up on a tile:
`Workspace::update`.
- [`komorebi/src/monitor.rs`](../../komorebi/src/monitor.rs): the work area, padding and
offset a monitor gives the workspace it shows.
- [`komorebi/src/static_config.rs`](../../komorebi/src/static_config.rs): `komorebi.json`.
[`komorebi/tests/config.rs`](../../komorebi/tests/config.rs) loads files over the fake
desktop, [`komorebi/tests/config_displays.rs`](../../komorebi/tests/config_displays.rs) one
with several monitors, [`komorebi/tests/hot_reload.rs`](../../komorebi/tests/hot_reload.rs) the
daemon following a file, and
[`komorebi/tests/config_parity.rs`](../../komorebi/tests/config_parity.rs) the files of other
platforms and the example, which load.
- [`komorebi/src/process_event.rs`](../../komorebi/src/process_event.rs): what each event
does, and the thread that handles them.
- [`komorebi/src/process_command.rs`](../../komorebi/src/process_command.rs): the socket, what
@@ -996,6 +1065,18 @@ A window is shown, and ends up on a tile:
a Plasma session in which the module's unit runs the daemon.
[`nixos-module.nix`]: ../../nix/nixos-module.nix
[`StaticConfig`]: ../../komorebi/src/static_config.rs
[`StaticConfig::preload`]: ../../komorebi/src/static_config.rs
[`StaticConfig::postload`]: ../../komorebi/src/static_config.rs
[`StaticConfig::reload`]: ../../komorebi/src/static_config.rs
[`Workspace::load_static_config`]: ../../komorebi/src/workspace.rs
[`HOME_DIR`]: ../../komorebi/src/lib.rs
[`LAYOUT_DEFAULTS`]: ../../komorebi/src/lib.rs
[`IGNORE_IDENTIFIERS`]: ../../komorebi/src/lib.rs
[`MANAGE_IDENTIFIERS`]: ../../komorebi/src/lib.rs
[`FLOATING_APPLICATIONS`]: ../../komorebi/src/lib.rs
[`hotwatch`]: https://crates.io/crates/hotwatch
[`WindowManager::init`]: ../../komorebi/src/window_manager.rs
[`Backend`]: ../../komorebi/src/backend/mod.rs
[`WindowInfo`]: ../../komorebi/src/backend/mod.rs
[`MonitorInfo`]: ../../komorebi/src/backend/mod.rs
+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`.
+17
View File
@@ -232,6 +232,7 @@ since a read right after `createDesktop` has to see the new desktop.
| Path | What | Lifetime |
|---|---|---|
| `$KOMOREBI_CONFIG_HOME/komorebi.json` (`~/.config/komorebi/komorebi.json`) | komorebi's configuration, which komorebi never writes: read when the daemon starts, and again when it changes. `--config` names another file | the user's |
| `$XDG_CONFIG_HOME/kwinrc` (`~/.config/kwinrc`) | KWin's configuration: komorebi sets `PerOutputVirtualDesktops=true` in `[Windows]`, changing that line or adding it and nothing else, and writes the file beside it first and renames it over it | put back as it was when the daemon stops |
| `$XDG_RUNTIME_DIR/komorebi/kwinrc-backup.json` | the value each key of `kwinrc` had before komorebi first changed it | removed when the values are put back; one a crash left behind is used by the next run |
| `$XDG_RUNTIME_DIR/komorebi/bridge.js` | the script KWin loads, with its configuration (the D-Bus names and the hold time of `Poll`) on its first line | written at every start; the directory is removed at logout |
@@ -251,6 +252,13 @@ The address of the session bus. If it is not set, komorebi uses `$XDG_RUNTIME_DI
systemd puts the session bus, and `/run/user/<uid>/bus` when `XDG_RUNTIME_DIR` is not set
either. An address with no bus behind it is the first error under [No KWin](#no-kwin).
### `KOMOREBI_CONFIG_HOME`
The config home, where komorebi looks for `komorebi.json`: a directory, in which `komorebic
configuration` and the daemon look for the file. Without it the config home is
`~/.config/komorebi`, whatever `XDG_CONFIG_HOME` is. When it is set and is not a directory, the
daemon and `komorebic` panic when they first need the config home, and say so.
### `XDG_RUNTIME_DIR`
The runtime directory of the user, normally `/run/user/<uid>`: komorebi writes the bridge to
@@ -292,6 +300,15 @@ When set to anything but the empty string, the log the daemon prints on its stan
has no ANSI colors, which is what standard output redirected to a file wants. The VM tests
set it. The log files are not affected: one has colors and the other none.
## Watching the configuration
The daemon watches `komorebi.json` with `hotwatch` 0.5, over `notify` 6.1, which on Linux is
inotify. At time of writing (2026-10-27) a change to the file reaches the daemon about two
seconds later, the delay of `hotwatch`'s debouncer, whether an editor wrote the file in place or
renamed a new file over it: `the_daemon_follows_the_file_it_is_given_when_the_file_changes` does
both, on aarch64 Linux. A file the daemon cannot read after a change is logged and leaves the
configuration it has.
## The bridge's environment
What the KWin scripting API offers a script, and what it does not, at time of writing
+176
View File
@@ -0,0 +1,176 @@
# Example configurations
`komorebi`, and tiling window managers in general, are very complex pieces of software. To make
starting out easier, the repository has an example configuration,
[`docs/komorebi.example.json`](komorebi.example.json), which is kept working: a test loads it with
every change.
## komorebi.json
The example sets some defaults and gives the first monitor eight workspaces, each with a
different layout. This page has the file as it is:
```json
{
"cross_monitor_move_behaviour": "Insert",
"default_workspace_padding": 15,
"default_container_padding": 15,
"floating_window_aspect_ratio": "Widescreen",
"floating_layer_behaviour": "Float",
"resize_delta": 100,
"ignore_rules": [],
"floating_applications": [],
"manage_rules": [],
"monitors": [
{
"workspaces": [
{
"name": "I",
"layout": "BSP"
},
{
"name": "II",
"layout": "VerticalStack"
},
{
"name": "III",
"layout": "HorizontalStack"
},
{
"name": "IV",
"layout": "UltrawideVerticalStack"
},
{
"name": "V",
"layout": "Rows"
},
{
"name": "VI",
"layout": "Grid"
},
{
"name": "VII",
"layout": "RightMainVerticalStack"
},
{
"name": "VIII",
"layout": "Scrolling"
}
]
}
]
}
```
Put it where the daemon looks for it, `~/.config/komorebi/komorebi.json`, or give it to the daemon
with `komorebic start --config`. [Configuration](usage/configuration.md) explains every key and
where the daemon looks. The settings of a monitor with more than one entry in `monitors`, and of
each workspace, are there too.
### Padding
While you can set the workspace padding (the space between the outer edges of the windows and
the edge of the monitor) and the container padding (the space between each of the tiled windows)
for each workspace on its own, you can also set a default for both of these values that applies
to all workspaces, using `default_workspace_padding` and `default_container_padding`.
### The floating layer
`floating_layer_behaviour` is `Float` in the example: a window that opens while a workspace is on
its floating layer floats, centered, where the default is to tile it. A window that opens while the
workspace is on its tiling layer is tiled either way.
### Layouts
#### BSP
```text
+-------+-----+
| | |
| +--+--+
| | |--|
+-------+--+--+
```
#### Vertical Stack
```text
+-------+-----+
| | |
| +-----+
| | |
+-------+-----+
```
#### RightMainVerticalStack
```text
+-----+-------+
| | |
+-----+ |
| | |
+-----+-------+
```
#### Horizontal Stack
```text
+------+------+
| |
|------+------+
| | |
+------+------+
```
#### Columns
```text
+--+--+--+--+
| | | | |
| | | | |
| | | | |
+--+--+--+--+
```
#### Rows
If you have a vertical monitor, I recommend using this layout.
```text
+-----------+
|-----------|
|-----------|
|-----------|
+-----------+
```
#### Ultrawide Vertical Stack
If you have an ultrawide monitor, I recommend using this layout.
```text
+-----+-----------+-----+
| | | |
| | +-----+
| | | |
| | +-----+
| | | |
+-----+-----------+-----+
```
#### Grid
If you like the `grid` layout in [LeftWM](https://github.com/leftwm/leftwm-layouts) this is almost exactly the same!
The `grid` layout does not support resizing windows tiles.
```text
+-----+-----+ +---+---+---+ +---+---+---+ +---+---+---+
| | | | | | | | | | | | | | |
| | | | | | | | | | | | | +---+
+-----+-----+ | +---+---+ +---+---+---+ +---+---| |
| | | | | | | | | | | | | +---+
| | | | | | | | | | | | | | |
+-----+-----+ +---+---+---+ +---+---+---+ +---+---+---+
4 windows 5 windows 6 windows 7 windows
```
+3
View File
@@ -50,6 +50,9 @@ and keep parts of a monitor free of them.
float its windows.
[Workspaces](usage/workspaces.md) explains how each monitor shows one of its workspaces, which
are KWin's virtual desktops, and how to show another or move a window to one.
[Configuration](usage/configuration.md) explains `komorebi.json`, where komorebi looks for it and
how it is reloaded when it changes, and [Example configurations](example-configurations.md) has
one to start from.
[Subscribing to notifications](usage/subscribing-to-notifications.md) explains how a program
such as a status bar follows what komorebi does. The [CLI reference](cli/start.md) has a page
for every `komorebic` command, generated from its help.
+14 -1
View File
@@ -72,7 +72,20 @@ the repository's `rust-toolchain.toml` selects, whatever nixpkgs your system use
| `services.komorebi.enable` | `false` | Installs komorebi and starts it with every Plasma session. |
| `services.komorebi.package` | `pkgs.komorebi-full` | The package with `bin/komorebi` and `bin/komorebic`; the unit runs the first, and both are installed. |
| `services.komorebi.logLevel` | `"info"` | The daemon's `--log-level`: `"error"`, `"warn"`, `"info"`, `"debug"` or `"trace"`. |
| `services.komorebi.execStart` | read only | The command line the unit starts komorebi with, built from `package` and `logLevel`. A unit of your own that runs komorebi uses it to start komorebi the same way. |
| `services.komorebi.configFile` | `null` | A `komorebi.json` for the daemon. The unit passes it to komorebi as `--config`, so the daemon reads it and not the `komorebi.json` of `~/.config/komorebi`. The file is in the Nix store: komorebi reads a new one when it starts again. |
| `services.komorebi.execStart` | read only | The command line the unit starts komorebi with, built from `package`, `logLevel` and `configFile`. A unit of your own that runs komorebi uses it to start komorebi the same way. |
The file for `configFile` is written like any other `komorebi.json`
([Configuration](usage/configuration.md)):
```nix
{
services.komorebi = {
enable = true;
configFile = ./komorebi.json;
};
}
```
### Running it
+49
View File
@@ -0,0 +1,49 @@
{
"cross_monitor_move_behaviour": "Insert",
"default_workspace_padding": 15,
"default_container_padding": 15,
"floating_window_aspect_ratio": "Widescreen",
"floating_layer_behaviour": "Float",
"resize_delta": 100,
"ignore_rules": [],
"floating_applications": [],
"manage_rules": [],
"monitors": [
{
"workspaces": [
{
"name": "I",
"layout": "BSP"
},
{
"name": "II",
"layout": "VerticalStack"
},
{
"name": "III",
"layout": "HorizontalStack"
},
{
"name": "IV",
"layout": "UltrawideVerticalStack"
},
{
"name": "V",
"layout": "Rows"
},
{
"name": "VI",
"layout": "Grid"
},
{
"name": "VII",
"layout": "RightMainVerticalStack"
},
{
"name": "VIII",
"layout": "Scrolling"
}
]
}
]
}
+188
View File
@@ -0,0 +1,188 @@
# Configuration
komorebi is configured by one file, `komorebi.json`. Many of its settings can also be changed
while the daemon runs, with a `komorebic` command, but the file is where the settings that should
be there every time komorebi starts belong: the workspaces of each monitor and their layouts, the
padding around the tiles, the rules that decide which windows are tiled.
[Example configurations](../example-configurations.md) has a file to start from.
## Where the file is
The daemon reads, in this order:
1. the file `--config` names: `komorebi --config ~/mine.json`, or `komorebic start --config
~/mine.json`. Environment variables in the path, such as `$HOME`, are replaced;
2. `komorebi.json` in the config home, which is `$KOMOREBI_CONFIG_HOME` when that is set (it has
to be a directory) and `~/.config/komorebi` when it is not.
With neither, komorebi runs on its defaults, which are what every setting below says it is when
the file leaves it out. [`komorebic configuration`](../cli/configuration.md) (or `komorebic
config`) prints the path of the file in the config home, when there is one.
On NixOS, [the module's `configFile`](../installation.md#options) gives the daemon a file the
same way `--config` does.
## Changing the file
The daemon watches the file it read. When the file changes, about two seconds later it reads it
again and applies it to the windows it has: it sets the settings, gives each monitor the
workspaces the file lists for it, and tiles every monitor again. The windows stay in the
workspaces they are in. An editor that writes the file in place and one that writes a new file
and renames it over the old one are both followed.
A file that cannot be read, or that has a value of the wrong kind, changes nothing: the daemon
logs the error and keeps what it has. The file is written as JSON that may have comments and
trailing commas.
Reading the file again sets every setting of the daemon from it, and a key the file leaves out is
the default of the setting: a `resize-delta` given with a command is gone when the file changes.
Three things stay as they were when the file leaves them out: `default_workspace_padding`,
`default_container_padding` and `display_index_preferences`. The rules add up, as
[Rules](#rules) says. A workspace the file lists gets its name, padding, offsets and rules from
its entry, and its layout when the entry names one; a workspace the file does not list is left as
it is.
[`komorebic generate-static-config`](../cli/generate-static-config.md) prints the settings the
daemon has now as a `komorebi.json`: a way to start a file from a setup arrived at with commands.
The rules (`ignore_rules`, `manage_rules` and `floating_applications`) are not in what it prints.
## One file for every platform
komorebi for Windows and komorebi for Mac have their own keys, and one `komorebi.json` can serve
all of them. A key that komorebi for KDE does not read is ignored, and so is a key it does not
know: loading never fails because of one. Keys that mean nothing on Plasma, because they are about
how another platform draws or hides windows, are accepted: `titleless_applications`,
`tabbed_applications`, `window_hiding_position` of a monitor, and the keys that only Windows has
(`window_hiding_behaviour`, `border_style`, `stackbar`, and the others of the Windows file).
## The keys
### Settings of the daemon
| Key | Default | What it does |
|---|---|---|
| `resize_delta` | `50` | How many pixels `resize-edge` and `resize-axis` resize by |
| `mouse_follows_focus` | `true` | Whether the pointer goes to the window that is given the focus |
| `cross_monitor_move_behaviour` | `Swap` | What `move` does at the edge of a monitor: `Swap`, `Insert` or `NoOp` |
| `cross_boundary_behaviour` | `Monitor` | Where `focus` and `move` go at the edge of a monitor: to the next `Monitor` or the next `Workspace` |
| `unmanaged_window_operation_behaviour` | `Op` | Whether a command is carried out while the focused window is not tiled: `Op` or `NoOp` |
| `window_container_behaviour` | `Create` | What a window that opens gets: a tile of its own (`Create`) or a place in the focused stack (`Append`) |
| `float_override` | `false` | Whether every window that opens floats |
| `float_override_placement` | `None` | What is done to a window the override floats: `None`, `Center` or `CenterAndResize` |
| `floating_layer_behaviour` | `Tile` | What a window that opens while a workspace is on its floating layer gets: `Tile` or `Float` |
| `floating_layer_placement` | `Center` | What is done to a window that `floating_layer_behaviour` floats |
| `monocle_focus_behaviour` | `NoOp` | What `focus` does while a container is in monocle: `NoOp` or `Cycle` |
| `toggle_float_placement` | `CenterAndResize` | What `toggle-float` does to the window it floats: `None`, `Center` or `CenterAndResize` |
| `float_rule_placement` | `None` | The same, for a window that opens and matches `floating_applications` |
| `floating_window_aspect_ratio` | `Standard` | The aspect ratio `CenterAndResize` gives the window: `Standard` (4:3), `Widescreen` (16:9), `Ultrawide` (21:9) or `[width, height]` |
### Padding and offsets
| Key | Default | What it does |
|---|---|---|
| `default_workspace_padding` | `5` | The gap, in pixels, between the edge of the work area and the tiles |
| `default_container_padding` | `5` | The gap around each tile |
| `global_work_area_offset` | none | The part of every monitor's work area that tiles stay out of: `left`, `top`, `right` and `bottom`. `left` and `top` move the edge in; `right` and `bottom` make the area narrower and shorter by that much |
[Padding and work area offsets](padding-and-offsets.md) explains how the three nest. A monitor
(`container_padding`, `workspace_padding`, `work_area_offset`) and a workspace (the same three)
can have values of their own, which come before the default.
### Rules
| Key | What it does |
|---|---|
| `ignore_rules` | Windows komorebi leaves alone (`float_rules` is the same key under its old name) |
| `manage_rules` | Windows komorebi tiles whatever the ignore rules say |
| `floating_applications` | Windows that open floating |
Each is a list of rules, which [Rules](rules.md) explains. A rule is an object with `kind` (`Exe`,
`Class`, `Title` or `Path`), `id` and `matching_strategy` (`Equals`, `StartsWith`, `EndsWith`,
`Contains`, `Regex`, or one of the four that negate them: `DoesNotEqual`, `DoesNotStartWith`,
`DoesNotEndWith` and `DoesNotContain`), or a list of such objects, all of which have to match.
Rules in the file add to the ones the daemon has: a rule that is taken out of the file stays
until the daemon restarts.
### Monitors and workspaces
`monitors` is a list with one entry for each monitor, each with its `workspaces`. The first entry
is for the first monitor, the second for the second, and so on. A monitor that has no entry keeps
what it has.
`display_index_preferences` puts an entry on a monitor by what the monitor is called instead
of by its place: `{ "0": "DP-1", "1": "HDMI-A-1" }` says that the entry at index 0 is for the
monitor `DP-1`. `komorebic monitor-information` shows the names.
A monitor that has no preference takes the first entry nobody's preference names and that no
other monitor has taken.
A monitor entry can also have a `floating_layer_behaviour`, which is the one its workspaces take
unless they have their own, and which comes before the one for every monitor.
A monitor takes as many workspaces as its entry lists, and KWin gets a virtual desktop for each,
named for it. A workspace has these keys:
| Key | Default | What it does |
|---|---|---|
| `name` | required | The name `focus-named-workspace` and the other named commands find it by |
| `layout` | none | The layout: `BSP`, `Columns`, `Rows`, `VerticalStack`, `RightMainVerticalStack`, `HorizontalStack`, `UltrawideVerticalStack`, `Grid` or `Scrolling` |
| `tile` | see below | Whether the workspace tiles its windows |
| `layout_flip` | none | The axis the layout is mirrored on: `Horizontal`, `Vertical` or `HorizontalAndVertical` |
| `layout_options` | none | Options of the layout, such as `column_ratios` and `scrolling` |
| `layout_rules` | none | `{ "3": "Columns" }`: the layout the workspace has once it has 3 containers or more |
| `layout_options_rules` | none | The same, for the layout options |
| `container_padding`, `workspace_padding` | the default | The padding of this workspace |
| `work_area_offset` | none | The offset of this workspace |
| `work_area_offset_rules` | none | `{ "2": { "left": 100, "top": 0, "right": 200, "bottom": 0 } }`: the offset the workspace has once it has 2 containers or more |
| `apply_window_based_work_area_offset` | `true` | Whether the workspace takes its monitor's window-based offset |
| `window_container_behaviour` | the default | What a window that opens on this workspace gets: `Create` or `Append` |
| `window_container_behaviour_rules` | none | `{ "2": "Append" }`: the behavior the workspace has once it has 2 containers or more |
| `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` |
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.
The highest of the rules that the number of containers reaches wins. A layout rule changes the
layout of the workspace and leaves it there when the number falls below the threshold again, so a
rule at 1 is how to say what the layout is when there is one window; the offset and the layout
options of a rule are the ones the workspace has while it has that many containers.
The window container behavior rules are the exception: while the workspace has fewer containers
than the lowest threshold it has no behavior of its own and takes the one for every workspace,
and a workspace that has rules takes its behavior from them alone, so
`toggle-workspace-window-container-behaviour` does not outlast the next time it is tiled.
### Layout options for every workspace
`layout_defaults` gives the layout options and the layout options rules of a layout to every
workspace that has that layout and sets neither `layout_options` nor `layout_options_rules`:
```json
{
"layout_defaults": {
"Columns": { "layout_options": { "column_ratios": [0.6] } },
"Scrolling": { "layout_options": { "scrolling": { "columns": 2 } } }
}
}
```
A workspace that sets either of its own has none of the defaults of its layout, not even for the
setting it leaves out.
## Layout rules from the command line
The layout rules of a workspace can be added and taken away while the daemon runs:
```sh
komorebic workspace-layout-rule 0 1 3 columns
komorebic named-workspace-layout-rule mail 2 rows
komorebic clear-workspace-layout-rules 0 1
komorebic clear-named-workspace-layout-rules mail
```
[`workspace-layout-rule`](../cli/workspace-layout-rule.md) takes the index of the monitor, the
index of the workspace, the number of containers and the layout;
[`named-workspace-layout-rule`](../cli/named-workspace-layout-rule.md) takes the name of the
workspace instead. A rule for a count that has one replaces it. The clear commands take every
rule of the workspace away and leave it with the layout it has.
+13
View File
@@ -31,6 +31,12 @@ komorebic toggle-workspace-float-override
The override is in the daemon's state, as `float_override` for every workspace and in each
workspace that has one of its own.
In `komorebi.json` it is `float_override`, for every workspace and in the entry of a workspace.
`float_override_placement` says what is done to the window the override floats: `None` leaves it
where KWin put it, `Center` centers it in the work area and `CenterAndResize` also makes it half
as tall as the work area, with the aspect ratio `floating_window_aspect_ratio` names. A window is
centered only on a workspace that tiles.
## The two layers
A workspace is on one of two layers: its tiles, or its floating windows. Which one decides what
@@ -68,3 +74,10 @@ On the floating layer:
there, and when it is restored it is a tile, not a floating window.
The layer is `layer` in the state of each workspace, `Tiling` or `Floating`.
What a window that opens while a workspace is on its floating layer gets is
`floating_layer_behaviour` in `komorebi.json`: `Tile`, the default, gives it a tile, and `Float`
floats it, centered in the work area as `floating_layer_placement` says (`Center` by default; the
values are those of `float_override_placement`). The entry of a monitor and the entry of a
workspace can have a `floating_layer_behaviour` of their own: the workspace's comes before the
monitor's, which comes before the one for every monitor.
+3 -2
View File
@@ -36,8 +36,9 @@ does meanwhile is set with
`right` or `up` the next one.
[`komorebic toggle-monocle-focus-behaviour`](../cli/toggle-monocle-focus-behaviour.md) switches
between the two. [`komorebic cycle-focus`](../cli/cycle-focus.md) always carries the monocle to
the next or the previous container, whatever the behavior is.
between the two, and `monocle_focus_behaviour` in `komorebi.json` (`NoOp` or `Cycle`) sets it from
the file. [`komorebic cycle-focus`](../cli/cycle-focus.md) always carries the monocle to the next or
the previous container, whatever the behavior is.
```sh
komorebic monocle-focus-behaviour cycle
+7
View File
@@ -35,6 +35,13 @@ to KWin on the session bus and loads a script into it, so start it from a termin
session. Outside a Plasma session it exits with an error that says what is missing, which
`komorebic start` prints.
`--config` gives the daemon the `komorebi.json` to read
([Configuration](configuration.md) says where it looks otherwise):
```sh
komorebic start --config ~/mine.json
```
Everything after a `--` is passed to `komorebi`. `--fake-backend` runs it against an
in-memory desktop with one monitor and no windows instead of KWin, which is a way to try the
daemon and `komorebic` without a compositor:
+12
View File
@@ -93,6 +93,18 @@ komorebic toggle-workspace-window-container-behaviour
The setting is in the daemon's state, as `new_window_behaviour` for every workspace and as
`window_container_behaviour` in each workspace that has one of its own.
In `komorebi.json`, `window_container_behaviour` is the setting for every workspace, `Create` or
`Append`, and the entry of a workspace can have its own. The entry of a workspace can also have
`window_container_behaviour_rules`, which give the behavior by the number of containers:
```json
{ "name": "chat", "layout": "Columns", "window_container_behaviour_rules": { "2": "Append" } }
```
A window opens in a tile of its own until the workspace has two containers, and joins the focused
stack from then on. The [configuration](configuration.md) page says how the rules and the toggle
for one workspace go together.
## Where the windows behind go
komorebi does not minimize the windows behind the front one: it moves them to a virtual desktop
+2 -2
View File
@@ -49,8 +49,8 @@ sent.
A subscriber can ask to be sent a notification only when the event or the message changed
the state, with the `filter_state_changes` option. It is still sent the notification of a
window that is shown and of every new subscription, so it receives the state as soon as it
subscribes. `komorebic subscribe-socket` has no option for it; a program writes the message
window that is shown, of every new subscription, so it receives the state as soon as it
subscribes, and of every reload of `komorebi.json`. `komorebic subscribe-socket` has no option for it; a program writes the message
on the daemon's socket itself:
```sh