diff options
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 27 |
1 files changed, 17 insertions, 10 deletions
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 | |||
105 | }; | 105 | }; |
106 | with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); | 106 | with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); |
107 | 107 | ||
108 | with_empty_unnamed_workspace = pkgs.writeShellApplication { | ||
109 | name = "with-empty-unnamed-workspace"; | ||
110 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
111 | text = '' | ||
112 | action="$1" | ||
113 | shift | ||
114 | |||
115 | workspaces_json="$(niri msg -j workspaces)" | ||
116 | active_output="$(jq '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
117 | 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")" | ||
118 | jq --argjson workspace_id "$target_workspace_id" -nc "$action" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
119 | ''; | ||
120 | }; | ||
121 | with-empty-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_empty_unnamed_workspace); | ||
122 | |||
108 | with_select_window = pkgs.writeShellApplication { | 123 | with_select_window = pkgs.writeShellApplication { |
109 | name = "with-select-window"; | 124 | name = "with-select-window"; |
110 | runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; | 125 | runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; |
@@ -821,16 +836,8 @@ in { | |||
821 | "Mod+Period".action = spawn makoctl "menu" (lib.getExe config.programs.fuzzel.package) "--dmenu"; | 836 | "Mod+Period".action = spawn makoctl "menu" (lib.getExe config.programs.fuzzel.package) "--dmenu"; |
822 | "Mod+Comma".action = spawn makoctl "restore"; | 837 | "Mod+Comma".action = spawn makoctl "restore"; |
823 | 838 | ||
824 | "Mod+Control+W".action = spawn (lib.getExe (pkgs.writeShellApplication { | 839 | "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; |
825 | name = "focus-empty-unnamed-workspace"; | 840 | "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; |
826 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
827 | text = '' | ||
828 | workspaces_json="$(niri msg -j workspaces)" | ||
829 | active_output="$(jq '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
830 | 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")" | ||
831 | jq --argjson workspace_id "$target_workspace_id" -nc '{"Action":{"FocusWorkspace":{"reference":{"Id": $workspace_id}}}}' | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
832 | ''; | ||
833 | })); | ||
834 | })) | 841 | })) |
835 | (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) | 842 | (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) |
836 | ] | 843 | ] |