From 10b7a66bdf7181026914e753c5260a5adef04214 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 13 Feb 2025 20:02:34 +0100 Subject: ... --- accounts/gkleen@sif/niri/default.nix | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'accounts') diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 8b95f00f..bbfc28d6 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -105,6 +105,21 @@ let }; with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); + with_empty_unnamed_workspace = pkgs.writeShellApplication { + name = "with-empty-unnamed-workspace"; + runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; + text = '' + action="$1" + shift + + workspaces_json="$(niri msg -j workspaces)" + active_output="$(jq '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" + target_workspace_id="$(jq --argjson active_output "$active_output" 'map(select(.active_window_id == null and .name == null and .output == $active_output)) | sort_by(.idx) | .[0].id' <<<"$workspaces_json")" + jq --argjson workspace_id "$target_workspace_id" -nc "$action" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" + ''; + }; + with-empty-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_empty_unnamed_workspace); + with_select_window = pkgs.writeShellApplication { name = "with-select-window"; runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; @@ -821,16 +836,8 @@ in { "Mod+Period".action = spawn makoctl "menu" (lib.getExe config.programs.fuzzel.package) "--dmenu"; "Mod+Comma".action = spawn makoctl "restore"; - "Mod+Control+W".action = spawn (lib.getExe (pkgs.writeShellApplication { - name = "focus-empty-unnamed-workspace"; - runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; - text = '' - workspaces_json="$(niri msg -j workspaces)" - active_output="$(jq '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" - target_workspace_id="$(jq --argjson active_output "$active_output" 'map(select(.active_window_id == null and .name == null and .output == $active_output)) | sort_by(.idx) | .[0].id' <<<"$workspaces_json")" - jq --argjson workspace_id "$target_workspace_id" -nc '{"Action":{"FocusWorkspace":{"reference":{"Id": $workspace_id}}}}' | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" - ''; - })); + "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; + "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_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) ] -- cgit v1.2.3