From d8427e213a7cd44016c48771e1c3f0282f592508 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 12 Jan 2025 13:17:53 -0600 Subject: [PATCH] niri: update rules to nix syntax Signed-off-by: Myned --- options/custom/desktops/niri/default.nix | 46 +++--------------------- options/custom/desktops/niri/rules.nix | 33 +++++++++++++++-- 2 files changed, 35 insertions(+), 44 deletions(-) diff --git a/options/custom/desktops/niri/default.nix b/options/custom/desktops/niri/default.nix index a0494bd..7a82c60 100644 --- a/options/custom/desktops/niri/default.nix +++ b/options/custom/desktops/niri/default.nix @@ -61,48 +61,10 @@ in { # https://github.com/YaLTeR/niri/wiki/Configuration:-Overview # HACK: Prepend validated kdl config not currently implemented in settings module for e.g. custom build # https://github.com/sodiboo/niri-flake/blob/main/settings.nix - config = let - # BUG: Fixed width may not take borders into account - # https://github.com/YaLTeR/niri/issues/269 - pip = with config.custom; rec { - x = gap; - y = gap; - w = builtins.floor (width * 0.3 - gap); # 30% - h = builtins.floor (w * 9 / 16); # 16:9 - }; - in - with inputs.niri-flake.lib; - (internal.settings-module {config = hm;}).options.programs.niri.config.default - # https://github.com/sodiboo/niri-flake/blob/main/default-config.kdl.nix - ++ (with kdl; [ - # TODO: Migrate to window-rules when released - # https://github.com/YaLTeR/niri/pull/871 - (plain "window-rule" [ - (leaf "match" {is-floating = true;}) - (plain "border" [(flag "off")]) - (plain "focus-ring" [(flag "off")]) - ]) - - (plain "window-rule" [ - (leaf "match" {title = "^Picture.in.[Pp]icture$";}) - - (leaf "default-floating-position" { - x = pip.x; - y = pip.y; - relative-to = "top-right"; - }) - - (plain "default-column-width" [(leaf "fixed" (pip.w))]) - (plain "default-window-height" [(leaf "fixed" (pip.h))]) - (leaf "open-floating" true) - (leaf "open-focused" false) - ]) - - (plain "window-rule" [ - (leaf "match" {app-id = "^(sdl-|wl|x)freerdp$";}) - (leaf "open-floating" false) - ]) - ]); + config = with inputs.niri-flake.lib; + (internal.settings-module {config = hm;}).options.programs.niri.config.default + # https://github.com/sodiboo/niri-flake/blob/main/default-config.kdl.nix + ++ (with kdl; []); # https://github.com/YaLTeR/niri/wiki/Configuration:-Debug-Options # https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsdebug diff --git a/options/custom/desktops/niri/rules.nix b/options/custom/desktops/niri/rules.nix index 2ae2587..8246356 100644 --- a/options/custom/desktops/niri/rules.nix +++ b/options/custom/desktops/niri/rules.nix @@ -42,6 +42,14 @@ in { clip-to-geometry = true; } + { + # Floating + matches = [{is-floating = true;}]; + + border.enable = false; + focus-ring.enable = false; + } + { # Startup #?? <= 60 secs after niri launches @@ -139,10 +147,30 @@ in { #// open-on-workspace = "2"; } - { + (let + # BUG: Fixed width may not take borders into account + # https://github.com/YaLTeR/niri/issues/269 + pip = with config.custom; rec { + x = gap; + y = gap; + w = builtins.floor (width * 0.3 - gap); # 30% + h = builtins.floor (w * 9 / 16); # 16:9 + }; + in { # PiP matches = [{title = "^Picture.in.[Pp]icture$";}]; - } + + default-floating-position = { + x = pip.x; + y = pip.y; + relative-to = "top-right"; + }; + + default-column-width.fixed = pip.w; + default-window-height.fixed = pip.h; + open-floating = true; + open-focused = false; + }) { # Terminals @@ -170,6 +198,7 @@ in { {app-id = "^virt-manager$";} ]; + open-floating = false; #// open-on-workspace = "1"; }