From 45a348bda6549147c3293bc6291341400906cd0a Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Sun, 3 Nov 2024 19:57:18 +0530 Subject: [PATCH 01/12] Added virtual desktop id attributes --- modules/kwin.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/kwin.nix b/modules/kwin.nix index 6d2c3d63..a8eb1626 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -56,6 +56,10 @@ let names: builtins.listToAttrs (lib.imap1 (i: v: (lib.nameValuePair "Name_${builtins.toString i}" v)) names); + virtualDesktopIdAttrs = + names: + builtins.listToAttrs (lib.imap1 (i: v: (lib.nameValuePair "Id_${builtins.toString i}" v)) names); + capitalizeWord = word: let @@ -712,6 +716,7 @@ in (lib.mkIf (cfg.kwin.virtualDesktops.names != null) { Desktops = lib.mkMerge [ { Number = builtins.length cfg.kwin.virtualDesktops.names; } + (virtualDesktopIdAttrs cfg.kwin.virtualDesktops.names) (virtualDesktopNameAttrs cfg.kwin.virtualDesktops.names) ]; }) From cb460094c6d16823c207de73132f5a8670c88d06 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Sun, 3 Nov 2024 22:32:48 +0530 Subject: [PATCH 02/12] Update virtual desktop id attributes --- modules/kwin.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/kwin.nix b/modules/kwin.nix index a8eb1626..f5597a4d 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -56,9 +56,10 @@ let names: builtins.listToAttrs (lib.imap1 (i: v: (lib.nameValuePair "Name_${builtins.toString i}" v)) names); + virtualDesktopIdAttrs = - names: - builtins.listToAttrs (lib.imap1 (i: v: (lib.nameValuePair "Id_${builtins.toString i}" v)) names); + number: + builtins.listToAttrs (map (i: (lib.nameValuePair "Id_${builtins.toString i}" "Desktop_${builtins.toString i}")) (lib.range 1 number)); capitalizeWord = word: @@ -708,7 +709,10 @@ in # Virtual Desktops (lib.mkIf (cfg.kwin.virtualDesktops.number != null) { - Desktops.Number = cfg.kwin.virtualDesktops.number; + Desktops = lib.mkMerge [ + { Number = cfg.kwin.virtualDesktops.number; } + (virtualDesktopIdAttrs cfg.kwin.virtualDesktops.number) + ]; }) (lib.mkIf (cfg.kwin.virtualDesktops.rows != null) { Desktops.Rows = cfg.kwin.virtualDesktops.rows; @@ -716,7 +720,7 @@ in (lib.mkIf (cfg.kwin.virtualDesktops.names != null) { Desktops = lib.mkMerge [ { Number = builtins.length cfg.kwin.virtualDesktops.names; } - (virtualDesktopIdAttrs cfg.kwin.virtualDesktops.names) + (virtualDesktopIdAttrs (builtins.length cfg.kwin.virtualDesktops.names)) (virtualDesktopNameAttrs cfg.kwin.virtualDesktops.names) ]; }) From 8a45de618dec54ceab7cfc243deb976b146b4842 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Fri, 22 Nov 2024 23:42:24 +0530 Subject: [PATCH 03/12] Added krohnkite kwin script --- modules/kwin.nix | 203 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 199 insertions(+), 4 deletions(-) diff --git a/modules/kwin.nix b/modules/kwin.nix index e37646ec..3f9bb19b 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -4,7 +4,6 @@ pkgs, ... }: - let cfg = config.programs.plasma; validTitlebarButtons = { @@ -56,10 +55,13 @@ let names: builtins.listToAttrs (lib.imap1 (i: v: (lib.nameValuePair "Name_${builtins.toString i}" v)) names); - virtualDesktopIdAttrs = number: - builtins.listToAttrs (map (i: (lib.nameValuePair "Id_${builtins.toString i}" "Desktop_${builtins.toString i}")) (lib.range 1 number)); + builtins.listToAttrs ( + map (i: (lib.nameValuePair "Id_${builtins.toString i}" "Desktop_${builtins.toString i}")) ( + lib.range 1 number + ) + ); capitalizeWord = word: @@ -569,6 +571,169 @@ 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 (floats.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."; + }; + 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."; + }; + }; + }; + }; }; }; @@ -638,7 +803,9 @@ in home.packages = with pkgs; - [ ] ++ lib.optionals (cfg.kwin.scripts.polonium.enable == true) [ polonium ]; + [ ] + ++ lib.optionals (cfg.kwin.scripts.polonium.enable == true) [ polonium ] + ++ lib.optionals (cfg.kwin.scripts.krohnkite.enable == true) [ kdePackages.krohnkite ]; programs.plasma.configFile."kwinrc" = ( lib.mkMerge [ @@ -774,6 +941,34 @@ in }; }) + (lib.mkIf (cfg.kwin.scripts.krohnkite.enable != null) { + Plugins.krohnkiteEnable = 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; From 57141d9706099cabda45094d8601e8073739fab5 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Fri, 22 Nov 2024 23:53:12 +0530 Subject: [PATCH 04/12] Fix spread layout --- modules/kwin.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/kwin.nix b/modules/kwin.nix index 3f9bb19b..d21a497f 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -623,7 +623,7 @@ in description = "Whether to limit tile width for krohnkite."; }; ratio = lib.mkOption { - type = with lib.types; nullOr (floats.between 1 100); + type = with lib.types; nullOr (ints.between 1 100); default = null; example = 1.6; description = "Tile width limiting ratio for krohnkite."; @@ -704,6 +704,12 @@ in 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; From 7a908122a713a850773de4c2e61cea7e72eba270 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Fri, 22 Nov 2024 23:57:23 +0530 Subject: [PATCH 05/12] Fix enabling issue --- modules/kwin.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kwin.nix b/modules/kwin.nix index d21a497f..3579c283 100644 --- a/modules/kwin.nix +++ b/modules/kwin.nix @@ -948,7 +948,7 @@ in }) (lib.mkIf (cfg.kwin.scripts.krohnkite.enable != null) { - Plugins.krohnkiteEnable = cfg.kwin.scripts.krohnkite.enable; + 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; From 1df9d879592d3e753c6c4e264f2d28ec48b2ce34 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Tue, 3 Dec 2024 15:47:33 +0530 Subject: [PATCH 06/12] Create module for krohnkite --- modules/kwin.nix | 202 +-------------------------- modules/scripts/tiling/krohnkite.nix | 135 ++++++++++++++++++ 2 files changed, 137 insertions(+), 200 deletions(-) create mode 100644 modules/scripts/tiling/krohnkite.nix 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; + }; + }; + } + ); +} From a75a88fe7747ed0b4279924261b623e976345d02 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Tue, 3 Dec 2024 17:12:45 +0530 Subject: [PATCH 07/12] Add options for tiling layouts krohnkite --- modules/scripts/tiling/krohnkite.nix | 127 ++++++++++++++++++--------- 1 file changed, 87 insertions(+), 40 deletions(-) diff --git a/modules/scripts/tiling/krohnkite.nix b/modules/scripts/tiling/krohnkite.nix index eb137a9f..e2e40ab9 100644 --- a/modules/scripts/tiling/krohnkite.nix +++ b/modules/scripts/tiling/krohnkite.nix @@ -6,6 +6,7 @@ }: let cfg = config.programs.plasma; + krohnkiteGaps = lib.types.submodule { options = let @@ -15,7 +16,7 @@ let type = with lib.types; nullOr (ints.between 0 999); default = null; example = 8; - description = "${name} gap for krohnkite."; + description = "${name} gap for Krohnkite."; }; in { @@ -26,6 +27,7 @@ let tiles = mkGapOption "Gap between tiles"; }; }; + krohnkiteSupportedLayouts = [ "btree" "monocle" @@ -39,9 +41,26 @@ let "spread" "stair" ]; + krohnkiteLayouts = lib.types.submodule { options = { - name = lib.mkOption { type = with lib.types; nullOr (enum krohnkiteSupportedLayouts); }; + name = lib.mkOption { + type = with lib.types; enum krohnkiteSupportedLayouts; + description = "The name of the layout."; + }; + + options = lib.mkOption { + type = with lib.types; attrsOf (with lib.types; anything); + default = { }; + example = { + maximize = true; + }; + description = '' + Layout-specific options. For example: + - `monocle` can have `{ maximize = true; }` + - `column` can have `{ balanced = true; }` + ''; + }; }; }; @@ -50,9 +69,20 @@ let 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 + example = example; description = description; }; + + getLayoutSetting = + layout: key: + lib.getAttrFromPath [ + "options" + key + ] layout + // null; + + isLayoutEnabled = + name: lib.any (layout: layout.name == name) cfg.kwin.scripts.krohnkite.settings.layouts.enabled; in { options.programs.plasma.kwin.scripts.krohnkite = with lib.types; { @@ -72,11 +102,12 @@ in tileWidthLimit = { enable = mkNullableOption bool "Whether to limit tile width for Krohnkite." true; + ratio = lib.mkOption { - type = with lib.types; nullOr (ints.between 1 100); + type = with lib.types; nullOr (numbers.between 0 99); default = null; - example = 1.6; # Example must match a valid float-like value - description = "Tile width limiting ratio for Krohnkite."; + example = 1.6; + description = "Tile width limiting ratio for Krohnkite. Must be a float between 0 and 99."; }; }; @@ -91,45 +122,61 @@ in maximize = true; }; } + { + name = "column"; + options = { + balanced = 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; + + config = lib.mkIf cfg.enable { + home.packages = + with pkgs; + lib.optionals (cfg.kwin.scripts.krohnkite.enable != null) [ kdePackages.krohnkite ]; + + programs.plasma.configFile."kwinrc" = lib.mkIf (cfg.kwin.scripts.krohnkite.enable != null) { + Plugins.krohnkiteEnabled = cfg.kwin.scripts.krohnkite.enable; + Script-krohnkite = + let + gaps = cfg.kwin.scripts.krohnkite.settings.gaps; + layouts = cfg.kwin.scripts.krohnkite.settings.layouts.enabled; + findLayout = name: lib.findFirst (layout: layout.name == name) layouts; + in + { + screenGapTop = gaps.top; + screenGapLeft = gaps.left; + screenGapRight = gaps.right; + screenGapBottom = gaps.bottom; + tileLayoutGap = gaps.tiles; + + limitTileWidth = cfg.kwin.scripts.krohnkite.settings.tileWidthLimit.enable; + limitTileWidthRatio = cfg.kwin.scripts.krohnkite.settings.tileWidthLimit.ratio; + + enableBTreeLayout = isLayoutEnabled "btree"; + enableColumnsLayout = isLayoutEnabled "column"; + columnsBalanced = getLayoutSetting (findLayout "column") "balanced"; + + enableFloatingLayout = isLayoutEnabled "floating"; + enableMonocleLayout = isLayoutEnabled "monocle"; + monocleMaximize = getLayoutSetting (findLayout "monocle") "maximize"; + + enableQuarterLayout = isLayoutEnabled "quarter"; + enableSpiralLayout = isLayoutEnabled "spiral"; + enableSpreadLayout = isLayoutEnabled "spread"; + enableStackedLayout = isLayoutEnabled "stacked"; + enableStairLayout = isLayoutEnabled "stair"; + enableThreeColumnLayout = isLayoutEnabled "threeColumn"; + enableTileLayout = isLayoutEnabled "tile"; + + layoutPerActivity = cfg.kwin.scripts.krohnkite.settings.layouts.layoutPerActivity; + layoutPerDesktop = cfg.kwin.scripts.krohnkite.settings.layouts.layoutPerDesktop; }; - }; - } - ); + }; + }; } From 36d5f5c57eb645bca8e2706cbbcf17dc8804d62a Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Tue, 3 Dec 2024 17:22:02 +0530 Subject: [PATCH 08/12] Optimize --- modules/scripts/tiling/krohnkite.nix | 47 +++++++++++++++------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/modules/scripts/tiling/krohnkite.nix b/modules/scripts/tiling/krohnkite.nix index e2e40ab9..d92751a6 100644 --- a/modules/scripts/tiling/krohnkite.nix +++ b/modules/scripts/tiling/krohnkite.nix @@ -73,8 +73,13 @@ let description = description; }; - getLayoutSetting = - layout: key: + findLayoutSetting = + name: key: + let + layout = lib.findFirst ( + layout: layout.name == name + ) cfg.kwin.scripts.krohnkite.settings.layouts.enabled; + in lib.getAttrFromPath [ "options" key @@ -83,6 +88,23 @@ let isLayoutEnabled = name: lib.any (layout: layout.name == name) cfg.kwin.scripts.krohnkite.settings.layouts.enabled; + + serializeLayouts = + layouts: + let + toLayoutEntry = + layout: + { + "enable${lib.capitalize layout}" = isLayoutEnabled layout; + } + // ( + if isLayoutEnabled layout then + lib.getAttrFromPath [ "options" ] (lib.findFirst (l: l.name == layout) layouts) // { } + else + { } + ); + in + lib.foldl' lib.recursiveUpdate { } (lib.map toLayoutEntry krohnkiteSupportedLayouts); in { options.programs.plasma.kwin.scripts.krohnkite = with lib.types; { @@ -145,10 +167,9 @@ in Script-krohnkite = let gaps = cfg.kwin.scripts.krohnkite.settings.gaps; - layouts = cfg.kwin.scripts.krohnkite.settings.layouts.enabled; - findLayout = name: lib.findFirst (layout: layout.name == name) layouts; in - { + serializeLayouts cfg.kwin.scripts.krohnkite.settings.layouts.enabled + // { screenGapTop = gaps.top; screenGapLeft = gaps.left; screenGapRight = gaps.right; @@ -158,22 +179,6 @@ in limitTileWidth = cfg.kwin.scripts.krohnkite.settings.tileWidthLimit.enable; limitTileWidthRatio = cfg.kwin.scripts.krohnkite.settings.tileWidthLimit.ratio; - enableBTreeLayout = isLayoutEnabled "btree"; - enableColumnsLayout = isLayoutEnabled "column"; - columnsBalanced = getLayoutSetting (findLayout "column") "balanced"; - - enableFloatingLayout = isLayoutEnabled "floating"; - enableMonocleLayout = isLayoutEnabled "monocle"; - monocleMaximize = getLayoutSetting (findLayout "monocle") "maximize"; - - enableQuarterLayout = isLayoutEnabled "quarter"; - enableSpiralLayout = isLayoutEnabled "spiral"; - enableSpreadLayout = isLayoutEnabled "spread"; - enableStackedLayout = isLayoutEnabled "stacked"; - enableStairLayout = isLayoutEnabled "stair"; - enableThreeColumnLayout = isLayoutEnabled "threeColumn"; - enableTileLayout = isLayoutEnabled "tile"; - layoutPerActivity = cfg.kwin.scripts.krohnkite.settings.layouts.layoutPerActivity; layoutPerDesktop = cfg.kwin.scripts.krohnkite.settings.layouts.layoutPerDesktop; }; From 910003e3cef0bcc118e7e05fdf71998ef4966055 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Tue, 3 Dec 2024 18:02:28 +0530 Subject: [PATCH 09/12] Update layouts --- modules/scripts/tiling/krohnkite.nix | 66 ++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/modules/scripts/tiling/krohnkite.nix b/modules/scripts/tiling/krohnkite.nix index d92751a6..1b200444 100644 --- a/modules/scripts/tiling/krohnkite.nix +++ b/modules/scripts/tiling/krohnkite.nix @@ -29,23 +29,56 @@ let }; krohnkiteSupportedLayouts = [ - "btree" - "monocle" - "column" - "floating" - "quarter" - "spiral" - "threeColumn" - "tile" - "stacked" - "spread" - "stair" + { + value = "btree"; + label = "BTreeLayout"; + } + { + value = "monocle"; + label = "MonocleLayout"; + } + { + value = "column"; + label = "ColumnsLayout"; + } + { + value = "floating"; + label = "FloatingLayout"; + } + { + value = "quarter"; + label = "QuarterLayout"; + } + { + value = "spiral"; + label = "SpiralLayout"; + } + { + value = "threeColumn"; + label = "ThreeColumnLayout"; + } + { + value = "tile"; + label = "TileLayout"; + } + { + value = "stacked"; + label = "StackedLayout"; + } + { + value = "spread"; + label = "SpreadLayout"; + } + { + value = "stair"; + label = "StairLayout"; + } ]; krohnkiteLayouts = lib.types.submodule { options = { name = lib.mkOption { - type = with lib.types; enum krohnkiteSupportedLayouts; + type = with lib.types; enum (lib.lists.forEach krohnkiteSupportedLayouts (x: x.value)); description = "The name of the layout."; }; @@ -95,11 +128,11 @@ let toLayoutEntry = layout: { - "enable${lib.capitalize layout}" = isLayoutEnabled layout; + "enable${layout.label}" = isLayoutEnabled layout.value; } // ( - if isLayoutEnabled layout then - lib.getAttrFromPath [ "options" ] (lib.findFirst (l: l.name == layout) layouts) // { } + if isLayoutEnabled layout.value then + lib.getAttrFromPath [ "options" ] (lib.findFirst (l: l.name == layout.value) layouts) // { } else { } ); @@ -178,9 +211,6 @@ in limitTileWidth = cfg.kwin.scripts.krohnkite.settings.tileWidthLimit.enable; limitTileWidthRatio = cfg.kwin.scripts.krohnkite.settings.tileWidthLimit.ratio; - - layoutPerActivity = cfg.kwin.scripts.krohnkite.settings.layouts.layoutPerActivity; - layoutPerDesktop = cfg.kwin.scripts.krohnkite.settings.layouts.layoutPerDesktop; }; }; }; From 5c6ba86859d954ace3d789911ca4329dd551fd7a Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Tue, 3 Dec 2024 21:23:49 +0530 Subject: [PATCH 10/12] Add more options --- modules/scripts/tiling/krohnkite.nix | 116 ++++++++++++++++++++------- 1 file changed, 86 insertions(+), 30 deletions(-) diff --git a/modules/scripts/tiling/krohnkite.nix b/modules/scripts/tiling/krohnkite.nix index 1b200444..3f270c06 100644 --- a/modules/scripts/tiling/krohnkite.nix +++ b/modules/scripts/tiling/krohnkite.nix @@ -83,8 +83,8 @@ let }; options = lib.mkOption { - type = with lib.types; attrsOf (with lib.types; anything); - default = { }; + type = with lib.types; nullOr (attrsOf (with lib.types; anything)); + default = null; example = { maximize = true; }; @@ -106,35 +106,39 @@ let description = description; }; - findLayoutSetting = - name: key: - let - layout = lib.findFirst ( - layout: layout.name == name - ) cfg.kwin.scripts.krohnkite.settings.layouts.enabled; - in - lib.getAttrFromPath [ - "options" - key - ] layout - // null; + convertListToString = list: if list == null then null else builtins.concatStringsSep "," list; + + mkFilterOption = + description: default: example: + lib.mkOption { + type = with lib.types; nullOr (listOf str); + default = default; + example = example; + description = description; + apply = convertListToString; + }; + + checkIfString = v: if lib.isString v then v else v.name; isLayoutEnabled = - name: lib.any (layout: layout.name == name) cfg.kwin.scripts.krohnkite.settings.layouts.enabled; + name: lib.any (l: (checkIfString l) == name) cfg.kwin.scripts.krohnkite.settings.layouts.enabled; serializeLayouts = layouts: let toLayoutEntry = layout: + let + layoutEnabled = isLayoutEnabled layout.value; + in { "enable${layout.label}" = isLayoutEnabled layout.value; } // ( - if isLayoutEnabled layout.value then - lib.getAttrFromPath [ "options" ] (lib.findFirst (l: l.name == layout.value) layouts) // { } - else - { } + let + layoutObj = lib.findFirst (l: (checkIfString l) == layout.value) layouts; + in + if isLayoutEnabled layout.value then lib.attrByPath [ "options" ] { } layoutObj // { } else { } ); in lib.foldl' lib.recursiveUpdate { } (lib.map toLayoutEntry krohnkiteSupportedLayouts); @@ -168,25 +172,66 @@ in layouts = { enabled = lib.mkOption { - type = with lib.types; listOf krohnkiteLayouts; + type = + with lib.types; + listOf (either (enum (lib.lists.forEach krohnkiteSupportedLayouts (x: x.value))) krohnkiteLayouts); default = [ ]; example = [ + "floating" { name = "monocle"; options = { maximize = true; }; } - { - name = "column"; - options = { - balanced = true; - }; - } ]; - description = "List of layout configurations for Krohnkite."; + description = '' + List of layout configurations for Krohnkite. This can be: + - An array of strings representing valid layout names, like `["floating" "monocle"]`. Valid values include: + ${lib.concatStringsSep ", " (lib.lists.forEach krohnkiteSupportedLayouts (x: x.value))}. + - An array of objects with layout-specific options: + ``` + [ + { name = "monocle"; options = { maximize = true; }; } + { name = "column"; options = { balanced = true; }; } + ] + ``` + Mixed types are also supported. + ''; }; }; + + # Tiling options + maximizeSoleTile = mkNullableOption bool "Whether to maximize the sole window" true; + keepFloatAbove = mkNullableOption bool "Whether to keep floating windows above tiled windows" true; + keepTilingOnDrag = + mkNullableOption bool "Always preserve the tiling status of the window upon dragging" + true; + preventMinimize = mkNullableOption bool "Prevent windows from minimizing" true; + preventProtrusion = mkNullableOption bool "Prevent window from protruding from its screen" true; + noTileBorders = mkNullableOption bool "Remove borders of tiled windows" true; + floatUtility = mkNullableOption bool "Float utility windows" true; + + # Filter rules + ignoreRoles = mkFilterOption "Ignore windows by role" [ "quake" ] [ "quake" ]; + ignoreTitles = mkFilterOption "Ignore windows by title" null [ "firefox" ]; + ignoreClasses = mkFilterOption "Ignore windows by class" [ + "krunner" + "yakuake" + "spectacle" + "kded5" + "xwaylandvideobridge" + "plasmashell" + "ksplashqml" + "org.kde.plasmashell" + "org.kde.polkit-kde-authentication-agent-1" + "org.kde.kruler" + ] [ "dialog" ]; + ignoreActivities = mkFilterOption "Disable tiling on activities" null [ "Activity1" ]; + ignoreScreens = mkFilterOption "Disable tiling on screens" null [ "Screen1" ]; + ignoreVirtualDesktops = mkFilterOption "Disable tiling on virtual desktops" null [ "Desktop_1" ]; + floatWindowsByClass = mkFilterOption "Float windows by class" null [ "dialog" ]; + floatWindowsByTitle = mkFilterOption "Float windows by title" null [ "firefox" ]; }; }; @@ -199,7 +244,9 @@ in Plugins.krohnkiteEnabled = cfg.kwin.scripts.krohnkite.enable; Script-krohnkite = let - gaps = cfg.kwin.scripts.krohnkite.settings.gaps; + settings = cfg.kwin.scripts.krohnkite.settings; + gaps = settings.gaps; + tileWidthLimit = settings.tileWidthLimit; in serializeLayouts cfg.kwin.scripts.krohnkite.settings.layouts.enabled // { @@ -209,8 +256,17 @@ in screenGapBottom = gaps.bottom; tileLayoutGap = gaps.tiles; - limitTileWidth = cfg.kwin.scripts.krohnkite.settings.tileWidthLimit.enable; - limitTileWidthRatio = cfg.kwin.scripts.krohnkite.settings.tileWidthLimit.ratio; + limitTileWidth = tileWidthLimit.enable; + limitTileWidthRatio = tileWidthLimit.ratio; + + # Tiling options + maximizeSoleTile = settings.maximizeSoleTile; + keepFloatAbove = settings.keepFloatAbove; + keepTilingOnDrag = settings.keepTilingOnDrag; + preventMinimize = settings.preventMinimize; + preventProtrusion = settings.preventProtrusion; + noTileBorders = settings.noTileBorders; + floatUtility = settings.floatUtility; }; }; }; From e669e2a126a918166e98f5f26da790c8c5dc204a Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Tue, 3 Dec 2024 23:16:45 +0530 Subject: [PATCH 11/12] Add more options --- modules/scripts/tiling/krohnkite.nix | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/scripts/tiling/krohnkite.nix b/modules/scripts/tiling/krohnkite.nix index 3f270c06..b7bbad4d 100644 --- a/modules/scripts/tiling/krohnkite.nix +++ b/modules/scripts/tiling/krohnkite.nix @@ -130,16 +130,12 @@ let layout: let layoutEnabled = isLayoutEnabled layout.value; + layoutObj = lib.findFirst (l: (checkIfString l) == layout.value) layouts; in { - "enable${layout.label}" = isLayoutEnabled layout.value; + "enable${layout.label}" = layoutEnabled; } - // ( - let - layoutObj = lib.findFirst (l: (checkIfString l) == layout.value) layouts; - in - if isLayoutEnabled layout.value then lib.attrByPath [ "options" ] { } layoutObj // { } else { } - ); + // (if layoutEnabled then lib.attrByPath [ "options" ] { } layoutObj // { } else { }); in lib.foldl' lib.recursiveUpdate { } (lib.map toLayoutEntry krohnkiteSupportedLayouts); in @@ -267,6 +263,16 @@ in preventProtrusion = settings.preventProtrusion; noTileBorders = settings.noTileBorders; floatUtility = settings.floatUtility; + + # Filter rules + ignoreRole = settings.ignoreRoles; + ignoreTitle = settings.ignoreTitles; + ignoreClass = settings.ignoreClasses; + ignoreActivity = settings.ignoreActivities; + ignoreScreen = settings.ignoreScreens; + ignoreVDesktop = settings.ignoreVirtualDesktops; + floatingClass = settings.floatWindowsByClass; + floatingTitle = settings.floatWindowsByTitle; }; }; }; From 94b19c644d7d5944b2d8fd0d4b2bf402f3089bfa Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Thu, 5 Dec 2024 00:50:14 +0530 Subject: [PATCH 12/12] Support layout specific options --- modules/scripts/tiling/krohnkite.nix | 41 ++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/modules/scripts/tiling/krohnkite.nix b/modules/scripts/tiling/krohnkite.nix index b7bbad4d..65303298 100644 --- a/modules/scripts/tiling/krohnkite.nix +++ b/modules/scripts/tiling/krohnkite.nix @@ -89,9 +89,10 @@ let maximize = true; }; description = '' - Layout-specific options. For example: - - `monocle` can have `{ maximize = true; }` - - `column` can have `{ balanced = true; }` + Layout-specific options. Supported options depend on the layout: + - `column`: `{ balanced = true; }` + - `monocle`: `{ maximize = true; minimizeRest = true; }` + - `stair`: `{ reverse = true; }` ''; }; }; @@ -123,6 +124,36 @@ let isLayoutEnabled = name: lib.any (l: (checkIfString l) == name) cfg.kwin.scripts.krohnkite.settings.layouts.enabled; + generateOptionsConfig = + layoutObj: + if layoutObj.name == "monocle" then + { + monocleMaximize = lib.attrByPath [ + "options" + "maximize" + ] false layoutObj; + monocleMinimizeRest = lib.attrByPath [ + "options" + "minimizeRest" + ] false layoutObj; + } + else if layoutObj.name == "column" then + { + columnsBalanced = lib.attrByPath [ + "options" + "balanced" + ] false layoutObj; + } + else if layoutObj.name == "stair" then + { + stairReverse = lib.attrByPath [ + "options" + "reverse" + ] false layoutObj; + } + else + { }; + serializeLayouts = layouts: let @@ -130,12 +161,12 @@ let layout: let layoutEnabled = isLayoutEnabled layout.value; - layoutObj = lib.findFirst (l: (checkIfString l) == layout.value) layouts; + layoutObj = lib.findFirst (l: (checkIfString l) == layout.value) { } layouts; in { "enable${layout.label}" = layoutEnabled; } - // (if layoutEnabled then lib.attrByPath [ "options" ] { } layoutObj // { } else { }); + // (if layoutEnabled && !lib.isString layoutObj then generateOptionsConfig layoutObj else { }); in lib.foldl' lib.recursiveUpdate { } (lib.map toLayoutEntry krohnkiteSupportedLayouts); in