summaryrefslogtreecommitdiff
path: root/accounts
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2025-02-13 20:02:34 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2025-02-13 20:02:34 +0100
commit10b7a66bdf7181026914e753c5260a5adef04214 (patch)
tree0c75073e34eef3da2519a9c071a9e32c1d222dfc /accounts
parent17dd0a467339a51b1b89456ade9ebf4a2e494537 (diff)
downloadnixos-10b7a66bdf7181026914e753c5260a5adef04214.tar
nixos-10b7a66bdf7181026914e753c5260a5adef04214.tar.gz
nixos-10b7a66bdf7181026914e753c5260a5adef04214.tar.bz2
nixos-10b7a66bdf7181026914e753c5260a5adef04214.tar.xz
nixos-10b7a66bdf7181026914e753c5260a5adef04214.zip
...
Diffstat (limited to 'accounts')
-rw-r--r--accounts/gkleen@sif/niri/default.nix27
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 ]