Add more kwin effects (#213)

This commit is contained in:
magnouvean 2024-06-16 18:50:05 +02:00 committed by GitHub
parent e2f2036ae7
commit 7bea3519af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 149 additions and 19 deletions

View File

@ -57,6 +57,12 @@ let
(imap1 (i: v: (nameValuePair "Name_${builtins.toString i}" v)) names);
in
{
imports = [
(lib.mkRenamedOptionModule
[ "programs" "plasma" "kwin" "virtualDesktops" "animation" ]
[ "programs" "plasma" "kwin" "effects" "desktopSwitching" "animation" ])
];
options.programs.plasma.kwin = {
titlebarButtons.right = mkOption {
type = with types; nullOr (listOf (enum validTitlebarButtons.longNames));
@ -79,18 +85,94 @@ in
shakeCursor.enable = mkOption {
type = with types; nullOr bool;
default = null;
example = true;
description = "Enable the shake cursor effect (plasma 6 only).";
description = "Enable the shake cursor effect.";
};
translucency.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Make windows translucent under different conditions.";
};
minimization = {
animation = mkOption {
type = with types; nullOr (enum [ "squash" "magiclamp" ]);
default = null;
example = "magiclamp";
description = "The effect when windows are minimized.";
};
duration = mkOption {
type = with types; nullOr ints.positive;
default = null;
example = 50;
description = ''
The duration of the minimization effect in milliseconds. Only
available when the minimization effect is magic lamp.
'';
};
};
wobblyWindows.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Deform windows while they are moving.";
};
fps.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Display KWin's fps in the corner of the screen;";
};
cube.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Arrange desktops in a virtual cube.";
};
desktopSwitching.animation = mkOption {
type = with types; nullOr (enum [ "fade" "slide" ]);
default = null;
example = "fade";
description = "The animation used when switching virtual desktop.";
};
windowOpenClose = {
animation = mkOption {
type = with types; nullOr (enum [ "fade" "glide" "scale" ]);
default = null;
example = "glide";
description = "The animation used when opening/closing windows.";
};
};
fallApart.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Closed windows fall into pieces.";
};
blur = {
enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Blurs the background behind semi-transparent windows.";
};
};
snapHelper.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Helps locate the center of the screen when moving a window.";
};
dimInactive.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Darken inactive windows.";
};
dimAdminMode.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Darken the entire when when requesting root privileges.";
};
slideBack.enable = mkOption {
type = with types; nullOr bool;
default = null;
description = "Slide back windows when another window is raised.";
};
};
virtualDesktops = {
animation = mkOption {
type = with types; nullOr (enum [ "slide" "fade" ]);
default = null;
example = "fade";
description = "The animation when switching virtual desktops.";
};
rows = mkOption {
type = with types; nullOr ints.positive;
default = null;
@ -135,6 +217,10 @@ in
(cfg.kwin.virtualDesktops.names != null && (builtins.length cfg.kwin.virtualDesktops.names) >= cfg.kwin.virtualDesktops.rows);
message = "KWin cannot have more rows virtual desktops.";
}
{
assertion = cfg.kwin.effects.minimization.duration == null || cfg.kwin.effects.minimization.animation == "magiclamp";
message = "programs.plasma.kwin.effects.minimization.duration is only supported for the magic lamp effect";
}
];
config.programs.plasma.configFile."kwinrc" = mkIf (cfg.enable)
@ -152,17 +238,61 @@ in
)
# Effects
(
mkIf (cfg.kwin.effects.shakeCursor.enable != null) {
Plugins.shakecursorEnabled = cfg.kwin.effects.shakeCursor.enable;
}
)
(mkIf (cfg.kwin.effects.shakeCursor.enable != null) {
Plugins.shakecursorEnabled = cfg.kwin.effects.shakeCursor.enable;
})
(mkIf (cfg.kwin.effects.minimization.animation != null) {
Plugins = {
magiclampEnabled = cfg.kwin.effects.minimization.animation == "magiclamp";
squashEnabled = cfg.kwin.effects.minimization.animation == "squash";
};
})
(mkIf (cfg.kwin.effects.minimization.duration != null) {
Effect-magiclamp.AnimationDuration = cfg.kwin.effects.minimization.duration;
})
(mkIf (cfg.kwin.effects.wobblyWindows.enable != null) {
Plugins.wobblywindowsEnabled = cfg.kwin.effects.wobblyWindows.enable;
})
(mkIf (cfg.kwin.effects.translucency.enable != null) {
Plugins.translucencyEnabled = cfg.kwin.effects.translucency.enable;
})
(mkIf (cfg.kwin.effects.windowOpenClose.animation != null) {
Plugins = {
glideEnabled = cfg.kwin.effects.windowOpenClose.animation == "glide";
fadeEnabled = cfg.kwin.effects.windowOpenClose.animation == "fade";
scaleEnabled = cfg.kwin.effects.windowOpenClose.animation == "scale";
};
})
(mkIf (cfg.kwin.effects.fps.enable != null) {
Plugins.showfpsEnabled = cfg.kwin.effects.fps.enable;
})
(mkIf (cfg.kwin.effects.cube.enable != null) {
Plugins.cubeEnabled = cfg.kwin.effects.cube.enable;
})
(mkIf (cfg.kwin.effects.desktopSwitching.animation != null) {
Plugins.slideEnabled = cfg.kwin.effects.desktopSwitching.animation == "slide";
Plugins.fadedesktopEnabled = cfg.kwin.effects.desktopSwitching.animation == "fade";
})
(mkIf (cfg.kwin.effects.fallApart.enable != null) {
Plugins.fallapartEnabled = cfg.kwin.effects.fallApart.enable;
})
(mkIf (cfg.kwin.effects.snapHelper.enable != null) {
Plugins.snaphelperEnabled = cfg.kwin.effects.snapHelper.enable;
})
(mkIf (cfg.kwin.effects.blur.enable != null) {
Plugins.blurEnabled = cfg.kwin.effects.blur.enable;
})
(mkIf (cfg.kwin.effects.dimInactive.enable != null) {
Plugins.diminactiveEnabled = cfg.kwin.effects.dimInactive.enable;
})
(mkIf (cfg.kwin.effects.dimAdminMode.enable != null) {
Plugins.dimscreenEnabled = cfg.kwin.effects.dimAdminMode.enable;
})
(mkIf (cfg.kwin.effects.slideBack.enable != null) {
Plugins.slidebackEnabled = cfg.kwin.effects.slideBack.enable;
})
# Virtual Desktops
(mkIf (cfg.kwin.virtualDesktops.animation != null) {
Plugins.slideEnabled = cfg.kwin.virtualDesktops.animation == "slide";
Plugins.fadedesktopEnabled = cfg.kwin.virtualDesktops.animation == "fade";
})
(mkIf (cfg.kwin.virtualDesktops.number != null) {
Desktops.Number = cfg.kwin.virtualDesktops.number;
})

View File

@ -40,7 +40,7 @@ let
else
null;
example = "fit";
description = "(Plasma 6 only) The length mode of the panel. Defaults to `custom` if either `minLength` or `maxLength` is set.";
description = "The length mode of the panel. Defaults to `custom` if either `minLength` or `maxLength` is set.";
};
location = lib.mkOption {
type = lib.types.str;
@ -74,7 +74,7 @@ let
plasma 6 only.
'';
};
floating = lib.mkEnableOption "Enable or disable floating style (plasma 6 only).";
floating = lib.mkEnableOption "Enable or disable floating style.";
widgets = lib.mkOption {
type = lib.types.listOf widgets.type;
default = [