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).
This commit is contained in:
LGUG2Z committed 2026-10-28 07:20:49 -07:00
1 parent 22c14ba5be
commit 4fa8108110
41 files changed
+1322 -93

No files matched your search

+5 -3
View File
@@ -95,12 +95,14 @@ License version 3, and is under the same license. A patch starts with a header
that describes the change and carries the license notice; `patch` skips the
text before the first `diff` line. To change a patch, make the change in the
effect's source at the version the package pins, and write the whole diff again
with `diff -ruN a b` below the header. The check of the package (in
[`nix/tests/effects.nix`](nix/tests/effects.nix)) builds it and checks the
files it installs, the patch included:
with `diff -ruN a b` below the header. The check of each package, named after
it (in [`nix/tests/effects.nix`](nix/tests/effects.nix)), builds the package
and checks the files it installs, and for a patched package that the patch is
in them:
```sh
nix build .#checks.x86_64-linux.kde-rounded-corners-komorebi-install
nix build .#checks.x86_64-linux.kwin-effect-geometry-change-komorebi-install
```
## Continuous integration
+9 -3
View File
@@ -69,8 +69,8 @@ without a checkout of the toolchain.
(`backend`), the backend that reaches KWin through a script it runs and edits
the settings of KWin's it needs in the user's `kwinrc`, the parking desktop it
hides the back of a stack and the windows behind a monocle on, and the borders
it has KWin draw (`kwin`), the border settings and the look they make
(`border_manager`),
and animations it has KWin draw (`kwin`), the border and animation settings and
the look they make (`border_manager`, `animation`),
the model of what it tiles (`monitor`, `workspace`, `container`, `window`), the
window manager that keeps the model (`window_manager`), loads it from the
backend (`desktop`) and changes it when the compositor reports an event
@@ -104,6 +104,10 @@ KWin:
Corners 0.11.0, which draws an outline around each window, built so that KWin
does not load it until it is asked to, and with a patch that lets komorebi
give each window a color of its own.
- `kwin-effect-geometry-change-komorebi`
([`nix/kwin-effect-geometry-change.nix`](nix/kwin-effect-geometry-change.nix)):
Geometry Change 1.5, a scripted effect that animates a window that a program
or a script moves or resizes.
Each one is a package for Linux and an attribute of `overlays.default`, built
with the KWin of the nixpkgs the overlay is applied to.
@@ -252,7 +256,9 @@ effect draw it, which the module installs. A border takes room around each
window, so the layout leaves the room while the compositor says it draws one, and
komorebi gives each window the border color of what it is to the layout: the focused
window, the others, a locked container, a floating window. `border`, `border-colour`,
`border-width` and `border-offset` set it.
`border-width` and `border-offset` set it. Windows going to their places are
animated by another effect, Geometry Change, which `animation` and
`animation-duration` turn on and set.
## Documentation
+19
View File
@@ -0,0 +1,19 @@
```text
Set the duration for movement animations in ms
Usage: animation-duration [OPTIONS] <DURATION>
Arguments:
<DURATION>
Desired animation durations in ms
Options:
-a, --animation-type <ANIMATION_TYPE>
Animation type to apply the duration to. If not specified, sets global duration
[possible values: movement]
-h, --help
Print help
```
+14
View File
@@ -0,0 +1,14 @@
```text
Set the frames per second for movement animations
Usage: animation-fps <FPS>
Arguments:
<FPS>
Desired animation frames per second
Options:
-h, --help
Print help
```
+19
View File
@@ -0,0 +1,19 @@
```text
Enable or disable movement animations
Usage: animation [OPTIONS] <BOOLEAN_STATE>
Arguments:
<BOOLEAN_STATE>
[possible values: enable, disable]
Options:
-a, --animation-type <ANIMATION_TYPE>
Animation type to apply the state to. If not specified, sets global state
[possible values: movement]
-h, --help
Print help
```
+40 -14
View File
@@ -68,9 +68,10 @@ grows with the code: each part of the daemon that is added has its place here.
- **Notification**: what a subscriber is sent after each event and each message the window
manager handles: the event or the message, and the state after it ([`Notification`]).
- **Look**: how the compositor is asked to dress the windows, which it draws ([`Look`]):
a border, with its width, its corner radius and two colors.
a border, with its width, its corner radius and two colors, and the animation of windows going
to their places, with its duration.
- **Effect**: a plugin of the compositor that changes how windows are drawn. KDE Rounded Corners
is the effect that draws the border.
is the effect that draws the border, and Geometry Change the one that animates windows.
- **Compositor**: the program that owns the screen and the windows. On KDE Plasma it is
KWin.
- **Backend**: the implementation of the [`Backend`](../../komorebi/src/backend/mod.rs)
@@ -765,14 +766,21 @@ goes the other way, for `GenerateStaticConfig`.
komorebi decides what the windows look like and the compositor draws it, since only the
compositor has the frames, the corners and the shadows. A border is the outer outline of a window,
drawn outside it, in the gap the layout leaves between tiles. The window manager describes a
drawn outside it, in the gap the layout leaves between tiles, and an animation is a window
sliding to its new place instead of jumping there. The window manager describes a
[`Look`] and asks the backend for it ([`Backend::apply_look`]); the backend sees that it is drawn
and answers whether borders are being drawn. The reasons are in
[DESIGN.md](DESIGN.md#why-does-the-compositor-draw-the-borders-and-not-komorebi).
[`border_manager`] holds the settings, as statics that the messages `Border`, `BorderWidth` and
`BorderOffset` set: whether borders are on, their width, the offset, the radius of the corners and
the two colors. [`border_manager::current_look`] makes the [`Look`] of them, and
[`border_manager`] holds the settings of the border, as statics that the messages `Border`,
`BorderWidth` and `BorderOffset` set: whether borders are on, their width, the offset, the radius
of the corners and the two colors. [`animation`] holds the settings of the animation, which
`Animation`, `AnimationDuration` and `AnimationFps` set: whether windows are animated and for how
long, for every kind of animation or for one ([`AnimationPrefix`]; movement is the only kind). The
settings of one kind win over the global ones, and a global setting clears the ones of the kinds.
The commands that change a stack turn the animation off while they run and put it back, as
komorebi does on the other platforms; the file's `animation` key sets the same settings.
[`border_manager::current_look`] makes the [`Look`] of them all, and
[`border_manager::send_notification`] asks the backend for it and keeps the answer in
[`BORDER_DRAWN`]. It is called before the first layout, after every event and every message, and
after every retile. A backend remembers the look it applied last and does nothing when it is asked
@@ -800,7 +808,10 @@ into the user's `kwinrc`, group `[Round-Corners]`, through [`Kwinrc`]; loads the
(`reconfigureEffect`), since KWin hands an effect the copy of `kwinrc` it read when it started. A
look without a border unloads the effect, if komorebi loaded it, and puts the user's settings
back. `shutdown` does the same. An effect KWin did not find when it started is reported once and
komorebi goes on without it, with `apply_look` answering false. The stock effect has one color for
komorebi goes on without it, with `apply_look` answering false. The animation is Geometry Change:
its `Duration` is the look's, and cross-fading is off. KWin animates what is painted, so the
frame the table reads is the final one at once and nothing waits for an animation to end. The
stock border effect has one color for
the active window and one for the others; komorebi's build of it takes a color for each window,
over D-Bus, by the UUID KWin knows the window by. `set_border_colours` answers false, and logs it
once, when the effect is the stock one: every border is then the focused or the unfocused color of
@@ -814,10 +825,11 @@ The flake exports one module under two names, `nixosModules.default` and
`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`,
`configFile`, `config`, `applicationSpecificConfiguration`, `effects.borders.enable` and
`effects.borders.package` (by default `pkgs.kde-rounded-corners-komorebi`, from the overlay), and
`execStart`, which is read-only: the module sets it to `bin/komorebi` of the package with
`--log-level`, and `--config` with a `komorebi.json` when `configFile` or `config` is set. `config`
is typed from
`effects.borders.package` (by default `pkgs.kde-rounded-corners-komorebi`, from the overlay),
`effects.animation.enable` and `effects.animation.package`
(`pkgs.kwin-effect-geometry-change-komorebi`), and `execStart`, which is read-only: the module
sets it to `bin/komorebi` of the package with `--log-level`, and `--config` with a
`komorebi.json` when `configFile` or `config` is set. `config` is typed from
`nix/komorebi-options.nix`, the options `schemars-nixgen` makes from the schema of `komorebi.json`;
the module writes it as JSON, with no null in it, and `configFile` and the written file both go
through `check-jsonschema` against `schema.json` when the system is built (comment lines taken out
@@ -827,7 +839,8 @@ fetched from GitHub that become `app_specific_configuration_path`; the module ha
With `services.komorebi.enable`, the module:
- installs the package in the system profile, and the effect that draws the borders unless
`effects.borders.enable` is off;
`effects.borders.enable` is off and the one that animates windows unless
`effects.animation.enable` is off;
- defines the user unit `komorebi.service`, which every user of the machine has. Plasma's
`plasma-workspace.target` wants it, so a Plasma session starts it at login, and it is ordered
after `plasma-core.target`, which Plasma orders after KWin's service, `plasma-kwin_wayland`;
@@ -852,6 +865,7 @@ module's unit.
| `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 |
| The border effect is installed with komorebi, and only by the module | the module installs `effects.borders.package` in the system profile when `effects.borders.enable` is set | `nixos-module-eval` ("the border effect is installed in the system profile", "with the border effect off, komorebi is installed and the effect is not"), `vm-look` | `effects.borders.enable = false` |
| The border effect the module installs is built for the KWin of the system and is not loaded until komorebi asks | the package: `kde-rounded-corners-komorebi` links the `libkwin` of the nixpkgs' KWin and says `EnabledByDefault` false in its metadata | the `kde-rounded-corners-komorebi-install` check | `effects.borders.package` |
| The animation effect is installed with komorebi, and not loaded until komorebi asks | the module installs `effects.animation.package` when `effects.animation.enable` is set, and the package's metadata says `EnabledByDefault` false | `nixos-module-eval` ("the animation effect is installed in the system profile", "with the animation effect off, ..."), the `kwin-effect-geometry-change-komorebi-install` check, `vm-look` | `effects.animation.enable = false` |
| 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 |
| A daemon that is told to stop stays stopped, and the unit is not failed | systemd: the exit statuses of `Stop` (0) and of `SIGTERM` (130) are successes | `vm-module` | none |
@@ -899,6 +913,7 @@ module's unit.
how it is loaded, reloaded and generated.
- [`border_manager`](../../komorebi/src/border_manager/mod.rs): the border settings, and the
[`Look`] they make, which it asks the backend for.
- [`animation`](../../komorebi/src/animation/mod.rs): the animation settings, which the look has.
- [`kwin::effects`](../../komorebi/src/kwin/effects.rs): the KWin effect that draws the border,
its settings and the state komorebi keeps of it.
- [`process_command`](../../komorebi/src/process_command.rs): the thread that listens on the
@@ -1044,6 +1059,9 @@ the fake. The window manager is its only caller, through [`backend`]. The contra
| No outline is drawn inside a window, and a border is never thicker than the effect can draw | framework path: [`kwin::effects`](../../komorebi/src/kwin/effects.rs) sets every inner outline to 0 and clamps the width to 20 | `the_border_is_the_outer_outline_and_nothing_is_drawn_inside_the_window`, `a_border_thicker_than_the_effect_can_draw_is_the_thickest_it_can`, `vm-look` | none |
| Every window has the border color of what it is to the layout, and a window whose kind changes has the new one at once | framework path: [`border_manager::update_colours`] is called after every event and every message, from [`border_manager::window_kinds`], and the backend sends the colors it did not send last time | `the_focused_window_has_the_focus_colour_and_the_others_do_not`, `a_locked_container_that_is_not_focused_is_marked`, `a_stack_has_its_own_colour_when_it_has_the_focus`, `a_monocled_window_has_the_monocle_colour`, `a_floating_window_has_the_floating_colour_while_it_has_the_focus`, `border_colours_are_a_command_only_when_they_change`, `vm-features` (section C) | the stock effect: two colors for every window |
| With borders off no window has a color | framework path: [`border_manager::update_colours`] tells the backend an empty list when `BORDER_ENABLED` is false | `with_borders_off_no_window_has_a_colour` | none |
| The settings of one kind of animation win over the global ones, and a global setting clears them | framework path: the arms of [`WindowManager::process_command`] for `Animation` and `AnimationDuration`, and [`animation::movement_animation`], which reads the kind's setting before the global one | `the_animation_messages_set_the_animation_and_the_compositor_is_asked_for_it` | none |
| A command that changes a stack is carried out with the animation off, and the animation is on again after it | framework path: the arms of [`WindowManager::process_command`] for the stack messages swap `ANIMATION_ENABLED_GLOBAL` for false and put the value back | `the_animation_is_on_again_after_a_command_that_changes_a_stack` | none |
| The `animation` key of the file is the animation settings, and a file without it leaves them | framework path: `StaticConfig::apply_globals` sets them only when the key is there, and `duration` only when the key has one | `the_animation_key_of_the_file_is_the_animation_settings` | none |
| The effect komorebi loaded is unloaded, and the user's settings of it are put back, when komorebi stops using it or exits | framework path: the effect's state unloads what komorebi loaded, and [`Kwinrc`] puts the group back | `one_group_can_be_put_back_while_the_others_stay_changed`, `vm-look` | `SIGKILL`: the next run puts the settings back when it stops |
| Queries never block on the compositor | convention only | none | the KWin backend's `cursor_pos` waits up to 250 ms |
| Only the backend module reaches the compositor | convention only | none | none |
@@ -1166,13 +1184,18 @@ A window is shown, and ends up on a tile:
- [`nix/kde-rounded-corners.nix`](../../nix/kde-rounded-corners.nix): the build of the KWin
effect that draws an outline around each window, with
[`komorebi-border-colours.patch`](../../nix/kde-rounded-corners/komorebi-border-colours.patch),
which lets komorebi give each window a color; and
which lets komorebi give each window a color;
[`nix/kwin-effect-geometry-change.nix`](../../nix/kwin-effect-geometry-change.nix), the
effect that animates a window going to its place; and
[`nix/tests/effects.nix`](../../nix/tests/effects.nix), the checks of the files each effect
package installs.
- [`komorebi/tests/borders.rs`](../../komorebi/tests/borders.rs) and
[`komorebi/tests/border_commands.rs`](../../komorebi/tests/border_commands.rs): the room a drawn
border takes, and the messages that set the border, against the fake;
[`komorebi/tests/border_colours.rs`](../../komorebi/tests/border_colours.rs) and
[`komorebi/tests/animation.rs`](../../komorebi/tests/animation.rs), the messages that set the
animation, [`komorebi/tests/animation_config.rs`](../../komorebi/tests/animation_config.rs), its
key of the file, and [`komorebi/tests/animation_stack.rs`](../../komorebi/tests/animation_stack.rs),
the stack commands that turn it off; [`komorebi/tests/border_colours.rs`](../../komorebi/tests/border_colours.rs) and
[`komorebi/tests/borders_off.rs`](../../komorebi/tests/borders_off.rs), the color of each
window's border, and none with borders off;
[`nix/tests/vm/suites/look`](../../nix/tests/vm/suites/look/test.py), the border in a real
@@ -1262,6 +1285,9 @@ A window is shown, and ends up on a tile:
[`border_manager::current_look`]: ../../komorebi/src/border_manager/mod.rs
[`border_manager::send_notification`]: ../../komorebi/src/border_manager/mod.rs
[`BORDER_DRAWN`]: ../../komorebi/src/border_manager/mod.rs
[`animation`]: ../../komorebi/src/animation/mod.rs
[`animation::movement_animation`]: ../../komorebi/src/animation/mod.rs
[`AnimationPrefix`]: ../../komorebi/src/animation/prefix.rs
[`Backend::set_border_colours`]: ../../komorebi/src/backend/mod.rs
[`border_manager::window_kinds`]: ../../komorebi/src/border_manager/mod.rs
[`border_manager::update_colours`]: ../../komorebi/src/border_manager/mod.rs
+18 -1
View File
@@ -390,7 +390,8 @@ then, and KDE Rounded Corners at its defaults draws a one pixel black outline ov
bar of every window. Built with `EnabledByDefault` false, an effect is loaded only when
something asks for it with `loadEffect`, which can come after its settings are written. That
KWin then starts without the effect and loads it when asked was measured before the package
was written ([PLATFORM.md](PLATFORM.md#kwin-effects)).
was written ([PLATFORM.md](PLATFORM.md#kwin-effects)). Geometry Change ships disabled by
default, and its check asserts it, so that an update of the effect cannot change it unseen.
## Why does the compositor draw the borders, and not komorebi?
@@ -434,6 +435,22 @@ active window" and "the others". komorebi's build of KDE Rounded Corners takes a
window over D-Bus, through KWin's name ([PLATFORM.md](PLATFORM.md#the-patches)). Without that
build every kind falls back to the two colors of the look, and komorebi says so once in its log.
## Why does komorebi animate nothing itself?
Because the compositor draws the windows: an animation komorebi made would be a series of frames
asked of KWin, each a command, where the Geometry Change effect animates what is painted, in the
compositor, at the refresh rate of the screen. komorebi tells the effect how long an animation
lasts ([`border_manager::current_look`](../../komorebi/src/border_manager/mod.rs)). That is why
`animation-fps` is accepted and does nothing, and why the frame KWin reports for a window is the
final one from the start of the animation: the effect moves what is painted and not the window
([PLATFORM.md](PLATFORM.md#kwin-effects)).
## Why is cross-fading off?
Because cross-fading the old contents of a window into the new while it changes size is the
effect's default, and it costs a redraw of both. A window going to its place is a move and a
resize, and what the window shows does not change.
## Why are the effects patched?
Because the stock effects lack what komorebi needs of them. Each patch leaves the effect
+52 -10
View File
@@ -141,7 +141,8 @@ sends another window there.
When borders are on, it also asks KWin to load KDE Rounded Corners, the effect that draws them,
after writing the effect's settings into `kwinrc`, and asks it to read them again
([KWin effects](#kwin-effects)). An effect KWin did not find is reported once in the log.
([KWin effects](#kwin-effects)). It does the same with Geometry Change, the effect that animates
windows, when animation is on. An effect KWin did not find is reported once in the log.
Every command of the window manager (move and resize, focus, raise, hide or restore, minimize,
bring back, maximize, unmaximize or close a window, show a workspace on an output, put a window
@@ -169,13 +170,13 @@ an owner again; the VM test `vm-kwin-restart` restarts KWin twice under a runnin
When it is stopped with `SIGINT`, `SIGTERM` or a `Stop` message on its socket, it brings back
the windows it hid, waits until the commands that do so have reached the bridge, removes the
parking desktop, unloads the border effect, if komorebi loaded it, puts back the values the keys it
set in `kwinrc` had (`PerOutputVirtualDesktops`, and the keys of the border effect), or removes a
key the user had not set, and asks KWin to reload its configuration, asks KWin to unload the
script, closes an empty connection to each subscriber, and removes the socket. The desktops it
created for workspaces stay: they are the user's desktops from then on. A `StopIgnoreRestore`
message stops it the same way, except that it does not bring the windows back: the parking desktop
is removed all the same. The file `bridge.js` stays in the runtime
parking desktop, unloads the effects it loaded, puts back the values the keys it set in `kwinrc`
had (`PerOutputVirtualDesktops`, and the keys of the effects), or removes a key the user had not
set, and asks KWin to reload its configuration, asks KWin to unload the script, closes an empty
connection to each subscriber, and removes the socket. The desktops it created for workspaces
stay: they are the user's desktops from then on. A `StopIgnoreRestore` message stops it the same
way, except that it does not bring the windows back: the parking desktop is removed all the same.
The file `bridge.js` stays in the runtime
directory, which is removed at logout. A daemon that is killed leaves the script running in
KWin, reporting to nobody, the socket file in the runtime directory, per-output desktops
on, and the parking desktop with the hidden windows on it, until the next start replaces the
@@ -226,7 +227,7 @@ What komorebi calls:
| `org.kde.KWin` | `/Scripting/Script<id>` | `org.kde.kwin.Script` | `run()` | after `loadScript` |
| `org.freedesktop.DBus` | `/org/freedesktop/DBus` | `org.freedesktop.DBus` | `AddMatch(s)`, for the signal `NameOwnerChanged` | at start, to see KWin leave the bus and come back |
| `org.kde.kglobalaccel` | `/component/kwin` | `org.kde.kglobalaccel.Component` | `invokeShortcut(s)`, with `MoveMouseToFocus` | when the pointer follows the focus |
| `org.kde.KWin` | `/Effects` | `org.kde.kwin.Effects` | `isEffectSupported(s)`, `isEffectLoaded(s)`, `loadEffect(s)`, `unloadEffect(s)`, `reconfigureEffect(s)`, with `kwin4_effect_shapecorners` | when the look changes (the border is turned on, off or changed), and at exit |
| `org.kde.KWin` | `/Effects` | `org.kde.kwin.Effects` | `isEffectSupported(s)`, `isEffectLoaded(s)`, `loadEffect(s)`, `unloadEffect(s)`, `reconfigureEffect(s)`, with `kwin4_effect_shapecorners` and `kwin4_effect_geometry_change` | when the look changes (the border is turned on, off or changed), and at exit |
| `org.kde.KWin` | `/org/komorebi/BorderColours` | `org.komorebi.BorderColours1` | `SetColours(asau)`: the UUID of each window and its color, `0xRRGGBB` | when the color of a window's border changes; the object is komorebi's build of the border effect ([The patches](#the-patches)) |
| `org.kde.KWin` | `/KWin` | `org.kde.KWin` | `reconfigure()` | after komorebi changed `kwinrc`, at start and at exit |
| `org.kde.KWin` | `/VirtualDesktopManager` | `org.kde.KWin.VirtualDesktopManager` | the properties `desktops` and `count`, `createDesktop(us)`, `setDesktopName(ss)`, `removeDesktop(s)` | when a workspace has no desktop, and at start; `createDesktop` also for the parking desktop, the first time a window is hidden, and `removeDesktop` for it when komorebi stops and for one a killed run left |
@@ -243,6 +244,7 @@ since a read right after `createDesktop` has to see the new desktop.
| `$XDG_CONFIG_HOME/autostart/komorebi.desktop` (`~/.config/autostart/komorebi.desktop`) | the XDG autostart entry `komorebic enable-autostart` writes: `Exec=komorebi`, or `komorebi --config "FILE"`, and `X-KDE-autostart-after=plasma-workspace`, which a Plasma session starts komorebi from at login | the user's; `komorebic disable-autostart` removes it |
| `$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_CONFIG_HOME/kwinrc`, group `[Round-Corners]` | the settings of the border effect, written when borders are on ([KWin effects](#kwin-effects)) | put back, with the rest of `kwinrc`, when borders are turned off and when the daemon stops |
| `$XDG_CONFIG_HOME/kwinrc`, group `[Effect-kwin4_effect_geometry_change]` | the settings of the animation effect, written when animation is on | put back as above, when animation is turned off and 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 |
| `$XDG_RUNTIME_DIR/komorebi/komorebi.sock` | the command socket | bound once the daemon is connected to KWin, after a file left there is removed; removed when the daemon stops |
@@ -293,6 +295,14 @@ The logs are written to `$XDG_DATA_HOME/komorebi` (`~/.local/share/komorebi` if
write to stops it at once. When `XDG_RUNTIME_DIR` is not set, the bridge and the socket go
there too.
### `KWIN_EFFECTS_FORCE_ANIMATIONS`
KWin's own variable, read by KWin and not by komorebi. With software rendering, which is all a
virtual machine has, KWin loads no effect that animates, Geometry Change included, unless it is
`1` in KWin's environment: at time of writing (2026-10-27) a guest loaded 11 effects without it and
29 with. The VM nodes set it ([Rendering](#rendering-in-virtual-machines-and-over-rdp)); a machine
with a GPU needs nothing.
### `RUST_LOG`
Which log lines the daemon prints, in the syntax of `tracing-subscriber`'s `EnvFilter`
@@ -408,6 +418,7 @@ patches (see [The patches](#the-patches)):
| Package | Effect | Plugin id | Installed as |
|---|---|---|---|
| `kde-rounded-corners-komorebi` | [KDE Rounded Corners](https://github.com/matinlotfali/KDE-Rounded-Corners) 0.11.0, which draws an outline around each window | `kwin4_effect_shapecorners` | a C++ plugin, `lib/qt-6/plugins/kwin/effects/plugins/kwin4_effect_shapecorners.so` |
| `kwin-effect-geometry-change-komorebi` | [Geometry Change](https://github.com/peterfajdiga/kwin4_effect_geometry_change) 1.5 (revision `398491e`), which animates a window that a program or a script moves or resizes | `kwin4_effect_geometry_change` | a scripted effect, `share/kwin/effects/kwin4_effect_geometry_change/` |
Each package is in the flake's `packages` for Linux and in `overlays.default`, which builds it
with the `callPackage` of the nixpkgs it is applied to, so that it follows that nixpkgs' KWin.
@@ -441,6 +452,20 @@ At time of writing (2026-10-27):
- **KDE Rounded Corners draws its outer outline in the window's shadow**: its shader stops
where the window's texture is transparent. A window without a shadow has no outer outline,
and the outline is at most 20 px thick.
- **Geometry Change ships disabled by default**: its `metadata.json` has
`"EnabledByDefault": false`, which the check asserts. It loads on `loadEffect`, and under
software rendering only with `KWIN_EFFECTS_FORCE_ANIMATIONS=1` in KWin's environment (see
[Rendering](#rendering-in-virtual-machines-and-over-rdp)): without it, a session in a
virtual machine loads 11 effects instead of 29.
- **Geometry Change animates what a program or a script asks for**: a move and a resize made
through KWin's scripting API are animated, and by its source an interactive move or resize
is not. It eases out exponentially (`QEasingCurve.OutExpo`), so the movement is nearly
over after a third of its duration. Its settings are in the
`[Effect-kwin4_effect_geometry_change]` group of `kwinrc` (`Duration`, `CrossFade`,
`ExcludedWindowClasses`), and it reads them again on `reconfigureEffect`: a `Duration` of
4000 written while it ran was the length of the next animation.
- **The animation moves what is painted, not the window**: the frame KWin reports for the
window (`frameGeometry`) is the final one from the start of the animation.
### What komorebi writes for the border
@@ -467,7 +492,7 @@ and unfocused colors, and not inside the frame.
Each patch is a derivative work of the effect it changes, and is under the same license, the
GNU General Public License version 3; its header states the license and describes the
change. The check of each package asserts that its patch is in the build.
change. The check of a patched package asserts that the patch is in the build.
[`komorebi-border-colours.patch`](../../nix/kde-rounded-corners/komorebi-border-colours.patch),
for KDE Rounded Corners, makes two changes:
@@ -489,6 +514,23 @@ for KDE Rounded Corners, makes two changes:
contents change or the window is resized, so a change of opacity alone would not show. The
patched effect redirects the window again when its opacity changes.
### What komorebi writes for the animation
Geometry Change reads its settings from the group `[Effect-kwin4_effect_geometry_change]` of
`kwinrc`:
| Key | Value |
|---|---|
| `Duration` | the animation's duration, in milliseconds |
| `CrossFade` | `false`: a window that changes size is not cross-faded |
komorebi then calls `reconfigureEffect`, and at time of writing (2026-10-27) the effect uses the
new `Duration` for the next move: a `Duration` of 4000 written while it ran was the length of the
next animation. An animation cannot be seen in a screenshot of a short one: the screenshot takes
seconds, and the effect eases out exponentially, nearly over after a third of its duration. A
screenshot of a session a few seconds into a 30 s animation shows a window that has not got to its
place, and the same move with animation off is there at once.
## Rendering in virtual machines and over RDP
At time of writing (2026-10-27):
+2 -1
View File
@@ -59,7 +59,8 @@ explains the files of rules for particular applications it can name.
[Quickstart and autostart](usage/quickstart-and-autostart.md) explains how to write an example
configuration, how to start komorebi with Plasma without the module, and how to replace the
configuration of a running daemon.
[Borders](usage/borders.md) explains how komorebi has KWin draw a border around each window.
[Borders](usage/borders.md) explains how komorebi has KWin draw a border around each window, and
[Animation](usage/animation.md) how it has KWin animate the windows going to their places.
[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.
+10 -6
View File
@@ -56,9 +56,10 @@ the repository's `rust-toolchain.toml` selects, whatever nixpkgs your system use
- It installs `komorebi` and `komorebic` in the system profile, so they are on every user's
`PATH`.
- It installs KDE Rounded Corners, the KWin effect that draws komorebi's borders, unless
`services.komorebi.effects.borders.enable` is `false`. KWin finds effects when it starts, so a
session that was running when you switched to the new configuration has the borders after the
next login.
`services.komorebi.effects.borders.enable` is `false`, and Geometry Change, the effect that
animates windows, unless `services.komorebi.effects.animation.enable` is `false`. KWin finds
effects when it starts, so a session that was running when you switched to the new
configuration has them after the next login.
- It defines a systemd user unit, `komorebi.service`, for every user of the machine. Plasma's
`plasma-workspace.target` starts it when a user logs in to a Plasma session, after
`plasma-core.target`, which Plasma orders after KWin. The unit runs the daemon with the `PATH`
@@ -81,6 +82,8 @@ the repository's `rust-toolchain.toml` selects, whatever nixpkgs your system use
| `services.komorebi.applicationSpecificConfiguration` | `enable = true`, `sources = [ ]` | Files of [application specific configuration](usage/application-specific-configuration.md) fetched from GitHub (`owner`, `repo`, `rev`, `path` and `hash` each), which become the `app_specific_configuration_path` of the configuration `config` makes. There are none by default. |
| `services.komorebi.effects.borders.enable` | `true` | Installs the KWin effect that draws komorebi's borders. Whether borders are drawn is komorebi's own setting ([Borders](usage/borders.md)). KWin finds effects when it starts: log in again after the first switch. The module warns when `config` sets `border` to `true` and this is off. |
| `services.komorebi.effects.borders.package` | `pkgs.kde-rounded-corners-komorebi` | The effect: KDE Rounded Corners 0.11.0, built against the KWin of the system and not loaded until komorebi asks. |
| `services.komorebi.effects.animation.enable` | `true` | Installs the KWin effect that animates komorebi's windows going to their places. Whether windows are animated is komorebi's own setting ([Animation](usage/animation.md)). KWin finds effects when it starts: log in again after the first switch. |
| `services.komorebi.effects.animation.package` | `pkgs.kwin-effect-geometry-change-komorebi` | The effect: Geometry Change, a scripted effect that is not loaded until komorebi asks. |
| `services.komorebi.execStart` | read only | The command line the unit starts komorebi with, built from `package`, `logLevel` and `configFile` or `config`. A unit of your own that runs komorebi uses it to start komorebi the same way. |
`config` takes the keys of `komorebi.json` ([Configuration](usage/configuration.md)) as Nix, and a
@@ -138,15 +141,16 @@ doing, and its log.
### The packages without the module
The flake's packages are `komorebi`, `komorebic`, and `komorebi-full`, which has both and is the
`default`, and `kde-rounded-corners-komorebi`, the effect that draws the borders. To install them without the unit, and start komorebi yourself:
`default`, `kde-rounded-corners-komorebi`, the effect that draws the borders, and
`kwin-effect-geometry-change-komorebi`, the effect that animates windows. To install them without the unit, and start komorebi yourself:
```sh
nix profile install github:LGUG2Z/komorebi-for-kde
```
On a NixOS configuration, the overlay, `overlays.default`, provides `pkgs.komorebi`,
`pkgs.komorebic`, `pkgs.komorebi-full` and `pkgs.kde-rounded-corners-komorebi` for
`environment.systemPackages`.
`pkgs.komorebic`, `pkgs.komorebi-full`, `pkgs.kde-rounded-corners-komorebi` and
`pkgs.kwin-effect-geometry-change-komorebi` for `environment.systemPackages`.
## Other distributions: from source
+74
View File
@@ -0,0 +1,74 @@
# Animation
komorebi can have a window slide to its new place when the layout changes, instead of jumping
there. It does not animate anything itself: a KWin effect, Geometry Change, animates a window
that a program or a script moves or resizes, and komorebi tells it how long the animation lasts.
Animation is off by default.
## Installing the effect
The effect is not part of KWin, and KWin finds effects when it starts: log out and in again after
installing it. On NixOS the flake's module installs it with komorebi, which is what
`services.komorebi.effects.animation.enable` does (it is on by default); the effect is built so
that KWin does not load it until komorebi asks.
[`installation.md`](../installation.md) has the module's options.
komorebi loads the effect when animation is turned on, and unloads it when it is turned off or
komorebi exits. A machine that does not have the effect has no animation: komorebi says so once
in its log, and windows jump to their places.
## Turning it on, and how long it lasts
[`komorebic animation`](../cli/animation.md) turns animation on or off, and
[`komorebic animation-duration`](../cli/animation-duration.md) sets how long it lasts, in
milliseconds: 250 by default.
```sh
komorebic animation enable
komorebic animation-duration 400
komorebic animation disable
```
Both take `--animation-type movement` to set the animation of windows going to their places apart
from the global setting, which is how the settings of one kind of animation win over the global
ones. Movement is the only kind there is. A global setting takes the settings of the kinds away.
```sh
komorebic animation enable --animation-type movement
komorebic animation-duration 600 --animation-type movement
```
[`komorebic animation-fps`](../cli/animation-fps.md) is accepted and does nothing: KWin animates
at the refresh rate of the screen.
## In komorebi.json
The `animation` key of [`komorebi.json`](configuration.md#animation) has the same settings:
`enabled` and `duration`, each either one value for every kind of animation or a value for each
kind (`{ "movement": true }`), and `fps`.
```json
{
"animation": {
"enabled": true,
"duration": 400
}
}
```
The file sets them when the daemon starts and when the file changes. A file without the key leaves
the settings as they are, and one with it that leaves out `duration` leaves the duration as it is.
## What is animated
What is painted moves; the window does not. The frame KWin reports for a window, and so the frame
komorebi reads back, is the final one from the start of the animation, so komorebi never waits for
an animation to end. The window is not cross-faded as it changes size: it is a move and a resize,
not a change of what the window shows. An interactive move or resize by the user is not animated.
While the effect is loaded, windows that other programs move are animated too.
## What is put back
The effect keeps its settings in the user's `kwinrc`, in the group
`[Effect-kwin4_effect_geometry_change]`. komorebi writes them when it asks for the animation, and
when it exits or animation is turned off it puts back what the user had there.
+16 -2
View File
@@ -38,8 +38,8 @@ 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.
These stay as they were when the file leaves them out: `default_workspace_padding`,
`default_container_padding`, `display_index_preferences` and the four settings of the borders.
The rules add up, as
`default_container_padding`, `display_index_preferences`, the four settings of the borders and the
animation, when the file has no `animation`. 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.
@@ -105,6 +105,20 @@ can have values of their own, which come before the default.
`komorebic border`, `border-width` and `border-offset` change the first three while the daemon
runs.
### Animation
`animation` is an object with these keys:
| Key | Default | What it does |
|---|---|---|
| `enabled` | `false`, required | Whether windows are animated going to their places: `true` or `false` for every kind of animation, or `{ "movement": true }` for the kinds it names |
| `duration` | `250` | How long the animation lasts, in milliseconds, in the same two forms |
| `fps` | `60` | Accepted and not used: KWin animates at the refresh rate of the screen |
[Animation](animation.md) explains what is animated. A file that has no `animation` leaves the
settings as they are, and one that has it and leaves out `duration` leaves the duration as it is;
`enabled` and `duration` given for every kind of animation take the settings of single kinds away.
### Rules
| Key | What it does |
+3
View File
@@ -257,6 +257,7 @@
module = self.nixosModules.default;
komorebiFor = guestSystem: self.packages.${guestSystem}.komorebi-full;
borderEffectFor = guestSystem: self.packages.${guestSystem}.kde-rounded-corners-komorebi;
animationEffectFor = guestSystem: self.packages.${guestSystem}.kwin-effect-geometry-change-komorebi;
};
}
# The VM tests need QEMU with KVM, so only Linux checks them. A Mac runs the same tests
@@ -295,6 +296,7 @@
komorebi-full = build.fullBuild;
default = build.fullBuild;
kde-rounded-corners-komorebi = pkgs.callPackage ./nix/kde-rounded-corners.nix { };
kwin-effect-geometry-change-komorebi = pkgs.callPackage ./nix/kwin-effect-geometry-change.nix { };
};
apps = lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
@@ -361,6 +363,7 @@
komorebi-full = build.fullBuild;
# with the consumer's KWin, so that the plugin links the libkwin it is loaded into
kde-rounded-corners-komorebi = final.callPackage ./nix/kde-rounded-corners.nix { };
kwin-effect-geometry-change-komorebi = final.callPackage ./nix/kwin-effect-geometry-change.nix { };
};
overlays.komorebi = self.overlays.default;
+1
View File
@@ -57,6 +57,7 @@ pub use komorebi::DATA_DIR;
pub use komorebi::LOG_DIR;
pub use komorebi::Notification;
pub use komorebi::NotificationEvent;
pub use komorebi::animation::AnimationPrefix;
pub use komorebi::container::Container;
pub use komorebi::core::ApplicationIdentifier;
pub use komorebi::core::Axis;
+89
View File
@@ -0,0 +1,89 @@
//! The animation settings (the `komorebic animation*` commands and the `animation` key of
//! `komorebi.json`).
//!
//! komorebi does not animate windows itself: KWin's Geometry Change effect animates a window going
//! to its place. [`movement_animation`] is what the effect is told, in the
//! [`Look`](crate::backend::Look) the border manager asks the backend for. The `fps` setting is
//! stored and has nothing to map to: the compositor animates at the refresh rate of the screen.
use parking_lot::Mutex;
pub use prefix::AnimationPrefix;
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::LazyLock;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicU64;
pub mod prefix;
use serde::Deserialize;
use serde::Serialize;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(untagged)]
/// Animation configuration
///
/// This can be either global:
/// ```json
/// {
/// "enabled": true,
/// "fps": 60,
/// "duration": 250
/// }
/// ```
///
/// Or scoped by an animation kind prefix:
/// ```json
/// {
/// "movement": {
/// "enabled": true,
/// "fps": 60,
/// "duration": 250
/// }
/// }
/// ```
pub enum PerAnimationPrefixConfig<T> {
/// Animation configuration prefixed for a specific animation kind
Prefix(HashMap<AnimationPrefix, T>),
/// Animation configuration for all animation kinds
Global(T),
}
pub const DEFAULT_ANIMATION_ENABLED: bool = false;
pub const DEFAULT_ANIMATION_DURATION: u64 = 250;
pub const DEFAULT_ANIMATION_FPS: u64 = 60;
pub static ANIMATION_ENABLED_GLOBAL: LazyLock<Arc<AtomicBool>> =
LazyLock::new(|| Arc::new(AtomicBool::new(DEFAULT_ANIMATION_ENABLED)));
pub static ANIMATION_DURATION_GLOBAL: LazyLock<Arc<AtomicU64>> =
LazyLock::new(|| Arc::new(AtomicU64::new(DEFAULT_ANIMATION_DURATION)));
pub static ANIMATION_ENABLED_PER_ANIMATION: LazyLock<Arc<Mutex<HashMap<AnimationPrefix, bool>>>> =
LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
pub static ANIMATION_DURATION_PER_ANIMATION: LazyLock<Arc<Mutex<HashMap<AnimationPrefix, u64>>>> =
LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
pub static ANIMATION_FPS: AtomicU64 = AtomicU64::new(DEFAULT_ANIMATION_FPS);
/// Returns how long window movement is animated for, in milliseconds, or `None` when it is not
/// animated.
///
/// The `movement` settings win over the global ones, for whether it is animated and for how long.
pub fn movement_animation() -> Option<u64> {
let enabled = ANIMATION_ENABLED_PER_ANIMATION
.lock()
.get(&AnimationPrefix::Movement)
.copied()
.unwrap_or_else(|| ANIMATION_ENABLED_GLOBAL.load(std::sync::atomic::Ordering::SeqCst));
enabled.then(|| {
ANIMATION_DURATION_PER_ANIMATION
.lock()
.get(&AnimationPrefix::Movement)
.copied()
.unwrap_or_else(|| ANIMATION_DURATION_GLOBAL.load(std::sync::atomic::Ordering::SeqCst))
})
}
+22
View File
@@ -0,0 +1,22 @@
//! The kinds of animation that settings can be given for, by prefix (`movement`).
use clap::ValueEnum;
use serde::Deserialize;
use serde::Serialize;
use strum::Display;
use strum::EnumString;
#[derive(
Copy, Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Display, EnumString, ValueEnum,
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum AnimationPrefix {
Movement,
}
pub fn new_animation_key(prefix: AnimationPrefix, key: String) -> String {
format!("{prefix}:{key}")
}
+1
View File
@@ -903,6 +903,7 @@ mod tests {
focused: (1, 2, 3),
unfocused: (4, 5, 6),
}),
animation: None,
};
assert!(fake.apply_look(&bordered)?);
+16 -2
View File
@@ -105,10 +105,12 @@ pub struct MonitorInfo {
/// # Example
///
/// ```rust
/// use komorebi::backend::AnimationLook;
/// use komorebi::backend::BorderLook;
/// use komorebi::backend::Look;
///
/// assert_eq!(Look::default().border, None);
/// assert_eq!(Look::default().animation, None);
///
/// let look = Look {
/// border: Some(BorderLook {
@@ -117,13 +119,23 @@ pub struct MonitorInfo {
/// focused: (66, 165, 245),
/// unfocused: (128, 128, 128),
/// }),
/// animation: Some(AnimationLook { duration_ms: 250 }),
/// };
/// assert!(look.border.is_some());
/// assert!(look.border.is_some() && look.animation.is_some());
/// ```
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Look {
/// A colored outline outside every window, or none.
pub border: Option<BorderLook>,
/// Animate windows going to their new places, or not.
pub animation: Option<AnimationLook>,
}
/// How windows are animated going to their places.
#[derive(Clone, Debug, PartialEq)]
pub struct AnimationLook {
/// How long the animation of a window takes, in milliseconds.
pub duration_ms: u64,
}
/// The outline around every window.
@@ -354,7 +366,8 @@ pub trait Backend: Send + Sync + 'static {
// ---- look, which a backend that draws nothing need not say anything about --------------------
/// Asks the compositor to draw this look, and returns true if and only if window borders are
/// being drawn afterwards.
/// being drawn afterwards. An animation is asked for the same way, and whether it is drawn is
/// not answered.
///
/// A drawn border takes room around each window, which the layout has to leave, so the answer
/// is what the window manager reads to know that. A backend remembers the look it applied last
@@ -382,6 +395,7 @@ pub trait Backend: Send + Sync + 'static {
/// focused: (66, 165, 245),
/// unfocused: (128, 128, 128),
/// }),
/// animation: None,
/// };
///
/// assert!(fake.apply_look(&look)?);
+31 -9
View File
@@ -6,8 +6,9 @@
//!
//! - [`send_notification`] asks the backend for the [`Look`] of the settings in force
//! ([`current_look`]): the border's width, radius and two colors, one for the focused window and
//! one for the others. The backend answers whether the borders are drawn, which is kept in
//! [`BORDER_DRAWN`]: a drawn border takes room around each window, which the layout leaves.
//! one for the others, and the animation of windows going to their places. The backend answers
//! whether the borders are drawn, which is kept in [`BORDER_DRAWN`]: a drawn border takes room
//! around each window, which the layout leaves.
//! - [`update_colours`] tells the backend the color of each window's border, by what the window
//! is to the layout ([`window_kinds`]). Only komorebi's build of the effect takes them; the
//! stock one draws the look's two colors, one for the active window and one for the others.
@@ -16,6 +17,7 @@
//! the `border*` keys of `komorebi.json` ([`crate::static_config::StaticConfig`]) give their
//! first values.
use crate::backend::AnimationLook;
use crate::backend::BorderLook;
use crate::backend::Look;
use crate::backend::backend;
@@ -227,7 +229,8 @@ pub static BORDER_DRAWN: AtomicBool = AtomicBool::new(false);
/// Returns the [`Look`] of these settings.
///
/// The border is there when `enabled`, with its width and radius at least 0; the colors are as the
/// statics store them, red, green and blue in one number.
/// statics store them, red, green and blue in one number. The animation is a duration in
/// milliseconds, when there is one.
///
/// ```rust
/// use komorebi::border_manager::look;
@@ -236,15 +239,23 @@ pub static BORDER_DRAWN: AtomicBool = AtomicBool::new(false);
/// let blue = pack(66, 165, 245);
/// let grey = pack(128, 128, 128);
///
/// let on = look(true, 8, -2, blue, grey);
/// let on = look(true, 8, -2, blue, grey, Some(250));
/// let border = on.border.expect("the borders are on");
/// assert_eq!((border.width, border.radius), (8, 0));
/// assert_eq!(border.focused, (66, 165, 245));
/// assert_eq!(border.unfocused, (128, 128, 128));
/// assert_eq!(on.animation.expect("an animation").duration_ms, 250);
///
/// assert_eq!(look(false, 8, 10, blue, grey).border, None);
/// assert_eq!(look(false, 8, 10, blue, grey, None).border, None);
/// ```
pub fn look(enabled: bool, width: i32, radius: i32, focused: u32, unfocused: u32) -> Look {
pub fn look(
enabled: bool,
width: i32,
radius: i32,
focused: u32,
unfocused: u32,
animation: Option<u64>,
) -> Look {
Look {
border: enabled.then(|| BorderLook {
width: width.max(0),
@@ -252,10 +263,12 @@ pub fn look(enabled: bool, width: i32, radius: i32, focused: u32, unfocused: u32
focused: unpack(focused),
unfocused: unpack(unfocused),
}),
animation: animation.map(|duration_ms| AnimationLook { duration_ms }),
}
}
/// Returns the [`Look`] of the settings in force: the border statics of this module.
/// Returns the [`Look`] of the settings in force: the border statics of this module, and the
/// movement animation of [`crate::animation`].
pub fn current_look() -> Look {
look(
BORDER_ENABLED.load(Ordering::SeqCst),
@@ -263,6 +276,7 @@ pub fn current_look() -> Look {
BORDER_RADIUS.load(Ordering::SeqCst),
FOCUSED.load(Ordering::SeqCst),
UNFOCUSED.load(Ordering::SeqCst),
crate::animation::movement_animation(),
)
}
@@ -302,12 +316,20 @@ mod tests {
let blue = pack(66, 165, 245);
let grey = pack(128, 128, 128);
let look = look(true, 10, 12, blue, grey);
let look = look(true, 10, 12, blue, grey, None);
let border = look.border.unwrap();
assert_eq!(border.focused, (66, 165, 245));
assert_eq!(border.unfocused, (128, 128, 128));
assert_eq!((border.width, border.radius), (10, 12));
assert_eq!(look.animation, None);
}
#[test]
fn borders_off_and_animation_on_are_independent() {
let look = look(false, 10, 12, 0, 0, Some(250));
assert_eq!(look.border, None);
assert_eq!(look.animation, Some(AnimationLook { duration_ms: 250 }));
}
#[test]
@@ -334,7 +356,7 @@ mod tests {
#[test]
fn a_negative_width_or_radius_is_none() {
let look = look(true, -4, -1, 0, 0);
let look = look(true, -4, -1, 0, 0, None);
let border = look.border.unwrap();
assert_eq!((border.width, border.radius), (0, 0));
}
+4
View File
@@ -12,6 +12,7 @@
//! [`OperationDirection`] is a side of the focused tile, and a [`CycleDirection`] the next or the
//! previous container in the order of the workspace.
use crate::animation::AnimationPrefix;
use crate::core::pathext::ResolvedPathBuf;
use clap::ValueEnum;
use color_eyre::eyre;
@@ -470,6 +471,9 @@ pub enum SocketMessage {
// WatchConfiguration(bool),
// CompleteConfiguration,
// AltFocusHack(bool),
Animation(bool, Option<AnimationPrefix>),
AnimationDuration(u64, Option<AnimationPrefix>),
AnimationFps(u64),
#[serde(alias = "ActiveWindowBorder")]
Border(bool),
#[serde(alias = "ActiveWindowBorderColour")]
+75 -23
View File
@@ -1,20 +1,25 @@
//! The KWin effect that draws komorebi's borders.
//! The two KWin effects that draw komorebi's borders and animate its windows.
//!
//! komorebi draws no border itself. A compositor effect does, and this module configures it:
//! **KDE Rounded Corners** ([`ROUNDED_CORNERS`]) draws the border, its outer outline, outside the
//! window, in the gap komorebi leaves between tiles. [`border_settings`] has the settings.
//! komorebi draws no border and animates nothing itself. Two compositor effects do, and this
//! module configures them:
//!
//! [`EffectsState::apply`] writes the effect's settings into `kwinrc` through [`Kwinrc`], loads the
//! - **KDE Rounded Corners** ([`ROUNDED_CORNERS`]) draws the border: its outer outline, outside the
//! window, in the gap komorebi leaves between tiles. [`border_settings`] has the settings.
//! - **Geometry Change** ([`GEOMETRY_CHANGE`]) animates a window going to its place.
//! [`animation_settings`] has the settings.
//!
//! [`EffectsState::apply`] writes an effect's settings into `kwinrc` through [`Kwinrc`], loads the
//! effect if it is not loaded, and tells it to read its settings again. It always does the last
//! step: KWin keeps the copy of `kwinrc` it read when it started, and an effect reads its settings
//! from that copy until it is told to reconfigure, even one loaded a moment ago.
//!
//! The effect does not come with KWin, and KWin discovers effects only when it starts: an effect
//! Neither effect comes with KWin, and KWin discovers effects only when it starts: an effect
//! installed later cannot be loaded until the next login. An effect that is not installed is
//! reported once in the log, and komorebi carries on without it.
//!
//! komorebi's build of the effect (`nix/kde-rounded-corners.nix`) adds what the stock one lacks: a
//! border color for each window, set over D-Bus with [`EffectsState::set_window_colours`].
//! komorebi's build of the border effect (`nix/kde-rounded-corners.nix`) adds what the stock one
//! lacks: a border color for each window, set over D-Bus with
//! [`EffectsState::set_window_colours`].
//!
//! # What is guaranteed, and by what
//!
@@ -33,6 +38,7 @@
#![deny(missing_docs)]
use super::kwinrc::Kwinrc;
use crate::backend::AnimationLook;
use crate::backend::BorderLook;
use crate::backend::Look;
use color_eyre::eyre;
@@ -41,9 +47,13 @@ use zbus::proxy::Proxy;
/// The plugin id of KDE Rounded Corners, the effect that draws the border.
pub const ROUNDED_CORNERS: &str = "kwin4_effect_shapecorners";
/// The plugin id of Geometry Change, the effect that animates windows.
pub const GEOMETRY_CHANGE: &str = "kwin4_effect_geometry_change";
/// The `kwinrc` group KDE Rounded Corners reads, as its `options.kcfg` names it.
const ROUNDED_CORNERS_GROUP: &str = "Round-Corners";
/// The `kwinrc` group Geometry Change reads.
const GEOMETRY_CHANGE_GROUP: &str = "Effect-kwin4_effect_geometry_change";
/// The D-Bus object path at which komorebi's build of the border effect takes a color for each
/// window, on KWin's bus name.
@@ -58,8 +68,8 @@ const COLOURS_INTERFACE: &str = "org.komorebi.BorderColours1";
/// screenshots of a KWin 6.8.1 session, at time of writing (2026-10-27).
const MAX_OUTLINE: i32 = 20;
/// The state komorebi keeps of the effect: the look it last applied, and what it has to undo when
/// it exits.
/// The state komorebi keeps of the two effects: the look it last applied, and what it has to undo
/// when it exits.
///
/// The KWin backend keeps one for the life of the connection to KWin. The default is the state of
/// a komorebi that has told the effects nothing.
@@ -121,6 +131,20 @@ pub fn border_settings(border: &BorderLook) -> Vec<(&'static str, String)> {
]
}
/// Returns the settings of Geometry Change, as `kwinrc` keys and values, for this animation.
///
/// Cross-fading is turned off. Cross-fading the old contents into the new while a window resizes is
/// the effect's default and costs a redraw of both; a window going to its place is a move and a
/// resize, not a change of what it shows.
///
/// Covered by `kwin::effects::tests::animation_is_a_duration_without_cross_fading`.
pub fn animation_settings(animation: &AnimationLook) -> Vec<(&'static str, String)> {
vec![
("Duration", animation.duration_ms.to_string()),
("CrossFade", "false".to_string()),
]
}
/// Returns a proxy for KWin's `/Effects` object, which loads, unloads and reconfigures effects.
async fn effects(connection: &Connection) -> eyre::Result<Proxy<'static>> {
Ok(Proxy::new(
@@ -150,17 +174,17 @@ async fn loaded(proxy: &Proxy<'_>, name: &str) -> bool {
}
impl EffectsState {
/// Brings the effect in line with `look`, and returns true if and only if borders are being
/// Brings the effects in line with `look`, and returns true if and only if borders are being
/// drawn afterwards.
///
/// A look with no border stops the use of the effect (see [`EffectsState::disable`]); one with a
/// border writes the effect's settings and has it running (see [`EffectsState::enable`]). The
/// same look as the last one does nothing.
/// A part of the look that is `None` stops the use of its effect (see
/// [`EffectsState::disable`]); a part that is set writes the effect's settings and has it
/// running (see [`EffectsState::enable`]). The same look as the last one does nothing.
///
/// # Errors
///
/// Returns an error if and only if there is no proxy for KWin's `/Effects` object. Everything
/// that goes wrong with the effect (not installed, settings not written, not loaded) is logged,
/// that goes wrong with one effect (not installed, settings not written, not loaded) is logged,
/// and the function still returns whether borders are drawn.
pub async fn apply(
&mut self,
@@ -192,6 +216,23 @@ impl EffectsState {
}
};
match &look.animation {
Some(animation) => {
self.enable(
&proxy,
kwinrc,
GEOMETRY_CHANGE,
GEOMETRY_CHANGE_GROUP,
&animation_settings(animation),
)
.await;
}
None => {
self.disable(&proxy, kwinrc, GEOMETRY_CHANGE, GEOMETRY_CHANGE_GROUP)
.await;
}
}
self.last = Some(look.clone());
Ok(self.drawn)
}
@@ -321,8 +362,8 @@ impl EffectsState {
}
}
/// Undoes what komorebi did to the effect, when it exits: unloads it if komorebi loaded it, and
/// puts back the user's settings.
/// Undoes what komorebi did to the effects, when it exits: unloads the effects it loaded, and
/// puts back the user's settings of both.
///
/// An effect the user had loaded keeps running, with the settings it had. Nothing is done when
/// there is no proxy for KWin's `/Effects` object.
@@ -336,12 +377,13 @@ impl EffectsState {
}
// an effect the user had running keeps running, with the settings it had
if kwinrc.restore_group(ROUNDED_CORNERS_GROUP).unwrap_or(false)
&& loaded(&proxy, ROUNDED_CORNERS).await
{
let _ = proxy
.call_method("reconfigureEffect", &(ROUNDED_CORNERS,))
.await;
for (effect, group) in [
(ROUNDED_CORNERS, ROUNDED_CORNERS_GROUP),
(GEOMETRY_CHANGE, GEOMETRY_CHANGE_GROUP),
] {
if kwinrc.restore_group(group).unwrap_or(false) && loaded(&proxy, effect).await {
let _ = proxy.call_method("reconfigureEffect", &(effect,)).await;
}
}
}
}
@@ -401,4 +443,14 @@ mod tests {
});
assert_eq!(s["OuterOutlineThickness"], "0");
}
#[test]
fn animation_is_a_duration_without_cross_fading() {
let s: std::collections::HashMap<_, _> =
animation_settings(&AnimationLook { duration_ms: 250 })
.into_iter()
.collect();
assert_eq!(s["Duration"], "250");
assert_eq!(s["CrossFade"], "false");
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
//! KWin's configuration file, `kwinrc`, for the few settings komorebi changes: per-output virtual
//! desktops and the settings of the border effect.
//! desktops and the settings of the border and animation effects.
//!
//! These are the user's settings, changed on their behalf, so [`Kwinrc::set`] records the value of
//! every key the first time komorebi changes it, in a backup file, and [`Kwinrc::restore`] puts the
+2 -1
View File
@@ -13,7 +13,7 @@
//!
//! On KDE Plasma the backend is [`kwin::KWinBackend`], which talks to a script it loads into KWin.
//! The compositor also draws what the windows look like: [`border_manager`] asks the backend for
//! the borders.
//! the borders, and [`animation`] holds how windows are animated going to their places.
//!
//! The daemon also listens on a socket, `komorebi.sock` in [`struct@DATA_DIR`], for the messages
//! in [`core::SocketMessage`]: [`process_command`] reads them and answers, with the window
@@ -55,6 +55,7 @@ use std::sync::atomic::AtomicI32;
#[macro_use]
pub mod ring;
pub mod animation;
pub mod backend;
pub mod border_manager;
pub mod container;
+2 -2
View File
@@ -228,8 +228,8 @@ fn main() -> eyre::Result<()> {
// them): the compositor needs a desktop for each
wm.lock().sync_workspace_desktops();
// how windows are to look (borders) is handed to the compositor before the first layout, which
// leaves room for a border that is being drawn
// how windows are to look (borders, animation) is handed to the compositor before the first
// layout, which leaves room for a border that is being drawn
border_manager::send_notification();
wm.lock().retile_all(false)?;
+49
View File
@@ -182,6 +182,11 @@
//! handled. **BorderColour** sets the color of the border of one kind of window
//! ([`WindowKind`]), and every message, once handled, tells the backend the color of each
//! window's border ([`border_manager::update_colours`]).
//! - **Animation** sets whether windows are animated going to their places, **AnimationDuration**
//! for how long, and **AnimationFps** the frame rate that is stored and has nothing to map to
//! (the compositor animates at the refresh rate of the screen); each is for every kind of
//! animation or, given an [`AnimationPrefix`](crate::animation::AnimationPrefix), for one. The
//! look asked of the backend after the message has the animation.
//! - **Retile** tiles the focused workspace of every monitor again, without the resize
//! adjustments, and **RetileWithResizeDimensions** with them.
//! - **AddSubscriberSocket** and **AddSubscriberSocketWithOptions** add a subscriber by the name
@@ -203,6 +208,11 @@ use crate::SESSION_FLOATING_APPLICATIONS;
use crate::SUBSCRIPTION_SOCKET_OPTIONS;
use crate::SUBSCRIPTION_SOCKETS;
use crate::WORKSPACE_MATCHING_RULES;
use crate::animation::ANIMATION_DURATION_GLOBAL;
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
use crate::animation::ANIMATION_ENABLED_GLOBAL;
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
use crate::animation::ANIMATION_FPS;
use crate::backend::backend;
use crate::border_manager;
use crate::core::ApplicationIdentifier;
@@ -564,24 +574,36 @@ impl WindowManager {
self.move_container_in_cycle_direction(direction)?;
}
SocketMessage::StackWindow(direction) => {
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
self.add_window_to_container(direction)?;
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
}
SocketMessage::UnstackWindow => {
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
self.remove_window_from_container()?;
border_manager::destroy_all_borders()?;
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
}
SocketMessage::StackAll => {
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
self.stack_all()?;
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
}
SocketMessage::UnstackAll => {
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
self.unstack_all(true)?;
border_manager::destroy_all_borders()?;
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
}
SocketMessage::CycleStack(direction) => {
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
self.cycle_container_window_in_direction(direction)?;
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
}
SocketMessage::CycleStackIndex(direction) => {
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
self.cycle_container_window_index_in_direction(direction)?;
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
}
SocketMessage::FocusStackWindow(idx) => {
// In case you are using this command on a bar on a monitor
@@ -591,7 +613,9 @@ impl WindowManager {
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
self.focus_monitor(monitor_idx)?;
}
let restore = ANIMATION_ENABLED_GLOBAL.swap(false, Ordering::SeqCst);
self.focus_container_window(idx)?;
ANIMATION_ENABLED_GLOBAL.store(restore, Ordering::SeqCst);
}
SocketMessage::CycleFocusMonitor(direction) => {
let monitor_idx = direction.next_idx(
@@ -1974,6 +1998,31 @@ impl WindowManager {
border_manager::BORDER_OFFSET.store(offset, Ordering::SeqCst);
border_manager::destroy_all_borders()?;
}
SocketMessage::Animation(enable, prefix) => match prefix {
Some(prefix) => {
ANIMATION_ENABLED_PER_ANIMATION
.lock()
.insert(prefix, enable);
}
None => {
ANIMATION_ENABLED_GLOBAL.store(enable, Ordering::SeqCst);
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
}
},
SocketMessage::AnimationDuration(duration, prefix) => match prefix {
Some(prefix) => {
ANIMATION_DURATION_PER_ANIMATION
.lock()
.insert(prefix, duration);
}
None => {
ANIMATION_DURATION_GLOBAL.store(duration, Ordering::SeqCst);
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
}
},
SocketMessage::AnimationFps(fps) => {
ANIMATION_FPS.store(fps, Ordering::SeqCst);
}
}
self.update_known_window_ids();
+56
View File
@@ -37,6 +37,13 @@ use crate::LAYOUT_DEFAULTS;
use crate::MANAGE_IDENTIFIERS;
use crate::REGEX_IDENTIFIERS;
use crate::WORKSPACE_MATCHING_RULES;
use crate::animation::ANIMATION_DURATION_GLOBAL;
use crate::animation::ANIMATION_DURATION_PER_ANIMATION;
use crate::animation::ANIMATION_ENABLED_GLOBAL;
use crate::animation::ANIMATION_ENABLED_PER_ANIMATION;
use crate::animation::ANIMATION_FPS;
use crate::animation::DEFAULT_ANIMATION_FPS;
use crate::animation::PerAnimationPrefixConfig;
use crate::border_manager;
use crate::core::Axis;
use crate::core::CrossBoundaryBehaviour;
@@ -498,6 +505,9 @@ pub struct StaticConfig {
// /// Stackbar configuration options
// #[serde(skip_serializing_if = "Option::is_none")]
// pub stackbar: Option<StackbarConfig>,
/// Animations configuration options
#[serde(skip_serializing_if = "Option::is_none")]
pub animation: Option<AnimationsConfig>,
/// Aspect ratio to resize with when toggling floating mode for a window
#[serde(skip_serializing_if = "Option::is_none")]
pub floating_window_aspect_ratio: Option<AspectRatio>,
@@ -506,6 +516,23 @@ pub struct StaticConfig {
// pub window_handling_behaviour: Option<WindowHandlingBehaviour>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
/// Animation configuration
pub struct AnimationsConfig {
/// Enable or disable animations
#[cfg_attr(feature = "schemars", schemars(extend("default" = PerAnimationPrefixConfig::Global(false))))]
pub enabled: PerAnimationPrefixConfig<bool>,
/// Set the animation duration in ms
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = PerAnimationPrefixConfig::Global(250))))]
pub duration: Option<PerAnimationPrefixConfig<u64>>,
/// Set the animation FPS
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = DEFAULT_ANIMATION_FPS)))]
pub fps: Option<u64>,
}
// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
// pub struct TabsConfig {
@@ -622,6 +649,7 @@ impl From<&WindowManager> for StaticConfig {
// monitor_index_preferences: Option::from(MONITOR_INDEX_PREFERENCES.lock().clone()),
display_index_preferences: Option::from(DISPLAY_INDEX_PREFERENCES.read().clone()),
// stackbar: None,
animation: None,
// slow_application_compensation_time: Option::from(
// SLOW_APPLICATION_COMPENSATION_TIME.load(Ordering::SeqCst),
// ),
@@ -666,6 +694,34 @@ impl StaticConfig {
// window::MINIMUM_WIDTH.store(width, Ordering::SeqCst);
// }
if let Some(animations) = &self.animation {
match &animations.enabled {
PerAnimationPrefixConfig::Prefix(enabled) => {
ANIMATION_ENABLED_PER_ANIMATION.lock().clone_from(enabled);
}
PerAnimationPrefixConfig::Global(enabled) => {
ANIMATION_ENABLED_GLOBAL.store(*enabled, Ordering::SeqCst);
ANIMATION_ENABLED_PER_ANIMATION.lock().clear();
}
}
match &animations.duration {
Some(PerAnimationPrefixConfig::Prefix(duration)) => {
ANIMATION_DURATION_PER_ANIMATION.lock().clone_from(duration);
}
Some(PerAnimationPrefixConfig::Global(duration)) => {
ANIMATION_DURATION_GLOBAL.store(*duration, Ordering::SeqCst);
ANIMATION_DURATION_PER_ANIMATION.lock().clear();
}
None => {}
}
ANIMATION_FPS.store(
animations.fps.unwrap_or(DEFAULT_ANIMATION_FPS),
Ordering::SeqCst,
);
}
if let Some(container) = self.default_container_padding {
DEFAULT_CONTAINER_PADDING.store(container, Ordering::SeqCst);
}
+74
View File
@@ -0,0 +1,74 @@
//! The messages that set the animation are carried out, and the compositor is asked for the
//! animation they make.
//!
//! This file has one test because it changes the process-wide animation settings, which every
//! other test that asks for the look would see.
use komorebi::animation::ANIMATION_FPS;
use komorebi::animation::AnimationPrefix;
use komorebi::backend::AnimationLook;
use komorebi::backend::fake::Command;
use komorebi::backend::fake::FakeBackend;
use komorebi::backend::with_backend;
use komorebi::core::SocketMessage;
use komorebi::window_manager::WindowManager;
use std::sync::Arc;
use std::sync::atomic::Ordering;
#[test]
fn the_animation_messages_set_the_animation_and_the_compositor_is_asked_for_it() {
let fake = Arc::new(FakeBackend::with_one_monitor());
let (_sender, receiver) = crossbeam_channel::bounded(1);
let socket = std::path::PathBuf::from(format!("/tmp/kmb-anim-{}.sock", std::process::id()));
let mut wm = with_backend(fake.clone(), || {
let mut wm = WindowManager::new(receiver, Some(socket)).unwrap();
wm.init().unwrap();
wm
});
let send = |wm: &mut WindowManager, message| {
with_backend(fake.clone(), || wm.process_command(message, Vec::new())).unwrap();
};
// what the compositor was last asked to animate
let animation = || {
fake.commands()
.into_iter()
.rev()
.find_map(|command| match command {
Command::ApplyLook(look) => Some(look.animation),
_ => None,
})
.expect("the compositor was asked for a look")
};
let animated = |duration_ms| Some(AnimationLook { duration_ms });
let movement = Some(AnimationPrefix::Movement);
// nothing is animated until it is asked for, and then for the default time
send(&mut wm, SocketMessage::BorderWidth(10));
assert_eq!(animation(), None);
send(&mut wm, SocketMessage::Animation(true, None));
assert_eq!(animation(), animated(250));
send(&mut wm, SocketMessage::AnimationDuration(120, None));
assert_eq!(animation(), animated(120));
// the settings of one kind of animation win over the global ones
send(&mut wm, SocketMessage::Animation(false, movement));
assert_eq!(animation(), None);
send(&mut wm, SocketMessage::AnimationDuration(500, movement));
assert_eq!(animation(), None);
send(&mut wm, SocketMessage::Animation(true, movement));
assert_eq!(animation(), animated(500));
// and a global setting takes the ones of the kinds away
send(&mut wm, SocketMessage::AnimationDuration(90, None));
assert_eq!(animation(), animated(90));
send(&mut wm, SocketMessage::Animation(false, None));
assert_eq!(animation(), None);
// the frame rate is kept, and asks nothing of the compositor
let asked = fake.commands().len();
send(&mut wm, SocketMessage::AnimationFps(30));
assert_eq!(ANIMATION_FPS.load(Ordering::SeqCst), 30);
assert_eq!(fake.commands().len(), asked);
}
+95
View File
@@ -0,0 +1,95 @@
//! The `animation` key of `komorebi.json` is the animation settings: the file sets them when the
//! daemon starts and when it is read again, for every kind of animation or for one, a file without
//! the key leaves them as they are, and the compositor is asked for the animation they make.
//!
//! This file has one test because it changes the process-wide animation settings, which every
//! other test that asks for the look would see.
use color_eyre::eyre;
use komorebi::animation::ANIMATION_FPS;
use komorebi::animation::movement_animation;
use komorebi::backend::fake::FakeBackend;
use komorebi::backend::with_backend;
use komorebi::static_config::StaticConfig;
use komorebi::window_manager::WindowManager;
use parking_lot::Mutex;
use std::os::unix::net::UnixListener;
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::atomic::Ordering;
fn write_config(name: &str, json: &str) -> PathBuf {
let path = PathBuf::from(format!("/tmp/kmb-anim-{name}-{}.json", std::process::id()));
std::fs::write(&path, json).unwrap();
path
}
#[test]
fn the_animation_key_of_the_file_is_the_animation_settings() {
let fake = Arc::new(FakeBackend::with_one_monitor());
let path = write_config(
"all",
r#"{ "animation": { "enabled": true, "duration": 120, "fps": 30 } }"#,
);
let (_sender, receiver) = crossbeam_channel::bounded(1);
let socket = PathBuf::from(format!("/tmp/kmb-anim-config-{}.sock", std::process::id()));
let listener = UnixListener::bind(&socket).unwrap();
let wm = with_backend(fake.clone(), || -> eyre::Result<WindowManager> {
let mut wm = StaticConfig::preload(&path, receiver, Some(listener))?;
wm.init()?;
Ok(wm)
})
.unwrap();
let wm = Arc::new(Mutex::new(wm));
StaticConfig::postload(&path, &wm).unwrap();
let _ = std::fs::remove_file(&socket);
// one value for every kind of animation
assert_eq!(movement_animation(), Some(120));
assert_eq!(ANIMATION_FPS.load(Ordering::SeqCst), 30);
// a value for the kinds a file names wins over the global ones, which a global value takes away
let by_kind = write_config(
"kind",
r#"{ "animation": { "enabled": { "movement": false }, "duration": { "movement": 500 } } }"#,
);
with_backend(fake.clone(), || {
StaticConfig::reload(&by_kind, &mut wm.lock()).unwrap();
});
assert_eq!(movement_animation(), None, "movement is off");
assert_eq!(
ANIMATION_FPS.load(Ordering::SeqCst),
60,
"a file that leaves fps out has the default"
);
let on = write_config(
"on",
r#"{ "animation": { "enabled": { "movement": true }, "duration": 90 } }"#,
);
with_backend(fake.clone(), || {
StaticConfig::reload(&on, &mut wm.lock()).unwrap();
});
assert_eq!(movement_animation(), Some(90), "a global duration wins");
// a file that leaves the key out, or the duration, leaves the settings as they are
let empty = write_config("empty", "{}");
with_backend(fake.clone(), || {
StaticConfig::reload(&empty, &mut wm.lock()).unwrap();
});
assert_eq!(movement_animation(), Some(90));
let no_duration = write_config("no-duration", r#"{ "animation": { "enabled": true } }"#);
with_backend(fake.clone(), || {
StaticConfig::reload(&no_duration, &mut wm.lock()).unwrap();
});
assert_eq!(movement_animation(), Some(90));
// `enabled` is the one key the file has to give
assert!(StaticConfig::read_raw(r#"{ "animation": { "duration": 100 } }"#).is_err());
for file in [path, by_kind, on, empty, no_duration] {
let _ = std::fs::remove_file(file);
}
}
+97
View File
@@ -0,0 +1,97 @@
//! A command that changes a stack is carried out with the animation off, and the animation is on
//! again when it is done: the compositor is asked for it as it was before. The two commands that
//! ask for the look while they run, the ones that take a window out of a stack, show it.
//!
//! This file has one test because it changes the process-wide animation settings, which every
//! other test that asks for the look would see.
use komorebi::animation::ANIMATION_ENABLED_GLOBAL;
use komorebi::backend::AnimationLook;
use komorebi::backend::fake::Command;
use komorebi::backend::fake::FakeBackend;
use komorebi::backend::with_backend;
use komorebi::core::CycleDirection;
use komorebi::core::OperationDirection;
use komorebi::core::SocketMessage;
use komorebi::window::Window;
use komorebi::window_manager::WindowManager;
use komorebi::window_manager_event::KWinNotification;
use komorebi::window_manager_event::SystemNotification;
use komorebi::window_manager_event::WindowManagerEvent;
use std::sync::Arc;
use std::sync::atomic::Ordering;
#[test]
fn the_animation_is_on_again_after_a_command_that_changes_a_stack() {
let fake = Arc::new(FakeBackend::with_one_monitor());
let (_sender, receiver) = crossbeam_channel::bounded(1);
let socket =
std::path::PathBuf::from(format!("/tmp/kmb-anim-stack-{}.sock", std::process::id()));
let mut wm = with_backend(fake.clone(), || {
let mut wm = WindowManager::new(receiver, Some(socket)).unwrap();
wm.init().unwrap();
wm
});
with_backend(fake.clone(), || {
for id in 45_001..45_004 {
fake.open_window(id, "foot", "foot", &format!("terminal {id}"));
wm.process_event(WindowManagerEvent::Show(
SystemNotification::KWin(KWinNotification::WindowAdded),
Window::from(id),
))
.unwrap();
}
});
let send = |wm: &mut WindowManager, message| {
with_backend(fake.clone(), || wm.process_command(message, Vec::new())).unwrap();
};
// what the compositor was last asked to animate
let animation = || {
fake.commands()
.into_iter()
.rev()
.find_map(|command| match command {
Command::ApplyLook(look) => Some(look.animation),
_ => None,
})
.expect("the compositor was asked for a look")
};
send(&mut wm, SocketMessage::Animation(true, None));
assert_eq!(animation(), Some(AnimationLook { duration_ms: 250 }));
// every look the compositor is asked for while the command runs, as what it animates
let looks = || {
fake.commands()
.into_iter()
.filter_map(|command| match command {
Command::ApplyLook(look) => Some(look.animation),
_ => None,
})
.collect::<Vec<_>>()
};
let on = Some(AnimationLook { duration_ms: 250 });
for (message, asked) in [
(SocketMessage::StackWindow(OperationDirection::Left), vec![]),
(SocketMessage::CycleStack(CycleDirection::Next), vec![]),
(SocketMessage::CycleStackIndex(CycleDirection::Next), vec![]),
(SocketMessage::FocusStackWindow(0), vec![]),
(SocketMessage::UnstackWindow, vec![None, on.clone()]),
(SocketMessage::StackAll, vec![]),
(SocketMessage::UnstackAll, vec![None, on.clone()]),
] {
fake.clear_commands();
send(&mut wm, message.clone());
assert!(
ANIMATION_ENABLED_GLOBAL.load(Ordering::SeqCst),
"the animation is on again after {message:?}"
);
assert_eq!(
looks(),
asked,
"the compositor is asked for the look with the animation off while {message:?} runs"
);
}
}
-2
View File
@@ -45,8 +45,6 @@ const WINDOWS_ONLY: &[&str] = &[
const NOT_YET: &[&str] = &[
// a color for each kind of window's border, whose type is komorebi-themes' (49)
"border_colours",
// animation (45)
"animation",
// transparency (47)
"transparency",
"transparency_alpha",
+50
View File
@@ -69,6 +69,8 @@
//! - `border` sets whether the compositor draws a border around each window, `border-colour` the
//! color of the border of a kind of window, and `border-width` and `border-offset` the room the
//! layout leaves for it.
//! - `animation`, `animation-duration` and `animation-fps` set whether windows are animated going
//! to their places, for how long, and the frame rate that is stored and ignored.
//!
//! `ignore-rule` and `manage-rule` add a rule that keeps an application out of the layout or
//! always in it, `session-float-rule` floats the focused window and every window like it until the
@@ -755,6 +757,30 @@ struct BorderOffset {
offset: i32,
}
#[derive(Parser)]
struct Animation {
#[clap(value_enum)]
boolean_state: BooleanState,
/// Animation type to apply the state to. If not specified, sets global state
#[clap(value_enum, short, long)]
animation_type: Option<komorebi_client::AnimationPrefix>,
}
#[derive(Parser)]
struct AnimationDuration {
/// Desired animation durations in ms
duration: u64,
/// Animation type to apply the duration to. If not specified, sets global duration
#[clap(value_enum, short, long)]
animation_type: Option<komorebi_client::AnimationPrefix>,
}
#[derive(Parser)]
struct AnimationFps {
/// Desired animation frames per second
fps: u64,
}
#[derive(Parser)]
struct Docgen {
/// Output directory for generated documentation files
@@ -1192,6 +1218,15 @@ enum SubCommand {
// /// Set the border implementation
// #[clap(arg_required_else_help = true)]
// BorderImplementation(BorderImplementation),
/// Enable or disable movement animations
#[clap(arg_required_else_help = true)]
Animation(Animation),
/// Set the duration for movement animations in ms
#[clap(arg_required_else_help = true)]
AnimationDuration(AnimationDuration),
/// Set the frames per second for movement animations
#[clap(arg_required_else_help = true)]
AnimationFps(AnimationFps),
/// Enable or disable mouse follows focus on all workspaces
#[clap(arg_required_else_help = true)]
MouseFollowsFocus(MouseFollowsFocus),
@@ -2016,6 +2051,21 @@ fn main() -> eyre::Result<()> {
SubCommand::BorderOffset(args) => {
send_message(&SocketMessage::BorderOffset(args.offset))?;
}
SubCommand::Animation(args) => {
send_message(&SocketMessage::Animation(
args.boolean_state.into(),
args.animation_type,
))?;
}
SubCommand::AnimationDuration(args) => {
send_message(&SocketMessage::AnimationDuration(
args.duration,
args.animation_type,
))?;
}
SubCommand::AnimationFps(args) => {
send_message(&SocketMessage::AnimationFps(args.fps))?;
}
}
Ok(())
+27
View File
@@ -512,6 +512,30 @@ fn the_border_subcommands_send_what_they_are_given() {
);
}
#[test]
fn the_animation_subcommands_send_what_they_are_given() {
sends(
&["animation", "enable"],
r#"{"type":"Animation","content":[true,null]}"#,
);
sends(
&["animation", "disable", "--animation-type", "movement"],
r#"{"type":"Animation","content":[false,"movement"]}"#,
);
sends(
&["animation-duration", "120"],
r#"{"type":"AnimationDuration","content":[120,null]}"#,
);
sends(
&["animation-duration", "500", "-a", "movement"],
r#"{"type":"AnimationDuration","content":[500,"movement"]}"#,
);
sends(
&["animation-fps", "30"],
r#"{"type":"AnimationFps","content":30}"#,
);
}
#[test]
fn visible_windows_prints_the_answer_of_the_daemon() {
let runtime = Runtime::new();
@@ -1029,6 +1053,9 @@ fn docgen_writes_the_help_of_every_subcommand_in_a_text_fence() {
[
"adjust-container-padding.md",
"adjust-workspace-padding.md",
"animation-duration.md",
"animation-fps.md",
"animation.md",
"application-specific-configuration-schema.md",
"border-colour.md",
"border-offset.md",
+52 -1
View File
@@ -1,4 +1,4 @@
# schema-sha256: 0f59fbd881e4247d5ffb1355b24b65f5f58302e74a8908b31837919445376113
# schema-sha256: e53fa2caa5377453b0cb6e1302e8ef951904fd38a488df1ad75997cd6fb97ea1
{ lib, ... }:
let
defaultLayout = (
@@ -161,6 +161,57 @@ in
options.komorebi = lib.mkOption {
type = lib.types.submodule {
options = {
animation = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.submodule {
options = {
duration = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.submodule {
options = {
movement = lib.mkOption {
type = lib.types.int;
};
};
})
lib.types.int
]
)
);
default = 250;
description = "Set the animation duration in ms";
};
enabled = lib.mkOption {
type = (
lib.types.oneOf [
(lib.types.submodule {
options = {
movement = lib.mkOption {
type = lib.types.bool;
};
};
})
lib.types.bool
]
);
default = false;
description = "Enable or disable animations";
};
fps = lib.mkOption {
type = (lib.types.nullOr lib.types.int);
default = 60;
description = "Set the animation FPS";
};
};
}
)
);
default = null;
description = "Animations configuration options";
};
app_specific_configuration_path = lib.mkOption {
type = (
lib.types.nullOr (
+36
View File
@@ -0,0 +1,36 @@
{
lib,
stdenvNoCC,
fetchFromGitHub,
}:
# "Geometry Change" by Peter Fajdiga (GPLv3): animates windows that are moved or resized by programs
# or scripts, which stock KWin does not. It is a scripted (JS) effect package, so installing it is
# only a copy into `share/kwin/effects`; kwin discovers it at startup, not afterwards. Its metadata
# already says `"EnabledByDefault": false`, so KWin does not load it until it is asked for.
stdenvNoCC.mkDerivation {
pname = "kwin-effect-geometry-change";
version = "1.5";
src = fetchFromGitHub {
owner = "peterfajdiga";
repo = "kwin4_effect_geometry_change";
rev = "398491e8a3f5b9bb785850439abd41820f3c5986";
hash = "sha256-aJx3hDzIk/bQrrRvs/CPigJ0miTgqxd8OI9I6kuiXkk=";
};
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/share/kwin/effects/kwin4_effect_geometry_change
cp -r package/* $out/share/kwin/effects/kwin4_effect_geometry_change/
runHook postInstall
'';
meta = {
description = "KWin effect that animates windows moved or resized by programs or scripts";
homepage = "https://github.com/peterfajdiga/kwin4_effect_geometry_change";
license = lib.licenses.gpl3Only;
platforms = lib.platforms.linux;
};
}
+25 -1
View File
@@ -240,6 +240,29 @@ in
};
};
effects.animation = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Install the KWin effect that animates komorebi's windows going to their places, Geometry
Change. This is installation only: whether windows are animated is komorebi's setting
(`komorebic animation`), which asks KWin to load the effect when it is on. KWin finds
effects when it starts, so an effect installed by a switch to a new system is found
after the next login.
Without the effect, windows jump to their places.
'';
};
package = lib.mkPackageOption pkgs "kwin-effect-geometry-change-komorebi" {
extraDescription = ''
It must have `share/kwin/effects/kwin4_effect_geometry_change`, a scripted effect that
is not loaded by default.
'';
};
};
internal.configAttrs = lib.mkOption {
type = lib.types.nullOr lib.types.attrs;
readOnly = true;
@@ -311,7 +334,8 @@ in
environment.systemPackages = [
cfg.package
]
++ lib.optional cfg.effects.borders.enable cfg.effects.borders.package;
++ lib.optional cfg.effects.borders.enable cfg.effects.borders.package
++ lib.optional cfg.effects.animation.enable cfg.effects.animation.package;
# A user unit, so it runs for every user who logs in to Plasma. plasma-workspace.target is
# the target of a Plasma session's services, and plasma-core.target, which it requires, is
+31 -4
View File
@@ -4,6 +4,12 @@
{ pkgs, packages }:
let
inherit (pkgs.kdePackages) kwin qttools;
fail = ''
fail() {
echo "FAIL: $*" >&2
exit 1
}
'';
in
{
kde-rounded-corners-komorebi-install =
@@ -17,10 +23,7 @@ in
];
}
''
fail() {
echo "FAIL: $*" >&2
exit 1
}
${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"
@@ -55,6 +58,30 @@ in
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
'';
}
+27 -1
View File
@@ -13,6 +13,8 @@
komorebiFor,
# the flake's KDE Rounded Corners for a system, which the overlay has to provide as well
borderEffectFor,
# the flake's Geometry Change for a system, likewise
animationEffectFor,
}:
let
inherit (pkgs) lib;
@@ -246,6 +248,14 @@ let
};
};
noAnimationEffect = eval {
imports = [ plasma ];
services.komorebi = {
enable = true;
effects.animation.enable = false;
};
};
# a package that is not the overlay's: any package will do, since nothing is built
otherBorderEffect = eval (
{ pkgs, ... }:
@@ -349,6 +359,21 @@ let
lib.elem otherBorderEffect.services.komorebi.effects.borders.package otherBorderEffect.environment.systemPackages
&& !(lib.elem enabled.services.komorebi.effects.borders.package otherBorderEffect.environment.systemPackages);
}
{
name = "the default animation effect is the flake's Geometry Change, from the overlay";
ok =
enabled.services.komorebi.effects.animation.package.outPath == (animationEffectFor system).outPath;
}
{
name = "the animation effect is installed in the system profile";
ok = lib.elem enabled.services.komorebi.effects.animation.package enabled.environment.systemPackages;
}
{
name = "with the animation effect off, the border effect is installed and the animation effect is not";
ok =
lib.elem noAnimationEffect.services.komorebi.effects.borders.package noAnimationEffect.environment.systemPackages
&& !(lib.elem noAnimationEffect.services.komorebi.effects.animation.package noAnimationEffect.environment.systemPackages);
}
{
name = "a configuration that draws borders, without the effect that draws them, is warned about";
ok = lib.any (lib.hasInfix "effects.borders.enable is false") borderWithoutEffect.warnings;
@@ -375,7 +400,8 @@ let
name = "disabled, nothing is installed";
ok =
!(lib.elem disabled.services.komorebi.package disabled.environment.systemPackages)
&& !(lib.elem disabled.services.komorebi.effects.borders.package disabled.environment.systemPackages);
&& !(lib.elem disabled.services.komorebi.effects.borders.package disabled.environment.systemPackages)
&& !(lib.elem disabled.services.komorebi.effects.animation.package disabled.environment.systemPackages);
}
{
name = "without Plasma 6, an assertion fails and names the option to set";
+4
View File
@@ -48,6 +48,10 @@
environment.systemPackages = [ pkgs.kdePackages.konsole ];
# KWin loads no effect that animates under software rendering, which is all a guest has, unless
# it is told to: with this it loads Geometry Change, which komorebi asks it to load
environment.sessionVariables.KWIN_EFFECTS_FORCE_ANIMATIONS = "1";
# Nothing adds a display device here (see komorebi.vm.renderNode above). The test driver gives
# every aarch64 guest a virtio-gpu, and an x86_64 guest has the default VGA; screenshots are taken
# of that one, and a second device would be a second head that KWin draws on and the screenshot
+4
View File
@@ -330,6 +330,10 @@ border-width 8
border-offset 1
border-colour --window-kind single 10 20 30
border disable
animation enable
animation-duration 120
animation-fps 30
animation disable
session-float-rule
session-float-rules
clear-session-float-rules
+81 -6
View File
@@ -1,11 +1,15 @@
# The border, in a real Plasma session whose machine has the border effect installed (the module
# does that): komorebi writes the effect's settings, loads it, and on exit puts everything back.
# The border and the animation, in a real Plasma session whose machine has the effects installed
# (the module does that): komorebi writes the effects' settings, loads them, and on exit puts
# everything back.
#
# What is checked is what is on the screen, not what komorebi wrote: the screenshot is read at the
# pixels just outside each window's frame. The runs of komorebi:
# What is checked is what is on the screen, not what komorebi wrote: a screenshot is read at the
# pixels just outside each window's frame (the border) and at the place a window is going to (the
# animation). The runs of komorebi:
#
# A the borders, as they are by default: the ring is outside the frame on all four sides
# B the commands that change them: the effect follows, and takes the border away and back
# C a 30 s animation: a window flipped to the other side is not there yet moments later
# D no animation, the control: the same flip is there at once
#
# Every window is a `foot` of one color all over (`Kde.colored_window`).
import time
@@ -17,8 +21,11 @@ UNIT = "komorebi.service"
LOG = "/home/komorebi/.local/share/komorebi/komorebi_plaintext.log.*"
ROUNDED_CORNERS = "kwin4_effect_shapecorners"
GROUP = "Round-Corners"
GEOMETRY_CHANGE = "kwin4_effect_geometry_change"
ANIMATION_GROUP = "Effect-kwin4_effect_geometry_change"
FOCUSED = (66, 165, 245)
UNFOCUSED = (128, 128, 128)
RED = (255, 0, 0)
start_all()
machine.wait_for_unit("multi-user.target")
@@ -60,17 +67,24 @@ print("== the effect is installed, and not loaded by anyone")
# the session started the module's unit when it logged in: this test starts its own runs
stop_komorebi()
checks.check("KDE Rounded Corners is installed", kde.effect_supported(ROUNDED_CORNERS))
checks.check("Geometry Change is installed", kde.effect_supported(GEOMETRY_CHANGE))
checks.check(
"and KWin does not load it by itself (it is built disabled by default)",
not kde.effect_loaded(ROUNDED_CORNERS),
"and KWin does not load either by itself (they are built disabled by default)",
not kde.effect_loaded(ROUNDED_CORNERS) and not kde.effect_loaded(GEOMETRY_CHANGE),
)
before = kde.kwinrc_group(GROUP)
before_animation = kde.kwinrc_group(ANIMATION_GROUP)
def put_back() -> None:
checks.check("komorebi exited", not running())
checks.check("the border effect is unloaded again", not kde.effect_loaded(ROUNDED_CORNERS))
checks.check("the animation effect is unloaded again", not kde.effect_loaded(GEOMETRY_CHANGE))
checks.check(f"kwinrc [{GROUP}] is as it was", kde.kwinrc_group(GROUP) == before)
checks.check(
f"kwinrc [{ANIMATION_GROUP}] is as it was",
kde.kwinrc_group(ANIMATION_GROUP) == before_animation,
)
print("== A. komorebi starts, with the borders it has by default")
@@ -159,4 +173,65 @@ checks.check(
stop_komorebi()
put_back()
def flip_of_red() -> tuple[Rect, Rect]:
"""Flips the layout, and returns the frame red had and the one komorebi gave it."""
kde.colored_window("red", "ff0000")
time.sleep(1)
kde.colored_window("blue", "0000ff")
kde.wait_for(lambda: kde.managed() == 2, timeout=30)
# well past the half of it, where an ease out is at 97 %: the windows have got where they go
time.sleep(16 * SCALE)
before_flip = kde.rect(kde.wid("red"))
kde.komorebic("flip-layout", "horizontal")
kde.wait_for(lambda: kde.rect(kde.wid("red")) != before_flip, timeout=10)
return before_flip, kde.rect(kde.wid("red"))
def point_in(frame: Rect) -> tuple[int, int]:
"""A point inside the frame, far from where red came from, which is on its left."""
return frame.x + frame.w - 60, frame.y + frame.h // 2
print("== C. komorebi runs a 30 s animation")
start_komorebi()
kde.komorebic("animation-duration", "30000")
kde.komorebic("animation", "enable")
checks.check(
"the animation effect is loaded",
kde.wait_for(lambda: kde.effect_loaded(GEOMETRY_CHANGE), timeout=10),
)
animation = kde.kwinrc_group(ANIMATION_GROUP)
checks.check(
"it lasts what it was asked to, without cross-fading",
animation.get("Duration") == "30000" and animation.get("CrossFade") == "false",
)
was, now = flip_of_red()
print(f" red: {was} -> {now}")
checks.check("komorebi moved the window", was != now)
x, y = point_in(now)
soon = pixels.pixel(kde.shot("soon"), x, y)
checks.check(
f"a moment after the flip red has not got to its new place ({soon})",
not pixels.near(soon, RED),
)
time.sleep(16 * SCALE)
later = pixels.pixel(kde.shot("later"), x, y)
checks.check(f"and 16 s later it has ({later})", pixels.near(later, RED))
stop_komorebi()
put_back()
print("== D. without an animation, the control, the same flip is there at once")
start_komorebi()
checks.check("the animation effect is not loaded", not kde.effect_loaded(GEOMETRY_CHANGE))
was, now = flip_of_red()
x, y = point_in(now)
at_once = pixels.pixel(kde.shot("control"), x, y)
checks.check(
f"red is at its new place when the screenshot is taken ({at_once})",
pixels.near(at_once, RED),
)
stop_komorebi()
put_back()
checks.finish()
+89
View File
@@ -4,6 +4,17 @@
"description": "The `komorebi.json` static configuration file reference for komorebi for KDE Plasma",
"type": "object",
"properties": {
"animation": {
"description": "Animations configuration options",
"anyOf": [
{
"$ref": "#/$defs/AnimationsConfig"
},
{
"type": "null"
}
]
},
"app_specific_configuration_path": {
"description": "Path to an applications.json, or a list of them, with rules for the applications that\nneed them: which windows to ignore, to manage and to float",
"anyOf": [
@@ -318,6 +329,42 @@
}
},
"$defs": {
"AnimationsConfig": {
"description": "Animation configuration",
"type": "object",
"properties": {
"duration": {
"description": "Set the animation duration in ms",
"anyOf": [
{
"$ref": "#/$defs/PerAnimationPrefixConfig2"
},
{
"type": "null"
}
],
"default": 250
},
"enabled": {
"description": "Enable or disable animations",
"$ref": "#/$defs/PerAnimationPrefixConfig",
"default": false
},
"fps": {
"description": "Set the animation FPS",
"type": [
"integer",
"null"
],
"format": "uint64",
"default": 60,
"minimum": 0
}
},
"required": [
"enabled"
]
},
"AppSpecificConfigurationPath": {
"description": "Path(s) to application-specific configuration file(s)",
"anyOf": [
@@ -833,6 +880,48 @@
"description": "A file system path. Environment variables like $VAR are automatically resolved.",
"type": "string"
},
"PerAnimationPrefixConfig": {
"description": "Animation configuration\n\nThis can be either global:\n```json\n{\n \"enabled\": true,\n \"fps\": 60,\n \"duration\": 250\n}\n```\n\nOr scoped by an animation kind prefix:\n```json\n{\n \"movement\": {\n \"enabled\": true,\n \"fps\": 60,\n \"duration\": 250\n }\n}\n```",
"anyOf": [
{
"description": "Animation configuration prefixed for a specific animation kind",
"type": "object",
"properties": {
"movement": {
"type": "boolean"
}
},
"additionalProperties": false
},
{
"description": "Animation configuration for all animation kinds",
"type": "boolean"
}
]
},
"PerAnimationPrefixConfig2": {
"description": "Animation configuration\n\nThis can be either global:\n```json\n{\n \"enabled\": true,\n \"fps\": 60,\n \"duration\": 250\n}\n```\n\nOr scoped by an animation kind prefix:\n```json\n{\n \"movement\": {\n \"enabled\": true,\n \"fps\": 60,\n \"duration\": 250\n }\n}\n```",
"anyOf": [
{
"description": "Animation configuration prefixed for a specific animation kind",
"type": "object",
"properties": {
"movement": {
"type": "integer",
"format": "uint64",
"minimum": 0
}
},
"additionalProperties": false
},
{
"description": "Animation configuration for all animation kinds",
"type": "integer",
"format": "uint64",
"minimum": 0
}
]
},
"Placement": {
"description": "Placement behavior for floating windows",
"oneOf": [