mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 14:48:34 +01:00
On NixOS, running komorebi should take one flake input and one module line. The flake exports `services.komorebi` as nixosModules.default (and .komorebi). It adds the flake's overlay, which gains komorebi-full, installs komorebi and komorebic, and runs the daemon in every Plasma session as a systemd user unit, wanted by plasma-workspace.target and ordered after plasma-core.target, which Plasma orders after KWin. systemd starts a daemon that fails again; the exit status of a SIGTERM (130) counts as success, so a stopped unit is not failed. The unit's PATH is the one a terminal in the session has, instead of the few store paths NixOS gives a unit. The options are enable, package, logLevel and a read-only execStart, the command line the unit runs. There is no configFile: the daemon reads no configuration file yet, and an option that linked one would do nothing. nixos-module-eval evaluates seven scenarios as real NixOS systems and checks their assertions, the unit and execStart, with builtins.tryEval for the two that must not evaluate. Nothing in it builds a Linux package, so it runs on a Mac as well. The VM nodes import the module, so every suite runs komorebi as the module installs it. The headless node's komorebi@NAME runs execStart, which has --log-level, so the nodes set logLevel to debug and the suites stop passing it; latency, which times the daemon, keeps the default level. The session node starts the module's unit at login; render-smoke turns it off, since a tiled terminal would cover the desktop it looks at. A new fast suite, vm-module, logs in to Plasma and checks that the unit runs the daemon with the module's log level and PATH, that a window opened in the session is tiled, that a killed daemon is started again, and that a stop is not a failure. docs/installation.md covers NixOS first, and building from source on other distributions. There is no binary cache: the Komorebi license does not allow third parties to redistribute binaries.
102 lines
3.6 KiB
Python
102 lines
3.6 KiB
Python
# How real clients answer the frame komorebi asks for. KWin carries out a request at once; the
|
|
# client then decides the size it draws at, and that is the frame KWin reports. What only real
|
|
# clients can tell, and what the fake desktop of the Rust tests cannot know: Qt and KDE programs
|
|
# and X11 programs on XWayland take the frame exactly, also below the minimum size they report;
|
|
# foot sizes itself down to whole cells of its font; GTK 4 programs and Firefox never go below
|
|
# their minimum size. Every client keeps the position komorebi asked for. The output is large
|
|
# enough that some tiles are bigger and some smaller than the clients' minimums.
|
|
from komorebi_vm import Checks, Kde, Rect, daemon
|
|
|
|
W, H = 3840, 2160
|
|
CELL = 24
|
|
|
|
EXACT = ["org.kde.konsole", "org.kde.kate", "org.kde.dolphin", "XTerm"]
|
|
WHOLE_CELLS = ["foot"]
|
|
NOT_BELOW_MINIMUM = ["org.gnome.TextEditor", "org.gnome.Calculator", "firefox"]
|
|
|
|
CLIENTS = {
|
|
"foot": "foot -T foot-term sleep 3000",
|
|
"org.kde.konsole": "konsole --separate",
|
|
"org.kde.dolphin": "dolphin --new-window /tmp",
|
|
"org.kde.kate": "kate --new",
|
|
"org.gnome.TextEditor": "gnome-text-editor --new-window",
|
|
"org.gnome.Calculator": "gnome-calculator",
|
|
"XTerm": "xterm -T xterm-x11",
|
|
"firefox": "firefox --no-remote --profile /tmp/firefox-profile about:blank",
|
|
}
|
|
|
|
start_all()
|
|
machine.wait_for_unit("multi-user.target")
|
|
machine.wait_for_unit("user@1000.service")
|
|
|
|
checks = Checks()
|
|
kde = Kde.headless(machine, "main", size=(W, H), xwayland=True, scale=SCALE)
|
|
kde.as_user("mkdir -p /tmp/firefox-profile")
|
|
kde.start_komorebi()
|
|
checks.check(
|
|
"the daemon loaded its script into KWin",
|
|
kde.wait_for(lambda: "loaded the KWin bridge script" in kde.komorebi_log(), timeout=30),
|
|
)
|
|
|
|
for app, command in CLIENTS.items():
|
|
kde.spawn(command, log=f"/tmp/{app}.log")
|
|
up = kde.wait_for(lambda app=app: kde.wid_by_class(app) != "", timeout=120)
|
|
if not checks.check(f"{app} has a window", up):
|
|
print(machine.execute(f"cat /tmp/{app}.log")[1])
|
|
|
|
|
|
def shown() -> int:
|
|
return sum(1 for e in daemon.events(kde.komorebi_log()) if e.kind == "Show")
|
|
|
|
|
|
checks.check("the daemon tiles all eight", kde.wait_for(lambda: shown() >= 8, timeout=60))
|
|
|
|
|
|
def show(r: Rect | None) -> str:
|
|
return "-" if r is None else f"{r.x},{r.y} {r.w}x{r.h}"
|
|
|
|
|
|
def snapshot() -> dict[str, Rect]:
|
|
return {app: kde.rect(kde.wid_by_class(app)) for app in CLIENTS}
|
|
|
|
|
|
# the clients answer in their own time; the frames are final once they stop changing
|
|
before: dict[str, Rect] = {}
|
|
|
|
|
|
def still() -> bool:
|
|
global before
|
|
now = snapshot()
|
|
unchanged = now == before
|
|
before = now
|
|
return unchanged
|
|
|
|
|
|
kde.wait_for(still, timeout=60, interval=3)
|
|
requests = list(daemon.requests(kde.komorebi_log()).values())
|
|
|
|
print(f" {'client':<22} {'asked':<22} {'has':<22}")
|
|
for app, have in snapshot().items():
|
|
asked = [r for r in requests if (r.x, r.y) == (have.x, have.y)]
|
|
want = asked[0] if asked else None
|
|
print(f" {app:<22} {show(want):<22} {show(have):<22}")
|
|
if not checks.check(f"{app} is where komorebi put it", want is not None):
|
|
continue
|
|
assert want is not None
|
|
if app in EXACT:
|
|
checks.check(f"{app} takes the size it is asked for", (have.w, have.h) == (want.w, want.h))
|
|
elif app in WHOLE_CELLS:
|
|
checks.check(
|
|
f"{app} sizes itself down to whole cells",
|
|
0 <= want.w - have.w < CELL and 0 <= want.h - have.h < CELL,
|
|
)
|
|
elif app in NOT_BELOW_MINIMUM:
|
|
checks.check(
|
|
f"{app} is never smaller than it is asked to be",
|
|
have.w >= want.w and have.h >= want.h,
|
|
)
|
|
|
|
kde.stop_komorebi()
|
|
kde.stop()
|
|
checks.finish()
|