Skip to content

Commit

Permalink
Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
sidmoreoss committed Dec 3, 2024
1 parent a75a88f commit 36d5f5c
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions modules/scripts/tiling/krohnkite.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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; {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
};
Expand Down

0 comments on commit 36d5f5c

Please sign in to comment.