Files
komorebi/docs/usage/running-komorebi.md
T
LGUG2Z b49c4fab0a feat(kwin): the daemon registers with KGlobalAccel
A static shortcut can only be one combo, pressed, the same in every application.
Modes, chord chains, release bindings and per-application bindings need komorebi
to hold the keys and decide what each press does: the engine of
komorebi-hotkeys, a state machine with no I/O. This commit runs it against
KWin's global shortcut daemon, which KWin 6.8 runs inside itself on the session
bus.

kwin::hotkeys owns the component komorebi in kglobalaccel, with one action per
combo, named after the combo (Alt+H). An activation of the engine is
setShortcutKeys(id, [[combo]], 6), with a doRegister the first time; a
deactivation is setInactive, after which the key reaches the focused window
again. The calls of one event are sent without waiting for each other's answers,
which Phase 0 measured at 60 calls in 2.4 ms. globalShortcutPressed and
globalShortcutReleased of /component/komorebi feed the engine;
globalShortcutRepeated is ignored, so a held key runs its binding once. A
komorebic command runs the komorebic next to the daemon with its words when they
need no shell, anything else runs through sh -c. The calls are computed by
Registry, which is pure and tested; the D-Bus part is proved by the VM test.

The engine hears the presses at the path /component/komorebi and does not ask
kglobalaccel for the object with getComponent. kglobalaccel makes the object
when the component gets its first action, so a start with no key to grab (every
binding is for an application other than the one with the focus) has none to ask
for: getComponent fails with NoSuchComponent, and an engine that asked would
never start. A signal is matched by the path it comes from, so the presses are
heard as soon as there is an object. PLATFORM.md says so.

kglobalaccel keeps the actions and the grabs of a client that was killed, so a
start is an idempotent reconcile: the actions of the component that the keymap
names are taken over and released unless the default mode wants them, the others
are unregistered. A stop releases and unregisters everything, from
KWinBackend::shutdown, which SIGINT, SIGTERM and the Stop message all go
through.

The daemon takes --keybindings FILE, --keybindings-format skhd|whkd|sxhkd (by
default from the file's name) and --keybindings-mode (the mode komorebic hotkeys
compile wrote the static shortcuts in, so that the daemon leaves those to KDE);
without --keybindings it reads the first of skhdrc, whkdrc and sxhkdrc in the
config directory (HOME_DIR, KOMOREBI_CONFIG_HOME). It logs one line about the
file and the diagnostics at debug level. An engine that cannot start is logged
and the window manager runs without keys; the fake backend runs none.

The VM test vm-keys-engine starts the daemon in a Plasma session with an skhdrc
in the config directory, presses its keys (a command, one through a shell,
komorebic retile reaching the daemon), kills the daemon and sees its keys stay
registered, starts it with another file and sees the old keys unregistered and
the new ones work, and stops it with komorebic stop, after which no key is
registered and none runs. The library gains spawn_komorebi,
kill_spawned_komorebi and shortcut_actions, and Checks.finish names the checks
that failed, since nix build shows only the last lines of a failed run. The
suite's node turns the module's unit off: the test runs daemons of its own.
2026-10-28 07:21:14 -07:00

6.2 KiB

Running komorebi

komorebi is the daemon that tiles your windows, and komorebic is the command line you control it with. This page covers starting and stopping the daemon, asking it what it is doing, and reading its log.

Getting the two programs

Installing komorebi covers NixOS, where the flake's module installs both and starts the daemon with every Plasma session, and building them from source. In a checkout of the repository, on Linux, nix build leaves them in result/bin, and nix profile install . puts them on your PATH. Without nix, build them with the Rust toolchain that rust-toolchain.toml selects:

cargo build --release --locked
export PATH="$PWD/target/release:$PATH"

With the NixOS module, the daemon is the user unit komorebi.service, which starts when you log in to Plasma. systemctl --user start komorebi starts it again after a komorebic stop, and journalctl --user -u komorebi shows what it wrote. Everything else on this page applies to it as it is.

Starting and stopping

komorebic start runs the komorebi on your PATH in the background, and checks three seconds later that it is running. It tries three times. If komorebi has not started by then, komorebic start runs it once more in the foreground and prints what it wrote on its standard error, which explains why it did not start. When a komorebi is running already, komorebic start does nothing.

komorebi manages the windows of the Plasma Wayland session it is started in: it connects to KWin on the session bus and loads a script into it, so start it from a terminal in that session. Outside a Plasma session it exits with an error that says what is missing, which komorebic start prints. komorebic check says what is missing from the session, and what is wrong with the configuration, without starting anything.

--config gives the daemon the komorebi.json to read (Configuration says where it looks otherwise), and komorebic quickstart writes one to start from:

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:

komorebic start
komorebic start -- --log-level debug
komorebic start -- --fake-backend

komorebic stop tells the daemon to stop. It brings back the windows it hid (the back of a stack, stacking windows, and the windows behind a monocle), removes the desktop they were hidden on, asks KWin to unload its script, removes its socket and exits. Stopping the process with SIGINT or SIGTERM does the same.

Key bindings

komorebi reads key bindings from a file in the format of skhd, whkd or sxhkd. The daemon looks for skhdrc, whkdrc or sxhkdrc in ~/.config/komorebi (or in $KOMOREBI_CONFIG_HOME) and takes the first it finds; --keybindings FILE names another, with --keybindings-format skhd|whkd|sxhkd when its name does not end with one of those. The daemon registers the keys with KDE itself and runs the command of each press:

komorebic start -- --keybindings ~/dotfiles/skhdrc

KDE can also run a binding with no komorebi process, as a static shortcut that shows in System Settings: komorebic hotkeys compile writes those, and --mode auto writes every binding that can be one. Give the daemon the same mode, so that it leaves those bindings to KDE:

komorebic hotkeys compile --mode auto
komorebic start -- --keybindings-mode auto

A daemon that is killed leaves its keys swallowed until it is started again; komorebic stop gives them back.

Asking komorebi what it is doing

The daemon answers questions on its socket, and these commands print the answers:

  • komorebic state: every monitor, with its workspaces, their containers and the windows in them, as JSON.
  • komorebic monitor-information: the id, the name and the bounds of every monitor, as JSON.
  • komorebic query: one value, the answer to one question: the index of the focused monitor, workspace, container or window, the layout of the focused workspace, whether the focused container is a single window or a stack, or the version of the daemon.
komorebic query focused-workspace-index
komorebic state | jq '.monitors.elements[0].workspaces.elements[0].containers.elements | length'

komorebic retile tiles the windows of every monitor again, which puts a window that was moved by hand back on its tile.

When the daemon is not running, these commands fail: there is no socket to write to.

A program that wants to know what komorebi does without asking can subscribe to its notifications instead (Subscribing to notifications).

The socket and the data directory

The daemon listens on komorebi.sock in its data directory, $XDG_RUNTIME_DIR/komorebi (the local data directory, ~/.local/share/komorebi, when there is no runtime directory). komorebic data-directory prints the directory, if it exists.

The log

The daemon logs to its standard output and to a file a day in ~/.local/share/komorebi ($XDG_DATA_HOME/komorebi when that is set): komorebi.log.YYYY-MM-DD, with colors, and komorebi_plaintext.log.YYYY-MM-DD, without. The day is the UTC date.

komorebic log follows the file of the current day, with colors, until you press Ctrl-C. The --log-level of komorebi sets how much is logged: error, warn, info (the default), debug or trace.

Shell completions

komorebic completions prints a completion script for bash, elvish, fish, PowerShell or zsh:

komorebic completions fish > ~/.config/fish/completions/komorebic.fish
komorebic completions bash > ~/.local/share/bash-completion/completions/komorebic

Every command

docs/cli has a page for every komorebic command, generated from its help with just docgen.