diff --git a/modules/kwin.nix b/modules/kwin.nix index f87cdc6f..3dd033a4 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -131,6 +131,7 @@ in "animation" ] ) + ./scripts/tiling/krohnkite.nix ]; options.programs.plasma.kwin = { @@ -571,175 +572,6 @@ in }; }; }; - - krohnkite = { - enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable Krohnkite."; - }; - - settings = { - geometry = { - gaps = { - top = lib.mkOption { - type = with lib.types; nullOr (ints.between 0 999); - default = null; - example = 8; - description = "Top screen gap for krohnkite."; - }; - left = lib.mkOption { - type = with lib.types; nullOr (ints.between 0 999); - default = null; - example = 8; - description = "Left screen gap for krohnkite."; - }; - right = lib.mkOption { - type = with lib.types; nullOr (ints.between 0 999); - default = null; - example = 8; - description = "Right screen gap for krohnkite."; - }; - bottom = lib.mkOption { - type = with lib.types; nullOr (ints.between 0 999); - default = null; - example = 8; - description = "Bottom screen gap for krohnkite."; - }; - tiles = lib.mkOption { - type = with lib.types; nullOr (ints.between 0 999); - default = null; - example = 8; - description = "Gap between tiles for krohnkite."; - }; - }; - - tileWidthLimit = { - enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to limit tile width for krohnkite."; - }; - ratio = lib.mkOption { - type = with lib.types; nullOr (ints.between 1 100); - default = null; - example = 1.6; - description = "Tile width limiting ratio for krohnkite."; - }; - }; - }; - - layouts = { - btree.enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable binary tree layout for krohnkite."; - }; - columns = { - enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable columns layout for krohnkite."; - }; - balanced = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable balanced mode for columns layout."; - }; - }; - floating.enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable floating layout for krohnkite."; - }; - monocle = { - enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable monocle layout for krohnkite."; - }; - maximize = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Fully maximize windows (no borders, no gaps) for monocle layout."; - }; - }; - quarter.enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable quarter layout for krohnkite."; - }; - spiral.enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable spiral layout for krohnkite."; - }; - threeColumn.enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable three column layout for krohnkite."; - }; - tile = { - enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable tile layout for krohnkite."; - }; - }; - stacked.enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable stacked layout for krohnkite."; - }; - spread.enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable spread layout for krohnkite."; - }; - stair = { - enable = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable stacked layout for krohnkite."; - }; - reverseDirection = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to reverse stair layout direction."; - }; - }; - - enableLayoutPerActivity = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable layout per activity for krohnkite."; - }; - enableLayoutPerDesktop = lib.mkOption { - type = with lib.types; nullOr bool; - default = null; - example = true; - description = "Whether to enable layout per desktop for krohnkite."; - }; - }; - }; - }; }; }; @@ -809,9 +641,7 @@ in home.packages = with pkgs; - [ ] - ++ lib.optionals (cfg.kwin.scripts.polonium.enable == true) [ polonium ] - ++ lib.optionals (cfg.kwin.scripts.krohnkite.enable == true) [ kdePackages.krohnkite ]; + [ ] ++ lib.optionals (cfg.kwin.scripts.polonium.enable == true) [ polonium ]; programs.plasma.configFile."kwinrc" = ( lib.mkMerge [ @@ -947,34 +777,6 @@ in }; }) - (lib.mkIf (cfg.kwin.scripts.krohnkite.enable != null) { - Plugins.krohnkiteEnabled = cfg.kwin.scripts.krohnkite.enable; - Script-krohnkite = { - screenGapTop = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.top; - screenGapLeft = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.left; - screenGapRight = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.right; - screenGapBottom = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.bottom; - tileLayoutGap = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.tiles; - limitTileWidth = cfg.kwin.scripts.krohnkite.settings.geometry.tileWidthLimit.enable; - limitTileWidthRatio = cfg.kwin.scripts.krohnkite.settings.geometry.tileWidthLimit.ratio; - enableBTreeLayout = cfg.kwin.scripts.krohnkite.settings.layouts.btree.enable; - enableColumnsLayout = cfg.kwin.scripts.krohnkite.settings.layouts.columns.enable; - columnsBalanced = cfg.kwin.scripts.krohnkite.settings.layouts.columns.balanced; - enableFloatingLayout = cfg.kwin.scripts.krohnkite.settings.layouts.floating.enable; - enableMonocleLayout = cfg.kwin.scripts.krohnkite.settings.layouts.monocle.enable; - monocleMaximize = cfg.kwin.scripts.krohnkite.settings.layouts.monocle.maximize; - enableQuarterLayout = cfg.kwin.scripts.krohnkite.settings.layouts.quarter.enable; - enableSpiralLayout = cfg.kwin.scripts.krohnkite.settings.layouts.spiral.enable; - enableSpreadLayout = cfg.kwin.scripts.krohnkite.settings.layouts.spread.enable; - enableStackedLayout = cfg.kwin.scripts.krohnkite.settings.layouts.stacked.enable; - enableStairLayout = cfg.kwin.scripts.krohnkite.settings.layouts.stair.enable; - enableThreeColumnLayout = cfg.kwin.scripts.krohnkite.settings.layouts.threeColumn.enable; - enableTileLayout = cfg.kwin.scripts.krohnkite.settings.layouts.tile.enable; - layoutPerActivity = cfg.kwin.scripts.krohnkite.settings.layouts.enableLayoutPerActivity; - layoutPerDesktop = cfg.kwin.scripts.krohnkite.settings.layouts.enableLayoutPerDesktop; - }; - }) - (lib.mkIf (cfg.kwin.tiling.padding != null) { Tiling = { padding = cfg.kwin.tiling.padding; diff --git a/modules/scripts/tiling/krohnkite.nix b/modules/scripts/tiling/krohnkite.nix new file mode 100644 index 00000000..eb137a9f --- /dev/null +++ b/modules/scripts/tiling/krohnkite.nix @@ -0,0 +1,135 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.programs.plasma; + krohnkiteGaps = lib.types.submodule { + options = + let + mkGapOption = + name: + lib.mkOption { + type = with lib.types; nullOr (ints.between 0 999); + default = null; + example = 8; + description = "${name} gap for krohnkite."; + }; + in + { + top = mkGapOption "Top screen"; + left = mkGapOption "Left screen"; + right = mkGapOption "Right screen"; + bottom = mkGapOption "Bottom screen"; + tiles = mkGapOption "Gap between tiles"; + }; + }; + krohnkiteSupportedLayouts = [ + "btree" + "monocle" + "column" + "floating" + "quarter" + "spiral" + "threeColumn" + "tile" + "stacked" + "spread" + "stair" + ]; + krohnkiteLayouts = lib.types.submodule { + options = { + name = lib.mkOption { type = with lib.types; nullOr (enum krohnkiteSupportedLayouts); }; + }; + }; + + mkNullableOption = + type: description: example: + lib.mkOption { + type = with lib.types; nullOr type; + default = null; + example = if type == lib.types.bool then true else null; # Example defaults for bool or other types + description = description; + }; +in +{ + options.programs.plasma.kwin.scripts.krohnkite = with lib.types; { + enable = mkNullableOption bool "Whether to enable Krohnkite." true; + + settings = { + gaps = + mkNullableOption krohnkiteGaps + "Gaps configuration for Krohnkite, e.g., top, bottom, left, right, and tiles." + { + top = 8; + bottom = 8; + left = 8; + right = 8; + tiles = 8; + }; + + tileWidthLimit = { + enable = mkNullableOption bool "Whether to limit tile width for Krohnkite." true; + ratio = lib.mkOption { + type = with lib.types; nullOr (ints.between 1 100); + default = null; + example = 1.6; # Example must match a valid float-like value + description = "Tile width limiting ratio for Krohnkite."; + }; + }; + + layouts = { + enabled = lib.mkOption { + type = with lib.types; listOf krohnkiteLayouts; + default = [ ]; + example = [ + { + name = "monocle"; + options = { + maximize = true; + }; + } + ]; + description = "List of layout configurations for Krohnkite."; + }; + }; + }; + }; + config = ( + lib.mkIf cfg.enable { + home.packages = + with pkgs; + [ ] ++ lib.optionals (cfg.kwin.scripts.krohnkite.enable == true) [ kdePackages.krohnkite ]; + + programs.plasma.configFile."kwinrc" = lib.mkIf (cfg.kwin.scripts.krohnkite.enable != null) { + Plugins.krohnkiteEnabled = cfg.kwin.scripts.krohnkite.enable; + Script-krohnkite = { + screenGapTop = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.top; + screenGapLeft = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.left; + screenGapRight = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.right; + screenGapBottom = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.bottom; + tileLayoutGap = cfg.kwin.scripts.krohnkite.settings.geometry.gaps.tiles; + limitTileWidth = cfg.kwin.scripts.krohnkite.settings.geometry.tileWidthLimit.enable; + limitTileWidthRatio = cfg.kwin.scripts.krohnkite.settings.geometry.tileWidthLimit.ratio; + enableBTreeLayout = cfg.kwin.scripts.krohnkite.settings.layouts.btree.enable; + enableColumnsLayout = cfg.kwin.scripts.krohnkite.settings.layouts.columns.enable; + columnsBalanced = cfg.kwin.scripts.krohnkite.settings.layouts.columns.balanced; + enableFloatingLayout = cfg.kwin.scripts.krohnkite.settings.layouts.floating.enable; + enableMonocleLayout = cfg.kwin.scripts.krohnkite.settings.layouts.monocle.enable; + monocleMaximize = cfg.kwin.scripts.krohnkite.settings.layouts.monocle.maximize; + enableQuarterLayout = cfg.kwin.scripts.krohnkite.settings.layouts.quarter.enable; + enableSpiralLayout = cfg.kwin.scripts.krohnkite.settings.layouts.spiral.enable; + enableSpreadLayout = cfg.kwin.scripts.krohnkite.settings.layouts.spread.enable; + enableStackedLayout = cfg.kwin.scripts.krohnkite.settings.layouts.stacked.enable; + enableStairLayout = cfg.kwin.scripts.krohnkite.settings.layouts.stair.enable; + enableThreeColumnLayout = cfg.kwin.scripts.krohnkite.settings.layouts.threeColumn.enable; + enableTileLayout = cfg.kwin.scripts.krohnkite.settings.layouts.tile.enable; + layoutPerActivity = cfg.kwin.scripts.krohnkite.settings.layouts.enableLayoutPerActivity; + layoutPerDesktop = cfg.kwin.scripts.krohnkite.settings.layouts.enableLayoutPerDesktop; + }; + }; + } + ); +}