From 1e1cd8cc2924c719a27ab92101e9d4087744c238 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 16 May 2025 10:24:36 +0200 Subject: ... --- accounts/gkleen@sif/niri/default.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (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 09482c51..fde08ae9 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -140,6 +140,25 @@ let ''; }; with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); + + with_predicate_window = pred: pkgs.writeShellApplication { + name = "with-predicate-window"; + runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; + text = '' + action="$1" + shift + + windows_json="$(niri msg -j windows)" + window_json="$(gojq -rc 'map(select(${pred})) | .[0]' <<<"$windows_json")" + + [[ -z "$window_json" || $window_json = "null" ]] && exit 1 + + jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET" + ''; + }; + + with-urgent-window-action = config.lib.niri.actions.spawn (lib.getExe (with_predicate_window ".is_urgent")); + with-focused-window-action = config.lib.niri.actions.spawn (lib.getExe (with_predicate_window ".is_focused")); in { imports = [ ./waybar.nix @@ -938,6 +957,9 @@ in { "Mod+X".action = set-dynamic-cast-window; "Mod+Shift+X".action = set-dynamic-cast-monitor; "Mod+Control+Shift+X".action = clear-dynamic-cast-target; + + "Mod+D".action = with-urgent-window-action "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; + "Mod+Shift+D".action = with-focused-window-action "{\"Action\":{\"UnsetUrgent\":{\"id\": .id}}}"; })) (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) (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) -- cgit v1.2.3