Files
komorebi/nix/tests/effects.nix
T
LGUG2Z 4fa8108110 feat(kwin): animation through the Geometry Change effect
Windows that jump to their new places are hard to follow. komorebi animates
nothing itself: KWin's Geometry Change effect animates a window that a script
moves, and komorebi tells it how long that takes. The look the window manager
asks the backend for now has an animation, a duration that the settings give for
every kind of animation or, when one is set for the movement of windows, for
that one. The KWin backend writes the effect's settings into the user's kwinrc
(a duration, and no cross-fading, since a window going to its place changes
where it is and not what it shows), loads the effect when animation is on, and
unloads it and puts the settings back when it is off or komorebi exits.

komorebic gets animation, animation-duration and animation-fps. The module
installs the effect (effects.animation), and the session node sets the variable
that makes KWin load effects that animate under software rendering. vm-look
reads the screen a moment after a flip of the layout, with a 30 s animation and
without one.

The commands that change a stack turn the animation off while they run, as
komorebi does elsewhere, and komorebi.json takes an animation key (enabled,
duration and fps, each for every kind of animation or for one).
2026-10-28 07:20:49 -07:00

88 lines
3.7 KiB
Nix

# Install checks of the KWin effects komorebi drives: each package is built and its files are
# inspected the way KWin finds them, without a session. Whether an effect loads in a real KWin is a
# question for the VM tests.
{ pkgs, packages }:
let
inherit (pkgs.kdePackages) kwin qttools;
fail = ''
fail() {
echo "FAIL: $*" >&2
exit 1
}
'';
in
{
kde-rounded-corners-komorebi-install =
pkgs.runCommand "kde-rounded-corners-komorebi-install"
{
nativeBuildInputs = [
pkgs.jq
pkgs.patchelf
# qtplugininfo reads a plugin's metadata as Qt and KWin read it
qttools
];
}
''
${fail}
plugin=${packages.kde-rounded-corners-komorebi}/lib/qt-6/plugins/kwin/effects/plugins/kwin4_effect_shapecorners.so
[ -f "$plugin" ] || fail "no plugin at $plugin"
echo "ok: the plugin is where KWin looks for effect plugins"
# The metadata is compiled into the plugin; KWin does not read metadata.json at run time.
qtplugininfo --full-json "$plugin" > metadata.json || fail "qtplugininfo cannot read $plugin"
if ! jq -e '.MetaData.KPlugin.EnabledByDefault == false' metadata.json > /dev/null; then
cat metadata.json
fail "the plugin's metadata does not say EnabledByDefault false"
fi
echo "ok: the plugin's metadata says EnabledByDefault false"
# The plugin is loaded into KWin, so it has to link the libkwin of that KWin: the dynamic
# loader takes the first directory of the RUNPATH that has the library.
needed=$(patchelf --print-needed "$plugin" | grep -m 1 -x 'libkwin\.so\.[0-9]*') ||
fail "the plugin does not link libkwin"
found=
IFS=: read -r -a dirs <<< "$(patchelf --print-rpath "$plugin")"
for dir in "''${dirs[@]}"; do
if [ -e "$dir/$needed" ]; then
found=$dir/$needed
break
fi
done
[ "$found" = "${kwin}/lib/$needed" ] ||
fail "$needed resolves to '$found', not to the KWin of this nixpkgs (${kwin})"
echo "ok: $needed is ${kwin}/lib/$needed"
# komorebi's patch: the interface that takes a color for each window
grep -q -a -F org.komorebi.BorderColours1 "$plugin" ||
fail "the plugin has no org.komorebi.BorderColours1: komorebi-border-colours.patch is not in it"
echo "ok: the plugin has org.komorebi.BorderColours1"
touch $out
'';
kwin-effect-geometry-change-komorebi-install =
pkgs.runCommand "kwin-effect-geometry-change-komorebi-install" { nativeBuildInputs = [ pkgs.jq ]; }
''
${fail}
# KWin finds scripted effects by their metadata.json, in a directory of share/kwin/effects
effect=${packages.kwin-effect-geometry-change-komorebi}/share/kwin/effects/kwin4_effect_geometry_change
[ -f "$effect/metadata.json" ] || fail "no metadata.json in $effect"
jq -e '.KPlugin.Id == "kwin4_effect_geometry_change"' "$effect/metadata.json" > /dev/null ||
fail "the metadata does not name the effect kwin4_effect_geometry_change"
main=$effect/contents/$(jq -r '."X-Plasma-MainScript"' "$effect/metadata.json")
[ -f "$main" ] || fail "no main script at $main"
echo "ok: the effect is where KWin looks for scripted effects, with its script"
# upstream's choice, which komorebi relies on: asserted so that an update cannot change it
if ! jq -e '.KPlugin.EnabledByDefault == false' "$effect/metadata.json" > /dev/null; then
cat "$effect/metadata.json"
fail "the metadata does not say EnabledByDefault false"
fi
echo "ok: the metadata says EnabledByDefault false"
touch $out
'';
}