mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-15 05:12:28 +01:00
The daemon answers on its socket, but a person has no way to write a message on it. komorebic is that way: each subcommand that asks something of the daemon is one message, sent with komorebi-client, and a question's answer is printed. komorebic is a separate program because the daemon takes no input but its socket, so a key binding, a script and a terminal all drive it the same way. It has what the daemon can answer so far: state, monitor-information, query, retile and stop. Around them, start runs the komorebi on the PATH in the background and passes it what follows a --, such as --fake-backend to try it without a compositor; log follows the daemon's log, which the daemon now writes to a file a day in LOG_DIR as well as to stdout; data-directory shows where the socket is; completions prints a shell completion script. The hidden docgen writes each subcommand's help to docs/cli, in fences that name their language and wrapped at 100 columns whatever the width of the terminal, so that the pages are the same wherever they are generated; just docgen runs it. The user guide starts here: docs/index.md for KDE Plasma, and a page on running komorebi. tests/cli.rs runs each subcommand against a socket the test serves in place of the daemon. In the VM tests the guests get komorebic next to the daemon, and vm-core-e2e reads the daemon's state with it (the windows it manages, the one it focuses, after KWin restarts too) and stops it with komorebic stop, which unloads the bridge and removes the socket. In the VM test library, Kde.state asks again, a second (times the scale) after an empty answer or a failed command, up to 10 times. The daemon drops a query when it cannot take hold of the window manager within a second, and komorebic then prints an empty line and succeeds; komorebic itself gives the daemon a second to answer and fails when that is not enough. A daemon busy with the first windows does either on a machine that is loaded or slow, and a suite that polled the state died on JSONDecodeError. An answer that is not JSON still fails at once.
53 lines
1.9 KiB
Makefile
53 lines
1.9 KiB
Makefile
export RUST_BACKTRACE := "full"
|
|
|
|
# format the Rust sources (needs a nightly rustfmt: rustfmt.toml uses unstable options)
|
|
fmt:
|
|
cargo fmt
|
|
|
|
# everything a change has to pass before it is pushed
|
|
check: lint check-js
|
|
cargo fmt --check
|
|
cargo clippy --workspace --all-targets --locked -- -D warnings
|
|
cargo test --workspace --locked
|
|
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --locked
|
|
|
|
# the KWin bridge, which is JavaScript: its types, checked by tsc from its JSDoc comments, and its
|
|
# tests, which node runs against a fake KWin (no package.json, no build step)
|
|
check-js:
|
|
cd komorebi/src/kwin && tsc -p tsconfig.json
|
|
node --test komorebi/src/kwin/bridge.test.js
|
|
|
|
# the macros the codebase has agreed not to use
|
|
lint:
|
|
test -z "$(rg 'eyre!' --type rust .)" || (echo "eyre! macro not allowed"; false)
|
|
test -z "$(rg 'dbg!' --type rust .)" || (echo "dbg! macro not allowed"; false)
|
|
test -z "$(rg 'println!' --type rust ./komorebi/src)" || (echo "println! macro not allowed"; false)
|
|
|
|
# one VM test, on this machine: `just vm kwin`. Linux boots the guest under KVM through the
|
|
# flake check; a Mac builds the guest on a builder and runs the driver (see docs/dev/vm-tests.md)
|
|
vm name:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
if [ "$(uname)" = Darwin ]; then
|
|
scripts/vm-mac {{ name }}
|
|
else
|
|
nix build -L .#checks.{{ arch() }}-linux.vm-{{ name }}
|
|
fi
|
|
|
|
# every VM test, in the order of the flake
|
|
vm-all:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
system=$(nix eval --raw --impure --expr builtins.currentSystem)
|
|
for name in $(nix eval --json ".#legacyPackages.$system.vm" --apply builtins.attrNames | jq -r '.[]'); do
|
|
just vm "$name"
|
|
done
|
|
|
|
# write the help of every komorebic subcommand to docs/cli, one page each
|
|
docgen:
|
|
rm -f docs/cli/*.md
|
|
cargo run --package komorebic --locked -- docgen --output docs/cli
|
|
|
|
run target *args:
|
|
cargo run --bin {{ target }} --locked -- {{ args }}
|