diff options
Diffstat (limited to 'accounts/gkleen@sif/niri/default.nix')
-rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 326 |
1 files changed, 206 insertions, 120 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 924d3843..35a3d799 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix | |||
@@ -3,6 +3,7 @@ let | |||
3 | cfg = config.programs.niri; | 3 | cfg = config.programs.niri; |
4 | 4 | ||
5 | kdl = flakeInputs.niri-flake.lib.kdl; | 5 | kdl = flakeInputs.niri-flake.lib.kdl; |
6 | sleaf = name: arg: kdl.node name [arg] []; | ||
6 | 7 | ||
7 | niri = cfg.package; | 8 | niri = cfg.package; |
8 | terminal = lib.getExe config.programs.kitty.package; | 9 | terminal = lib.getExe config.programs.kitty.package; |
@@ -35,7 +36,11 @@ let | |||
35 | if jq -e '.is_focused' <<<"$window_json" >/dev/null; then | 36 | if jq -e '.is_focused' <<<"$window_json" >/dev/null; then |
36 | niri msg action focus-workspace-previous | 37 | niri msg action focus-workspace-previous |
37 | else | 38 | else |
38 | niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" | 39 | if [[ $(jq -r --arg workspace_name "$workspace_name" 'map(select(.name == $workspace_name)) | .[0].is_focused' <<<"$workspaces_json") != "true" ]] && [[ $(jq -r --arg workspace_name "$workspace_name" 'map(select(.name == $workspace_name)) | .[0].id' <<<"$workspaces_json") = $(jq -r '.workspace_id' <<<"$window_json") ]]; then |
40 | niri msg action focus-workspace "$workspace_name" | ||
41 | else | ||
42 | niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" | ||
43 | fi | ||
39 | fi | 44 | fi |
40 | exit 0 | 45 | exit 0 |
41 | fi | 46 | fi |
@@ -45,7 +50,6 @@ let | |||
45 | ''; | 50 | ''; |
46 | }; | 51 | }; |
47 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); | 52 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); |
48 | focus-or-spawn-action-app_id = app_id: focus-or-spawn-action ''select(.app_id == "${app_id}")''; | ||
49 | 53 | ||
50 | with_adjacent_workspace = pkgs.writeShellApplication { | 54 | with_adjacent_workspace = pkgs.writeShellApplication { |
51 | name = "with-adjacent-workspace"; | 55 | name = "with-adjacent-workspace"; |
@@ -84,7 +88,7 @@ let | |||
84 | }; | 88 | }; |
85 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^${lib.concatMapStringsSep "|" ({ name, ...}: name) cfg.scratchspaces}$"; | 89 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^${lib.concatMapStringsSep "|" ({ name, ...}: name) cfg.scratchspaces}$"; |
86 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | 90 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; |
87 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | 91 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}, "focus": true}}}''; |
88 | 92 | ||
89 | with_unnamed_workspace = pkgs.writeShellApplication { | 93 | with_unnamed_workspace = pkgs.writeShellApplication { |
90 | name = "with-unnamed-workspace"; | 94 | name = "with-unnamed-workspace"; |
@@ -131,7 +135,7 @@ let | |||
131 | 135 | ||
132 | windows_json="$(niri msg -j windows)" | 136 | windows_json="$(niri msg -j windows)" |
133 | active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" | 137 | active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" |
134 | window_ix="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\u0000icon\u001f\(.app_id)"' <<<"$windows_json" | fuzzel --log-level=warning --dmenu --index)" | 138 | window_ix="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\u0000icon\u001f\(.app_id)"' <<<"$windows_json" | fuzzel --width=60 --log-level=warning --dmenu --index)" |
135 | # shellcheck disable=SC2016 | 139 | # shellcheck disable=SC2016 |
136 | window_json="$(gojq -rc --arg active_workspace "$active_workspace" --arg window_ix "$window_ix" 'map(select('"$window_select"')) | .[($window_ix | tonumber)]' <<<"$windows_json")" | 140 | window_json="$(gojq -rc --arg active_workspace "$active_workspace" --arg window_ix "$window_ix" 'map(select('"$window_select"')) | .[($window_ix | tonumber)]' <<<"$windows_json")" |
137 | 141 | ||
@@ -141,6 +145,25 @@ let | |||
141 | ''; | 145 | ''; |
142 | }; | 146 | }; |
143 | with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); | 147 | with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); |
148 | |||
149 | with_predicate_window = pred: pkgs.writeShellApplication { | ||
150 | name = "with-predicate-window"; | ||
151 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
152 | text = '' | ||
153 | action="$1" | ||
154 | shift | ||
155 | |||
156 | windows_json="$(niri msg -j windows)" | ||
157 | window_json="$(gojq -rc 'map(select(${pred})) | .[0]' <<<"$windows_json")" | ||
158 | |||
159 | [[ -z "$window_json" || $window_json = "null" ]] && exit 1 | ||
160 | |||
161 | jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET" | ||
162 | ''; | ||
163 | }; | ||
164 | |||
165 | with-urgent-window-action = config.lib.niri.actions.spawn (lib.getExe (with_predicate_window ".is_urgent")); | ||
166 | with-focused-window-action = config.lib.niri.actions.spawn (lib.getExe (with_predicate_window ".is_focused")); | ||
144 | in { | 167 | in { |
145 | imports = [ | 168 | imports = [ |
146 | ./waybar.nix | 169 | ./waybar.nix |
@@ -171,6 +194,17 @@ in { | |||
171 | type = lib.types.nullOr lib.types.str; | 194 | type = lib.types.nullOr lib.types.str; |
172 | default = null; | 195 | default = null; |
173 | }; | 196 | }; |
197 | moveKey = lib.mkOption { | ||
198 | type = lib.types.nullOr lib.types.str; | ||
199 | default = let | ||
200 | keys = lib.splitString "+" config.key; | ||
201 | defMoveKey = lib.concatStringsSep "+" (lib.flatten [ | ||
202 | (lib.take (lib.length keys - 1) keys) | ||
203 | ["Shift"] | ||
204 | (lib.takeEnd 1 keys) | ||
205 | ]); | ||
206 | in if config.key == null then null else defMoveKey; | ||
207 | }; | ||
174 | spawn = lib.mkOption { | 208 | spawn = lib.mkOption { |
175 | type = lib.types.nullOr (lib.types.listOf lib.types.str); | 209 | type = lib.types.nullOr (lib.types.listOf lib.types.str); |
176 | default = null; | 210 | default = null; |
@@ -416,8 +450,8 @@ in { | |||
416 | { title = "^Access Request.*"; } | 450 | { title = "^Access Request.*"; } |
417 | { title = ".*Passkey credentials$"; } | 451 | { title = ".*Passkey credentials$"; } |
418 | ]; | 452 | ]; |
419 | windowRuleExtra = [ | 453 | windowRuleExtra = with kdl; [ |
420 | (kdl.leaf "open-focused" false) | 454 | (sleaf "open-focused" false) |
421 | ]; | 455 | ]; |
422 | key = "Mod+Control+P"; | 456 | key = "Mod+Control+P"; |
423 | app-id = "org.keepassxc.KeePassXC"; | 457 | app-id = "org.keepassxc.KeePassXC"; |
@@ -444,6 +478,20 @@ in { | |||
444 | app-id = "com.github.wwmm.easyeffects"; | 478 | app-id = "com.github.wwmm.easyeffects"; |
445 | spawn = [ "easyeffects" ]; | 479 | spawn = [ "easyeffects" ]; |
446 | } | 480 | } |
481 | { name = "time"; | ||
482 | key = "Mod+Control+K"; | ||
483 | app-id = "chrome-kimai.yggdrasil.li__-Default"; | ||
484 | spawn = [ (toString (pkgs.resholve.writeScript "kimai" { | ||
485 | interpreter = pkgs.runtimeShell; | ||
486 | inputs = [ pkgs.dex ]; | ||
487 | execer = [ "cannot:${lib.getExe pkgs.dex}" ]; | ||
488 | } '' | ||
489 | exec dex $HOME/.local/state/nix/profile/share/applications/kimai.desktop | ||
490 | '')) ]; | ||
491 | windowRuleExtra = with kdl; [ | ||
492 | (sleaf "block-out-from" "screencast") | ||
493 | ]; | ||
494 | } | ||
447 | ]; | 495 | ]; |
448 | programs.niri.config = | 496 | programs.niri.config = |
449 | let | 497 | let |
@@ -453,10 +501,12 @@ in { | |||
453 | then v | 501 | then v |
454 | else null; | 502 | else null; |
455 | opt-props = lib.filterAttrs (lib.const (value: value != null)); | 503 | opt-props = lib.filterAttrs (lib.const (value: value != null)); |
504 | normalize-nodes = nodes: lib.remove null (lib.flatten nodes); | ||
456 | in | 505 | in |
457 | [ (flag "prefer-no-csd") | 506 | normalize-nodes [ |
507 | (flag "prefer-no-csd") | ||
458 | 508 | ||
459 | (leaf "screenshot-path" "~/screenshots/%Y-%m-%dT%H:%M:%S.png") | 509 | (sleaf "screenshot-path" "~/screenshots/%Y-%m-%dT%H:%M:%S.png") |
460 | 510 | ||
461 | (plain "hotkey-overlay" [ | 511 | (plain "hotkey-overlay" [ |
462 | (flag "skip-at-startup") | 512 | (flag "skip-at-startup") |
@@ -464,27 +514,27 @@ in { | |||
464 | 514 | ||
465 | (plain "input" [ | 515 | (plain "input" [ |
466 | (plain "keyboard" [ | 516 | (plain "keyboard" [ |
467 | (leaf "repeat-delay" 300) | 517 | (sleaf "repeat-delay" 300) |
468 | (leaf "repeat-rate" 50) | 518 | (sleaf "repeat-rate" 50) |
469 | 519 | ||
470 | (plain "xkb" [ | 520 | (plain "xkb" [ |
471 | (leaf "layout" "us,us") | 521 | (sleaf "layout" "us,us") |
472 | (leaf "variant" "dvp,") | 522 | (sleaf "variant" "dvp,") |
473 | (leaf "options" "compose:caps,grp:win_space_toggle") | 523 | (sleaf "options" "compose:caps,grp:win_space_toggle") |
474 | ]) | 524 | ]) |
475 | ]) | 525 | ]) |
476 | 526 | ||
477 | (flag "workspace-auto-back-and-forth") | 527 | (flag "workspace-auto-back-and-forth") |
478 | # (leaf "focus-follows-mouse" {}) | 528 | # (sleaf "focus-follows-mouse" {}) |
479 | # (flag "warp-mouse-to-focus") | 529 | # (flag "warp-mouse-to-focus") |
480 | 530 | ||
481 | # (plain "touchpad" [ (flag "off") ]) | 531 | # (plain "touchpad" [ (flag "off") ]) |
482 | (plain "trackball" [ | 532 | (plain "trackball" [ |
483 | (leaf "scroll-method" "on-button-down") | 533 | (sleaf "scroll-method" "on-button-down") |
484 | (leaf "scroll-button" 278) | 534 | (sleaf "scroll-button" 278) |
485 | ]) | 535 | ]) |
486 | (plain "touch" [ | 536 | (plain "touch" [ |
487 | (leaf "map-to-output" "eDP-1") | 537 | (sleaf "map-to-output" "eDP-1") |
488 | ]) | 538 | ]) |
489 | ]) | 539 | ]) |
490 | 540 | ||
@@ -492,7 +542,7 @@ in { | |||
492 | (plain "hot-corners" [(flag "off")]) | 542 | (plain "hot-corners" [(flag "off")]) |
493 | ]) | 543 | ]) |
494 | 544 | ||
495 | (plain "environment" (lib.mapAttrsToList leaf { | 545 | (plain "environment" (lib.mapAttrsToList sleaf { |
496 | NIXOS_OZONE_WL = "1"; | 546 | NIXOS_OZONE_WL = "1"; |
497 | QT_QPA_PLATFORM = "wayland"; | 547 | QT_QPA_PLATFORM = "wayland"; |
498 | QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; | 548 | QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; |
@@ -500,49 +550,52 @@ in { | |||
500 | SDL_VIDEODRIVER = "wayland"; | 550 | SDL_VIDEODRIVER = "wayland"; |
501 | DISPLAY = ":0"; | 551 | DISPLAY = ":0"; |
502 | ELECTRON_OZONE_PLATFORM_HINT = "auto"; | 552 | ELECTRON_OZONE_PLATFORM_HINT = "auto"; |
553 | SSH_ASKPASS_REQUIRE = "prefer"; | ||
554 | SSH_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass; | ||
555 | SUDO_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass; | ||
503 | })) | 556 | })) |
504 | 557 | ||
505 | (node "output" "eDP-1" [ | 558 | (node "output" ["eDP-1"] [ |
506 | (leaf "scale" 1.5) | 559 | (sleaf "scale" 1.5) |
507 | (leaf "position" { x = 0; y = 0; }) | 560 | (sleaf "position" { x = 0; y = 0; }) |
508 | ]) | 561 | ]) |
509 | (node "output" "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" [ | 562 | (node "output" ["Ancor Communications Inc ASUS PB287Q 0x0000DD9B"] [ |
510 | (leaf "scale" 1.5) | 563 | (sleaf "scale" 1.5) |
511 | (leaf "position" { x = 2560; y = 0; }) | 564 | (sleaf "position" { x = 2560; y = 0; }) |
512 | ]) | 565 | ]) |
513 | (node "output" "HP Inc. HP 727pu CN4417143K" [ | 566 | (node "output" ["HP Inc. HP 727pu CN4417143K"] [ |
514 | (leaf "mode" "2560x1440@119.998") | 567 | (sleaf "mode" "2560x1440@119.998") |
515 | (leaf "scale" 1) | 568 | (sleaf "scale" 1) |
516 | (leaf "position" { x = 2560; y = 0; }) | 569 | (sleaf "position" { x = 2560; y = 0; }) |
517 | (flag "variable-refresh-rate") | 570 | (flag "variable-refresh-rate") |
518 | ]) | 571 | ]) |
519 | 572 | ||
520 | (plain "debug" [ | 573 | (plain "debug" [ |
521 | (leaf "render-drm-device" "/dev/dri/by-path/pci-0000:00:02.0-render") | 574 | (sleaf "render-drm-device" "/dev/dri/by-path/pci-0000:00:02.0-render") |
522 | ]) | 575 | ]) |
523 | 576 | ||
524 | (plain "animations" [ | 577 | (plain "animations" [ |
525 | (leaf "slowdown" 0.5) | 578 | (sleaf "slowdown" 0.5) |
526 | (plain "workspace-switch" [(flag "off")]) | 579 | (plain "workspace-switch" [(flag "off")]) |
527 | ]) | 580 | ]) |
528 | 581 | ||
529 | (plain "layout" [ | 582 | (plain "layout" [ |
530 | (leaf "gaps" 8) | 583 | (sleaf "gaps" 8) |
531 | (plain "struts" [ | 584 | (plain "struts" [ |
532 | (leaf "left" 26) | 585 | (sleaf "left" 26) |
533 | (leaf "right" 26) | 586 | (sleaf "right" 26) |
534 | (leaf "top" 0) | 587 | (sleaf "top" 0) |
535 | (leaf "bottom" 0) | 588 | (sleaf "bottom" 0) |
536 | ]) | 589 | ]) |
537 | (plain "border" [ | 590 | (plain "border" [ |
538 | (leaf "width" 2) | 591 | (sleaf "width" 2) |
539 | (leaf "active-gradient" { | 592 | (sleaf "active-gradient" { |
540 | from = "hsla(195 100% 45% 1)"; | 593 | from = "hsla(195 100% 45% 1)"; |
541 | to = "hsla(155 100% 37.5% 1)"; | 594 | to = "hsla(155 100% 37.5% 1)"; |
542 | angle = 29; | 595 | angle = 29; |
543 | relative-to = "workspace-view"; | 596 | relative-to = "workspace-view"; |
544 | }) | 597 | }) |
545 | (leaf "inactive-gradient" { | 598 | (sleaf "inactive-gradient" { |
546 | from = "hsla(0 0% 27.7% 1)"; | 599 | from = "hsla(0 0% 27.7% 1)"; |
547 | to = "hsla(0 0% 23% 1)"; | 600 | to = "hsla(0 0% 23% 1)"; |
548 | angle = 29; | 601 | angle = 29; |
@@ -553,29 +606,29 @@ in { | |||
553 | (flag "off") | 606 | (flag "off") |
554 | ]) | 607 | ]) |
555 | 608 | ||
556 | (plain "preset-column-widths" (map (prop: leaf "proportion" prop) [ | 609 | (plain "preset-column-widths" (map (prop: sleaf "proportion" prop) [ |
557 | (1. / 4.) (1. / 3.) (1. / 2.) (2. / 3.) (3. / 4.) (1.) | 610 | (1. / 4.) (1. / 3.) (1. / 2.) (2. / 3.) (3. / 4.) (1.) |
558 | ])) | 611 | ])) |
559 | (plain "default-column-width" [ (leaf "proportion" (1. / 2.)) ]) | 612 | (plain "default-column-width" [ (sleaf "proportion" (1. / 2.)) ]) |
560 | (plain "preset-window-heights" (map (prop: leaf "proportion" prop) [ | 613 | (plain "preset-window-heights" (map (prop: sleaf "proportion" prop) [ |
561 | (1. / 3.) (1. / 2.) (2. / 3.) (1.) | 614 | (1. / 3.) (1. / 2.) (2. / 3.) (1.) |
562 | ])) | 615 | ])) |
563 | 616 | ||
564 | (flag "always-center-single-column") | 617 | (flag "always-center-single-column") |
565 | 618 | ||
566 | (plain "tab-indicator" [ | 619 | (plain "tab-indicator" [ |
567 | (leaf "gap" 4) | 620 | (sleaf "gap" 4) |
568 | (leaf "width" 8) | 621 | (sleaf "width" 8) |
569 | (leaf "gaps-between-tabs" 4) | 622 | (sleaf "gaps-between-tabs" 4) |
570 | (flag "place-within-column") | 623 | (flag "place-within-column") |
571 | (leaf "length" { total-proportion = 1.; }) | 624 | (sleaf "length" { total-proportion = 1.; }) |
572 | (leaf "active-gradient" { | 625 | (sleaf "active-gradient" { |
573 | from = "hsla(195 100% 60% 0.75)"; | 626 | from = "hsla(195 100% 60% 0.75)"; |
574 | to = "hsla(155 100% 50% 0.75)"; | 627 | to = "hsla(155 100% 50% 0.75)"; |
575 | angle = 29; | 628 | angle = 29; |
576 | relative-to = "workspace-view"; | 629 | relative-to = "workspace-view"; |
577 | }) | 630 | }) |
578 | (leaf "inactive-gradient" { | 631 | (sleaf "inactive-gradient" { |
579 | from = "hsla(0 0% 42% 0.66)"; | 632 | from = "hsla(0 0% 42% 0.66)"; |
580 | to = "hsla(0 0% 35% 0.66)"; | 633 | to = "hsla(0 0% 35% 0.66)"; |
581 | angle = 29; | 634 | angle = 29; |
@@ -589,129 +642,140 @@ in { | |||
589 | ]) | 642 | ]) |
590 | 643 | ||
591 | (map (name: | 644 | (map (name: |
592 | (node "workspace" name [ | 645 | (node "workspace" [name] [ |
593 | (leaf "open-on-output" "eDP-1") | 646 | (sleaf "open-on-output" "eDP-1") |
594 | ]) | 647 | ]) |
595 | ) (map ({name, ...}: name) cfg.scratchspaces)) | 648 | ) (map ({name, ...}: name) cfg.scratchspaces)) |
596 | (map (name: | 649 | (map (name: |
597 | (leaf "workspace" name) | 650 | (sleaf "workspace" name) |
598 | ) ["comm" "web" "vid" "bmr"]) | 651 | ) ["comm" "web" "vid" "bmr"]) |
599 | 652 | ||
600 | (plain "window-rule" [ | 653 | (plain "window-rule" [ |
601 | (leaf "clip-to-geometry" true) | 654 | (sleaf "clip-to-geometry" true) |
602 | ]) | 655 | ]) |
603 | 656 | ||
604 | (plain "window-rule" [ | 657 | (plain "window-rule" [ |
605 | (leaf "match" { is-floating = true; }) | 658 | (sleaf "match" { is-floating = true; }) |
606 | (leaf "geometry-corner-radius" 8) | 659 | (sleaf "geometry-corner-radius" 8) |
607 | (plain "shadow" [ (flag "on") ]) | 660 | (plain "shadow" [ (flag "on") ]) |
608 | ]) | 661 | ]) |
609 | 662 | ||
610 | (plain "window-rule" [ | 663 | (plain "window-rule" [ |
611 | (leaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; }) | 664 | (sleaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; }) |
612 | (leaf "block-out-from" "screencast") | 665 | (sleaf "block-out-from" "screencast") |
613 | ]) | 666 | ]) |
614 | (plain "window-rule" [ | 667 | (plain "window-rule" (normalize-nodes [ |
615 | (map (title: | 668 | (map (title: |
616 | (leaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; inherit title; }) | 669 | (sleaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; inherit title; }) |
617 | ) ["^Unlock Database.*" "^Access Request.*" ".*Passkey credentials$"]) | 670 | ) ["^Unlock Database.*" "^Access Request.*" ".*Passkey credentials$" "Browser Access Request$"]) |
618 | (leaf "open-focused" true) | 671 | (sleaf "open-focused" true) |
619 | (leaf "open-floating" true) | 672 | (sleaf "open-floating" true) |
620 | ]) | 673 | ])) |
621 | 674 | ||
622 | (map ({ name, match, exclude, windowRuleExtra, ... }: | 675 | (map ({ name, match, exclude, windowRuleExtra, ... }: |
623 | (optional-node (match != []) (plain "window-rule" [ | 676 | (optional-node (match != []) (plain "window-rule" (normalize-nodes [ |
624 | (map (leaf "match") match) | 677 | (map (sleaf "match") match) |
625 | (map (leaf "exclude") exclude) | 678 | (map (sleaf "exclude") exclude) |
626 | (leaf "open-on-workspace" name) | 679 | (sleaf "open-on-workspace" name) |
627 | (leaf "open-maximized" true) | 680 | (sleaf "open-maximized" true) |
628 | windowRuleExtra | 681 | windowRuleExtra |
629 | ])) | 682 | ]))) |
630 | ) cfg.scratchspaces) | 683 | ) cfg.scratchspaces) |
631 | 684 | ||
632 | (plain "window-rule" [ | 685 | (plain "window-rule" [ |
633 | (leaf "match" { app-id = "^emacs$"; }) | 686 | (sleaf "match" { app-id = "^emacs$"; }) |
634 | (leaf "match" { app-id = "^firefox$"; }) | 687 | (sleaf "match" { app-id = "^firefox$"; }) |
635 | (plain "default-column-width" [(leaf "proportion" (2. / 3.))]) | 688 | (plain "default-column-width" [(sleaf "proportion" (2. / 3.))]) |
636 | ]) | 689 | ]) |
637 | (plain "window-rule" [ | 690 | (plain "window-rule" [ |
638 | (leaf "match" { app-id = "^kitty$"; }) | 691 | (sleaf "match" { app-id = "^kitty$"; }) |
639 | (leaf "match" { app-id = "^kitty-play$"; }) | 692 | (sleaf "match" { app-id = "^kitty-play$"; }) |
640 | (plain "default-column-width" [(leaf "proportion" (1. / 3.))]) | 693 | (plain "default-column-width" [(sleaf "proportion" (1. / 3.))]) |
641 | ]) | 694 | ]) |
642 | 695 | ||
643 | (plain "window-rule" [ | 696 | (plain "window-rule" [ |
644 | (leaf "match" { app-id = "^thunderbird$"; }) | 697 | (sleaf "match" { app-id = "^thunderbird$"; }) |
645 | (leaf "match" { app-id = "^Element$"; }) | 698 | (sleaf "match" { app-id = "^Element$"; }) |
646 | (leaf "match" { app-id = "^Rainbow$"; }) | 699 | (sleaf "match" { app-id = "^chrome-web\.openrainbow\.com__-Default$"; }) |
647 | (leaf "open-on-workspace" "comm") | 700 | (sleaf "open-on-workspace" "comm") |
648 | ]) | 701 | ]) |
649 | (plain "window-rule" [ | 702 | (plain "window-rule" [ |
650 | (leaf "match" { app-id = "^firefox$"; }) | 703 | (sleaf "match" { app-id = "^firefox$"; }) |
651 | (leaf "open-on-workspace" "web") | 704 | (sleaf "open-on-workspace" "web") |
652 | (leaf "open-maximized" true) | 705 | (sleaf "open-maximized" true) |
653 | ]) | 706 | ]) |
654 | (plain "window-rule" [ | 707 | (plain "window-rule" [ |
655 | (leaf "match" { app-id = "^mpv$"; }) | 708 | (sleaf "match" { app-id = "^mpv$"; }) |
656 | (leaf "open-on-workspace" "vid") | 709 | (sleaf "open-on-workspace" "vid") |
657 | (plain "default-column-width" [(leaf "proportion" 1.)]) | 710 | (plain "default-column-width" [(sleaf "proportion" 1.)]) |
658 | ]) | 711 | ]) |
659 | (plain "window-rule" [ | 712 | (plain "window-rule" [ |
660 | (leaf "match" { app-id = "^kitty-play$"; }) | 713 | (sleaf "match" { app-id = "^kitty-play$"; }) |
661 | (leaf "open-on-workspace" "vid") | 714 | (sleaf "open-on-workspace" "vid") |
662 | (leaf "open-focused" false) | 715 | (sleaf "open-focused" false) |
663 | ]) | 716 | ]) |
664 | (plain "window-rule" [ | 717 | (plain "window-rule" [ |
665 | (leaf "match" { app-id = "^pdfpc$"; }) | 718 | (sleaf "match" { app-id = "^chrome-audiobookshelf\.yggdrasil\.li__-Default$"; }) |
666 | (plain "default-column-width" [(leaf "proportion" 1.)]) | 719 | (sleaf "match" { app-id = "^YouTube Music Desktop App$"; }) |
720 | (sleaf "open-on-workspace" "vid") | ||
667 | ]) | 721 | ]) |
668 | (plain "window-rule" [ | 722 | (plain "window-rule" [ |
669 | (leaf "match" { app-id = "^pdfpc$"; title = "^.*presentation.*$"; }) | 723 | (sleaf "match" { app-id = "^pdfpc$"; }) |
670 | (plain "default-column-width" [(leaf "proportion" 1.)]) | 724 | (plain "default-column-width" [(sleaf "proportion" 1.)]) |
671 | (leaf "open-fullscreen" true) | ||
672 | (leaf "open-on-workspace" "bmr") | ||
673 | (leaf "open-focused" false) | ||
674 | ]) | 725 | ]) |
675 | (plain "window-rule" [ | 726 | (plain "window-rule" [ |
676 | (map (leaf "match") [ | 727 | (sleaf "match" { app-id = "^pdfpc$"; title = "^.*presentation.*$"; }) |
728 | (plain "default-column-width" [(sleaf "proportion" 1.)]) | ||
729 | (sleaf "open-fullscreen" true) | ||
730 | (sleaf "open-on-workspace" "bmr") | ||
731 | (sleaf "open-focused" false) | ||
732 | ]) | ||
733 | (plain "window-rule" (normalize-nodes [ | ||
734 | (map (sleaf "match") [ | ||
677 | { app-id = "^Gimp-"; title = "^Quit GIMP$"; } | 735 | { app-id = "^Gimp-"; title = "^Quit GIMP$"; } |
678 | { app-id = "^org\\.kde\\.polkit-kde-authentication-agent-1$"; } | 736 | { app-id = "^org\\.kde\\.polkit-kde-authentication-agent-1$"; } |
679 | { app-id = "^xdg-desktop-portal-gtk$"; } | 737 | { app-id = "^xdg-desktop-portal-gtk$"; } |
680 | ]) | 738 | ]) |
681 | (leaf "open-floating" true) | 739 | (sleaf "open-floating" true) |
682 | ]) | 740 | ])) |
683 | (plain "window-rule" [ | 741 | (plain "window-rule" [ |
684 | (leaf "match" { app-id = "^org\\.pwmt\\.zathura$"; }) | 742 | (sleaf "match" { app-id = "^org\\.pwmt\\.zathura$"; }) |
685 | (leaf "match" { app-id = "^evince$"; }) | 743 | (sleaf "match" { app-id = "^evince$"; }) |
686 | (leaf "match" { app-id = "^org\\.gnome\\.Papers$"; }) | 744 | (sleaf "match" { app-id = "^org\\.gnome\\.Papers$"; }) |
687 | (leaf "default-column-display" "tabbed") | 745 | (sleaf "default-column-display" "tabbed") |
688 | ]) | 746 | ]) |
689 | 747 | ||
690 | (plain "layer-rule" [ | 748 | (plain "layer-rule" [ |
691 | (leaf "match" { namespace = "^notifications$"; }) | 749 | (sleaf "match" { namespace = "^notifications$"; }) |
692 | (leaf "match" { namespace = "^waybar$"; }) | 750 | (sleaf "match" { namespace = "^waybar$"; }) |
693 | (leaf "match" { namespace = "^launcher$"; }) | 751 | (sleaf "match" { namespace = "^launcher$"; }) |
694 | (leaf "block-out-from" "screencast") | 752 | (sleaf "block-out-from" "screencast") |
695 | ]) | 753 | ]) |
696 | 754 | ||
697 | (plain "binds" | 755 | (plain "binds" |
698 | (let | 756 | (let |
699 | bind = name: cfg: node name (opt-props { | 757 | bind = name: cfg: node name [(lib.removeAttrs cfg ["action"])] (lib.mapAttrsToList leaf (lib.removeAttrs cfg.action ["__functor"])); |
700 | cooldown-ms = cfg.cooldown-ms or null; | ||
701 | } | ||
702 | // (lib.optionalAttrs (!(cfg.repeat or true)) { | ||
703 | repeat = false; | ||
704 | }) | ||
705 | // (lib.optionalAttrs (cfg.allow-when-locked or false) { | ||
706 | allow-when-locked = true; | ||
707 | })) (lib.mapAttrsToList leaf (lib.removeAttrs cfg.action ["__functor"])); | ||
708 | in | 758 | in |
709 | [ | 759 | normalize-nodes [ |
710 | (lib.mapAttrsToList bind (with config.lib.niri.actions; { | 760 | (lib.mapAttrsToList bind (with config.lib.niri.actions; { |
711 | "Mod+Slash".action = show-hotkey-overlay; | 761 | "Mod+Slash".action = show-hotkey-overlay; |
712 | 762 | ||
713 | "Mod+Return".action = spawn terminal; | 763 | "Mod+Return".action = spawn terminal; |
714 | "Mod+Shift+Return".action = spawn terminal (lib.getExe config.programs.nushell.package); | 764 | "Mod+Shift+Return".action = |
765 | let | ||
766 | nushellKitty = pkgs.symlinkJoin { | ||
767 | name = "nushell-kitty"; | ||
768 | paths = [ config.programs.kitty.package ]; | ||
769 | buildInputs = [ pkgs.makeWrapper ]; | ||
770 | postBuild = '' | ||
771 | wrapProgram $out/bin/kitty \ | ||
772 | --add-flags "--config ${pkgs.writeText "kitty.conf" '' | ||
773 | include $HOME/${config.xdg.configFile."kitty/kitty.conf".target} | ||
774 | shell ${lib.getExe config.programs.nushell.package} | ||
775 | ''}" | ||
776 | ''; | ||
777 | }; | ||
778 | in spawn (lib.getExe' nushellKitty "kitty"); | ||
715 | "Mod+Q".action = close-window; | 779 | "Mod+Q".action = close-window; |
716 | "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); | 780 | "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); |
717 | "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; | 781 | "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; |
@@ -747,12 +811,12 @@ in { | |||
747 | done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) | 811 | done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) |
748 | $FOUND || echo | 812 | $FOUND || echo |
749 | } | 813 | } |
750 | FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? | 814 | FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> " --width=60) || exit $? |
751 | if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then | 815 | if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then |
752 | QALC_RES="$FUZZEL_RES" | 816 | QALC_RES="$FUZZEL_RES" |
753 | QALC_RET=0 | 817 | QALC_RET=0 |
754 | else | 818 | else |
755 | QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) | 819 | QALC_RES=$(qalc -set "autocalc off" "$FUZZEL_RES" 2>&1) |
756 | QALC_RET=$? | 820 | QALC_RET=$? |
757 | fi | 821 | fi |
758 | [[ -n "$QALC_RES" ]] || exit 1 | 822 | [[ -n "$QALC_RES" ]] || exit 1 |
@@ -772,11 +836,26 @@ in { | |||
772 | notify-send "$QALC_RES" | 836 | notify-send "$QALC_RES" |
773 | ''; | 837 | ''; |
774 | })); | 838 | })); |
839 | "Mod+Shift+U".action = | ||
840 | let | ||
841 | qalcKitty = pkgs.symlinkJoin { | ||
842 | name = "qalc-kitty"; | ||
843 | paths = [ config.programs.kitty.package ]; | ||
844 | buildInputs = [ pkgs.makeWrapper ]; | ||
845 | postBuild = '' | ||
846 | wrapProgram $out/bin/kitty \ | ||
847 | --add-flags "--config ${pkgs.writeText "kitty.conf" '' | ||
848 | include $HOME/${config.xdg.configFile."kitty/kitty.conf".target} | ||
849 | shell ${lib.getExe pkgs.libqalculate} | ||
850 | ''}" | ||
851 | ''; | ||
852 | }; | ||
853 | in spawn (lib.getExe' qalcKitty "kitty"); | ||
775 | "Mod+E".action = spawn (lib.getExe (pkgs.writeShellApplication { | 854 | "Mod+E".action = spawn (lib.getExe (pkgs.writeShellApplication { |
776 | name = "emoji-fuzzel"; | 855 | name = "emoji-fuzzel"; |
777 | runtimeInputs = with pkgs; [ config.programs.fuzzel.package wtype wl-clipboard-rs ]; | 856 | runtimeInputs = with pkgs; [ config.programs.fuzzel.package wtype wl-clipboard-rs ]; |
778 | text = '' | 857 | text = '' |
779 | FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <"$HOME"/.local/share/emoji-data/list.txt) || exit $? | 858 | FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " --cache "$HOME"/.cache/fuzzel-emoji --width=60 <"$HOME"/.local/share/emoji-data/list.txt) || exit $? |
780 | [[ -n "$FUZZEL_RES" ]] || exit 1 | 859 | [[ -n "$FUZZEL_RES" ]] || exit 1 |
781 | wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste | 860 | wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste |
782 | ''; | 861 | ''; |
@@ -837,7 +916,7 @@ in { | |||
837 | "Mod+Shift+Asterisk".action = kdl.magic-leaf "move-column-to-workspace" "vid"; | 916 | "Mod+Shift+Asterisk".action = kdl.magic-leaf "move-column-to-workspace" "vid"; |
838 | 917 | ||
839 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | 918 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; |
840 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | 919 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}, "focus": true}}}''; |
841 | 920 | ||
842 | "Mod+M".action = consume-or-expel-window-left; | 921 | "Mod+M".action = consume-or-expel-window-left; |
843 | "Mod+W".action = consume-or-expel-window-right; | 922 | "Mod+W".action = consume-or-expel-window-right; |
@@ -909,13 +988,20 @@ in { | |||
909 | "Mod+Comma".action = spawn makoctl "restore"; | 988 | "Mod+Comma".action = spawn makoctl "restore"; |
910 | 989 | ||
911 | "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; | 990 | "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; |
912 | "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; | 991 | "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_id}, \"focus\": true}}}"; |
913 | 992 | ||
914 | "Mod+X".action = set-dynamic-cast-window; | 993 | "Mod+X".action = set-dynamic-cast-window; |
915 | "Mod+Shift+X".action = set-dynamic-cast-monitor; | 994 | "Mod+Shift+X".action = set-dynamic-cast-monitor; |
916 | "Mod+Control+Shift+X".action = clear-dynamic-cast-target; | 995 | "Mod+Control+Shift+X".action = clear-dynamic-cast-target; |
996 | |||
997 | "Mod+D".action = with-urgent-window-action "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
998 | "Mod+Shift+D".action = with-focused-window-action "{\"Action\":{\"UnsetUrgent\":{\"id\": .id}}}"; | ||
999 | |||
1000 | "Mod+K".action = spawn (lib.getExe' pkgs.worktime "worktime-ui"); | ||
1001 | "Mod+Shift+K".action = spawn (lib.getExe' pkgs.worktime "worktime-stop"); | ||
917 | })) | 1002 | })) |
918 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) | 1003 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) |
1004 | (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) | ||
919 | ] | 1005 | ] |
920 | )) | 1006 | )) |
921 | ]; | 1007 | ]; |