From ba907ef7b4f5962a11c20adb4036b6ddad26a000 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 22 Jun 2025 21:13:23 +0200 Subject: ... --- accounts/gkleen@sif/niri/default.nix | 221 +++++++++++++++++------------------ 1 file changed, 108 insertions(+), 113 deletions(-) (limited to 'accounts/gkleen@sif/niri/default.nix') diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 8752f3e3..35a3d799 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -3,6 +3,7 @@ let cfg = config.programs.niri; kdl = flakeInputs.niri-flake.lib.kdl; + sleaf = name: arg: kdl.node name [arg] []; niri = cfg.package; terminal = lib.getExe config.programs.kitty.package; @@ -450,7 +451,7 @@ in { { title = ".*Passkey credentials$"; } ]; windowRuleExtra = with kdl; [ - (kdl.leaf "open-focused" false) + (sleaf "open-focused" false) ]; key = "Mod+Control+P"; app-id = "org.keepassxc.KeePassXC"; @@ -488,7 +489,7 @@ in { exec dex $HOME/.local/state/nix/profile/share/applications/kimai.desktop '')) ]; windowRuleExtra = with kdl; [ - (leaf "block-out-from" "screencast") + (sleaf "block-out-from" "screencast") ]; } ]; @@ -500,10 +501,12 @@ in { then v else null; opt-props = lib.filterAttrs (lib.const (value: value != null)); + normalize-nodes = nodes: lib.remove null (lib.flatten nodes); in - [ (flag "prefer-no-csd") + normalize-nodes [ + (flag "prefer-no-csd") - (leaf "screenshot-path" "~/screenshots/%Y-%m-%dT%H:%M:%S.png") + (sleaf "screenshot-path" "~/screenshots/%Y-%m-%dT%H:%M:%S.png") (plain "hotkey-overlay" [ (flag "skip-at-startup") @@ -511,27 +514,27 @@ in { (plain "input" [ (plain "keyboard" [ - (leaf "repeat-delay" 300) - (leaf "repeat-rate" 50) + (sleaf "repeat-delay" 300) + (sleaf "repeat-rate" 50) (plain "xkb" [ - (leaf "layout" "us,us") - (leaf "variant" "dvp,") - (leaf "options" "compose:caps,grp:win_space_toggle") + (sleaf "layout" "us,us") + (sleaf "variant" "dvp,") + (sleaf "options" "compose:caps,grp:win_space_toggle") ]) ]) (flag "workspace-auto-back-and-forth") - # (leaf "focus-follows-mouse" {}) + # (sleaf "focus-follows-mouse" {}) # (flag "warp-mouse-to-focus") # (plain "touchpad" [ (flag "off") ]) (plain "trackball" [ - (leaf "scroll-method" "on-button-down") - (leaf "scroll-button" 278) + (sleaf "scroll-method" "on-button-down") + (sleaf "scroll-button" 278) ]) (plain "touch" [ - (leaf "map-to-output" "eDP-1") + (sleaf "map-to-output" "eDP-1") ]) ]) @@ -539,7 +542,7 @@ in { (plain "hot-corners" [(flag "off")]) ]) - (plain "environment" (lib.mapAttrsToList leaf { + (plain "environment" (lib.mapAttrsToList sleaf { NIXOS_OZONE_WL = "1"; QT_QPA_PLATFORM = "wayland"; QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; @@ -552,47 +555,47 @@ in { SUDO_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass; })) - (node "output" "eDP-1" [ - (leaf "scale" 1.5) - (leaf "position" { x = 0; y = 0; }) + (node "output" ["eDP-1"] [ + (sleaf "scale" 1.5) + (sleaf "position" { x = 0; y = 0; }) ]) - (node "output" "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" [ - (leaf "scale" 1.5) - (leaf "position" { x = 2560; y = 0; }) + (node "output" ["Ancor Communications Inc ASUS PB287Q 0x0000DD9B"] [ + (sleaf "scale" 1.5) + (sleaf "position" { x = 2560; y = 0; }) ]) - (node "output" "HP Inc. HP 727pu CN4417143K" [ - (leaf "mode" "2560x1440@119.998") - (leaf "scale" 1) - (leaf "position" { x = 2560; y = 0; }) + (node "output" ["HP Inc. HP 727pu CN4417143K"] [ + (sleaf "mode" "2560x1440@119.998") + (sleaf "scale" 1) + (sleaf "position" { x = 2560; y = 0; }) (flag "variable-refresh-rate") ]) (plain "debug" [ - (leaf "render-drm-device" "/dev/dri/by-path/pci-0000:00:02.0-render") + (sleaf "render-drm-device" "/dev/dri/by-path/pci-0000:00:02.0-render") ]) (plain "animations" [ - (leaf "slowdown" 0.5) + (sleaf "slowdown" 0.5) (plain "workspace-switch" [(flag "off")]) ]) (plain "layout" [ - (leaf "gaps" 8) + (sleaf "gaps" 8) (plain "struts" [ - (leaf "left" 26) - (leaf "right" 26) - (leaf "top" 0) - (leaf "bottom" 0) + (sleaf "left" 26) + (sleaf "right" 26) + (sleaf "top" 0) + (sleaf "bottom" 0) ]) (plain "border" [ - (leaf "width" 2) - (leaf "active-gradient" { + (sleaf "width" 2) + (sleaf "active-gradient" { from = "hsla(195 100% 45% 1)"; to = "hsla(155 100% 37.5% 1)"; angle = 29; relative-to = "workspace-view"; }) - (leaf "inactive-gradient" { + (sleaf "inactive-gradient" { from = "hsla(0 0% 27.7% 1)"; to = "hsla(0 0% 23% 1)"; angle = 29; @@ -603,29 +606,29 @@ in { (flag "off") ]) - (plain "preset-column-widths" (map (prop: leaf "proportion" prop) [ + (plain "preset-column-widths" (map (prop: sleaf "proportion" prop) [ (1. / 4.) (1. / 3.) (1. / 2.) (2. / 3.) (3. / 4.) (1.) ])) - (plain "default-column-width" [ (leaf "proportion" (1. / 2.)) ]) - (plain "preset-window-heights" (map (prop: leaf "proportion" prop) [ + (plain "default-column-width" [ (sleaf "proportion" (1. / 2.)) ]) + (plain "preset-window-heights" (map (prop: sleaf "proportion" prop) [ (1. / 3.) (1. / 2.) (2. / 3.) (1.) ])) (flag "always-center-single-column") (plain "tab-indicator" [ - (leaf "gap" 4) - (leaf "width" 8) - (leaf "gaps-between-tabs" 4) + (sleaf "gap" 4) + (sleaf "width" 8) + (sleaf "gaps-between-tabs" 4) (flag "place-within-column") - (leaf "length" { total-proportion = 1.; }) - (leaf "active-gradient" { + (sleaf "length" { total-proportion = 1.; }) + (sleaf "active-gradient" { from = "hsla(195 100% 60% 0.75)"; to = "hsla(155 100% 50% 0.75)"; angle = 29; relative-to = "workspace-view"; }) - (leaf "inactive-gradient" { + (sleaf "inactive-gradient" { from = "hsla(0 0% 42% 0.66)"; to = "hsla(0 0% 35% 0.66)"; angle = 29; @@ -639,129 +642,121 @@ in { ]) (map (name: - (node "workspace" name [ - (leaf "open-on-output" "eDP-1") + (node "workspace" [name] [ + (sleaf "open-on-output" "eDP-1") ]) ) (map ({name, ...}: name) cfg.scratchspaces)) (map (name: - (leaf "workspace" name) + (sleaf "workspace" name) ) ["comm" "web" "vid" "bmr"]) (plain "window-rule" [ - (leaf "clip-to-geometry" true) + (sleaf "clip-to-geometry" true) ]) (plain "window-rule" [ - (leaf "match" { is-floating = true; }) - (leaf "geometry-corner-radius" 8) + (sleaf "match" { is-floating = true; }) + (sleaf "geometry-corner-radius" 8) (plain "shadow" [ (flag "on") ]) ]) (plain "window-rule" [ - (leaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; }) - (leaf "block-out-from" "screencast") + (sleaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; }) + (sleaf "block-out-from" "screencast") ]) - (plain "window-rule" [ + (plain "window-rule" (normalize-nodes [ (map (title: - (leaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; inherit title; }) + (sleaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; inherit title; }) ) ["^Unlock Database.*" "^Access Request.*" ".*Passkey credentials$" "Browser Access Request$"]) - (leaf "open-focused" true) - (leaf "open-floating" true) - ]) + (sleaf "open-focused" true) + (sleaf "open-floating" true) + ])) (map ({ name, match, exclude, windowRuleExtra, ... }: - (optional-node (match != []) (plain "window-rule" [ - (map (leaf "match") match) - (map (leaf "exclude") exclude) - (leaf "open-on-workspace" name) - (leaf "open-maximized" true) + (optional-node (match != []) (plain "window-rule" (normalize-nodes [ + (map (sleaf "match") match) + (map (sleaf "exclude") exclude) + (sleaf "open-on-workspace" name) + (sleaf "open-maximized" true) windowRuleExtra - ])) + ]))) ) cfg.scratchspaces) (plain "window-rule" [ - (leaf "match" { app-id = "^emacs$"; }) - (leaf "match" { app-id = "^firefox$"; }) - (plain "default-column-width" [(leaf "proportion" (2. / 3.))]) + (sleaf "match" { app-id = "^emacs$"; }) + (sleaf "match" { app-id = "^firefox$"; }) + (plain "default-column-width" [(sleaf "proportion" (2. / 3.))]) ]) (plain "window-rule" [ - (leaf "match" { app-id = "^kitty$"; }) - (leaf "match" { app-id = "^kitty-play$"; }) - (plain "default-column-width" [(leaf "proportion" (1. / 3.))]) + (sleaf "match" { app-id = "^kitty$"; }) + (sleaf "match" { app-id = "^kitty-play$"; }) + (plain "default-column-width" [(sleaf "proportion" (1. / 3.))]) ]) (plain "window-rule" [ - (leaf "match" { app-id = "^thunderbird$"; }) - (leaf "match" { app-id = "^Element$"; }) - (leaf "match" { app-id = "^chrome-web\.openrainbow\.com__-Default$"; }) - (leaf "open-on-workspace" "comm") + (sleaf "match" { app-id = "^thunderbird$"; }) + (sleaf "match" { app-id = "^Element$"; }) + (sleaf "match" { app-id = "^chrome-web\.openrainbow\.com__-Default$"; }) + (sleaf "open-on-workspace" "comm") ]) (plain "window-rule" [ - (leaf "match" { app-id = "^firefox$"; }) - (leaf "open-on-workspace" "web") - (leaf "open-maximized" true) + (sleaf "match" { app-id = "^firefox$"; }) + (sleaf "open-on-workspace" "web") + (sleaf "open-maximized" true) ]) (plain "window-rule" [ - (leaf "match" { app-id = "^mpv$"; }) - (leaf "open-on-workspace" "vid") - (plain "default-column-width" [(leaf "proportion" 1.)]) + (sleaf "match" { app-id = "^mpv$"; }) + (sleaf "open-on-workspace" "vid") + (plain "default-column-width" [(sleaf "proportion" 1.)]) ]) (plain "window-rule" [ - (leaf "match" { app-id = "^kitty-play$"; }) - (leaf "open-on-workspace" "vid") - (leaf "open-focused" false) + (sleaf "match" { app-id = "^kitty-play$"; }) + (sleaf "open-on-workspace" "vid") + (sleaf "open-focused" false) ]) (plain "window-rule" [ - (leaf "match" { app-id = "^chrome-audiobookshelf\.yggdrasil\.li__-Default$"; }) - (leaf "match" { app-id = "^YouTube Music Desktop App$"; }) - (leaf "open-on-workspace" "vid") + (sleaf "match" { app-id = "^chrome-audiobookshelf\.yggdrasil\.li__-Default$"; }) + (sleaf "match" { app-id = "^YouTube Music Desktop App$"; }) + (sleaf "open-on-workspace" "vid") ]) (plain "window-rule" [ - (leaf "match" { app-id = "^pdfpc$"; }) - (plain "default-column-width" [(leaf "proportion" 1.)]) + (sleaf "match" { app-id = "^pdfpc$"; }) + (plain "default-column-width" [(sleaf "proportion" 1.)]) ]) (plain "window-rule" [ - (leaf "match" { app-id = "^pdfpc$"; title = "^.*presentation.*$"; }) - (plain "default-column-width" [(leaf "proportion" 1.)]) - (leaf "open-fullscreen" true) - (leaf "open-on-workspace" "bmr") - (leaf "open-focused" false) + (sleaf "match" { app-id = "^pdfpc$"; title = "^.*presentation.*$"; }) + (plain "default-column-width" [(sleaf "proportion" 1.)]) + (sleaf "open-fullscreen" true) + (sleaf "open-on-workspace" "bmr") + (sleaf "open-focused" false) ]) - (plain "window-rule" [ - (map (leaf "match") [ + (plain "window-rule" (normalize-nodes [ + (map (sleaf "match") [ { app-id = "^Gimp-"; title = "^Quit GIMP$"; } { app-id = "^org\\.kde\\.polkit-kde-authentication-agent-1$"; } { app-id = "^xdg-desktop-portal-gtk$"; } ]) - (leaf "open-floating" true) - ]) + (sleaf "open-floating" true) + ])) (plain "window-rule" [ - (leaf "match" { app-id = "^org\\.pwmt\\.zathura$"; }) - (leaf "match" { app-id = "^evince$"; }) - (leaf "match" { app-id = "^org\\.gnome\\.Papers$"; }) - (leaf "default-column-display" "tabbed") + (sleaf "match" { app-id = "^org\\.pwmt\\.zathura$"; }) + (sleaf "match" { app-id = "^evince$"; }) + (sleaf "match" { app-id = "^org\\.gnome\\.Papers$"; }) + (sleaf "default-column-display" "tabbed") ]) (plain "layer-rule" [ - (leaf "match" { namespace = "^notifications$"; }) - (leaf "match" { namespace = "^waybar$"; }) - (leaf "match" { namespace = "^launcher$"; }) - (leaf "block-out-from" "screencast") + (sleaf "match" { namespace = "^notifications$"; }) + (sleaf "match" { namespace = "^waybar$"; }) + (sleaf "match" { namespace = "^launcher$"; }) + (sleaf "block-out-from" "screencast") ]) (plain "binds" (let - bind = name: cfg: node name (opt-props { - cooldown-ms = cfg.cooldown-ms or null; - } - // (lib.optionalAttrs (!(cfg.repeat or true)) { - repeat = false; - }) - // (lib.optionalAttrs (cfg.allow-when-locked or false) { - allow-when-locked = true; - })) (lib.mapAttrsToList leaf (lib.removeAttrs cfg.action ["__functor"])); + bind = name: cfg: node name [(lib.removeAttrs cfg ["action"])] (lib.mapAttrsToList leaf (lib.removeAttrs cfg.action ["__functor"])); in - [ + normalize-nodes [ (lib.mapAttrsToList bind (with config.lib.niri.actions; { "Mod+Slash".action = show-hotkey-overlay; -- cgit v1.2.3